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

int main() {
  int n;
  cin >> n;
  long sum = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 3 != 0 && i % 5 != 0) sum += i;
  }
  cout << sum << endl;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 2e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
	int n, k;
	cin>>n>>k;
	int arr[3];
	rep(i, 0, 3) cin>>arr[i];
	string s;
	cin>>s;
	ll ans = 0;
	string aa = "";
	rep(i ,0 , s.length())
	{
		if(i-k < 0)
		{
			if(s[i] == 'r') ans += arr[2], aa += "p";
			if(s[i] == 'p') ans += arr[1], aa += "s";
			if(s[i] == 's') ans += arr[0], aa += "r";
		}
		else
		{
			if(s[i] == 'r') {
				if(aa[i-k] == 'p')
				{
					if(i+k < s.length() && s[i+k] == 's')
					{
						aa += "s";
					}
					else aa += "r";
				}
				else aa += "p", ans += arr[2];
			}
			if(s[i] == 'p') {
				if(aa[i-k] == 's')
				{
					if(i+k < s.length() && s[i+k] == 'r')
					{
						aa += "r";
					}
					else aa += "p";
				}
				else aa += "s", ans += arr[1];
			}
			if(s[i] == 's') {
				if(aa[i-k] == 'r')
				{
					if(i+k < s.length() && s[i+k] == 'p')
					{
						aa += "p";
					}
					else aa += "s";
				}
				else aa += "r", ans += arr[0];
			}		}
	}
	cout<<ans<<endl;
	//cout<<aa<<endl;
}


Measured memory_bytes: 640
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int N, X;
int arr[105];
int sum = 0;
int finalAns = 0;

int main()
{
	scanf("%d %d", &N, &X);
	for(int i = 0; i < N; i++) {
		scanf("%d", &arr[i]);
		sum += arr[i];
	}
	sort(arr, arr + N);

	X = X - sum;
	// cerr << X << " ";
	finalAns = N;
	// cerr << X % arr[0] << " ";
	finalAns += X / arr[0];
	printf("%d\n", finalAns);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
N = int(input())
A = input().split()

dis = 0
now = 0
for i in range(N):
    dis += abs(int(A[i]) - now)
    now = int(A[i])
dis += abs(int(A[N-1]))

ans = [0] * N

for i in range(N):
    if i == 0:
        if (int(A[i]) * int(A[i+1]) < 0) or (int(A[i+1]) == 0):
            ans[i] = dis - abs(int(A[i])) * 2
        elif int(A[i]) == 0:
            ans[i] = dis
        else:
            if abs(int(A[i+1])) >= abs(int(A[i])):
                ans[i] = dis
            else:
                ans[i] = dis - abs(int(A[i+1]) - int(A[i])) * 2
    elif i == N-1:
        a = int(A[i-1])
        b = int(A[i])
        if (a*b > 0):
            if abs(b)-abs(a) > 0:
                ans[i] = dis - abs(b-a)*2
            else:
                ans[i] = dis
        else:
            ans[i] = dis - abs(b)*2
    else:
        a = int(A[i-1])
        b = int(A[i]) - a
        c = int(A[i+1]) - a
        if (b * c < 0) or (c == 0):
            ans[i] = dis - abs(b) * 2
        elif b == 0:
            ans[i] = dis
        else:
            if abs(c) >= abs(b):
                ans[i] = dis
            else:
                ans[i] = dis - abs(c - b) * 2


for i in range(N):
    print(ans[i])

Measured memory_bytes: 13396
def counting_sort(A):
    B = A.copy()
    C = [0 for _ in range(max(A) + 1)]
    
    for num in A:
        C[num] += 1
    for index in range(1, len(C)):
        C[index] = C[index] + C[index-1]

    for index in range(len(A) - 1, -1, -1):
        C[A[index]] -= 1
        B[C[A[index]]] = A[index]
    return B

num = int(input())
arr = list(map(int, input().split()))
arr = counting_sort(arr)
print(" ".join(map(str, arr)))


Measured memory_bytes: 224704
#include <bits/stdc++.h>
#define yes { cout << "YES" << endl; exit(0); }
#define no { cout << "NO" << endl; exit(0); }
#define impossible { cout << "Impossible" << endl; exit(0); }

using namespace std;

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

const ll inf = 1e18;
const int Nmax = 2e5 + 5;

ll dp[Nmax];
set<Pair> S1, S2;

priority_queue< pair<ll, int>, vector<pair<ll,int>>, greater<pair<ll,int>> > heap;

int L[Nmax], R[Nmax], C[Nmax];
int n, m;


void solve()
{
    int i;
    for(i=1; i<=m+1; ++i) S1.insert( {L[i], i} );
    for(i=1; i<=m+1; ++i) S2.insert( {R[i], i} );

    heap.push({ 0, 0 });

    for(i=1; i<=m+1; ++i) dp[i] = inf;

    while(heap.size())
    {
        int node = heap.top().second;
        heap.pop();
        
        ll dist = dp[node];

        ///
        set<Pair> :: iterator start, it;
        start = it = S1.lower_bound( { L[node], 0 } );
        

        while(it != S1.end() && it->first <= R[node])
        {
            int curr = it->second;
            if(dp[curr] == inf)
            {
                dp[curr] = dist + C[curr];
                heap.push( {dp[curr], curr} );
            }

            ++it;
        }

        S1.erase(start, it);
      
      //////
        start = it = S2.lower_bound( {L[node], 0} );
        while(it != S2.end() && it->first <= R[node])
        {
            int curr = it->second;
            if(dp[curr] == inf)
            {
                dp[curr] = dist + C[curr];
                heap.push( {dp[curr], curr} );
            }

            ++it;
        }

        S2.erase(start, it);
    }


    if(dp[m+1] == inf) cout << -1 << '\n';
        else cout << dp[m+1] << '\n';
}

int main()
{
  //  freopen("inputD", "r", stdin);
    // freopen("output", "w", stdout);
    cin.sync_with_stdio(false); cin.tie(0);
    
    cin >> n >> m;

    int i;
    for(i=1; i<=m; ++i) cin >> L[i] >> R[i] >> C[i];

    L[0] = R[0] = 1; C[0] = 0;
    L[m+1] = R[m+1] = n; C[m+1] = 0;

    solve();

    return 0;
}



Measured memory_bytes: 13556
#include <stdio.h>
  int main(){
	  while(1){
		  int x[400][400]={};
          int a=200,b=200,n,i,j,k,c,d,w=0,h=0;
		  x[a][b]=1;
		  scanf("%d",&n); if(n==0) break;
		  for(i=1;i<n;i++){
			  scanf("%d%d",&c,&d);
			  for(j=-n;j<n;j++){
				  for(k=-n;k<n;k++){ 
					  if(x[a+j][b+k]==c+1){
						  if(d==0) x[a-1+j][b+k]=i+1; 
						  if(d==1) x[a+j][b-1+k]=i+1; 
						  if(d==2) x[a+1+j][b+k]=i+1; 
						  if(d==3) x[a+j][b+1+k]=i+1;
					  }
				  }
			  }
		  }
		  for(i=0;i<400;i++){
			  for(j=0;j<400;j++){
				  if(x[i][j]!=0){ 
					  w++;
					  goto aaa; 
				  } } aaa:;}
		  for(i=0;i<400;i++){
			  for(j=0;j<400;j++){
				  if(x[j][i]!=0){ 
					  h++;
					  goto baa; 
				  } } baa:;}
		  printf("%d %d\n",w,h);
	  }
	  return 0;
  }

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

int main() {
    ll N;
    cin >> N;
    vll A(N + 2);
    A[0] = 0;
    A[N + 1] = 0;
    ll sum = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
        sum += abs(A[i] - A[i - 1]);
    }
    sum += abs(A[N] - 0);
    ll tmp = sum;
    for (int i = 1; i <= N; ++i) {
        tmp = sum;
        tmp -= abs(A[i + 1] - A[i]);
        tmp -= abs(A[i] - A[i - 1]);
        tmp += abs(A[i + 1] - A[i - 1]);
        cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
N = int(input())
S = []
L = []
for i in range(N):
  s = str(input())
  S.append(s)
M = int(input())
for i in range(M):
  l = str(input())
  L.append(l)
Ans = 0
for i in range(N):
  a = S[i]
  A = S.count(a)-L.count(a)  
  if A > Ans:
    Ans = A
print(Ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
int main(){
        long long N,d[100000],ans;
        std::cin>>N;
        for(int i=0; i<N; i++)
                std::cin>>d[i];
        std::sort(d,d+N);
        ans=d[(N+1)/2]-d[(N-1)/2];
        std::cout<<ans;
        return 0;
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

int all9(int digit, int notzero){
    int tmp = 1;

    if(digit < notzero || notzero < 0) return 0;

    rep(i, notzero){
        tmp *= digit - i;
        tmp /= i + 1;
    }

    rep(i, notzero){
        tmp *= 9;
    }

    return tmp;
}

int main(){

    string n;
    int k;
    cin >> n;
    cin >> k;

    int size = n.size();

    vector<int> nv(1);      //nの各桁をvectorに代入
    vector<int> notzero(1); //nを大きいほうの桁から見た時の0ではない桁の数

    int ans = 0;

    rep(i, size){
        nv.pback(n[i] - '0');

        if(n[i] == '0'){
            notzero.pback(notzero[i]);
        }else{
            notzero.pback(notzero[i] + 1);
        }
    }

    for(int i = 1; i <= size + 1; i++){

        if(i == size + 1){
            if(notzero[size] == k) ans++;
        }else if(i == size){

            if(nv[i] != 0){
                if(notzero[i - 1] == k){
                    ans++;
                }else if(notzero[i - 1] == k - 1){
                    ans += nv[i] - 1;
                }
            }

        }else{

            //左から桁目をnの左からi桁目の数未満の数とする

            if(nv[i] != 0){
                ans += (nv[i] - 1) * all9(size - i, k - 1 - notzero[i - 1]);
                ans += all9(size - i, k - notzero[i - 1]);
            }

        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  
  double num;
  double num2;
  double num3;
  double num4 = 0.0;
  double num5 = 0.0;
    
  vector<vector<double>> A(N,vector<double>(2));
  
  for(int i = 0;i < N;++i){
    for(int j = 0;j < 2;++j){
      cin >> A[i][j];
    }
  }
  
  for(int i = 0;i < N - 1;++i){
    for(int j = i + 1;j < N;++j){
      num = sqrt(((A[i][0] - A[j][0]) * (A[i][0] - A[j][0])) + ((A[i][1] - A[j][1]) * (A[i][1] - A[j][1])));
      num4 = num + num4;
      num5 = num5 + 1.0;
    }
  }
  
  cout << setprecision(20)<<num4 * (N - 1) / num5 << endl;
  
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().mainrun();
	}

	Scanner scan;
	int A,B;

	private void mainrun() {
		scan = new Scanner(System.in);
		int N = scan.nextInt();

		for(;N != 0;N = scan.nextInt()) {
			looprun(N);
		}

		scan.close();
	}

	private void looprun(int N) {
		int[][] F = new int[N][N];
		int Ans = 0;
		Integer[] cmin = new Integer[N];
		Integer[] rmax = new Integer[N];

		Arrays.fill(cmin, Integer.MAX_VALUE);
		Arrays.fill(rmax, Integer.MIN_VALUE);

		//初期化&標準入力からの読み込み
		for(int i = 0;i < N;i++) {
			for(int j = 0;j < N;j++) {
				F[i][j] = scan.nextInt();
				cmin[i] = Math.min(cmin[i], F[i][j]);
			}
		}

		for(int i = 0;i < N;i++) {
			for(int j = 0;j < N;j++) {
				rmax[i] = Math.max(rmax[i], F[j][i]);
			}
		}

		for(Integer c : cmin) {
			for(Integer r: rmax) {
				if(c == r) {
					Ans = r;
				}
			}
		}

		System.out.println(Ans);
	}
}


Measured memory_bytes: 26296
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>

typedef long long ll;
const ll MOD = 1e9 + 7;

using namespace std;

const int NMAX = 2* 1e5;
int N;
vector<vector<int>> to(NMAX);
map<pair<int,int>,ll> dpv;
map<pair<int,int>,ll> treenum;

ll fact[NMAX+1], invfact[NMAX+1];

long pow(long a, long b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    long d = pow(a, b / 2);
    return (d * d) % MOD;
  } else {
    long d = pow(a, b - 1);
    return (a * d) % MOD;
  }
}

void dfs(ll v, ll parent){
    if(dpv[{parent,v}] != 0){
        return;
    }

    ll ans = 1;
    ll num = 1;

    for(int i = 0; i < to[v].size(); i++){
        if(to[v][i] != parent and to[v][i] != v){
            dfs(to[v][i], v);
            num += treenum[{v,to[v][i]}];
            ans = ans * dpv[{v,to[v][i]}] %MOD;
            ans = ans * invfact[treenum[{v,to[v][i]}]] % MOD;
        }
    }

    treenum[{parent,v}] = num;
    treenum[{v,v}] = N;
    dpv[{parent,v}] = ans * fact[num-1] % MOD;
}

void bfs(ll v, ll parent){
    if(dpv[{parent,parent}] == 0){
        treenum[{parent,v}] = N-treenum[{v,parent}];
        ll vl = dpv[{v,v}]*invfact[treenum[{v,v}]-1] %MOD;
        vl = vl * fact[treenum[{v,v}]-1-treenum[{v,parent}]] % MOD;
        vl = vl * fact[treenum[{v,parent}]] % (MOD);
        dpv[{parent,parent}] =  vl *invfact[treenum[{parent,v}]] % MOD;
        dpv[{parent,parent}] = dpv[{parent,parent}] * invfact[treenum[{v,parent}]-1] % MOD;
        dpv[{parent,parent}] = dpv[{parent,parent}] * fact[N-1] % (MOD);
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    cin >> N;

    for(int i = 0; i < N-1; i++){
        int a,b;
        cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    fact[0] = 1;
    invfact[0] = 1;
    for(ll i = 0; i < NMAX; i++){
        fact[i+1] = fact[i]*(i+1)%MOD;
    }
    invfact[NMAX] = pow(fact[NMAX], MOD-2);
    for(ll i = NMAX-1; i > 0; i--){
        if(i ==0) exit(1);
        invfact[i] = invfact[i+1]*(i+1)%MOD;
    }
    
    dfs(1,1);

    queue<pair<int,int> > bfs_queue;

    for(ll i = 0; i < to[1].size(); i++){
        pair<int,int> pr = make_pair(1, to[1][i]);
        bfs_queue.push(pr);
    }

    while(bfs_queue.empty() == false){
        pair<int, int> p = bfs_queue.front();
        bfs_queue.pop();
        bfs(p.first, p.second);
        for(ll i = 0; i < to[p.second].size(); i++){
            if(to[p.second][i] != p.first){
                bfs_queue.push(make_pair(p.second, to[p.second][i]));
            }
        }
    }

    for(ll i = 1; i < N+1; i++){
        cout << dpv[{i,i}] << endl;
    }

    return 0;
}

Measured memory_bytes: 79604
# include <bits/stdc++.h>
using namespace std; 
int main(){
  int n,i; 
  cin>>n; 
  int ar[3];
  for(i=0;i<3;i++){
    cin>>ar[i];
  }
  int dp[n][3];
  for(i=0;i<3;i++){
    dp[0][i]=ar[i];
  }
  for(i=1;i<n;i++){
    cin>>ar[0]>>ar[1]>>ar[2];
    dp[i][0]=ar[0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=ar[1]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=ar[2]+max(dp[i-1][1],dp[i-1][0]);
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool flag = true;
  for (int i = 0; i < s.size(); i++) {
    for (int j = i + 1; j < s.size(); j++) {
    	if (s[i] == s[j]) {
          	flag = false;
        	goto BRAKE_LABEL;
        }
    }
  }
  BRAKE_LABEL:
  if (flag) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}


Measured memory_bytes: 256
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int[] n = io.r<int>(' ');
        Array.Sort(n);
        io.w(n[0] + " " + n[1] + " " + n[2]);
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10340
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>

using namespace std;
using ll=long long int;

int main() {
    int a;
    cin >> a;
    string s;
    cin >> s;

    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}


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

int main() {
  //input
  int N;
  cin >> N;
  //calc
  int answer;
  if ( N % 2 == 0 ) {
    answer = (N-2)/2;
  }
  else {
    answer = (N-1)/2;
  }
  //output
  cout << answer << endl;
}

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

int main(){
    vector<vector<ll>> a(3, vector<ll>(3, 0));
    rep(i, 0, 3) cin >> a[i][0] >> a[i][1] >> a[i][2];
    ll n;
    cin >> n;
    vector<ll> b(n);
    rep(i, 0, n) cin >> b[i];

    vector<vector<bool>> op(3, vector<bool>(3, false));
    rep(i, 0, 3){
        rep(j, 0, 3){
            for(auto k : b){
                if(k == a[i][j]) op[i][j] = true; 
            }
        }
    }

    bool flag = false;
    rep(i, 0, 3){
        if(op[i][0] && op[i][1] && op[i][2]) flag = true; 
        if(op[0][i] && op[1][i] && op[2][i]) flag = true;
    }

    if(op[0][0] && op[1][1] && op[2][2]) flag = true;
    if(op[2][0] && op[1][1] && op[0][2]) flag = true;

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Problem : B - Traveling AtCoDeer Problem
// Contest : AtCoder - AtCoder Beginner Contest 064
// URL : https://atcoder.jp/contests/abc064/tasks/abc064_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n;cin>>n;
vi v(n);cin>>v;
int ans=0;
sort(all(v));
for(int i=1;i<n;i++)
ans+=v[i]-v[i-1];
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
#define RP(i, f, t) for (int i = f; i < t; i++)
#define PR(i, f, t) for (int i = t - 1; i >= f; i--)
#define MAX_C 1000000
long long mod_c[MAX_C + 1], mod_r[MAX_C + 1], mod_d;

long long mod_pow(long long x, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
void comb()
{
    if (mod_d == 0)
    {
        long long i;
        mod_c[0] = 1;
        mod_r[0] = 1;
        for (i = 1; i <= MAX_C; i++)
        {
            mod_c[i] = mod_c[i - 1] * i % 1000000007;
        }
        for (i = 1; i <= MAX_C; i++)
        {
            mod_r[i] = mod_pow(mod_c[i], 1000000005, 1000000007);
        }
        mod_d = 1;
    }
}
long long nck(long long x, long long y)
{
    comb();
    long long res = 1;
    res = res * mod_c[x] % 1000000007;
    res = res * mod_r[x - y] % 1000000007;
    res = res * mod_r[y] % 1000000007;
    return res;
}
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    RP(i, 0, n)
    cin >> a[i];
    sort(a.begin(), a.end());
    ll res = 0;
    RP(i, 0, n)
    {
        ll s = 0;
        if (i >= k - 1)
            s += nck(i, k - 1);
        if (n - 1 - i >= k - 1)
            s -= nck(n - 1 - i, k - 1);
        s %= 1000000007;
        res += s * a[i];
        res %= 1000000007;
        // cout << s << endl;
    }
    cout << res << endl;
}

Measured memory_bytes: 16640
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long LL;
const int N = 1<<18|1 , mod = 998244353 , G = 3 , Ginv = (mod + 1) / 3 , inv2 = (mod + 1) / 2;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , len;
int p[N] , q[N] , F[N];

inline int add(int a , int b) { a += b; return a >= mod ? a - mod : a; }
inline int mul(int a , int b) { return (LL)a * b % mod; }
inline int ksm(int a , int k) { int ans = 1; a %= mod; for( ; k ; k >>= 1 , a = mul(a , a)) if(k & 1) ans = mul(ans , a); return ans; }

void FWT(int *A , int opt)
{
	for(int mid = 1 ; mid < len ; mid <<= 1)
	{
		int siz = mid << 1;
		for(int j = 0 ; j < len ; j += siz)
		{
			for(int k = 0 ; k < mid ; ++k)
			{
				int a = A[j + k] , b = A[j + k + mid];
				if(opt == 1) 
					A[j + k] = add(a , b) , A[j + k + mid] = add(a , mod - b);
				else
					A[j + k] = mul(inv2 , add(a , b)) , A[j + k + mid] = mul(inv2 , add(a , mod - b));
			}
		}
	}
	return ;
}

int main()
{
	n = read(); len = 1 << n; int sum = 0;
	for(int i = 0 ; i < len ; ++i) sum += (p[i] = read());
	sum = ksm(sum , mod - 2);
	for(int i = 0 ; i < len ; ++i) p[i] = mul(p[i] , sum);
	for(int i = 1 ; i < len ; ++i) q[i] = mod - 1;
	q[0] = len - 1; p[0] = add(p[0] , mod - 1);
	FWT(q , 1); FWT(p , 1);
	for(int i = 1 ; i < len ; ++i) F[i] = mul(q[i] , ksm(p[i] , mod - 2));
	FWT(F , -1);
	int tmp = mod - F[0];
	for(int i = 0 ; i < len ; ++i) cout << add(tmp , F[i]) << '\n';
	return 0; 
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first fi;
#define second se;
using namespace std;
typedef pair<int, int> P;

signed main(){
    int m, n;
    while(1){
        cin >> m >> n;
        if(m + n == 0) break;
        vector<bool> f(10000000, true);
        int cnt = 0, ans = 0;
        rep(i, m, 10000000){
            if(f[i]){
                cnt++;
                if(cnt == n + 1){
                    ans = i;
                    break;
                }
                for(int j = 2 * i; j <= 10000000; j += i){
                    f[j] = false;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4304
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<int>pos;
	for(int i=0;i<n;i++)
		cin>>b[i];
	reverse(b,b+n);
	for(int i=0;i<n;i++){
		if(a[i]==b[i])
			pos.push_back(i);
	}
	if(!pos.empty()){
	for(int i=0;i<n&&!pos.empty();i++){
		if(a[i]!=b[i]&&a[i]!=b[pos.back()]&&b[i]!=a[pos.back()]){
			swap(b[i],b[pos.back()]);
			pos.pop_back();
			}
	}
	if(!pos.empty()){
		cout<<"No";
		return 0;
	}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<n;i++)
		cout<<b[i]<<" ";
	return 0;
}



Measured memory_bytes: 5776
def is_prime(n):
    if n <= 1:
        return False

    for i in range(2, n):
        if n % i == 0:
            return False

    return True

X = int(input())
lis = [i for i in range(1,34)]
num = []

for i in lis:
    for j in range(2, 11):
        if i**j <= X:
            num.append(i**j)

print(max(num))

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

int main() {
  long long N, K; cin >> N >> K;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    if (i >= K) {
      if (A[i] <= A[i-K]) {
        cout << "No" << endl;
      } else {
        cout << "Yes" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4840
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      String s = sc.next();//文字列
      int length = s.length();//文字列の長さ
      char [] c = s.toCharArray();//格納
      
      //条件に満たない文字を探す
      for(int i =0; i<length; i++){
        if(i%2!=0){
          if(c[i]=='R'){
            System.out.println("No");
            return;
          }
        }    
        else if(i%2==0){
           if(c[i]=='L'){
            System.out.println("No");
            return;
          }
        }
      }
      System.out.println("Yes");
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;cin>>a>>b;
	for(int i=1;i<=3;++i){
		if((a*i*b)%2==1){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
W = np.array([int(x) for x in input().split()])

ans = np.zeros(N-1, dtype=int)

ans = ans + np.inf

for i in range(N-1):
    ans[i] = abs(W[:i+1].sum() - W[i+1:].sum())

print(int(ans.min()))

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

multiset<li> st;


int main() {
    li n;
    cin >> n;
    rin{
        li a;
        cin >> a;
        st.insert(a);
    }
    li res = 0;
    while (!st.empty()) {
        auto it = st.end();
        it--;
        auto val = *it;
        st.erase(it);
        li beki = 1;
        while (beki <= val) beki *= 2;
        auto pair = st.find(beki - val);
        if (pair != st.end()) {
            ++res;
            st.erase(pair);
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar();}
	return f * x;
}

int f[105];  

inline void write(int i) {  
    int p = 0;  
    if (i == 0) p++;  
    else while (i) 
	{  
        f[p++] = i % 10;  
        i /= 10;  
    }  
    for (int j = p - 1; j >= 0; j--) putchar('0' + f[j]);  
}

int n, len, ans, tot[1000003], m, a[500003], b[500003];
struct Modui
{
	int x, y, id;
}q[500003];

inline bool cmp(Modui l, Modui r)
{
	return (l.x / len) ^ (r.x / len) ? (l.x < r.x) : (((l.x / len) & 1)? (l.y < r.y) : (l.y > r.y));
}

inline void add(int xx)
{
	if (++tot[a[xx]] == 1) ++ans;
}

inline void del(int xx)
{
	if (--tot[a[xx]] == 0) --ans;
}

int main()
{
	n = gi(), m = gi();
	for (int i = 1; i <= n; i++) a[i] = gi();
	len = n / sqrt(m * 2 / 3);
	for (int i = 1; i <= m; i++) q[i].x = gi(), q[i].y = gi(), q[i].id = i;
	sort(q + 1, q + 1 + m, cmp);
	int l1 = 0, r1 = 0;
	for (int i = 1; i <= m; i++)
	{
		int kl = q[i].x, kr = q[i].y;
		while (l1 < kl) del(l1++);
		while (l1 > kl) add(--l1);
		while (r1 < kr) add(++r1);
		while (r1 > kr) del(r1--);
		b[q[i].id] = ans;
	}
	for (int i = 1; i <= m; i++) write(b[i]), puts("");
	return 0; 
}

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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
	sum += n % 10;
	n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
	int sum = findSumOfDigits(i); // i の各桁の和
	if (sum >= A && sum <= B) { //  i の各桁の和が A 以上 B 以下かどうか
	  total += i;
	}
  }
  cout << total << endl;
}


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

int main() {
  int X, Y;
  cin >> X >> Y;

  if (2 * X <= Y && Y <= 4 * X && Y % 2 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def porownaj(): 
    a, b = wczytaj_liste() 
    if a < b:
        for i in range(b):
            print(a , end ='')
    else: 
        for i in range(a):
            print(b , end ='')

porownaj()

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int MAX = 1e5;
struct S
{
    int a, num;
};
bool cmp(S a, S b)
{
    return a.a < b.a;
}
int main()
{
    S xx[MAX + 5];
    int n;
    long long k;
    int a, b;
    scanf("%d%lld", &n, &k);
    for(int i = 0; i < n; ++i)
    {
        scanf("%d%d", &xx[i].a, &xx[i].num);
    }
    sort(xx, xx + n, cmp);

    for(int i = 0; i < n; ++i)
    {
        k -= xx[i].num;
        if(k <= 0)
        {
            cout << xx[i].a << endl;
            break;
        }
    }
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<double> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  for(int j=0;j<N;j++){
    vec[j]=1/vec[j];
  }
  double sum=0;
  for(int k=0;k<N;k++){
    sum+=vec[k];
  }
  double ans;
  ans=1/sum;
  cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 256
def gcd(a, b):
  m = max(a, b)
  n = min(a, b)
  if n==0:
    return m
  else:
    return gcd(n, m%n)
 
N = int(input())
l = 1
for i in range(N):
  t = int(input())
  g = gcd(l, t)
  l *= t//g
print(l)

Measured memory_bytes: 2568
while True:
    m,f,r = map(int,input().split())
    
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger x = new BigInteger(sc.next());
		boolean flag = true;
		BigInteger ans = x.divide(new BigInteger("11")).multiply(new BigInteger("2"));
		int y = x.mod(new BigInteger("11")).intValue();
		if(0 < y && y <= 6) {
			ans = x.divide(new BigInteger("11")).multiply(new BigInteger("2")).add(new BigInteger("1"));
		} else if(6 < y) {
			ans = x.divide(new BigInteger("11")).multiply(new BigInteger("2")).add(new BigInteger("2"));
		}
		System.out.println(ans.toString());

	}

}


Measured memory_bytes: 21844
N,K=map(int,input().split())

if K == 0:
  print(N*N)
else:
  total = 0
  for i in range(1,N+1):
    if K <= (i-1):
      total += (N//i)*(i-K)
    if K <= (N%i):
      total += (N%i)-K+1
  print(total)

Measured memory_bytes: 3060
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<string>
#include<cmath>
#include<cassert>
#include<map>
using namespace std;

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ (i)=0;(i)<(j);(i)++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);(i)++)
#define all(v) begin(v),end(v)

typedef pair<int,int> pii;

int H,W,s;
vector< vector<int> > G;

pii MEMO[32][32][32][32];//<??°???????????°????????????>

int ALLSUM[32][32];

pii rec(int y,int x,int h,int w){
  if(MEMO[y][x][h][w].first!=0)return MEMO[y][x][h][w];

  int rect_sum=ALLSUM[y+h-1][x+w-1];
  if(y>0 && x>0)rect_sum+=ALLSUM[y-1][x-1];
  if(y>0)rect_sum-=ALLSUM[y-1][x+w-1];
  if(x>0)rect_sum-=ALLSUM[y+h-1][x-1];
  if(s<ALLSUM[H-1][W-1]-rect_sum)return make_pair(-1,-1);
  
  if(w==1&& h==1){
    return make_pair(1,s-ALLSUM[H-1][W-1]+G[y][x]);
  }
  
  pii ret=make_pair(1,s-ALLSUM[H-1][W-1]+rect_sum);
  rep(i,h-1){
    //i=0 to h-2;
    pii ret1=rec(y,x,i+1,w);
    pii ret2=rec(y+i+1,x,h-(i+1),w);
    pii tmp;
    if(ret1.first==-1 || ret2.first==-1)continue;
    tmp.first=ret1.first+ret2.first;
    tmp.second=min(ret1.second,ret2.second);
    ret=max(ret,tmp);
  }
  rep(i,w-1){
    pii ret1=rec(y,x,h,i+1);
    pii ret2=rec(y,x+i+1,h,w-(i+1));
    pii tmp;
    if(ret1.first==-1 || ret2.first==-1)continue;
    tmp.first=ret1.first+ret2.first;
    tmp.second=min(ret1.second,ret2.second);
    ret=max(ret,tmp);
  }
  return MEMO[y][x][h][w]=ret;
}

int main()
{
  while(true){
    G.clear();
    rep(i,32)rep(j,32)rep(k,32)rep(l,32)MEMO[i][j][k][l]=make_pair(0,0);
    rep(i,32)rep(j,32)ALLSUM[i][j]=0;
    
    cin>>H>>W>>s;
    if(!H and !W and !s)break;
    G.resize(H,vector<int>(W));
    rep(i,H)rep(j,W)scanf("%d",&G[i][j]);

    rep(i,H){
      rep(j,W){
        ALLSUM[i][j]=G[i][j];
        if(j>0)ALLSUM[i][j]+=ALLSUM[i][j-1];
      }
    }
    rep(i,H){
      rep(j,W){
        if(i>0)ALLSUM[i][j]+=ALLSUM[i-1][j];
      }
    }

    
    pii ans=rec(0,0,H,W);
    printf("%d %d\n",ans.first,ans.second);
    
  }
  return 0;
}

Measured memory_bytes: 9448
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef map<ll,ll> mpll;
typedef set<ll> setll;
typedef multiset<ll> msetll;
 
#define F first
#define S second
#define pb push_back
#define mp make_pair
 
const ll inf = ll(1e18);
const ll MOD = (1e9 + 7);
 

ll n,k;


vvll mult(vvll v1,vvll v2){
	vvll temp(n);
	for(int i=0;i<n;i++) {
		temp[i].resize(n);
		fill(temp[i].begin(), temp[i].end(),0);
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ll xx = 0;
			for(int i1=0;i1<n;i1++){
				xx += (v1[i][i1]*v2[i1][j]);
				// /cout<<v1[i][i1]<<" "<<v2[i1][j]<<"\n";
				xx%=MOD;
			}
			//cout<<i<<" "<<j<<"\n";
			temp[i][j] = xx;
		}
	}
	return temp;
}

vvll func(vvll arr,ll p){
	vvll res(n);
	for(int i=0;i<n;i++){
		res[i].resize(n);
		fill(res[i].begin(), res[i].end(),0);
	}
	for(int i=0;i<n;i++){
		res[i][i] = 1;
	}
	while(p){
		if(p&1){
			res = mult(res,arr);
		}
		arr = mult(arr,arr);
		p=p>>1;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG_
		freopen("input.txt","r",stdin);
	#endif
	cout.setf(ios::fixed), cout.precision(20);

	cin >> n >> k;
	vector<vector<ll>> arr;
	arr.resize(n);
	for(int i=0;i<n;i++){
		arr[i].resize(n);
		for(int j=0;j<n;j++){
			cin >> arr[i][j];
		}
	}

	vvll ans;
	ans  = func(arr,k);

	ll su =0; 
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			su+=ans[i][j];
			su%=MOD;
		}
	}
	cout<<su<<"\n";
	return 0;
}


Measured memory_bytes: 384
n = int(input())
if n<10:
    print(n)
elif n<100:
    print(9)
elif n<1000:
    print(n-(99-9))
elif n<10000:
    print(999-(99-9))
elif n<100000:
    print(n-(9999-999)-(99-9))
elif n==100000:
    print(99999-(9999-999)-(99-9))



Measured memory_bytes: 2940
#include <stdio.h>
using namespace std;

int main()
{
    char s[100];
    scanf("%s", s);
    if(s[0] == 'Y'&&s[1] == 'A'&&s[2] == 'K'&&s[3] == 'I') printf("Yes\n");
    else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (A, B) = sc.nextLine().split(" ")

    val numA = A.toInt()
    val numB = B.toInt()
    val start = A.substring(0, 3)
    val end = B.substring(0, 3)

    val startPal = start + start[1] + start[0]
    val endPal = end + end[1] + end[0]

    var ret = end.toInt() - start.toInt() - 1

    if (A <= startPal) {
        ret++
    }
    if (endPal <= B) {
        ret++
    }
    println(ret)
}

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

import numpy as np
import itertools

N = int(input())
xs = np.zeros(N)
ys = np.zeros(N)
for i in range(N):
  xs[i], ys[i] = map(int, input().split())

lenMat = np.zeros((N, N))
for j in range(N):
  for i in range(N):
    lenMat[j,i] = np.sqrt((xs[i]-xs[j])**2 + (ys[i]-ys[j])**2)

sumVal = 0.0     
count = 0

seq = np.arange(N)
for lst in list(itertools.permutations(seq)):
    #print(lst)
    count += 1
    for i in range(N-1):
	    sumVal += lenMat[lst[i], lst[i+1]] 

print(sumVal/count)
        
        
#for i in range(N):
#  print(xs[i],ys[i])


Measured memory_bytes: 16968
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'='|'>='|'>'|'<='|'<'='=')=>{for(let i=0;i<a.length;i+=2){if(op==='='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};

const main = ()=>{
  let [a,b]=srin(2)
  out(a==b?'=':eval('0x' + a + '> 0x'+ b)?'>':'<')
}
main()

Measured memory_bytes: 7372
#include <stdio.h>

int main(void){

  int n;
  int r;
  int i;
  int j;

  while(1){
    int hanafuda[50]={0};
    int copy[51]={0};
    int change[51]={0};
    int p=0;
    int c=0;
    int k=1;

    scanf("%d%d",&n,&r);
    if(n==0 && r==0){
      break;
    }

    for(i=n;i>0;i--){
      hanafuda[i]=k;
      k++;
    }

    /* for(i=1;i<=n;i++){
      printf("hanafuda[%d]:%d\n",i,hanafuda[i]);
      }*/

    for(i=0;i<r;i++){

      scanf("%d%d",&p,&c);
      
      for(j=1;j<p;j++){
	copy[j]=hanafuda[j];
	/*printf("copy[%d]:%d\n",j,copy[j]);*/
      }

      k=1;
      for(j=p;j<p+c;j++){
       
	change[k]=hanafuda[j];
	/*printf("change[%d]:%d\n",k,change[k]);*/
	k++;
      }

      for(j=1;j<=c;j++){
	hanafuda[j]=change[j];
      }

      k=1;
      for(j=c+1;j<p+c;j++){
    
	hanafuda[j]=copy[k];
	k++;
      }

    }

    /* printf("hanafuda:");
    for(i=1;i<=5;i++){
      printf("%d",hanafuda[i]);
      }*/
    printf("%d\n",hanafuda[1]);

  }

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX_N = 60;

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

vector<int> par;
vector<int> rnk;
int root;

void init(int n){
    par = vector<int>(n);
    rnk = vector<int>(n);
    root = n;
    for (int i = 0; i < n; i++){
        par[i] = i;
        rnk[i] = 0;
    }
}

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) par[x] = y;
    else{
        par[y] = x;
        if (rnk[x] == rnk[y]) par[y] = x;
    }

    root--;
}

bool same(int x, int y){
    return find(x) == find(y);
}

int a[MAX_N], b[MAX_N], g[MAX_N][MAX_N];

int main(){
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        a[i] = x - 1;
        b[i] = y - 1;
        g[x - 1][y - 1] = 1;
    }

    int ans = 0;
    for (int i = 0; i < m; i++){
        init(n);
        g[a[i]][b[i]] = 0;
        for (int j = 0; j < m; j++){
            if (g[a[j]][b[j]]) unite(a[j], b[j]);
        }

        if (!same(a[i], b[i])) ans++;
        
        g[a[i]][b[i]] = 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
class UnionFind:
  def __init__(self,n):
    self.parent=[i for i in range(n)] # 親要素のノード番号を格納 parent[x]==xの時そのノードは根
    self.rank=[0]*n # 木の高さを格納する
    self.count=0
    
  def root(self,x): # 根を返す
    if self.parent[x]==x: # 根ならその番号を返す
      return x
    else: # 根でないなら、親の要素で再検索 捜査の過程で親を書き換える
      self.parent[x]=self.root(self.parent[x])
      return self.root(self.parent[x])
    
  def is_same(self,x,y): # 同じ集合に属するか(根が同じか)判定
    return self.root(x)==self.root(y)
  
  def union(self,x,y): # 併合
    # 根を探す
    x=self.root(x)
    y=self.root(y)
    if x==y: return # 根が同じなら既に同じ集合なのでreturn
    # 木の高さを比較し、低い方から高い方に辺を張る
    if self.rank[x]<self.rank[y]:
      self.parent[x]=y
    else:
      self.parent[y]=x
      if self.rank[x]==self.rank[y]: self.rank[x]+=1
    self.count+=1
    
from collections import Counter
n,m,k=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]
CD=[list(map(int,input().split())) for _ in range(k)]

blocks=[set() for _ in range(n)]
for c,d in CD:
  c,d=c-1,d-1
  blocks[c].add(d)
  blocks[d].add(c)

friends=[0]*n
uf=UnionFind(n)
for a,b in AB:
  a,b=a-1,b-1
  friends[a]+=1
  friends[b]+=1
  if not uf.is_same(a,b): uf.union(a,b)
    
ctr=Counter()
for i in range(n):
  r=uf.root(i)
  ctr[r]+=1
  
ans=[]
for i in range(n):
  tmp=ctr[uf.root(i)]-friends[i]-1
  for b in blocks[i]:
    if uf.is_same(i,b): tmp-=1
  ans.append(tmp)
print(*ans)

Measured memory_bytes: 105088
#include <bits/stdc++.h>
 #include <math.h>
 #include <string>
 using namespace std;
 
 int main(){
    int W, H, N;
    int x[120], y[120], a[120];
    int i,j,k;
    int ans[120][120];
    int num=0;

    cin >> W >> H >> N;
    for (i=0; i<N; i++){
        cin >> x[i] >> y[i] >> a[i];
        }

    for (i=0; i<N; i++) {
    
    if (a[i]==1){
    for (j=0; j<x[i]; j++){
        for(k=0; k<H; k++)
            ans[j][k]=1;
        }
    }
    if (a[i]==2){
    for (j=x[i]; j<W; j++){
        for(k=0; k<H; k++)
            ans[j][k]=1;
        }
    }
    if (a[i]==3){
    for (j=0; j<y[i]; j++){
        for(k=0; k<W; k++)
            ans[k][j]=1;
        }
    }
    if (a[i]==4){
    for (j=y[i]; j<H; j++){
        for(k=0; k<W; k++)
            ans[k][j]=1;
        }
    }
    }

    for (i=0; i< W; i++){
        for(j=0; j<H; j++){
            if(ans[i][j]==0)
                num++;
        }
   }
        cout << num << endl;

    return 0;
 }
 


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        int num = sc.nextInt();
        
        if(num % 2 == 0) System.out.println(num / 2);
        else System.out.println(num / 2 + 1);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,t=0;
  cin>>N;
  string s;
  map<string,int> m;
  for(int i=0;i<N;i++){
    cin>>s;
    if(m.count(s)) continue;
    else{
      m[s]=1;
      t++;
    }
  }
  cout<<t<<endl;
}


Measured memory_bytes: 19228