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

int main(){
  int h,w;
  string a,b;
  cin >> h >>w;
  for(int i=0; i<w+2; i++){
    b += '#';
  }
  cout << b << endl;
  for(int i=0; i<h; i++){
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  cout << b << endl;
}

Measured memory_bytes: 256
my $n = <STDIN>;
my $s = <STDIN>;

my @dat = split(/ /,$s);
@dat = sort {$a <=> $b} @dat;

#print "@dat\n";
my $sum = $dat[0];
for(my $i=1;$i<=$#dat;$i++){
  $sum = ($sum + $dat[$i])/2;
}

print "$sum";

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
typedef unsigned long long int ULL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//Works for forward as well as backward iteration

#define gu getchar
#define pu putchar
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
//# define M_PI           3.14159265358979323846264338327950288

#define DRT() int t; si(t); while(t--)

#define PlUSWRAP(index,n) index = (index+1)%n		//index++; if(index>=n) index=0
#define MINUSWRAP(index,n) index = (index + n -1)%n 	//index--; if(index<0) index=n-1
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)	//Round off d to nearest integer

#define FLUSHN while(gu()!='\n')
#define FLUSHS while(gu()!=' ')

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.

int main() {
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
	LL n,t;
	cin>>n>>t;
	VL tt(n);
	VL cost(n);
	LL m = INT_MAX;
	rep(i,0,n){
		cin>>cost[i];
		cin>>tt[i];
		if(tt[i] <= t){
			m = min(m, cost[i]);
		}
	}
	if(m == INT_MAX)
		cout<<"TLE";
	else
		cout<<m;
  	return 0;
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    if(abs(c-a)<=d){
        cout<<"Yes"<<endl;
        return 0;
    }else if(abs(c-b)<=d&&abs(b-a)<=d){
        cout<<"Yes"<<endl;
        return 0;
    }else cout<<"No"<<endl;

    return 0;


}

Measured memory_bytes: 256
//template
import java.util.*;
import java.util.stream.Stream;
import java.io.*;
public class Main{
	static BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	public static void main(String[] args) throws IOException{
		StringTokenizer st=new StringTokenizer(in.readLine());
		int N=Integer.parseInt(st.nextToken());
		int X=Integer.parseInt(st.nextToken());
		int T=Integer.parseInt(st.nextToken());
		int times=0;
		int sum=0;
		while(sum<N) {
			sum+=X;
			times++;
		}
		out.append(times*T+"");
		
		out.flush();
		in.close();
		out.close();
	}
	public static boolean palindrome(String s) {
		boolean palindrome=true;
		int i=0,j=s.length()-1;
		while(i<j&&palindrome) {
			if(s.charAt(i++)!=s.charAt(j--))
				palindrome=false;
		}
		return palindrome;
	}
	public static long reverse(String s) {
		String aux="";
		for(int i=s.length()-1;i>=0;i--) {
			aux+=s.charAt(i);
		}
		return Long.parseLong(aux);
	}
	private static int modulo(int S, int N) { return ((S) & (N - 1)); } // returns S % N, where N is a power of 2
	private static int isPowerOfTwo(int S) { return (S & (S - 1)) == 0 ? 1 : 0; }
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}
	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}
	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}
	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}
	 
}

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

#define ran 10011

int n;
char s[ran];

int main() {
	scanf("%d", &n);
	scanf("%s", s);
	for(int i=0;s[i];i++) {
		char ch = s[i];
		ch += n;
		if(ch>'Z') ch-=26;
		putchar(ch);
	}
	puts("");
	
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& i : v) cin >> i;

    int ans = inf;
    FOR(i, 1, 101){
        int dist = 0;
        REP(j, n){
            dist += (i - v[j]) * (i - v[j]);
        }
        chmin(ans, dist);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";

        int fun(vector<pair<int,int>> &bin)
        {
            int prev = bin[0].ff;
            map<int,int> mp;
            mp[bin[0].ss]++;
            int ans = 1;
            int f[1000000] = {0};
            for(auto u:bin)
                f[u.ss]++;
            int mx = 0,id = -1;
            for(int i = 1; i < 1000000; i++)
            {
                if(mx < f[i])
                {
                    mx = f[i];
                    id = i;
                }
            }
            int count = 1;
            for(int i = 1; i < bin.size(); i++)
            {
                if(bin[i].ff == prev)
                {
                    mp[bin[i].ss]++;
                    count++;
                }
                else
                {
                    ans = max(ans, count + f[id] - mp[id]);
                    mp.clear();
                    prev = bin[i].ff;
                    mp[bin[i].ss]++;
                    count = 1;
                }
            }
            ans = max(ans, count + f[id] - mp[id]);
            return ans;
        }
        int32_t main()
        {
            tani_nachi_ke  
            
            
            int n,m,q;
            cin >> n >> m >> q;

            vector<pair<int,int>> bin1,bin2;
            for(int i = 0; i < q; i++)
            {
                int x,y;
                cin >> x >> y;
                bin1.push_back({x,y});
                bin2.push_back({y,x});
            }  

            sort(bin1.begin(), bin1.end());
            sort(bin2.begin(), bin2.end());

            cout << max(fun(bin1), fun(bin2)) << endl;
           





           return 0;
        }
          

Measured memory_bytes: 39184
#include<iostream>
#include<vector>
using namespace std;
int main(int argc, char *argv[])
{
  const int BIG = 1000000;
  const int CMAX = 5000;
  for(;;) {
    int n;
    cin >> n;
    if(n == 0) break;
    vector<int> ps;
    for(int i = 0; i < n; i++) {
      int p; cin >> p; ps.push_back(p);
    }
    // shop : at most 100
    // change : at most 49900... too much?
    // # of 500 got so far : at most 100
    // value : minimum payment
    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(CMAX+1, vector<int>(101, BIG)));
    dp[0][0][0] = 0;
    for(int i = 0; i < n; i++) {
      const int ii = i + 1;
      for(int j = 0; j <= CMAX; j++) { // not buying
        for(int k = 0; k <= 100; k++) {
          dp[ii][j][k] = dp[i][j][k];
        }
      }
      // buying
      const int p = ps[i] % 1000;
      if(p != 0 && p <= 500) { // got 500!
        for(int j = 0; j <= CMAX; j++) {
          const int jj = min(j + 500 - p, CMAX);
          for(int k = 0; k < 100; k++) {
            const int kk = k + 1;
            dp[ii][jj][kk] = min(dp[ii][jj][kk], dp[i][j][k] + ps[i]);
          }
        }
      } else {
        // get 500 if possible!
        const int q = (p == 0 ? 1000 : p) - 500;
        for(int j = 0; j <= CMAX; j++) {
          if(j >= q) {
            const int jj = j - q;
            for(int k = 0; k < 100; k++) {
              const int kk = k + 1;
              dp[ii][jj][kk] = min(dp[ii][jj][kk], dp[i][j][k] + ps[i]);
            }
          } else { // get change
            const int jj = j + 1000 - p;
            if( jj < 1000) {
              for(int k = 0; k <= 100; k++) {
                const int kk = k;
                dp[ii][jj][kk] = min(dp[ii][jj][kk], dp[i][j][k] + ps[i]);
              }
            }
          }
        }
      }
    }
    for(int k = 100; k >= 0; k--) {
      int p = BIG;
      for(int j = 0; j <= CMAX; j++) {
        p = min(p, dp[n][j][k]);
      }
      if(p != BIG) {
        cout << k << " " << p << endl;
        break;
      }
    }
  }
  return 0;
}



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

const int mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;

  LL ans, t;
  if (s1[0] == s2[0]) ans = 3, t = 1;
  else ans = 6, t = 2;

  for (int i = t; i < n; i ++) {
    if ((s1[i - 1] == s2[i - 1]) && (s1[i] == s2[i])) {
      ans *= 2;
    } else if ((s1[i - 1] == s2[i - 1]) && (s1[i] != s2[i])) {
      ans *= 2, i ++;
    } else if ((s1[i - 1] != s2[i - 1]) && (s1[i] == s2[i])) {
      ans *= 1;
    } else if ((s1[i - 1] != s2[i - 1]) && (s1[i] != s2[i])) {
      ans *= 3, i ++;
    }
    ans %= mod;
  }

  cout << ans << endl;
}

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

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		sc.nextLine();
		String[] s = new String[N];
		for(int i = 0; i < N; i++) {
			s[i] = sc.nextLine();
		}
		sc.close();
		Arrays.sort(s);
		for(int i = 0; i < N; i++) {
			System.out.print(s[i]);
		}
		System.out.println("");
	}
}

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

typedef long long int int64;

typedef struct RSQandRAQ{
  int *add;
  int64 *sum;
  int size;
} segTree;

segTree* newRSQandRAQ(const int n){
  int k=1;
  while(k<n) k*=2;
  segTree *s=(segTree *)malloc(sizeof(segTree));
  s->add=(int *)calloc(2*k,sizeof(int));
  s->sum=(int64 *)calloc(2*k,sizeof(int64));
  s->size=k;
  return s;
}

void add_sub(segTree *s,int k,int l,int r,int x,int y,int v){
  if(y<=l || r<=x) return;
  if(x<=l && r<=y){
    s->add[k]+=v;
    return;
  }
  int m=(l+r)/2;
  add_sub(s,2*k  ,l,m,x,y,v);
  add_sub(s,2*k+1,m,r,x,y,v);
  s->sum[k]=s->sum[2*k]+(int64)(m-l)*s->add[2*k]+s->sum[2*k+1]+(int64)(r-m)*s->add[2*k+1];
  return;
}

void add(segTree *s,int l,int r,int v){
  add_sub(s,1,0,s->size,l,r,v);
}

int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}

int64 getSum_sub(segTree *s,int k,int l,int r,int x,int y){
  if(y<=l || r<=x) return 0;
  if(x<=l && r<=y) return s->sum[k]+(int64)(r-l)*s->add[k];
  int m=(l+r)/2;
  return getSum_sub(s,2*k,l,m,x,y)+getSum_sub(s,2*k+1,m,r,x,y)+(int64)(min(y,r)-max(x,l))*s->add[k];
}

int64 getSum(segTree *s,int l,int r){
  return getSum_sub(s,1,0,s->size,l,r);
}

void run(void){
  int n,q;
  scanf("%d%d",&n,&q);
  segTree *s=newRSQandRAQ(n);
  while(q--){
    int c;
    scanf("%d",&c);
    if(c==0){
      int l,r,v;
      scanf("%d%d%d",&l,&r,&v);
      add(s,l-1,r,v);
    } else {
      int l,r;
      scanf("%d%d",&l,&r);
      printf("%lld\n",getSum(s,l-1,r));
    }
  }
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 3392
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, input().split()))


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


X, N = zz()
p = zz()
small_x = X
big_x = X
if (X not in p):
    print(X)
    exit()

while True:
    # for v in [-1, 1]:
    if (small_x - 1 not in p):
        print(small_x-1)
        exit()
    if (big_x + 1 not in p):
        print(big_x+1)
        exit()
    small_x -= 1
    big_x += 1


Measured memory_bytes: 27088
#include<stdio.h>

int main(void)
{
  int a, b;

  scanf("%d %d", &a, &b);
  if(a < b)
  {
    printf("a < b\n");
  }

  else if(a > b)
  {
    printf("a > b\n");
  }

  else
  {
    printf("a == b\n");
  }

  return 0;
}




Measured memory_bytes: 2104
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
#define x first
#define y second
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;

typedef pair<int, int> pii;

int main() {
	INIT
	string s;
	cin >> s;
	int l = s.length(), ans = 0, a = 0, b = 0;
	for (int i = 0; i < l; ++i) {
		if ( s[i] == '0') ++a;
		else ++b;
	}
	cout << 2 * min(a, b);
	return 0;
}

Measured memory_bytes: 512
import numpy as np
d, g = map(int, input().split())
p = []
c = []
for _ in range(d):
    _p, _c = map(int, input().split())
    p.append(_p)
    c.append(_c)

s = np.arange(1, d + 1) * 100
p = np.array(p)

ans_list = []

bool_list = [False] * d

state_list = []

def dfs(i, n, bool_list):
    bool_list = bool_list.copy()
    if i == n:
        state_list.append(bool_list)
    else:
        dfs(i + 1, n, bool_list)
        bool_list[i] = True
        dfs(i + 1, n, bool_list)

dfs(0, d, bool_list)

for state in state_list:
    if np.dot(s * p, state) + np.dot(c, state) >= g:
        ans_list.append(np.dot(p, state))
    else:
        score = max(s * np.array([not i for i in state]))
        for j in range(1, p[score//100 - 1] + 1):
            if np.dot(s * p, state) + np.dot(c, state) + score * j >= g:
                ans_list.append(np.dot(p, state) + j)

print(min(ans_list))

Measured memory_bytes: 14480
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

void solve() {
  int n;
  i64 d;
  cin >> n >> d;
  d = d * d;
  int ans = 0;
  rep(i, n) {
    i64 x, y;
    cin >> x >> y;
    i64 dist = x * x + y * y;
    if (dist <= d) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

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

const int N = 100;
int A[N];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  sort(A, A+n);
  int bob = 0, alice = 0;
  for (int i = n-1; i >= 0; --i) {
    if ((n-i) % 2 != 0) {
      alice += A[i];
    }
    else {
      bob += A[i];
    }
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
N = int(input())

count = [0 for _ in range(200000)]
line = [int(i) for i in input().split()]
pattern = [0 for _ in range(200000)]
sum = 0
# index = []

for i in line:
	# if count[i] == 0:
		# index.append(i)
	count[i] += 1

for num in count:
	sum += (num*(num-1))//2



for i in line:
	if count[i] > 2:
		result = sum - (count[i]-1) 
	elif count[i] == 2:
		result = sum - 1
	elif count[i] == 1:
		result = sum
	print(result) 


Measured memory_bytes: 27340
#include "bits/stdc++.h"
using namespace std;

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

double pi  = 3.14159265358979323846 ;

int main()
{
	#ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	double a , b , x , ans;
	cin >> a >> b >> x ;
	if(x >= (b*a*a/2))
	{
		double y = ((2*x)/(a*a)) - b ;
		if(y >= 0)
		cerr << fixed << setprecision(10) << y;
		ans = atan((b-y)/a)*180/pi;
		cout << fixed << setprecision(10) << ans;
	}
	else
	{
		double y = (2*x/(a*b)) ;
		cout << fixed << setprecision(10) << atan2(b , y)*180/pi ;

	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())

string_list=[input() for i in range(N)]
i = 0
string_list2 = list(set(string_list))
if(len(string_list2)==N):
    check = 1
else:
    check = 0

while(i < N-1):
    string1  = string_list[i]
    string2 = string_list[i+1]
    str1 = string1[-1]
    str2 = string2[0]
    if(str1 != str2):
        check = 0
    i +=1

if(check ==1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
n = int(input())
s = [sorted(input()) for i in range(n)]
ans = ''
while 1:
    flag = 0
    for c in 'abcdefghijklmnopqrstuvwxyz':
        if sum(c not in s[i] for i in range(n)) == 0:
            flag = 1
            for i in range(n):
                pos = s[i].index(c)
                s[i].pop(pos)
            break
    if not flag:
        break
    ans += c
print(ans)

Measured memory_bytes: 3188
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

void main()
{
    auto cin = new Scanner;
    string s;
    cin.scan(s);
    int ans;
    foreach (c; s)
    {
        ans += c - '0';
    }
    writeln(max(ans, s[0] - '0' - 1 + 9.repeat.take(s.length - 1).sum));
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n, k;
vl a;
/******* define variable end *******/
int solve() {
	cin >> n >> k;
	RES(a, n);
	REP(i, n){
		cin >> a[i];
	}
	bool flag = true;
	REP(i, n-k){
		if(a[i] >= a[i + k]){
			cout <<"No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 4780
#include<stdio.h>

int main(){
  int a,b,c,d,e,k;
  scanf("%d\n%d\n%d\n%d\n%d\n%d",&a,&b,&c,&d,&e,&k);
  if(e-a>k){
    printf(":(");
  }else{
    printf("Yay!");
  }
return 0;
}

Measured memory_bytes: 128
import sys
import bisect

N = int(input())
D = list(map(int, input().split()))

for i, d in enumerate(D):
    if d != 0 and i == 0:
        print(0)
        sys.exit()

    elif d == 0 and i != 0:
        print(0)
        sys.exit()

D.sort()


ans = 1
cnt = []
for d in range(N):

    cnt.append(bisect.bisect(D, d))

for d in D:
    if d == 0 or d == 1:
        continue

    ans = ans * (cnt[d - 1] - cnt[d - 2]) % 998244353


print(ans)

Measured memory_bytes: 56300
#include<iostream>
#include<algorithm>
using namespace std;
string a[1000];
int comp(string zh,string hz)
{
	return zh<hz;
}
int main()
{
	int n,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+1+n,comp);
	for(int i=1;i<=n;i++)
	  cout<<a[i];
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
 char c[256]; 
 int d[100],i,s,p,f;
 while(true) {
 for (i=0;i<255;i++) c[i]=1;
 i=p=0;
 gets(c);
 if (c[0]=='0') break;
 while(true) {
	 if (c[p+2]==' ' || c[p+2]=='\0') { d[i]=(c[p]-'0')*10+(c[p+1]-'0'); p+=3;}
	 else if (c[p+1]==' ' || c[p+1]=='\0') { d[i]=(c[p]-'0'); p+=2;}
	 if (c[p-1]=='\0') break;
	 i++;
 }
 for (s=0,f=0;i>=0;i--) if (d[i]>0 && d[i]<10) { s+=d[i]; if (d[i]==1) f=1;} else s+=10;
 if (f==1 && s+10<22) s+=10;
 if (s>21) s=0;
 cout << s << endl;
 }
 return 0;
 }

Measured memory_bytes: 1124
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache

sys.setrecursionlimit(10 ** 8)

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


def main():
    # N = int(input())
    N, K = [int(a) for a in input().split()]
    # A = [int(a) for a in input().split()]

    res = 0

    for k in range(K, N + 2):
        minv = k * (k + 1) // 2
        maxv = minv + (N + 1 - k) * k
        t = maxv - minv + 1
        res = (res + t) % MOD

    print(res)

    # @lru_cache(None)
    # def f(i, j):
    #     if i < 0 or j < 0:
    #         return -INF
    #     if i == 0:
    #         return -INF
    #     if abs(j - i // 2 - 1) >= 2:
    #         return -INF
    #     if j == 0:
    #         return 0
    #     if j == 1:
    #         return max(A[:i])
    #     return max(A[i - 1] + f(i - 2, j - 1), f(i - 1, j))
    #
    # print(f(N, math.floor(N / 2)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 10124
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, A, x, y;
    cin >> n;
    vector<vector<int>> mat(n+1, vector<int>(n+1, 0));
    for(int i = 0; i < n; i++) {
        cin >> A;
        for(int j = 0; j < A; j++) {
            cin >> x >> y;
            mat[i+1][x] = (y==1)?1:-1;
        }
    }
    int ans = 0;
    for(int state = 0; state < (1<<n); state++) {
        unordered_set<int> mem;
        for(int i = 0; i < n; i++) {
            if ((state >> i)&1)
                mem.insert(i+1);
        }
        bool cand = true;
        for(int from: mem) {
            for(int i = 0; i < n; i++) {
                if (mat[from][i+1] == 1 && ((state>>i)&1) == 0) {
                    cand = false;
                    break;
                }
                if (mat[from][i+1] == -1 && ((state>>i)&1) == 1) {
                    cand = false;
                    break;
                }
            }
            if(!cand) break;
        }
        if(cand)
            ans = max(ans, int(mem.size()));
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

short p[100];
short pNum;

void makePrimeList(short n);

int main(void)
{
	char n,i,j,k,tmp;
	short b[100]={};
	int ans=0;
	scanf("%hhd",&n);

	makePrimeList(n);
	
	for (i=2;i<=n;i++) {
		for (j=0;j<pNum;j++) {
			if (i < p[j]) break;
			
			tmp = i;
			while (tmp > 1) {
				if (tmp % p[j] != 0) break;
				tmp = tmp / p[j];
				b[j]++;
			}
		}
	}

	// a^2 b^4 c^4
	for (i=0;i<pNum;i++) {
		if (b[i]>=4) {
			for (j=i+1;j<pNum;j++) {
				if (b[j]>=4) {
					for (k=0;k<pNum;k++) {
						if (b[k]>=2 && i!=k && j!=k) ans += 1;
					}
				}
			}
		}
	}

	// a^2 b^24
	for (i=0;i<pNum;i++) {
		if (b[i]>=24) {
			for (j=0;j<pNum;j++) {
				if (b[j]>=2 && i!=j) ans += 1;
			}
		}
	}

	// a^4 b^14
	for (i=0;i<pNum;i++) {
		if (b[i]>=14) {
			for (j=0;j<pNum;j++) {
				if (b[j]>=4 && i!=j) ans += 1;
			}
		}
	}

	// a^74
	for (i=0;i<pNum;i++) {
		if (b[i]>=74) ans += 1;
	}

	printf("%d\n",ans);
	return 0;
}

void makePrimeList(short n)
{
	short i,j,*tmpP;
	tmpP = (short *)malloc(sizeof(short) * n);
	tmpP[0] = 1;
	for (i=1;i<n;i++) tmpP[i] = 0;

	pNum = 0;
	for (i=2;i<=sqrt(n);i++) {
		if (tmpP[i-1]==1) continue;
		
		p[pNum] = i;
		pNum++;
		for (j=i;j<=n;j+=i) {
			tmpP[j-1] = 1;
		}
	}

	for (i=(int)sqrt(n);i<=n;i++) {
		if (tmpP[i-1]==1) continue;

		p[pNum] = i;
		pNum++;
	}

	return;
}




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

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

    llint n, k;
    cin >> n >> k;

    if (n % k == 0)
        cout << 0 << endl;
    else {
        llint mod = n % k;
        llint other = abs(k - mod);
        if (mod > other)
            cout << other << endl;
        else
            cout << mod << endl;
    }
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b && b==c){
        cout<<"0\n";
        return 0;
    }

    int res = 0;
    

    for(;;){
        int Max = max({a,b,c});
        int Min = min({a,b,c});

        int dif = Max - Min;

        if(dif % 2 == 0){
            if(Min == a){
                a+=2;
                res++;
            }
            else if(Min == b){
                b+=2;
                res++;
            }
            else if(Min == c){
                c+=2;
                res++;
            }

        }

        else if(dif % 2 ==1){
            if(Max == a){
                ++b;
                ++c;
                res++;
            }
            else if(Max == b){
                ++a;
                ++c;
                res++;
            }
            else if(Max == c){
                ++b;
                ++a;
                res++;
            }
        }
        if(a==b && b==c) break;
        
    }
    cout<<res<<"\n";
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


ll gcd(ll a, ll b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}

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

void solve() {
    ll N, M; cin >> N >> M;
    string s, t; cin >> s >> t;
    ll res = lcm(N, M);
    ll m = gcd(N, M);
    ll m1 = N/m, m2 = M/m;
    bool f = true;
    ll d1 = 0, d2 = 0;
    rep(i, m){
        if(s[d1] != t[d2]) f = false;
        d1 += m1; d2 += m2;
    }
    if(f) cout << res << endl;
    else cout << -1 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  if(tail + 1 == LEN+1)tail = 0;
  else tail++;
}

P dequeue(){
  P a;
  a = Q[head];
  if(head + 1 == LEN + 1) head = 0;
  else head++;
  return a;
}

int isEmpty(){
  if(head == tail) return 1;
  else return 0;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head =1;
  tail = n + 1;
  
  for(;;){
    u = dequeue();
    c = u.t - q;
    
    if(c > 0){
      elaps += q;
      u.t = c;
      enqueue(u);
    }
    
    else if(c <= 0){
      elaps += u.t;
      printf("%s %d\n", u.name, elaps);
    }

    if(isEmpty() == 1)break;
    else continue;
  }
  return 0;
}

Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll m, k; cin >> m >> k;
  ll n = 1<<m;

  if (k >= n || (m == 1 && k > 0)) {
    cout << -1 << "\n";
    return 0;
  }

  if (m == 1 && k == 0) {
    cout << "0 0 1 1" << "\n";
    return 0;
  } 

  drep(i, n) if (i != k) cout << i << " ";
  cout << k << " ";
  rep(i, n) if (i != k) cout << i << " ";
  cout << k << "\n";
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A.at(i);
  int ans = 10000*100;
  rep(i,100){
    int n = i + 1;
    int sum = 0;
    rep(j,N){
      sum += (A.at(j) - n) * (A.at(j) - n);
    }
    if(sum <= ans){
    ans = sum;
    }
    else{
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    string n;
    map<string, int> cnt;
    
    while(getline(cin, n, ',')) {
        string blood;
        cin >> blood;
        cnt[blood]++;
    }

    cout << cnt["A"] << endl;
    cout << cnt["B"] << endl;
    cout << cnt["AB"] << endl;
    cout << cnt["O"] << endl;

    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include<math.h>
using namespace std;


int main() {
  int A,B,r,Ap;
  int c = 0;
  int newA = 0;
  cin >> A >> B;
  for(int i=A;i<B+1;i++){
    if(i%10 == 0)
      continue;
    Ap = i;
    for(int j=0;j<5;j++){
       r = Ap%10;
      //  cout << r << endl;
       Ap -= r;
      //  cout << Ap << endl;
       Ap /= 10;
      //  cout << Ap << endl;
       r *= 1*pow(10,4-j);
      //  cout << r << endl;
       newA += r;
      //  cout << newA << endl;
       r = 0;
    }
    // cout << i << endl;
    // cout << newA << endl;
    if(newA == i){
      c += 1;
    }
    newA = 0;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
use std::io;

fn can_solve(av: &Vec<i32>, bv: &Vec<i32>, c: i32) -> bool {
    av.iter().zip(bv.iter()).map(|(a, b)| a * b).sum::<i32>() + c > 0
}

#[test]
fn test_can_solve_1() {
    assert!(!can_solve(&vec![3, 2, 1], &vec![1, 2, 3], -10));
    assert!(can_solve(&vec![1, 2, 2], &vec![1, 2, 3], -10));
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut iter = input.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut iter = input.split_whitespace();
    let bv: Vec<i32> = (0..m).map(|_| { iter.next().unwrap().parse().unwrap() }).collect();
    let mut a_matrix: Vec<Vec<i32>> = Vec::with_capacity(n);
    for _ in 0..n {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        let mut iter = input.split_whitespace();
        let av: Vec<i32> = (0..m).map(|_| { iter.next().unwrap().parse().unwrap() }).collect();
        a_matrix.push(av);
    }
    let count = a_matrix.iter().filter(|av| { can_solve(av, &bv, c) }).count();
    println!("{}", count);
}


Measured memory_bytes: 4352
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut ans = 0;
    for _ in 0..n {
        let mut x:usize = read();
        while x % 2 == 0 {
            x /= 2;
            ans += 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
//#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

# define mod (ll)998244353

ll modpow(ll a, ll n, ll modo) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % modo;
        a = a * a % modo;
        n >>= 1;
    }
    return res;
}

const int MAX = 710000;
long long fac[MAX], finv[MAX], inv[MAX];

//使う前に実行
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> dp(k+1);
	dp[0] = m;
	rep(i, n-1)dp[0] = dp[0] * (m-1) % mod;
	COMinit();
	REP(i, k){
		dp[i] = ((m * COM(n-1, i)) % mod * modpow(m-1, n-i-1, mod)) % mod;
	}
	ll ans = 0;
	rep(i, k+1){
		ans = (ans % mod + dp[i] % mod) % mod;
	}
	cout << ans % mod << endl;
}


Measured memory_bytes: 21380
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vl = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    ll L = S.size();
    vector<int> AC(L);
    ll count = 0;
    AC[0] = 0;
    for(int i=1; i<L; i++){
        if(S[i-1]=='A'&&S[i]=='C'){
            count++;
        }
        AC[i] = count;
    }
    vi ans(0);
    for(int i=0; i<Q; i++){
        int l,r; cin >> l >> r;
        l-=1; r-=1;
        ans.emplace_back(AC[r]-AC[l]);
    }
    for(auto x: ans){
        cout << x << endl;
    }
}

Measured memory_bytes: 1912
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n;
	while (cin >> n, n) {
		vector<double>v(n);
		rep(i, 0, n) {
			int p; cin >> p; p--;
			double h, w; cin >> h >> w;
			h /= 100;
			v[p] = w / (h*h);
		}
		int index(0);
		double bmi(v[0]);
		rep(i, 1, n) {
			if (abs(22 - v[i]) < abs(22 - bmi)) {
				bmi = v[i];
				index = i;
			}
		}
		cout << index + 1 << endl;

	}
	return 0;
}

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

#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout)

int main() {
	ioso;
	#ifndef ONLINE_JUDGE
	ffe;
	#endif

	string s;
	cin >> s;
	if(s[1]=='R') {s[1]='B';}
	else {s[1]='R';}
	cout <<  s << endl;	
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
signed main(void) {
	string s;
	cin >> s;

	sort(ALL(s));

	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<double> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    sort(v.begin(),v.end());

    double ans = v[0];

    for(int i = 1; i < n; i++){
        ans = (ans + v[i]) / 2;
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int c(int x,int y){
	long long int res = 1;
	for(int i=0; i<y; i++)
		res = res * (x-i) / (i+1);
	return res;
}
int main(){
	int m,p,odd=0,even=0;
	for(scanf("%d%d",&m,&p); m--;){
		int x;
		scanf("%d",&x);
		if(x%2==0)even++;else
			odd++;
	}
	long long int res = 0;
	for(; p<=odd; p+=2)
		res += c(odd,p);
	cout << (res<<even) << endl;
	return 0;
}


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

using namespace std;


int main() {
	int a,N; cin >> N;
	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		cin >> a;
		int count = 0;
		while (a % 2 == 0) {
			b[i]++;
			a = a / 2;
		}
	}
	int mins= 2147483647;
	for (int j = 0; j <N; j++) {
		mins = min(mins, b[j]);
	}
	
	cout << mins << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define maxn 100005
#define ll long long
#define ld double
#define mod 998244353
#define pb push_back
#define vi vector<int> 
using namespace std;
ll n, x; 
ll b[maxn], l[maxn], u[maxn];
ll fn;
struct th
{
	ll x, y;
	bool operator < (const th &u)const
	{
		return x > u.x;
	}
}p[maxn];
bool check(ll a)
{
	int ns = a / x;
	if(ns >= n) return 1;
	ll ls = a % x;
	for(int i = 1; i <= n; i++)
	{
		p[i].x = u[i] * b[i] + (x - b[i]) * l[i];
		p[i].y = u[i] * ls;
		if(ls > b[i]) p[i].y += (l[i] - u[i]) * (ls - b[i]);
//		cout<<p[i].x<<" "<<p[i].y<<endl;
	}
//	cout<<fn<<endl;
	sort(p + 1, p + n + 1);
	ll nmx = 0;
	ll S = 0;
	for(int i = 1; i <= ns; i++)
		S += p[i].x;
	for(int i = 1; i <= n; i++)
	{
		ll nans = S + p[i].y;
		if(i <= ns) nans -= p[i].x, nans += p[ns + 1].x;
		nmx = max(nmx, nans);
	}	
	return nmx >= fn;
}
int main()
{
	cin>>n>>x;
	for(int i = 1; i <= n; i++)
		cin>>b[i]>>u[i]>>l[i], 
		fn += b[i] * u[i];
//	check(115);
//	while(1); 
	ll l = 0, r = 1ll * n * x;
	while(l < r)
	{
		ll mid = (l + r) >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout<<l<<endl;
	return 0;
} 
/*
5 7 24
*/

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	else if (s == "Cloudy")cout << "Rainy" << endl;
	else cout << "Sunny" << endl;

	return 0;
}


Measured memory_bytes: 256
def ABC145B_Echo():
    N = int(input())
    S = input()

    if (N % 2) == 0:
        cnt = N // 2
        s1 = S[:cnt]
        s2 = S[cnt:]

        if(s1 == s2):
            print('Yes')
        else:
            print('No')
    else:
        print('No')

ABC145B_Echo()

Measured memory_bytes: 3060