akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    string s; cin >> s;
    int same = 0, diff = 0;
    For(i, 1, s.size()) {
        if(s[i] != s[i-1]) diff++;
        else same++;
    }

    if(same == s.size()-1) cout << 0;
    else cout << diff;

    
    
    
    return 0;
}

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

int main() {
	int a; string b;
	while (cin >> a, a) {
		cin >> b;
		for (int c = 0; c < a; c++) {
			string s = "";
			for (int d = 0; d < b.length(); d++) {
				int e = d;
				for (; d < b.length() - 1; e++) {
					if (b[d] != b[e + 1])break;
				}
				s += to_string(e-d+1); s += b[d]; d = e;
			}
			b = s;
		}
		cout << b << endl;
	}
}

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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int x=0;
	int ans =0;
	rep(i,s.size()){
		if(s[i]=='I')x++;
		else if(s[i]=='D')x--;
		ans=max(ans,x);
	}
	cout << ans << endl;
	
}


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

vector<int> w;
int n, k, sum, W;

bool hoge(int P){//cout<<P<<" --P--"<<endl;
	int count = 1, temp = 0;
	for(int y : w){//cout<<y<<" "<<count<<" "<<temp<<endl;
		if(y > P) return false;
		if(temp + y <= P){
			temp += y;
		} else {
			count++;
			temp = y;
		}
	}
	if(count <= k) return true;
	else return false;
}

int solve(){
	int r = sum+1, l = 0, m = (l+r)/2;
	
	while(r-l>1){//cout<<m<<" "<<l<<" "<<r<<endl;
		m = (l+r)/2;
		if(hoge(m)) r = m;
		else l = m;
	}
	
	return r;
}

int main(){
	
	cin>>n>>k;
	
	for(int i = 0; i < n; i++){
		cin>>W;
		sum += W;
		w.push_back(W);
	}
	
	cout<<solve()<<endl;
	return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[200010];
int main()
{
	scanf("%d",&n);
	int sum=0;
	for (int i=0;i<n;i++) scanf("%d",&a[i]),sum^=a[i];
	for (int i=0;i<n;i++) printf("%d ",sum^a[i]);
	return 0;
}

Measured memory_bytes: 4600
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
int a[100100], b[100100];
int q;
int V[100100], D[100100], C[100100];

vector<int> G[100100];

int color[100100];
int dist[100100];

void dfs(int v, int d, int c) {
    if (d < dist[v] || (d == dist[v] && d > 0))
        return;
    if (color[v] == 0) {
        color[v] = c;
    }
    if (d == 0)
        return;

    dist[v] = d;
    for (int u : G[v]) {
        dfs(u, d-1, c);
    }
}

void solve() {
    for (int i = 0; i < m; i++) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    
    for (int i = q-1; i >=0; i--) {
        dfs(V[i], D[i], C[i]);
    }

    for (int i = 0; i < n; i++) {
        cout << color[i] << endl;
    }
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> V[i] >> D[i] >> C[i];
        V[i]--;
    }
}

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

    input();
    solve();
}


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

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int num = l/d;
    int count=0;
    int n;
    if(l%d==0){
        n=l;
        while(n<=r){
            count++;
            n=n+d;
        }
        cout<<count;
    }
    else {
        n=((l/d)+1)*d;
        while(n<=r){
            count++;
            n=n+d;
        }
        cout<<count;
    }
    return 0;
}





Measured memory_bytes: 3564
/**
 *    Author  : Ador
 *    Created : 24.07.2020
**/
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cctype>
typedef long long int ll ;
typedef unsigned long long int ull ;
using namespace std ;
int main(void)
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
        //freopen("input.txt", "r", stdin) ;
        //freopen("output.txt", "w", stdout) ;
    int n , d , flag = 0 , i ; cin >> n ;
    for(i = 1 ; i <= 9 ; ++i)
    {
        if(!(n % i)) d = n / i ;
        if(d < 10) {flag = 1 ; break ; }
    }
    if(flag) cout << "Yes\n" ;
    else cout << "No\n" ;
    return 0 ;
}


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

using namespace std;

using ll = long long;

ll lcm(ll x, ll y) {
    return x / __gcd(x, y) * y;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll m;
    cin >> m;
    vector<ll> a(n);
    ll total = 1;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] >>= 1;
        total = lcm(total, a[i]);
    }

    ll ans = (m / total + 1) / 2;
    for (int i = 0; i < n; ++i) {
        if (total / a[i] % 2 == 0) {
            ans = 0;
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1152
N = int(input())						# 5


ans = 0

#1:1-9
if 1<=N<=9:
	ans += N

#2:10-99
if 10<=N:
	ans += 9

#3:100-999
if 100<=N<=999:
	ans += N-99

#4:1000-9999
if 1000<=N:
	ans += 900

#5:10000-99999
if 10000<=N<=99999:
	ans += N-9999


#6:100000-999999
if 100000<=N:
	ans += 90000


print(ans)


Measured memory_bytes: 3060
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL MaxN = 1 + 1e5;

LL n, a[MaxN];

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1 ; i <= 9 ; ++i)
    if(n % i == 0 && n / i <= 9){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long LL;
const LL inf = 0x3f3f3f3f3f3f3f3f;
int n;
LL ans, sum;

int main() {
	scanf("%d", &n);
	ans = inf;
	for(int i = 1, x, y; i <= n; ++i) {
		scanf("%d%d", &x, &y);
		sum += x;
		if(x > y) ans = min((LL)y, ans);
	}
	if(ans == inf) puts("0");
	else printf("%lld\n", sum-ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int A,B,C,X;
int ma,mb,mc,cunt;
int main(){
    cin>>A>>B>>C>>X;
    ma=X/500,mb=X/100,mc=X/50;
    for(int i=0;i<=min(ma,A);i++){
        for(int j=0;j<=min(mb,B);j++){
            for(int k=0;k<=min(mc,C);k++){                          
                if(50*k+100*j+500*i==X)cunt++;

            }   
        }   
    }   
    cout<<cunt<<"\n";
    return 0;

}


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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (const auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
#define int long long
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vb = vector<bool>;
using vii = vector<ii>;
using vivi = vector<vi>;

const int N = 1e5 + 5, MOD = 1e9 + 7, INF = 1e9 + 5;

int add(int x, int y) { return (((x + MOD) % MOD) + ((y + MOD) % MOD)) % MOD; }

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int dp[n][k + 1];
    for (int j = 0; j <= k; j++) dp[0][j] = (j <= a[0]);
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= k; j++) {
            if (j == 0) dp[i][j] = dp[i - 1][j] % MOD;
            else dp[i][j] = add(dp[i - 1][j], dp[i][j - 1] - (j - a[i] - 1 >= 0 ? dp[i - 1][j - a[i] - 1] : 0));
        }
    }
    cout << dp[n - 1][k] % MOD;
}

Measured memory_bytes: 81548
#include<stdio.h>

int main(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);                
    if (a <= b && b <= c)
    {
        printf("%d %d %d",a,b,c);
    }    
    else if (a <= c && c <= b)
    {
        printf("%d %d %d",a,c,b);
    }    
    else if (b <= a && a <= c)
    {
        printf("%d %d %d",b,a,c);
    }    
    else if (b <= c && c <= a)
    {
        printf("%d %d %d",b,c,a);
    }    
    else if (c <= a && a <= b)
    {
        printf("%d %d %d",c,a,b);
    }    
    else if (c <= b && b <= a)
    {
        printf("%d %d %d",c,b,a);
    }    
    printf("\n");
    return 0;
}

Measured memory_bytes: 1032
#!/usr/bin/env python3
import sys
import math


def solve(N: int, K: int):
    l = [(1 / 2) ** max(0, math.ceil(math.log2(K / i))) for i in range(1, N + 1)]
    print(sum(l) / len(l))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

	public static void main(String args[]) throws IOException {

		HashSet<Long> set = new HashSet<>();

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		long a = Integer.parseInt(str[0]);
		long b = Integer.parseInt(str[1]);
		int k = Integer.parseInt(str[2]);
		for (long i = a; i < a + k; i++) {
			if (i >= a && i <= b) {
				set.add(i);
				System.out.println(i);
			}
		}
		for (long i = b - k + 1; i <= b; i++) {
			if (i >= a && i <= b) {
				if (!set.contains(i))
					System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 22996
# AOJ ITP1_10_A

import math

def floatinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = float(a[i])
    return a

def main():
    data = floatinput()
    a = data[0]; b = data[1]; C = data[2]
    S = a * b * 0.5 * math.sin(math.radians(C))
    c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C)))
    L = a + b + c
    h = b * math.sin(math.radians(C))
    print(S); print(L); print(h)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5696
n=int(input())
s=input()
data=[0]*(n+1)
for i in range(n):
  if s[i]=='E':
    data[i+1]=data[i]+1
  else:
    data[i+1]=data[i]
print(min(i-data[i]+data[n]-data[i+1] for i in range(n)))

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

int main () {
    string s, t;
    cin >> s >> t;
    int alphabet[26];
    for (int i = 0; i < 26; i++) {
        alphabet[i] = -1;
    }
    vector<vector<int> > all(26, vector<int> ());
    for (int i = 0; i < s.size(); i++) {
        all[s[i] - 97].push_back(i);       
    }

    for (int i = 0; i < s.size(); i++) {
        // まずは、s[i]が変わっていないか調べる
        if (s[i] == t[i] || alphabet[s[i] - 97] == 1) {
            // なにもしない
            if (s[i] != t[i]) {
                cout << "No" << endl;
                break;
            }
            alphabet[t[i] - 97] = 1;
        }
        else {
            // s[i]に該当するところを変えていく
            vector<int> ss;
            for (int j = 0; j < all[s[i] - 97].size(); j++) {
                int sub = all[s[i] - 97][j];
                if (sub != i) {
                    s[sub] = t[i];
                }
                if (sub < i) {
                    cout << "No" << endl;
                    return 0;
                }
            }
            for (int j = 0; j < all[t[i] - 97].size(); j++) {
                int sub = all[t[i] - 97][j];
                if (sub != i) {
                    s[sub] = s[i];
                }
            }
            all[s[i] - 97].swap(all[t[i] - 97]);
            s[i] = t[i];
            alphabet[t[i] - 97] = 1;
   
        }
        if (s == t) {
            cout << "Yes" << endl;
            break;
        }
        if (i == (s.size() - 1)) {
            if (s == t) {
                cout << "Yes" << endl;
            }    
            else {
                cout << "No" << endl;    
            }
        }
    }
}

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

int main() {
	long long a, b;
	scanf("%lld%lld", &a, &b);
	long long c = b/__gcd(a, b);
	if(c == 1) printf("-1\n");
	else printf("%lld\n", (c-1)*a);
	return 0;
}


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

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

const int INF = 1000000007;

int main(void){
    ll x, a, b;
    cin >> x >> a >> b;
    if(a >= b){
        cout << "delicious" << endl;
        return 0;
    }else if(a < b){
        if(a+x >= b){
            cout << "safe" << endl;
            return 0;
        }else{
            cout << "dangerous"<< endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
s=input()
ans="No"
if len(s)==2 and s=="hi":
  ans="Yes"
if len(s)==4 and s=="hihi":
  ans="Yes"
if len(s)==6 and s=="hihihi":
  ans="Yes"
if len(s)==8 and s=="hihihihi":
  ans="Yes"
if len(s)==10 and s=="hihihihihi":
  ans="Yes"
print(ans)



Measured memory_bytes: 3064
#include<stdio.h>

int s[100002],n,k,q,a;

int main(){
  scanf("%d%d%d",&n,&k,&q);
  k=q-k;
  for(int i=0;i<q;i++){
    scanf("%d",&a);
    s[a]++;
  }
  for(int i=1;i<=n;i++){
    if(s[i]>k)puts("Yes");
    else puts("No");
  }
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define endl '\n'
 
const ll MOD = 1000000007;

int main() {
   int n; scanf("%d", &n);
   char c[n]; scanf("%s", c);
   int cnt = 0;
   for (char i : c)
      if (i == 'R') cnt++;
   int ans = cnt;
   for (int i = 0; i < cnt; i++)
      if (c[i] == 'R') ans--;
   printf("%d", ans);
   return 0;
}

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

int main(void){
 
    int N;
    cin >> N;
    
    if(N /10 == 9 || N % 10 == 9){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
}

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

class Program
{
    static int A;
    static int B;

    static void Main(string[] args)
    {
        var s = new Scanner();
        A = s.ReadInt();
        B = s.ReadInt();

        Solve();
    }

    static void Solve()
    {
        var ans = 0;
        var count = 1;
        while (count < B)
        {
            count += A - 1;
            ans += 1;
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }

    public string ReadStr()
    {
        return this.Next();
    }

    public char ReadChar()
    {
        return this.Next()[0];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }

    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }

    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

int main() {
	string S;
	cin >> S;
	ll a=0;
	ll b=0;
	ll sum = 0;
	for (ll i = 0; i < S.size(); i++) {
		if (S[i] == '<') {

			if (b != 0&&a!=0) {
				//輪を求める
				if (a >= b) {

					sum += a * (a + 1) / 2 + b * (b - 1) / 2;

				}
				else {
					sum += b * (b + 1) / 2 + a * (a - 1) / 2;


				}
				

				a = 0;
				b = 0;
			}
			if (a == 0) {


				sum += b * (b + 1) / 2;
				b = 0;
			}
			a++;
		}
		else {
			b++;
			
		}

	}
	if (a >= b) {

		sum += a * (a + 1) / 2 + b * (b - 1) / 2;

	}
	else{
		sum += b * (b + 1) / 2 + a * (a - 1) / 2;


	}
	
	cout << sum;

}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define lint long long
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define tracea(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define print(arr, n) for (int iDx = 0; iDx < (n); iDx++) cout << arr[iDx] << " \n"[iDx == (n)-1]
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;

int cnt, prt[MAXN], lvl[MAXN], size[MAXN];
vector<int> edge[MAXN];

void dfs(int now, int par) {
	size[now] = 1;
	for (auto i: edge[now]) {
		if (i == par) continue;
		prt[i] = now;
		lvl[i] = lvl[now]+1;
		dfs(i, now);
		size[now] += size[i];
	}
}

int cari(int now, int par, int step) {
	if (now == N) return step;
	for (auto i: edge[now]) {
		if (i == par) continue;
		int x = cari(i, now, step+1);
		if (x != -1) return x;
	}
	return -1;
}

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		scanf("%d%d", &x, &y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	prt[1] = -1;
	lvl[1] = 0;
	dfs(1, -1);
	x = cari(1, -1, 0);
	if (lvl[1] <= lvl[N]) {
		int now;
		int tar = (x-1)/2;
		for (now = N; lvl[now] > lvl[N]-tar; now = prt[now]);
		if (size[now] < (N+1)/2) {
			puts("Fennec");
		} else {
			puts("Snuke");
		}
	} else {
		int now;
		int tar = (x-1)/2;
		for (now = 1; lvl[now] > lvl[N]-tar; now = prt[now]);
		if (size[now] < (N+1)/2) {
			puts("Snuke");
		} else {
			puts("Fennec");
		}
	}
	
	return 0;
}


Measured memory_bytes: 13184
def solve():
    N,M,C = [int(s) for s in input().split() if s]
    B = [int(s) for s in input().split() if s]
    A = [[int(s) for s in input().split() if s] for _ in range(N)]
    count = sum(sum(a*b for a,b in zip(A[i],B)) + C > 0 for i in range(N))
    print(count)
    
solve()

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}
int no=1,n1;
int recu(int n,int k,int val){


	if(n==n1){
		return min(val*2,val+k);
	}
	return min( recu(n+1,k,2*val),recu(n+1,k,val+k)              );


}

int main() {
    int i,m,n,k,c=0,sum=0;
    c_p_c();
    // cout<<"Sd"<<endl;>
  	cin>>n;
  	n--;
  	ll l0=2ll,l1=1ll,l2=1ll;
  	while(n--){

  		l2=l0+l1;
  		l0=l1;
  		l1=l2;


  	}
  	cout<<l2<<endl;

   }

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

template<typename T>
void O(T t){
  cout << t << endl;
}

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<ll> v(3),k;
  rep(i,3){
    cin >> v[i];
  }
  rep(j,3){
    if(v[j] % 2){
      cout << 0 << endl;
      return 0;
    }
  }
  set<vector<ll>> s;
  s.insert(v);
  ll ans = 0;
  while(1){
    k = v;
    v[0] = k[1]/2 + k[2]/2;
    v[1] = k[0]/2 + k[2]/2;
    v[2] = k[1]/2 + k[0]/2;
    rep(j,3){
      if(v[j] % 2){
        cout << ans+1 << endl;
        return 0;
      }
    }
    if(s.find(v) == s.end()){
      s.insert(v);
    }
    else{
      cout << -1 << endl;
      return 0;
    }
    ++ans;
  }
  return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define INF 1152921504606846976

int main() {
    i64 N, K; cin >> N >> K;
    vector<i64> A(N);

    i64 mini;
    REP(i, N) {
        cin >> A[i];
        if (A[i] == 1) mini = i;
    }

    i64 minc = INF;
    REP(i, K) {
        i64 left_n = mini - (K - 1 - i);
        i64 right_n = N - (mini + 1) - i;
        i64 cnt = 1;
        if (left_n > 0) cnt += left_n / (K - 1) + (left_n % (K - 1) > 0);
        if (right_n > 0) cnt += right_n / (K - 1) + (right_n % (K - 1) > 0);
        chmin(minc, cnt);
    }
    cout << minc << endl;

    return 0;
}

Measured memory_bytes: 1024
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn get_digit(mut n: usize) -> usize {
    let mut a = 0;
    while n > 0 {
        n /= 10;
        a += 1;
    }
    a
}

fn main() {
    let n: usize;
    input!(n);
    let mut ans = 0;
    for z in 1..n + 1 {
        if get_digit(z) % 2 != 0 {
            ans += 1;
        }
    }
    p(ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0 ; i < n ; i++ )
using namespace std;
void input(bool grid[][9]){
  rep(i,9){
    string s;
    cin >> s;
    if(i%2 == 0){
      rep(j,4)grid[i][j*2+1] = s[j] - '0';
    } else {
      rep(j,5)grid[i][j*2] = s[j] - '0';
    }
  }
}

enum dir{
  UP,RIGHT,DOWN,LEFT
};
const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};
const char output[] = "URDL";

bool in_range(int a,int b){
  return 0 <= a && a < 9 && 0 <= b && b < 9;
}
int main(){
  bool grid[9][9] = {{0}};
  input(grid);

  int i = 0,j = 0;
  dir prev = RIGHT;
  for(;;){
    dir next[] = {LEFT,UP,RIGHT,DOWN};
    rotate(next,next + prev,next + 4);

    int k;
    for(k = 0 ; k < 3 ; k++ ){
      if(in_range(i+di[next[k]],j+dj[next[k]]) &&
	 grid[i+di[next[k]]][j+dj[next[k]]]){
	break;
      }
    }
    cout << output[next[k]];
    i+=di[next[k]]*2;
    j+=dj[next[k]]*2;
    prev = next[k];
    if(i == 0 && j == 0)break;
  } 
  cout << endl;
  return 0;
}

Measured memory_bytes: 1196
M = 1000000007


def main():
    n, k = list(map(int, input().split()))

    f = [1]
    g = [1]
    for i in range(1, 2 * n + 1):
        f.append(i * f[i - 1] % M)
        g.append(pow(f[i], -1, M))
    for i in range(1, k + 1):
        if n - k < i - 1:
            print(0)
        else:
            blue_ball = k - i
            blue_box = i
            blue_comb = f[blue_ball + blue_box - 1] * \
                g[blue_ball] % M * g[blue_box - 1] % M
            red_ball = n - k - i + 1
            red_box = i + 1
            red_comb = f[red_ball + red_box - 1] * \
                g[red_ball] % M * g[red_box - 1] % M
            print(blue_comb * red_comb % M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9412
import numpy as np

s = input()
t = list("abcdefghijklmnopqrstuvwxyz")
s = list(sorted(set(s)))

ans = "None"
ls = len(s)
for i in range(ls):
    if s[i] != t[i]:
        ans = t[i]
        break
    elif s[i] == t[i] and i == ls-1 and i < 25:
        ans = t[i+1]
        break
        
print(ans)

Measured memory_bytes: 12628
#include<iostream>
using namespace std;
int main()
{
	int n,w[100],bn=0,bs=0,mi=100,a;
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>w[t];
		bs=bs+w[t];
	}
	for(int t=0;t<n;t++)
	{
		bn=bn+w[t];
		bs=bs-w[t];
		a=max(bn-bs,bs-bn);
		if(mi>a)
		{
			mi=a;
		}
	}
	cout<<mi;
	return 0;
}

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

ans = []
if N % 2 == 0:
    l1 = A[0::2]
    l2 = A[1::2]
    l2 = l2[::-1]
    ans = l2+l1
else:
    l1 = A[0::2]
    l2 = A[1::2]
    l1 = l1[::-1]
    ans = l1+l2

print(" ".join(list(map(str, ans))))


Measured memory_bytes: 119252
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define first X
#define second Y
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
char s[5];
int main()
{
    while(~scanf("%s",s))
    {
        for(int i = 0; i < 3; ++i)
        if(s[i] == '1')
        s[i] = '9';
        else if(s[i] == '9')
            s[i] = '1';
        printf("%s\n",s);
    }
}












Measured memory_bytes: 256
import math
n, k = map(int, input().split())
mod = 10**9 + 7

modinv_table = [-1] * (k+1)
modinv_table[1] = 1
for i in range(2, k+1):
    modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod

def binomial_coefficients(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans

for i in range(1,k+1):
    print(int(binomial_coefficients(n-k+1, i)*binomial_coefficients(k-i+i-1, i-1)%mod))

Measured memory_bytes: 69868
#include "bits/stdc++.h"
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N;
    cin >> N;

    cout << 180 * (N - 2) << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
const int N=100005;
int n;
vector<int> vec[N];
int main()
{
	scanf("%d",&n);
	if (n==1)
	{
		printf("Yes\n");
		printf("2\n");
		printf("1 1\n");
		printf("1 1\n");
		return 0;
	}
	if (n==2)
	{
		printf("No\n");
		return 0;
	}
	int now=3;
	vec[1].push_back(1);
	vec[1].push_back(3);
	vec[2].push_back(1);
	vec[2].push_back(2);
	vec[3].push_back(2);
	vec[3].push_back(3);
	int lalal=3;
	while (now<n)
	{
		lalal++;
		for (int i=1;i<lalal;i++)
		{
			now++;
			vec[i].push_back(now);
			vec[lalal].push_back(now);
			if (now>n)
			{
				printf("No\n");
				return 0;
			}
		}
		if (now>n)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	printf("%d\n",lalal);
	for (int u=1;u<=lalal;u++)
	{
		int siz=vec[u].size();
		printf("%d ",siz);
		for (int i=0;i<siz;i++) printf("%d ",vec[u][i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 4608
#include<iostream>
using namespace std;
int main()
{
	int r, c,a[101],b[100],d=0;
	int h[101][101]={0};
	cin >> r >> c;
	for (int i=0; i < r;i++){
		for (int j=0; j < c; j++){
			cin >> h[i][j];
		}
	}
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			h[i][c] += h[i][j];
		}
	}
	
	for (int j = 0; j <= c; j++){
		for (int i = 0; i < r; i++){
			h[r][j] += h[i][j];
		}
	}
	for (int i = 0; i < r+1; i++){
		for (int j = 0; j < c+1; j++){
			if (d) cout << " "; 
			cout << h[i][j];
			d = 1;
		}
		d = 0;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int n, x, cnt[200010], ans;

int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n;
	for( int a = 1; a <= n; a++ )
	{
		cin>>x;
		cnt[x]++;	
	}
	for( int a = 0; a <= 1e5; a++ )
	{
		if( a == 0 )ans = max( ans, cnt[a] + cnt[a+1] );
		else ans = max( ans, cnt[a-1] + cnt[a] + cnt[a+1] );	
	}
	cout<<ans<<endl;
	return 0;
}	

Measured memory_bytes: 640
words = lambda t : list(map(t, input().split()))
n,l = words(int)

if l > 0:
    print(sum(range(l+1,l+n)))
elif l <= 0 and n > abs(l):
    ans = 0
    for i in range(l,l+n):
        ans += i
    print(ans)
else:
    #print("else")
    print(sum(range(l,l+n-1)))


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  int sum = 0;
  vector<int> A(N);
  for (auto&& e : A) {
    cin >> e;
    sum += e;
  }
  vector<int> divisor;
  for (int i = 1; i * i < sum + 1; i++) {
    if (sum % i == 0) {
      divisor.emplace_back(i);
      divisor.emplace_back(sum / i);
    }
  }
  int res = 0;
  for (int d : divisor) {
    vector<pair<int, int>> R;
    for (const auto& e : A) {
      R.emplace_back(make_pair(e % d, (d - (e % d)) % d));
    }
    sort(R.begin(), R.end());
    vector<int64_t> X(R.size() + 1, 0), Y(R.size() + 1, 0);
    for (int i = 0; i < (int)R.size(); i++) {
      X[i + 1] += X[i] + R[i].first;
    }
    for (int i = (int)R.size(); i > 0; i--) {
      Y[i - 1] += Y[i] + R[i - 1].second;
    }
    for (int i = 0; i < (int)R.size(); i++) {
      if (X[i] == Y[i] && X[i] <= K) {
        res = max(res, d);
      }
    }
    if (Y.front() == 0) res = max(res, d);
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;

long long n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (long long i = 0; i <= 205; ++i)
    {
        for (long long j = 0; j <= 205; ++j)
        {
            if (i * i * i * i * i - j * j * j * j * j == n)
            {
                cout << i << ' ' << j;
                return 0;
            }
            else if (i * i * i * i * i + j * j * j * j * j == n)
            {
                cout << i << ' ' << -j;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,ans=0x3f3f3f3f;
char s[5050],t[5050];
void work(int x)
{
	int res=0;
	for(int i=1;i<x;++i)if(s[i]!=s[i+1])res+=i;
	int p=0;
	for(int i=x;i<=n;++i)
		if(s[i]!=s[i+1])
		{
			if(!p&&t[1]!=s[i+1])res+=i;
			else
			{
				while(t[p]==t[p+1])++p;
				res+=abs(i-p);
				if(p!=n)++p;
			}
		}
	for(int i=p;i<=n;++i)
		if(t[i]!=t[i+1])res+=n-i;
	ans=min(ans,res);
}
int main()
{
	scanf("%d %s %s",&n,s+1,t+1);
	s[0]=s[1]^1,s[n+1]=s[n]^1;
	t[0]=t[1]^1,t[n+1]=t[n]^1;
	for(int i=0;i<=n;++i)if(!i||(s[i-1]!='1'&&s[i]=='1'))work(i);
	swap(s,t);
	for(int i=0;i<=n;++i)if(!i||(s[i-1]!='1'&&s[i]=='1'))work(i);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#pragma region declaration
#include <iostream>
#include <vector>
#include <array>
#include <numeric>
#include <algorithm>
#include <set>
#include <deque>
using namespace std;
using ll = long long;
constexpr double INF{ 1e9 };
constexpr int MOD{ 1000000000 + 7 };
#define rep(i,n) for (int i = 0; i < n; ++i)
constexpr array<int, 4> dy{ -1, 1, 0, 0 };
constexpr array<int, 4> dx{ 0, 0, -1, 1 };
constexpr int div_ru(int a, int b)
{
    return (a - b + 1) / b;
}
ll pow_mod(ll b, ll e, ll m)
{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
    ll r = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            r = (r * b) % m;
        b = (b * b) % m;
    }
    return r;
}
#pragma endregion
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int& xx : x) {
        cin >> xx;
    }

    int ans = 0;
    if (n >= m) {
        ans = 0;
    }
    else {
        sort(x.begin(), x.end());
        vector<int> xx(m - 1);
        int total_len = 0;
        for (int i = 0; i < m - 1; i++) {
            total_len += xx[i] = x[i + 1] - x[i];
        }
        sort(xx.rbegin(), xx.rend());

        ans = total_len;
        for (int i = 0; i < n - 1; i++) {
            ans -= xx[i];
        }

    }
    cout << ans << endl;
}
// vector<vector<int>> mm(h, vector<int>(w, -1));


Measured memory_bytes: 1024
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        r: usize
    }
    println!("{}", r * r);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef pair<string,int> psi;
typedef pair<psi,int> psii;
int N,M;
vector<int> s[15];
int p[15];
bool lon[15];
int ans=0;
int main(int argc,char const* argv[])
{
  cin >> N >> M;
  memset(lon,false,sizeof(lon));
  for(int i=1;i<=M;i++)
    {
      int k;
      cin >> k;
      for(int j=0;j<k;j++)
	{
	  int tmp;
	  cin >> tmp;
	  s[i].push_back(tmp);
	}
    }
  for(int i=1;i<=M;i++)
    {
      cin >> p[i];
    }
  for(int i=0;i<=((1<<N)-1);i++)
    {
      memset(lon,false,sizeof(lon));
      bool canall=true;
      for(int j=1;j<=M;j++)
	{
	  int light=0;
	  for(int k=0;k<int(s[j].size());k++)
	    {
	      if(i&(1<<(s[j][k]-1)))light++;
	    }
	  if(light%2==p[j]) lon[j]=true;
	}
      for(int j=1;j<=M;j++) if(!lon[j]) canall=false;
      if(canall) ans++;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int H, W, D;
int g[301][301];
ll dis[301 * 301];
pair<int,int> pos[301 * 301];
int main () {
  ios::sync_with_stdio(false);
  cin >> H >> W >> D;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      int A;
      cin >> A;
      g[i][j] = A;
      pos[A] = {i, j};
    }
  }
  for(int p = 1; p <= D; ++p) {
    for(int nx = p; nx + D <= H * W; nx += D) {
      int nnx = nx + D;
      int a1, b1, a2, b2;
      tie(a1, b1) = pos[nx];
      tie(a2, b2) = pos[nnx];
      ll dd = abs(a1 - a2) + abs(b1 - b2);
      ll cd = dis[nx] + dd;
      dis[nnx] = cd;
    } 
  }

  int Q;
  cin >> Q;
  for(int i = 0; i < Q; ++i) {
    int L, R;
    cin >> L >> R;
    cout << abs(dis[R] - dis[L]) << endl;
  }
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt(),x=sc.nextInt();
		int[] a = new int[m];
		for(int i=0; i<m; i++) {
			a[i]=sc.nextInt();
		}
		int cost1=0,cost2=0;
		for (Integer i : a) {
			if(i > x) cost1++;
			else cost2++;
		}
		System.out.println(cost1 < cost2 ? cost1:cost2);
	}
}


Measured memory_bytes: 21716
n = int(input())
d,x = (int(i) for i in input().split())
a = [int(input()) for i in range(n)]
answer = 0
for i in a:
	if d%i==0: answer += (d-d%i)//i
	else: answer += (d-d%i)//i+1
print(answer+x)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
int n,a,b,c;

cin >> n;

a=n/100;
b=(n-a*100)/10;
c=n-a*100-b*10;
if (a==9) a=1;
else if (a==1) a=9;
if (b==9) b=1;
else if (b==1) b=9;
if (c==9) c=1;
else if (c==1) c=9;

cout << 100*a+10*b+c<<endl;

}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int x[100000];
int f[100000];
int r[100000];
int par[100000];
long long sum[100000];
vector <int> v[100000];
vector <pair<int, int>> w;

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

void unite(int x, int y, int z) {
    x = find(x);
    y = find(y);
    
    if (x == y) return;
    
    if (r[x] > r[y]) swap(x, y);
    
    par[x] = y;
    r[y] += r[x];
    sum[y] += sum[x];
    v[y].push_back(x);
    if (z == 1) f[y] = v[y].size();
}

long long get(int x) {
    return sum[find(x)];
}

void dfs(int x, int y) {
    int i;
    
    for (i = 0; i < v[x].size(); i++) {
        int ny = y;
        
        if (i < f[x]) ny = 1;
        
        if (ny == 1) w.push_back(make_pair(x, v[x][i]));
        dfs(v[x][i], ny);
    }
}

int main() {
    int n, m, ans = 0, i;
    vector <pair<int, pair<int, int>>> v;
    
    scanf("%d %d", &n, &m);
    
    for (i = 0; i < n; i++) scanf("%d", &x[i]);
    
    for (i = 0; i < m; i++) {
        int a, b, y;
        
        scanf("%d %d %d", &a, &b, &y);
        
        a--;
        b--;
        
        v.push_back(make_pair(y, make_pair(a, b)));
    }
    
    sort(v.begin(), v.end());
    
    for (i = 0; i < n; i++) {
        par[i] = i;
        r[i] = 1;
        sum[i] = x[i];
    }
    
    for (i = 0; i < m; i++) {
        int a = v[i].second.first;
        int b = v[i].second.second;
        int y = v[i].first;
        int f = 0;
        
        if (find(a) == find(b)) continue;
        
        if (get(a) + get(b) >= y) f = 1;
        unite(a, b, f);
    }
    
    dfs(find(0), 0);
    
    for (i = 0; i < n; i++) {
        par[i] = i;
        r[i] = 1;
        sum[i] = x[i];
    }
    
    for (i = 0; i < w.size(); i++) unite(w[i].first, w[i].second, 0);
    
    for (i = 0; i < m; i++) {
        int a = v[i].second.first;
        int b = v[i].second.second;
        int y = v[i].first;
        
        if (find(a) == find(b) && get(a) >= y) continue;
        
        ans++;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 9076
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

void solve(){
    ll n;
    cin >> n;
    ll x[n],y[n];
    rep(i,n){
        cin >> x[i];
    }
    rep(i,n) cin >> y[i];
    ll sum1[n],sum2[n];
    sum1[0]=x[0];sum2[n-1]=y[n-1];
    for(ll i=1;i<n;i++){
        sum1[i]=x[i]+sum1[i-1];
        sum2[n-1-i]=sum2[n-1-i+1]+y[n-1-i];
    }
    ll ans=0;
    rep(i,n){
        ll ans1=sum1[i]+sum2[i];
        ans=max(ans,ans1);
    }
    kaku(ans);
}

int main(){
    solve();
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;

int main(){
  int N;
  long long int ANS = 0;

  scanf("%d", &N);

  for (int i = 1; i <= N; i++){
    if (i % 3 != 0 && i % 5 != 0) ANS += i;
  }

  printf("%lld\n", ANS);

  return 0;
}

Measured memory_bytes: 1732