akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    int len1=s.size(),len2=t.size();
    int index=-1;
    for(int i=len1-1;i>=0;i--){
        bool flag=true;
        for(int j=0;j<len2;j++){
            if(i+j>=len1){
                flag=false;
                break;
            }
            if(s[i+j]!=t[j]&&s[i+j]!='?'){
                flag=false;
                break;
            }
        }
        if(flag){
            index=i;
            break;
        }
    }
    if(index!=-1){
        for(int i=0;i<index;i++){
            if(s[i]=='?')
                cout<<"a";
            else
                cout<<s[i];
        }
        cout<<t;
        for(int i=index+len2;i<len1;i++){
            if(s[i]=='?')
                cout<<"a";
            else
                cout<<s[i];
        }
        cout<<endl;
    }
    else
        cout<<"UNRESTORABLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

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


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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



int main(){
    int N;
    cin>>N;
    out((N-1)/2);
    
    
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.System.in;

public class Main {
    static int n,k;
    static long mod = 1000000000+7;
    static long[] fac,inv;
    static int[] id,size;
    //static long mod = 1000000000+7;
    //static HashSet<Integer>[] graph;
    //static ArrayList<Integer>[] graph;
    static ArrayList<Integer> ans = new ArrayList<>();
    static boolean flag = true;
    public static void main(String[] args)throws IOException {
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        //String[] buf = reader.readLine().split(" ");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //int[] b = new int[n+1];
        //for(int i=1;i<=n;i++) b[i]=sc.nextInt();
        // reverse the time line
        ArrayList<Integer> rec = new ArrayList<>();
        for(int i=0;i<n;i++) rec.add(sc.nextInt());
        LinkedList<Integer> ans = new LinkedList<>();
        while(rec.size()>0){
            int idx=-1;
            for(int i=rec.size()-1;i>=0;i--){
                if(rec.get(i)==i+1){
                    idx = i;
                    break;
                }
            }
            if(idx==-1) break;
            ans.addFirst(rec.get(idx));
            rec.remove(idx);
        }
        if(ans.size()!=n) System.out.println(-1);
        else{
            for(int w:ans) System.out.println(w);
        }
    }
}

Measured memory_bytes: 23764
#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#define ll long long
#define rep(i,rept) for (ll i = 0; i < rept; i++)
#define Yes(b) std::cout<< (b ? "Yes" : "No")<<std::endl
#define YES(b) std::cout<< (b ? "YES" : "NO")<<std::endl
using namespace std;

int main() {
	string s,str;
	cin >> s >> str;
	rep(i, s.size()) {
		if (str == s) {
			Yes(true);
			return 0;
		}
                str.insert(str.begin(), str[s.size() - 1]);
		str.pop_back();
	}
	Yes(false);
	return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val groupCounts = Seq.fill(sc.nextInt())(sc.next()).map(_.sorted).groupBy(identity).mapValues(_.size.toLong).values
  println(groupCounts.foldLeft(0L)((acc, i) => acc + i * (i - 1L) / 2L))
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin>>n;
    string arr[n];
    for (int i=0;i<n;i++){
        cin>>arr[i];
        sort(arr[i].begin(),arr[i].end());
    }if (n==1){
        cout<<arr[0]<<endl;
        return 0;
    }
    string ans="";
    int p=0,q=0;
    while (p<arr[0].size()&&q<arr[1].size()){
        if (arr[0][p]==arr[1][q]){
            ans+=arr[0][p];
            p++;q++;
        }else if (arr[0][p]>arr[1][q]){
            q++;
        }else p++;
    }string cans;
    for (int i=2;i<n;i++){
        cans="";
        p=0;q=0;
        while (p<arr[i].size()&&q<ans.size()){
            if (arr[i][p]==ans[q]){
                cans+=arr[i][p];
                p++;q++;
            }else if (arr[i][p]>ans[q]){
                q++;
            }else p++;
        }ans=cans;
    }cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    VI flag;
    VI ball;
    int n,m;
    cin >> n >> m;
    REP(i, n){
        flag.PB(0);
        ball.PB(1);
    }

    flag[0] = 1;
    REP(i, m){
        int x, y;
        cin >> x >> y;
        x--; y--;
        if(flag[x] == 1) flag[y] = 1;
        ball[x]--;
        ball[y]++;
        if(ball[x] == 0) flag[x] = 0;
    }

    int ans = 0;
    REP(i, n){
        ans += flag[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 1276
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    for(int i = 0; i < k; i++){
        if(i % 2 == 0){
            if(a % 2 == 1){
                a--;
            }
            a /= 2;
            b += a;
        } else{
            if(b % 2 == 1){
                b--;
            }
            b /= 2;
            a += b;
        }
    }
    printf("%d %d\n", a, b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll N, K;
    cin >> N >> K;
    while (N > K/2) {
        if (N > K)
            N = N % K;
        else
            N = K - N;
    }
    cout << N << endl;
    return 0;
}


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

int N,T,L,B;
int t[104];
double dp[104][104];

int nidx(int idx,int th){
	int sum = idx + th;
	if(sum > N){
		int diff = sum - N;
		sum = N - diff;
	}
	return sum;
}

int main(void){
	while(cin>>N>>T>>L>>B, (N||T||L||B)){
		memset(t,0,sizeof(t));
		for(int i=0;i<L;i++){
			int idx;
			cin>>idx;
			t[idx] = 1;
		}
		for(int i=0;i<B;i++){
			int idx;
			cin>>idx;
			t[idx] = 2;
		}

		memset(dp,0,sizeof(dp));
		dp[0][0] = 1.0;
		for(int i=0;i<T;i++){
			for(int j=0;j<N;j++){
				if(dp[i][j] > 0){
					for(int k=1;k<=6;k++){
						int next = nidx(j,k);

						//lose
						if(t[next] == 1){
							dp[i+2][next] += dp[i][j] / 6;
						}
						//back
						else if(t[next] == 2){
							dp[i+1][0] += dp[i][j] / 6;
						}
						else{
							dp[i+1][next] += dp[i][j] / 6;
						}
					}
				}
			}
		}

		double sum = 0;
		for(int i=0;i<=T;i++){
			sum += dp[i][N];
		}
		printf("%.6lf\n",sum);
	}


	return 0;
}

Measured memory_bytes: 0
# 写経
# にぶたん不要の解法
# https://atcoder.jp/contests/agc034/submissions/5768266
# generatorを作って
# 外でminする


def accumulate(a):
    """初項0"""
    su = 0
    yield su

    for x in a:
        su += x
        yield su


# class TestCaseReader:
#     def __init__(self):
#         self._gen = self.gen()
#
#     def gen(self):
#         import os
#         folder = r'XXX'
#         with open(os.path.join(folder, 'in.txt'), mode='r') as f:
#             for row in f:
#                 row = row.rstrip()
#                 yield row
#
#     def __call__(self):
#         return next(self._gen)


def solve_agc034c():
    from bisect import bisect_left
    from collections import namedtuple
    import sys
    input = sys.stdin.readline
    # input = TestCaseReader()

    Test = namedtuple('Test', 'Aoki_score lower_bound upper_bound')
    Test.Merit = lambda self, Takahashi_score: \
        self.lower_bound * Takahashi_score if Takahashi_score <= self.Aoki_score \
            else self.upper_bound * Takahashi_score - (self.upper_bound - self.lower_bound) * self.Aoki_score

    N, X = map(int, input().split())
    tests = []
    for _ in range(N):
        row = map(int, input().split())
        tests.append(Test(*row))
    tests.sort(key=lambda test: test.Merit(Takahashi_score=X), reverse=True)
    # 勝つ科目は重要度upper_bound,負ける科目は重要度lower_bound

    need = sum(test.lower_bound * test.Aoki_score for test in tests)

    *acc, = accumulate(test.Merit(Takahashi_score=X) for test in tests)

    bi = bisect_left(acc, need)  # bi問目まで完答でneed以上を達成(bi:1-indexed)=bi問解けばよい
    if bi == 0:
        print(0)  # 追加した
        return

    ge_need = acc[bi]  # need以上を達成するのに要した点数
    lt_need = acc[bi - 1]  # need未満の最大値を達成するのに要した点数

    def generate_candidates():
        INF = 10 ** 20
        for i, p in enumerate(tests, start=1):
            # p: partially_solved_test
            if i < bi:
                rest = need - (ge_need - p.Merit(Takahashi_score=X))
            else:
                rest = need - lt_need

            if rest <= p.Merit(Takahashi_score=p.Aoki_score):
                # 科目p単体の所要点数はAoki君以下でよく,lower_boundで計算
                add_ = (rest + p.lower_bound - 1) // p.lower_bound
            else:
                # 科目p単体の所要点数はAoki君を超える必要があり,upper_boundで計算
                add_ = p.Aoki_score
                add_ += (rest - p.Merit(Takahashi_score=p.Aoki_score) + p.upper_bound - 1) // p.upper_bound

            if add_ > X:
                yield INF
            else:
                ret = X * (bi - 1) + add_
                yield ret

    gen = generate_candidates()
    res = min(gen)
    print(res)
    return


if __name__ == '__main__':
    solve_agc034c()


Measured memory_bytes: 79708
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> vec(n);
  REP(i,n) cin >> vec[i];
  sort(vec.begin(), vec.end());
  int sum1 = accumulate(vec.begin(), vec.end(),0);
  int sum2 = accumulate(vec.begin(), vec.end()-k,0);
  cout << sum1 - sum2 << endl;
  return 0;
}
//templete by private_yusuke

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


def solve(a: int, b: int):
    d = b - a
    ret = 0
    for i in range(d + 1):
        ret += i
    ret -= b
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n, m = map(int, input().split())

lMax = float("-inf")
rMin = float("inf")
for i in range(m):
	l, r = map(int, input().split())
	lMax = max(l, lMax)
	rMin = min(r, rMin)

if lMax > rMin:
	print(0)
else:
	print(rMin - lMax + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
bool used[26];
int main() {
    init();
    string S, e;
    cin >> S;
    ll sn = S.size();
    repr(i, 26) e += 'a' + i;
    if(S==e){
        cout << -1 << endl;
        return 0;
    }

    if(sn==26){
        reverse(all(S));
        ll en = 26;
        bool isok = false;
        rep(i,sn){
            ll cn = S[i] - 'a';
            used[cn] = true;
            repe(j,cn+1, 26){
                if(used[j]){
                    isok = true;
                    S[i] = 'a' + j;
                    break;
                }
            }
            if (isok) break;
            en--;
        }
        reverse(all(S));
        cout << S.substr(0, en) << endl;
    }
    else{
        rep(i, sn) used[S[i]-'a'] = true;
        rep(i,26){
            if(!used[i]){
                S += 'a' + i;
                break;
            }
        }
        cout << S << endl;
    }



}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

vector<int> make753() {

	vector<int> vec753;
	int bit_used = 0, range = 9;
	int tmp, ternary, n753;

	for (int digit = 3; digit <= 9; digit++) {

		range *= 3;

		for (int i = range + 1; i <= range * 3; i++) {

			bit_used = 0;
			ternary = i;
			n753 = 0;

			for (int j = 0; j < digit; j++) {

				tmp = ternary % 3;
				ternary /= 3;
				n753 *= 10;
				
				if (tmp == 0) {
					n753 += 3;
					bit_used |= 1;
				}				
				if (tmp == 1) {
					n753 += 5;
					bit_used |= 2;
				}
				if (tmp == 2) {
					n753 += 7;
					bit_used |= 4;
				}
			}

			if (!(bit_used ^ 7)) vec753.push_back(n753);

		}

	}

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

	return vec753;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> vec = make753();
	int ans = upper_bound(vec.begin(), vec.end(), N) - vec.begin();

	cout << ans / 2 << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    if(s.size() < t.size()){
        cout << "UNRESTORABLE\n";
        return 0;
    }
    bool check;
    for(int i = s.size() - t.size(); i >= 0; i--){
        check = true;
        for(int j = 0; j < t.size(); j++){
            if(s[i + j] != t[j] && s[i + j] != '?'){
                check = false;
                break;
            }
        }
        if(check){
            s = s.substr(0, i) + t + s.substr(i + t.size());
            break;
        }
    }
    if(check){
        for(auto&& i : s){
            if(i == '?'){
                cout << "a";
            }else{
                cout << i;
            }
        }
        cout << "\n";
    }else{
        cout << "UNRESTORABLE\n";
    }
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, M = sc.nextInt()

    val step = M * 1900 + (N - M) * 100
    val ans = pow(2, M) * step
    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = (0 until n) foreach f

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    (0 until n) foreach (i => res(i) = f(i))
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(a => map.getOrElseUpdate(f(a), ArrayBuffer()) += a)
      map
    }

    def rep(f: A => Unit): Unit = {
      as.indices foreach (i => f(as(i)))
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(a => sum = num.plus(sum, f(a)))
      sum
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }

  def pow(x: Int, n: Int): Int = {
    n match {
      case 0 => 1
      case _ =>
        val r = pow(x * x, n / 2)
        if (n % 2 == 1) r * x else r
    }
  }
}


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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,n,t1=inf,t2=-1,t;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>t;
		t1=min(t1,t);
		t2=max(t2,t);
	}
	cout<<t2-t1;
	return 0;
}

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

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= M; j++){
            if(i * (M - j) + j * (N - i) == K){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;


int main() {
	int n, l; cin >> n >> l;
	vector<string>s(n);
	vector<int>si(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	sort(s.begin(), s.end());
	
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
}

    

Measured memory_bytes: 256
n = int(input())
a_list = [int(num) for num in list(input().split(" "))]

ope_count = 0
flag = True
while(flag):
    for i in range(n):
        if a_list[i]%2==0:
            a_list[i] /= 2
        else :
            flag = False
    if flag:
        ope_count+=1

print(ope_count)


Measured memory_bytes: 3188
l = [int(input()) for _ in range(5)]
m = 100
ind = 100
res = 0
for i in range(5):
    if l[i]%10 == 0:
        continue
    if l[i]%10 < m:
        m = l[i]%10
        ind = i
for i in range(5):
    if i == ind:
        continue
    else:
        res += -(-l[i]//10)*10
if ind < 5:
    res += l[ind]
print(res)


Measured memory_bytes: 3060
# https://atcoder.jp/contests/abc122/tasks/abc122_b

import itertools
import collections
import bisect

def main():
    S = list(input())
    ans = 0
    current = 0
    for i in range(len(S)):
        if S[i] in ['A', 'C', 'G', 'T']:
            current += 1
            ans = max(ans, current)
        else:
            current = 0
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
s = input()
n = len(s) - 1
plus_all = []
def cal(a):
  count = 0
  left = 0
  for i in range(len(a)):
    if a[i] == True:
          count+= int(s[left:i+1])
          left = i + 1
          
  count += int(s[left:])
  return count
result = []
def dfs(A):
  if len(A) == n:
    result.append(cal(A))
    return A
  else:
    for i in range(2):
      if i == 0:
        A.append(True)
      else:
        A.append(False)
      dfs(A)
      A.pop(-1)
dfs([])
print(sum(result))
          




      


Measured memory_bytes: 39024
#include<iostream>
#include<cmath>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;

char s[200011];
int n;
map<int,int>dp;
int main()
{
    int i,j,k;
    
    scanf("%s",s+1);
    n=strlen(s+1);
    
    dp[0]=0;
    int f=0;
    
    int now=0x3f3f3f3f;
    for(i=1;i<=n;i++)
    {
        f^=(1<<(s[i]-'a'));
        now=0x3f3f3f3f;
        if(dp.find(f)!=dp.end())
        {
            now=min(now,dp[f]);
        }
        for(j=0;j<26;j++)
        {
            int tmp=(f^(1<<(j)));
            if(dp.find(tmp)!=dp.end())
            {
                now=min(now,dp[tmp]);
            }
        }
        
        //cout<<f<<' '<<now<<endl;
        
        if(now!=0x3f3f3f3f)
        {
        if(dp.find(f)==dp.end())
        {
            dp[f]=now+1;
        }
        else
        {
            dp[f]=min(dp[f],now+1);
        }
        }
    }
    
    cout<<now+1<<endl;
    
    
    return 0;
}


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

#define   ll             long long int
#define   pb             push_back
#define   mp             make_pair
#define   fast           ios_base::sync_with_stdio(false);cin.tie(NULL);
#define   ff             first
#define   ss             second
#define   nil           -10e+9
#define   initial         0
#define   waiting         1
#define   visit           2
#define   inf            10e+9
#define   mx             200005
#define   mxx            1000005
#define   mod            1000000007
#define   pr             pair<ll,ll>
#define   pp_queue       priority_queue<pr,vector<pr>, greater<pr> >
#define   dp_queue       priority_queue<int,vector<int>, greater<int> >
#define   sp_queue       priority_queue<int>
#define   fr(i,p,q)      for(int i=p;i<q;++i)
#define   frr(i,p,q)     for(int i=p;i<=q;++i)
#define   mem(a,b)       memset(a,b,sizeof(a))
#define   len(a)         (int)a.size()
#define   input          freopen("input.txt", "r", stdin);
#define   output         freopen("output.txt", "w", stdout);
#define   hash_map(mpp)  unordered_map<ll,ll> mpp;mpp.reserve(1048576);mpp.max_load_factor(0.25);
#define   all(a)         a.begin(),a.end()
#define   lower(a,x)     lower_bound(all(a),x)-a.begin()
#define   upper(a,x)     upper_bound(all(a),x)-a.begin()
#define   debug(arr,j,n) fr(i,j,n) cout<<arr[i]<<" ";

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

using namespace std;

int main()
{
  int t;
  cin>>t;
  map<int,int> mpp;
  for(int i=2;i<=t;i++){
    int x;
    cin>>x;
    mpp[x]++;
  }

  for(int i=1;i<=t;i++){
    cout<<mpp[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 13004
#include<bits/stdc++.h>
using namespace std;
#define mx 200005
vector<int>adj[mx];
bool vis[mx];
int dp[mx];

void dfs(int src){
vis[src] = 1;

for(int i = 0;i<adj[src].size(); i++){
    if(!vis[adj[src][i]])
        dfs(adj[src][i]);
dp[src] = max(dp[src],1 + dp[adj[src][i]]);
}
}
int longest_path(int n){
    int ans = 0;
    memset(dp,0,sizeof dp);
    memset(vis,0,sizeof vis);

    for(int i = 1;i<=n;i++){
        if(!vis[i])
            dfs(i);
    }
    for(int i = 1;i<=n;i++){
        ans = max(ans,dp[i]);
    }
return ans;
}




int main(){
int n,m;
cin>>n>>m;
for(int i = 1;i<=m;i++){
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
}

cout<<longest_path(n)<<endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
bool vis[200000];
map<char,pair<char,ll>>g;
int main()
{
  //flash;
  ll n,k;
  ll r,s,p;
  string T;
  cin>>n>>k>>r>>s>>p>>T;
  ll ans=0;
  g['r']={'p',p};
  g['s']={'r',r};
  g['p']={'s',s};
  for (ll i = 0; i < T.size(); ++i)
  {
    if(!vis[i])
    {
      char last='1';
      for (ll j = i; j < T.size(); j+=k)
      {
        vis[j]=1;
        if(g[T[j]].first!=last)
        {
          ans+=g[T[j]].second;
          last=g[T[j]].first;
        }
        else last='1';
      }
    }
    else break;
  }
  cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map


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

int main() {
	int N; cin >> N;
	vector<int>A(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		sum += A.at(i);
	}
	int val = 0, val2 = 0, ans = 999999;
	for (int i = 0; i < N - 1; i++) {
		val += A.at(i);
		val2 = sum - val;
		ans = min(ans, abs(val2 - val));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   cout<<c<<" "<<a<<" "<<b;
   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        ll r, d, x;
        cin >> r >> d >> x;
        for (int i = 0; i < 10; ++i) {
            x = r * x - d;
            cout << x << endl;
        }

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
bool f(int a,int b,int c,int k){
    if(b>a&&c>b) return 1;
    if(k<=0) return 0;
    return f(a*2,b,c,k-1)||f(a,b,c*2,k-1)||f(a,b*2,c,k-1);
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c;
	cin>>k;
	if(f(a,b,c,k)) cout<<"Yes";
	else cout<<"No";
	return 0; 
	
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    cin>>n;
    switch(n%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        cout<<"hon"<<endl;
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        cout<<"pon"<<endl;
        break;
        case 3:
        cout<<"bon"<<endl;
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int N, M, np = 2, ans = 1;
	cin >> N >> M;
	vector<queue<int> > P(N+1, queue<int> ());
	vector<bool> T(N+1, false);

	rep(i, M){
		int x, y, z;
		cin >> x >> y >> z;
		P[x].push(y);
		P[y].push(x);
	}

	queue<int> Q;
	Q.push(1);

	while(!Q.empty()){
		int q;
		q = Q.front();
		Q.pop();
		T[q] = true;

		while(!P[q].empty()){
			if(!T[P[q].front()]) Q.push(P[q].front());
			P[q].pop();
		}

		if(Q.empty()){
			while(true){
				if(np == N+1) break;
				if(T[np]) np++;
				else{
					Q.push(np);
					ans++;
					break;
				}
			}
		}
	}

	cout << ans << endl;



}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}



Measured memory_bytes: 68224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();

	}
	static class Task{
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			long r = in.nextLong(), d = in.nextLong(), x = in.nextLong();
			for(int i = -1; ++i <10;)
			{
				x = r*x-d;
				out.println(x);
			}
		}//Solve
	}//task
	
	
	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer == null || ! tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for(int i = -1; ++i < n;) a[i] = nextInt();
			return a;
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 21460
aa=input()
bb=input()
cc=input()
alist=list(aa)
blist=list(bb)
clist=list(cc)
lists=[alist, blist, clist]


turn=0

while len(lists[turn])>0:
    if lists[turn][0]=="a":
        del lists[turn][0]
        turn=0
        
    elif lists[turn][0]=="b":
        del lists[turn][0]
        turn=1
            
    elif lists[turn][0]=="c":
        del lists[turn][0]
        turn=2

if turn==0:
    print("A")
elif turn==1:
    print("B")
else:
    print("C")

Measured memory_bytes: 3064
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC
{
  public class Program
  {
    public static void Main(string[] args)
    {
      char c;
      string s = Console.ReadLine();
      c = Convert.ToChar(s);
      char[] voins = {'a', 'i', 'u', 'e', 'o'};
      int n = Array.IndexOf(voins, c);
      if(n==-1)
      {
        Console.WriteLine("consonant");
      }
      else
      {
        Console.WriteLine("vowel");
      }
    }
  }
}

Measured memory_bytes: 2904
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(rng(a));
  int sum = 0;
  rep(i,k) sum += a[i];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
ll fac[110000];
ll finv[110000];
ll inv[110000];
void modinv(int max) {
	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;
	}
}
ll comb(int n, int r) {
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
int main() {
	modinv(10000);
	int n, k;
	cin >> n >> k;
	rep1(i, k) {
		ll blue = comb(k - 1, i - 1);
		ll red = comb(n - k + 1, i);
		ll ans = blue * red % MOD;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 512
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
bool pal (int x )
{
    int t[20];
    int id =0 ;
    while (x)
    {
        t[id++] = x %10 ;
        x/=10;
    }
    id--;
    int i =0 ;
    while (i < id )
    {
        if (t[i] != t[id])return false ;
        i++; id--;
    }
    return true ;
}
int main()
{
    int a, b ;
    scanf ("%d%d" , &a ,&b );
    int ans =0 ;
    while (a <= b )
    {
        ans += pal(a);
        a++;
    }
    printf ("%d\n" ,ans );

}


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

int n;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	long long h[n], dp[n];
	for (int i=0; i<n; i++) cin >> h[i];
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i=2; i<n; i++) {
		dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
int main() {
	int D, T, S; cin >> D >> T >> S;
	double temp;
	temp = (double)D / S;
	if (temp <= T) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl;
	}
}

Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll f[400000];

void calc() {
    f[0] = 1;
    rep(i, 1, 400001) {
        f[i] = f[i - 1] * i;
        f[i] %= mod;
    }
}

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m){
    return pow_mod(a, m - 2, m);
}

ll comb(ll n, ll r) {
    ll ret = f[n];
    ret *= inv_mod(f[r], mod);
    ret %= mod;
    ret *= inv_mod(f[n - r], mod);
    ret %= mod;
    return ret;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll N, K;
    cin >> N >> K;
    calc();
    
    vector<ll> A(N);
    A[0] = 1;
    A[1] = N * (N - 1) % mod;
    rep(i, 2, N) {
        A[i] = comb(N, i);
        A[i] *= comb(N - 1, i);
        A[i] %= mod;
    }
    
    ll ans = 0;
    rep(i, min(K + 1, N)) {
        ans += A[i];
        ans %= mod;
    }
    output(ans);
    
    return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int a = 1;
        while(a <= n){
            String str = String.valueOf(a);
            if (a % 3 == 0 || str.indexOf("3") != -1){
                System.out.print(" ");
                System.out.print(a);
            }
            a++;
        }
//        System.out.print(" ");
        System.out.println();
    }

}



Measured memory_bytes: 32372
s = input() #文字列


difCount = 0
col = 1 #最初に比べる桁は黒にする
for i in range(len(s)):
  if s[i:i+1] != str(col): #色が違えば
    difCount += 1
  col = abs(col - 1)
  
print(min(difCount,len(s)-difCount))

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

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

  int ans1 = 0, ans2 = 0;
  for(int i=0; i<S.length(); i++){
    if(i % 2 == 0){
      if(S[i] != '0') ans1++;
      if(S[i] != '1') ans2++;
    } else {
      if(S[i] != '1') ans1++;
      if(S[i] != '0') ans2++;
    }
  }
  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

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

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll x;
	cin >> x;
	cout << (x / 500) * 1000 + ((x % 500) / 5) * 5 << endl;			
}

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

int main()
{
	for (unsigned long a, b, x, r; cin >> a >> b; cout << a << ' ' << x << endl) {
		unsigned long at = a, bt = b;
		do {
			r = a%b;
			a = b;
			b = r;
		} while (r);
		x = at / a *bt;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int a[1000005];
int b[1000005];

ll res;
set <pair <int, int>> q;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
        q.insert({b[i], i});
    }
    while(!q.empty()){
        pair <int, int> par = *q.rbegin();
        q.erase(par);
        int i = par.second;
        //cout << par.first << " " << i << endl;
        //cout << b[i] << " " << b[(i-1+n)%n] << " " << b[(i+1)%n] << endl;
        if(b[i] == a[i]) continue;
        if(b[i] - (b[(i-1+n)%n] + b[(i+1)%n]) < a[i]){
            cout << -1;
            return 0;
        }
        int s = b[(i-1+n)%n] + b[(i+1)%n];
        int k = (b[i]-a[i])/s;
        res += k;
        b[i] -= s*k;
        q.insert({b[i], i});
    }
    cout << res;
    return 0;
}


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

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

    int r, D, x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; ++i) {
        x = r * x - D;
        cout << x << "\n";
    }
    cout << flush;

    return 0;
}


Measured memory_bytes: 256