akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 1000000007

typedef long long ll;
long long int dp[100005];
int main(){
    int n,m; cin >> n >> m;
    vector<int> a(m); rep(i,m) cin >> a[i];
    rep(i,m-1) if(a[i]+1==a[i+1]){ cout << 0 << endl; return 0;}
    vector<bool> b(n+1); rep(i,n) b[i] = false;
    rep(i,m) b[a[i]] = true;
    rep(i,100005) dp[i] = 0;
    dp[0] = 1;
    for(int i=1;i <= n ;i++){
        if(b[i]) continue;
        if(i-1 >= 0 && !b[i-1]) dp[i] = (dp[i] + dp[i-1]) % MOD;
        if(i-2 >= 0 && !b[i-2]) dp[i] = (dp[i] + dp[i-2]) % MOD;
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <functional>
#include <algorithm>

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

using namespace std;

typedef pair<int, int> P;

int n, m;
P x[10000];

int main(){
	while(scanf("%d%d", &n, &m), n){
		rep(i, n){
			int d, p;
			scanf("%d%d", &d, &p);
			x[i] = P(p, d);
		}
		sort(x, x + n, greater<P>());
		int ans = 0;
		rep(i, n){
			if(m >= x[i].second){
				m -= x[i].second;
			}
			else{
				ans += (x[i].second - m) * x[i].first;
				m = 0;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1104
s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
out=0
for i in range(0,1000):
  out=0
  for j in range(n):
    if slist[j]==x-i:
      out=1
  if out !=1:
   print(x-i)
   exit()
  out=0
  for k in range(n):
    if slist[k]==x+i:
      out=1
  if out !=1:
    print(x+i)
    exit()

Measured memory_bytes: 9152
#include<bits/stdc++.h>
#define int double
using namespace std;
 
signed main(){
int a,b;
while(cin>>a>>b,a||b){
    int c=a*a;
    int d=sqrt((a*a/4)+b*b);
    c+=a*d*2;
    cout<<fixed<<setprecision(10)<<c<<endl;
    }
}

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

int main(){ 
    Int N;
    cin >> N;

    vector<Int> A(N);
    rep (i,N) {
        Int a;
        cin >> a;
        if (a >= N) A[i] = N;
        else A[i] = a;
    }

    vector<Int> x(N), y(N);

    rep(i,N) {
        x[i] = min(A[i]+i+1, N);
        if (i+1 <= A[i]) y[i] = 0;
        else y[i] = i + 1 - A[i];
    }

    sort(x.begin(),x.end());
    sort(y.begin(),y.end());


    Int ans = 0;
    rep1(i,N-1) {
        ans += (upper_bound(x.begin(),x.end(), i) - lower_bound(x.begin(),x.end(), i)) * (upper_bound(y.begin(),y.end(), i) - lower_bound(y.begin(),y.end(), i));
    }

    cout << ans << endl;
}


Measured memory_bytes: 8008
N=int(input())
dic = {}
for i in range(N):
    s =input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s] =1

items = list(dic.items())
max_num = max([v[1] for v in items])
ans = []

for k,v in items:
    if max_num == v:
        ans.append(k)

ans.sort()

for v in ans:
    print(v)

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

int main(){
    double a,b;
    cin >> a >> b;
    if (a > b){
        cout << "GREATER" << endl;
    }
    else if (a < b){
        cout << "LESS" << endl;
    }
    else if (a == b){
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
$n = gets.to_i
INF = 1 << 30
$mat = []
$n.times{ $mat << gets.split.map(&:to_i) }
$v = []
$e = []
def prim(x)
  $v << x
  while $v.size < $n
    min_v ,min_t = INF
    $v.each do |t|
      $n.times do |i|
        next if $v.include? i 
        if $mat[t][i] != -1 && min_v > $mat[t][i]
          min_v = $mat[t][i]
          min_t = i
        end
      end
    end
    $v << min_t
    $e << [min_v, min_t]
  end
  ret = 0 
  $e.each{ |v| ret += v[0] }
  ret
end
p prim(0)

Measured memory_bytes: 8912
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

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

const int maxn = 3010;
const ll md = 1e9 + 7;

pii Z[maxn];
ll C[maxn][maxn];
ll dp[maxn][maxn];
int pref[maxn];

int main() {
	IOS; string s;

	for (int i = 0; i < maxn; i++) {
		for (int j = 0; j < maxn; j++) {
			if (i == 0) { C[i][j] = (j==0); continue; }
			if (j == 0) { C[i][j] = 1; continue; }
			C[i][j] = (C[i-1][j] + C[i-1][j-1])%md;
		}
	}

	int n,m; cin>>n>>m>>s; s = " " + s; int idx = 0; pref[0] = 0;
	for (int i = 1; i <= n; i++) {
		pref[i] = pref[i-1]; pref[i] += (s[i] == '1');
	}
	for (int i = 1; i <= m; i++) {
		int l,r;
		cin>>l>>r; pii z = mp(l,r);  
		if (idx == 0) { idx++; Z[idx] = z; continue; }
		if (Z[idx].first == l) {
			if (Z[idx].second < r) Z[idx] = z;
			else continue;
		} else {
			if (Z[idx].second >= r) continue;
			else { idx++; Z[idx] = z; }
		}
	}
	m = idx; Z[m+1] = mp(n+7,n+7); Z[0] = mp(-7,-7); dp[m+1][0] = 1;
	for (int k = m; k >= 1; k--) {
		int lft = Z[k].first, rgt = Z[k].second;
		int p = max(Z[k-1].second, lft-1); 
		int tc = pref[rgt] - pref[p];
		for (int l = 0; l <= (p-lft+1); l++) {
			dp[k][l] = 0;
			int t = tc + l;
			int d = max(rgt - Z[k+1].first + 1, 0);
			int my = rgt - lft + 1 - d;
			if (d == 0) { dp[k][l] = (C[my][t] * dp[k+1][0])%md; continue; } // arrange yours
			for (int g = max(t-my,0); g <= min(d,t); g++) { // can give atleast 0 and t-my atmost overlap and t
				ll cur = C[my][t-g] * dp[k+1][g];
				dp[k][l] = (cur + dp[k][l])%md;
			}
		}
	}
	cout<<dp[1][0]<<endl;				
}


Measured memory_bytes: 101248
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        char[] ch = sc.next().toCharArray();
        String ans = "";
        for (int i = 0; i < a; i++) {
            if (i == b - 1) {
                ans += Character.toLowerCase(ch[i]);
            } else {
                ans += ch[i];
            }
        }
        System.out.println(ans);
    }
}


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

using namespace std;

#define ll long long

int bin_pow(int a, int pow) {
    if (pow == 0) return 1;
    if (pow == 1) return a;
    if (pow % 2 == 0) {
        int tmp = bin_pow(a, pow / 2);
        return tmp * tmp;
    }
    return a * bin_pow(a, pow - 1);
}

int fact(int x) {
    int ans = 1;

    for (int i = 1; i <= x; i++) ans *= i;
    return ans;
}

int count(vector<int> a) {
    int ans = 0;
    unordered_set<int> was;
    for (int i = 0; i < a.size(); i++) {
        int count = a[i] - 1;
        for (int j = 1; j < a[i]; j++) {
            count -= was.count(j);
        }
        ans += count * fact(a.size() - i - 1);
        was.insert(a[i]);
    }

    return ans;
}

ll m = 1000000007;

bool isPrime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    int n;
    cin >> n;

    vector<pair<double, double>> a(n);

    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;

    vector<int> perm;

    for (int i = 0; i < n; i++) perm.push_back(i);
    double ways = 0.0;
    int cnt = 0;
    do {
        cnt++;
        for (int i = 1; i < n; i++) {
            ways += hypot(a[perm[i]].first - a[perm[i - 1]].first, a[perm[i]].second - a[perm[i - 1]].second);
        }
    } while (next_permutation(perm.begin(), perm.end()));

    cout << setprecision(20) << ways / cnt;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	cin>>n;
	x=n%10;
	if(x==2||x==4||x==5||x==7||x==9) cout<<"hon"<<endl;
	else if(x==0||x==1||x==6||x==8) cout<<"pon"<<endl;
	else cout<<"bon"<<endl;
	return 0;
}


Measured memory_bytes: 3596
import sys
from collections import deque, defaultdict
import copy
import bisect
sys.setrecursionlimit(10 ** 9)
import math
import heapq
from itertools import product, permutations,combinations
import fractions

import sys
def input():
	return sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
A = list(map(int, input().split()))

sum_list = [0]
even_odd_sum = [0, 0]
for i in range(N):
	sum_list.append(sum_list[-1] + A[i])
	even_odd_sum.append(even_odd_sum[-2] + A[i])

for q in range(Q):
	x = int(input())
	if x >= A[-1]:
		print(even_odd_sum[-1])
	else:
		loc_min = bisect.bisect_left(A, x)
		loc_min = max(loc_min, N // 2)
		loc_max = (loc_min + N) // 2

		t = (loc_min + loc_max) // 2


		#print(x, loc_min, loc_max, t, 2*t - N - 1)
		while (loc_min <= loc_max):

			if 2*t - N - 1 >= 0 and A[t - 1] - x >= x - A[2*t - N - 1]:
				loc_max = t - 1
			elif 2*t - N >= 0 and A[t] - x < x - A[2*t - N]:
				loc_min = t + 1
			elif 2*t - N < 0 and A[t] - x < x - A[0]:
				loc_min = t + 1
			else:
				break

			t = (loc_min + loc_max) // 2
		ans = sum_list[-1] - sum_list[t] + even_odd_sum[2*t - N - 1 + 2]
		print(ans)

Measured memory_bytes: 102308
import sys
import bisect
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
cnt = 0
ans = 0
memo = [0] * n

for i in range(n):
    insert_index_c = bisect.bisect_right(c, b[i])
    cnt += n - insert_index_c
    memo[i] += cnt

for i in range(n):
    if a[i] > b[n - 1]:
        break
    insert_index_b = bisect.bisect_right(b, a[i])  # 昇順
    if insert_index_b >= 1:
        ans += memo[n - 1] - memo[insert_index_b - 1]
    else:
        ans += memo[n - insert_index_b - 1]

print(ans)


Measured memory_bytes: 23120
// g++ -I ~/Documents/programming/cppLib -std=gnu++14 -o test ~/Documents/programming/cppLib/test.cpp && ./test && rm test
#include <bits/stdc++.h>
#define rep(i, n) for( lint i=0; i<(n); ++i )
#define all(v)    (v).begin(), (v).end()
using namespace std;
using lint = long long;

//  cinからvectorへ入力
template<typename T>
istream& operator >> ( istream& is, vector<T>& vec ) {
    for( T& x: vec ) {
        is >> x;
    }
    return is;
}

//  coutへvectorから出力
template<typename T>
ostream& operator << ( ostream& os, vector<T>& vec ){
    for( T& x: vec ) {
        if( x == vec[0] ) {
            cout << x;
        } else {
            cout << " " << x;
        }
    }
    return os;
}

//  ループ制御を表す列挙子
enum LoopControl {
    Again,
    Break,
    Continue,
};

//  それぞれのvectorから１つずつ選ぶ組み合わせを全探索
#define select( v, data ) SELECTION<typeof(data[0][0])>(data) * [&](vector<typeof(data[0][0])> v)
template<typename T> struct SELECTION {
    vector<vector <T>> &data;
    SELECTION( vector<vector <T>> &d ) :data(d) {}
    void operator* ( function<LoopControl(vector<T>&)> closure ) {
        int N = data.size();
        vector<int> K(N);
        for( int i=0; i<N; i++ ) {
            K[i] = data[i].size();
        }

        vector<int> now( N, 0 );
        vector<T> arg(N);
        while(true) {
            for( int i=0; i<N; i++ ) {
                arg[i] = data[i][now[i]];
            }

            again:
            switch( closure(arg) ){
                case Again:
                    goto again;
                case Break:
                    return;
                case Continue:;
            }

            for( int i=0; i<N; i++ ) {
                now[i] ++;
                if( now[i] < K[i] ) {
                    break;
                }
                if( i == N-1 ) {
                    return;
                }
                for( int j=0; j<=i; j++ ) {
                    now[j] = 0;
                }
            }
        }
    }
};


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

    vector<int> ABC(3);
    cin >> ABC;

    vector<int> L(N);
    cin >> L;

    vector<vector<int>> table( N, vector<int>({0,1,2,3}) );
    int minimum = INT_MAX;
    select( v, table ) {
        int sum = 0;
        rep( i, 3 ) {
            int len = 0;
            int cnt = 0;
            rep( j, N ) {
                if( v[j] == i ) {
                    len += L[j];
                    cnt ++;
                }
            }
            if( cnt == 0 ) {
                return Continue;
            }
            sum += cnt * 10 - 10;
            sum += abs( ABC[i] - len );
        }

        minimum = min( minimum, sum );
        return Continue;
    };

    cout << minimum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  vector<P> vec(n);
  bool odd = false;
  rep(i, n) {
    int x, y; cin >> x >> y;
    int u = x+y;
    int v = x-y;
    if (i==0 && u%2 != 0) {
      odd = true;
    }
    // if not even, x++;
    if (odd) {
      u++; v++;
    }

    if (u%2 != 0) {
      cout << -1 << endl;
      return 0;
    }
    vec.at(i) = P(u, v);
  }

  int m = 32;
  if (odd) m++;
  cout << m << endl;
  if (odd) {
    cout << 1 << ' ';
  }
  for(int k=30; k>=0; k--) {
    cout << (1<<k) << ' ';
  }
  cout << 1 << endl;

  rep(i, n) {
    if (odd) {
      cout << 'L';
    }
    int u = vec.at(i).first;
    int v = vec.at(i).second;
    for(int k=30; k>=-1; k--) {
      int tmp = k;
      if (tmp == -1) tmp++;
      int d = (1<<tmp);
      if (u > 0 && v > 0) {
        cout << 'R';
        u -= d;
        v -= d;
      } else if (u > 0 && v <= 0) {
        cout << 'U';
        u -= d;
        v += d;
      } else if (u <= 0 && v > 0) {
        cout << 'D';
        u += d;
        v -= d;
      } else {
        cout << 'L';
        u += d;
        v += d;
      }
    }
    cout << '\n';
    //debug(u);debugln(v);
  }
}

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


int main()
{
  string s, t;
  cin >> s >> t;
  if (s == t.substr(0, s.size()))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef pair < int, int > pii;

const int INF = 1000000007;
const int N = 100005;
int n, m, l, r, d, ans[N];
bool mark[N];
vector < pii > g[N];

void dfs(int v) {
    mark[v] = true;
    for (int i = 0; i < g[v].size(); i++) {
        int to = g[v][i].first;
        int len = g[v][i].second;
        if (ans[to] == INF) {
            ans[to] = ans[v] + len;
        }
        if (ans[to] != ans[v] + len) {
            cout << "No";
            exit(0);
        }
        if (!mark[to]) {
            dfs(to);
        }
    }
}

int main() {
    fill(ans, ans+N, INF);
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> l >> r >> d;
        g[l].push_back(make_pair(r, d));
        g[r].push_back(make_pair(l, -d));
    }

    for (int i = 1; i <= n; i++) {
        if (!mark[i]) {
            ans[i] = 0;
            dfs(i);
        }
    }

    cout << "Yes";
    return 0;
}

Measured memory_bytes: 12032
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

vector<int> Eratosthenes( const int N )
{
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

    ll n;
    cin>>n;

    auto b = Eratosthenes(55555);

    int cnt=0;
    for(auto a : b){
        if(a%5==1){
            cout<<a<<' ';
            cnt++;
            if(cnt==n){
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3712
n=int(input())
s=[]
for i in range(n):
  a,b=map(str, input().split())
  s.append([a,-1*int(b),i+1])
s.sort()
sorted(s, key=lambda x:(x[0],x[1]))
ans=[]
for i in range(n):
  ans.append([s[i][1],s[i][2]])
  
ans.sort(reverse=True)
for i in range(n):
  #print(ans[i][1])
  print(s[i][2])

Measured memory_bytes: 3064
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	string s;
	int n;
	int num;
	unsigned char uchr;
	
	cin >> n >> s;
	size_t size = s.length();
	for (int i = 0; i < size; i++) {
		num = (int)s[i];
		num += n;
	
		if (num > 90) {
			num -= 26;
		}

		uchr = (char)num ;
		
		cout << uchr;
	}
	cout << endl;
	return 0;
}


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

int main(){
	int n,cnt=0,max=0;
	bool a[26];
	bool b[26];
	string s;
	cin>>n>>s;
	for(int i=1;i<n-1;i++){
		for(int i=0;i<26;i++){
			a[i]=false;
			b[i]=false;
		}
		for(int j=0;j<i;j++)
			a[s[j]-'a']=true;
		for(int j=i;j<n;j++)
			b[s[j]-'a']=true;
		cnt=0;
		for(int j=0;j<26;j++)
			if(a[j]==true&&b[j]==true)cnt++;
		if(cnt>max)max=cnt;
	}
	cout<<max<<endl;
	return 0;
}


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

typedef long long ll;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

void solve() {
	int a,b;
	cin >> a >> b;
	cout << a*b;
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
}



Measured memory_bytes: 3644
// clang-format off
#include <bits/stdc++.h>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr int MAX = 200000;
int N;
ll T;
ll t[MAX];

int main()
{
    cin >>N >> T;
    rep(i, N){
        cin >> t[i];
    }
    ll sum =0;
    ll start = t[0];
    rep1(i, N-1){
        if(t[i]-t[i-1]<=T){
            ;
        } else {
            sum += t[i-1]+T-start;
            start = t[i];
        }
    }
    sum += t[N-1]+T-start;
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 1792
import heapq

n, tickets = map(int, input().split())
a = list(map(int, input().split()))

pq = []
for price in a:
    heapq.heappush(pq, -price)

while tickets:
    biggest = heapq.heappop(pq)
    biggest = (-biggest) // 2
    tickets -= 1
    heapq.heappush(pq, -biggest)

print(-sum(pq))

Measured memory_bytes: 14180
#include <iostream>
using namespace std;
int main(){
    int x,y;
    while(1){
        cin>>x>>y;
        if(x==0 && y==0){
            break;
        }
        else if(x>=y){
            cout<<y<<" "<<x<<endl;
        }
        else{
            cout<<x<<" "<<y<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
def main():
    S=input()
    P=2019
    ans=0
    
    count=[0]*P
    count[0]=1
    u=0
    
    for i,s in enumerate(reversed(S)):
        u=(int(s)*pow(10,i,P)+u)%P
        ans+=count[u]
        count[u]+=1
    print(ans)
    

if __name__=="__main__":
    main()

Measured memory_bytes: 9276
import sys
input = sys.stdin.readline

N, M, L = map(int, input().split())
inf = 10**15
V = [[] for _ in range(N)]

for _ in range(M):
    A, B, C = map(int, input().split())
    if C>L:continue
    V[A-1].append((B-1, C))
    V[B-1].append((A-1, C))

dists = []
for i in range(N):
    dist = [(inf,inf)] * N
    dist[i] = (0, 0)
    u = [False] * N
    for _ in range(N):
        (charged, used), j = min([(dist[i], i) for i in range(N) if not u[i]])
        u[j] = True
        for k, next_cost in V[j]:
            if j==k: continue
            c = (charged+1, next_cost) if used+next_cost>L else (charged, used+next_cost)
            if dist[k] > c:
                dist[k] = c
    dists.append(dist)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    ans = dists[s-1][t-1][0]
    print(ans if ans!=inf else -1)


Measured memory_bytes: 66268
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
 
using namespace std;
 
int main(int argc, char* argv[])
{
 
	int a,b,c;
 
	cin >> a >> b >> c;
 
	cout << ((b-a==c-b) ? "YES": "NO") << endl;
 
	return 0;
 
}

Measured memory_bytes: 256
H, W = [int(_) for _ in input().split()]

if 0 in [H % 3, W % 3]:
    print(0)
    exit()


def calc(x, y):
    res = float('inf')
    for p in [y // 3, 1 + y // 3]:
        q = x // 2
        a = sorted([x * p, q * (y - p), (x - q) * (y - p)])
        res = min(res, abs(a[2] - a[0]))
    return res


print(min(H, W, calc(H, W), calc(W, H)))


Measured memory_bytes: 3064
n = int(input())
s = input()

w = s.count('.')
b = n - w
ans = min(w, b)
r = 0
l = w
for si in s:
    if si == '#':
        r += 1
    else:
        l -= 1
    if ans > r + l:
        ans = r + l
print(ans)


Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[100][5],u[100][5];
vector<int> ii;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h,j;
  cin >>a>>b>>c;
  a=a*100+b*10+c;
  if(a%4==0) cout <<"YES\n";
  else cout <<"NO\n";
  return (0);
}


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


const long long mod=1e9+7;
int n;
vector<int>adjl[100002];

pair<long long, long long> dfs(int now, int prev){ // black, white
	long long b=1, w=1;
	for (int next : adjl[now]){
		if (next==prev) continue;
		auto tmp=dfs(next,now);
		b*=tmp.second;
		b%=mod;
		w*=tmp.second+tmp.first;
		w%=mod;
	}
	return {b,w};
}

int main(){
	cin >> n;
	for (int i=1;i<n;i++){
		int u, v;
		cin >> u >> v;
		adjl[u].push_back(v);
		adjl[v].push_back(u);
	}
	auto ans=dfs(1,0);
	cout << (ans.first+ans.second)%mod << "\n";
}

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

int main() {
  string s;
  vector<string> cand = {"dreamer", "eraser", "dream", "erase"};
  cin >> s;
  reverse(s.begin(), s.end());
  rep(i, 4) reverse(cand[i].begin(), cand[i].end());

  bool flag = true;
  while (flag) {
    flag = false;
    // cerr << s << endl;
    rep(i, 4) {
      if (s.substr(0, cand[i].size()) == cand[i]) {
        s.erase(0, cand[i].size());
        flag = true;
        break;
      }
    }
  }
  cout << (s.size() == 0 ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 3724
n,k = map(int, input().split())
a = list(map(int, input().split()))
event = []
for i in range(k):
    data = [0 for _ in range(n + 1)]
    for i in range(n):
        data[max(0,i-a[i])] += 1
        data[min(n,i+a[i]+1)] -= 1

    for i in range(n):
        data[i+1] += data[i]
    check = True
    for i in range(n):
        if data[i] != n:
            check = False
            break
    if check:
        print(*data[:n])
        exit()
    a = data
print(*a[:n])

Measured memory_bytes: 169088
#include<bits/stdc++.h>
#define N 2010
using namespace std;
int n,k;
int ans[N][N],res;
int dep1,dep2,dep[N];
int cnt,s[N];
struct node
{
	int num,next;
}mp[N<<1];
void init(int x,int y)
{
	mp[++cnt].next=s[x];
	mp[cnt].num=y;
	s[x]=cnt;
}
void dfs(int x,int f)
{
	ans[x][1]=1;
	for(int i=s[x];i;i=mp[i].next)
	{
		int y=mp[i].num;
		if(y==f)continue;
		dfs(y,x);
	}
	int son=0;
	dep1=dep2=0;
	int j,maxp=0;
	for(int i=s[x];i;i=mp[i].next)
	{
		int y=mp[i].num;
		if(y==f)continue;
		++son;
		for(j=1;ans[y][j]&&j<k;j++)
			dep[j+1]+=ans[y][j];
		if(j>dep1)dep2=dep1,dep1=j,maxp=y;
		else if(j>dep2)dep2=j;
		--j;
		for(int r=j+1;r<k;r++)
			dep[r+1]+=ans[y][j];
	}
	int l=min(dep1,k);
	for(j=2;j<=l;j++)
	{
		if(son==1||j*2<=k+1)
			ans[x][j]=dep[j];
		else if(k-j>=dep2)
			ans[x][j]=ans[maxp][j-1]+dep[k-j+1]-ans[maxp][k-j];
		else for(int i=s[x];i;i=mp[i].next)
			{
				int y=mp[i].num;
				if(y==f)continue;
				if(ans[y][j-1])
					ans[x][j]=max(ans[x][j],ans[y][j-1]+dep[k-j+1]-ans[y][k-j]);
			}
		res=max(res,ans[x][j]);
	}
	for(int j=2;j<=k;j++)
		dep[j]=1;
}
int main()
{
	scanf("%d%d",&n,&k);
	++k;
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		init(x,y);
		init(y,x);
	}
	for(int i=1;i<=k;i++)
		dep[i]=1;
	dfs(1,1);
	printf("%d",n-res);
}

Measured memory_bytes: 15488
s = input()
t = input()

ls = len(s)
lt = len(t)
ret = lt
for i in range(ls+1 - lt):
  diff = 0
  for j in range(lt):
    diff += (t[j] != s[i+j])
  if diff == 0:
    ret = diff
    break
  if diff < ret:
    ret = diff
print(ret)

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

typedef long long ll;
typedef long double ld;

int N, K;
int remo[102];
bool dp[100002];
bool solved[100002];

bool calc(int remaining) {
    if(remaining == 0) return false;
    if(remaining < 0) return true;
    if(solved[remaining]) return dp[remaining];

    for(int i = 0; i < N; i++)
        dp[remaining] = dp[remaining] || !calc(remaining - remo[i]);

    solved[remaining] = true;
    return dp[remaining];
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> K;

    for(int i = 0; i < N; i++) 
        cin >> remo[i];

    if(calc(K)) cout << "First\n";
    else cout << "Second\n";

    return 0;
}


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

int main()
{
    int N, l, r, sum;
    sum = 0;
    cin >> N;

    for (int i = 0; i < N; ++i)
    {
        cin >> l >> r;
        sum += r - l + 1;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int A,B,C;
    cin >> A >> B >> C;
    int X,Y;
    cin >> X >> Y;
    // int total = 0;
    // REP(i, min(X,Y)){
    //     total += min(A+B, 2*C);
    // }
    // Rep(i, min(X,Y), max(X,Y)){
    //     if(X>Y) total += min(A, 2*C);
    //     else total += min(B, 2*C);
    // }
    // pr(total);
    pr((A+B>2*C?2*C*min(X,Y):(A+B)*min(X,Y))+(X>Y?(A>2*C?2*C*(X-Y):A*(X-Y)):(B>2*C?2*C*(Y-X):B*(Y-X))));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
	int r, c, q;
	int a[50000];
	int b[50000];
	int o[50000];
	int row[50000];
	int col[50000];
	int nrow, ncol;

	long int out;

	while( cin >> r >> c >> q, (r||c||q))
	{
		memset( row, 0 , sizeof(row));
		memset( col, 0 , sizeof(col));
		nrow=0;
		ncol=0;
		out=0;

		for( int i = 0; i < q ; i++)
		{
			cin >> a[q-i-1] >> b[q-i-1] >> o[q-i-1];
		}

		for( int i = 0; i < q ; i++)
		{
			if( a[i] == 0)
			{
				if( row[b[i]] == 1)
				{
					continue;
				}
				else
				{
					row[b[i]] = 1;
					nrow++;

					if( o[i] == 1)
						out += c-ncol;
				}
			}
			else
			{
				if( col[b[i]] == 1)
				{
					continue;
				}
				else
				{
					col[b[i]] = 1;
					ncol++;

					if( o[i] == 1)
						out += r-nrow;
				}
			}
		}

		cout << out <<endl;
	}

	return 0;
}

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

int n;
char s[111][111];

int f(vector<int> u, vector<int> b){
    int h = 0;
    while(u.size()){
        int k = max_element(begin(b), end(b)) - begin(b);
        if(h + b[k] < 0) return -1;
        h += u[k];
        u.erase(u.begin() + k);
        b.erase(b.begin() + k);
    }
    return h;
}

string solve(){
    vector<int> up[2], bottom[2];
    rep(i,n){
        int h = 0, b = 0;
        for(char *p = s[i]; *p; ++p){
            if(*p == '(') ++h;
            else --h;
            b = min(b, h);
        }
        if(h >= 0){
            up[0].push_back(h);
            bottom[0].push_back(b);
        } else {
            up[1].push_back(-h);
            bottom[1].push_back(b-h);
        }
    }
    int a = f(up[0],bottom[0]), b = f(up[1],bottom[1]);
    return a == b && a != -1 ? "Yes" : "No";
}

int main(){
    while(cin >> n){
        rep(i,n) cin >> s[i];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
   int N;
   cin>>N;
   vector<int>P(N);
   vector<int>Q(N);

   vector<int>P2(N);
   vector<int>Q2(N);
   rep(i,N){
       cin>>P.at(i);
       P2.at(i)=P.at(i);
   };
   rep(i,N){
       cin>>Q.at(i);
       Q2.at(i)=Q.at(i);
   }
   sort(P2.begin(),P2.end());
   sort(Q2.begin(),Q2.end());
   int count_p=1;
   int count_q=1;
   int flag=0;
   do{
       for(int i=0;i<N;i++){
           if(P2.at(i)==P.at(i)){
           
           }else{
               flag=1;
           }
       }
       if(flag==1){
           count_p++;
           flag=0;
       }else{
           break;
       }
    }while(next_permutation(P2.begin(),P2.end()));

    do{
       for(int i=0;i<N;i++){
           if(Q2.at(i)==Q.at(i)){
           
           }else{
               flag=1;
           }
       }
       if(flag==1){
           count_q++;
           flag=0;
       }else{
           break;
       }
    }while(next_permutation(Q2.begin(),Q2.end()));
    
    cout<<abs(count_p-count_q)<<endl;


    

    return 0;
}

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

#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll ans;
	if (x<=6){ cout << 1 << endl; return 0; }
	ans = 2*((x-1)/11+1);
	if ((x%11 != 0) && (x%11 <=6)){ ans--; }
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair

int main(){
	ll n;
	cin >> n;
	ll a[12];
	a[0]=0;
	ll p=26;
	for(ll i=1;i<12;i++){
		a[i]=a[i-1]+p;
		p*=26;
	}
	ll memo;
	for(ll i=0;i<12;i++){
		if(a[i]<n&&a[i+1]>=n){
			memo=i+1;
		}
	}
	ll b[12];
	b[0]=1;
	for(ll i=1;i<=11;i++){
		b[i]=b[i-1]*26;
	}
	string c;
	n-=a[memo-1];
	n--;
	for(ll i=memo-1;i>=0;i--){
		char d=n/b[i]+'a';
		n=n%b[i];
		c=c+d;
	}
	cout << c << endl;
}


Measured memory_bytes: 3624
n=int(input())
s=1
f=0
x=[int(x) for x in input().split()]
if x.count(0)>0:
    print(0)
else:
    for i in range(len(x)):
        s=s*x[i]
        if s>10**18:
            f=1
            break
    if f:
        print(-1)
    else:print(s)

Measured memory_bytes: 84820
#include<stdio.h>
main(void)
{
int i,n,a[100],m=0,c=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]==1) c++;
else{
  if(c>m) m=c;
  c=0;
  }
  }
  if(a[n-1]==1){
  if(c>m) m=c;
}
  printf("%d\n",m+1);
  return 0;
}
  



Measured memory_bytes: 2760
# coding: utf-8
class Case01

  def initialize
  end

  def show
    p self.instance_variables
        .map{ |sym| [sym, self.instance_variable_get(sym)] }
        .to_h
  end
  
  # 実行する
  def execute
    read
    solve
    output
  end

  # 読込
  def read
    @s = gets.chomp
    @t = gets.chomp
  end

  # 回答
  def solve
    @result = 0
    1.upto(3) do |i|
      @result += 1 if @s[i-1] == @t[i-1]
    end
  end
  
  # 出力
  def output
    puts @result
  end

end

Case01.new.execute if $0 == __FILE__



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll A, B, C, X, Y;
int main() {
    cin >> A >> B >> C >> X >> Y;

    ll ans = INF;

    // AB を固定する
    ll limit = max(X * 2, Y * 2);
    for (int i = 0; i <= limit; i += 2) {
       ll cost = 0;  
       ll half = i / 2;

       // AB ピザ
       cost += i * C;

       // X 揃える (A ピザ)
       cost += max(X - half, 0LL) * A; 

       // Y 揃える (B ピザ)
       cost += max(Y - half, 0LL) * B; 

       ans = min(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
module e;

import std.conv, std.stdio;
import std.algorithm, std.array, std.string, std.range;

void main()
{
    auto
        buf = readln.chomp.split.to!(int[]);
    immutable
        xEatRed = buf[0], yEatGreen = buf[1],
        aHaveRed = buf[2], bHaveGreen = buf[3], cHaveTrans = buf[4];
    auto
        pRed = readln.chomp.split.to!(ulong[]),
        qGreen = readln.chomp.split.to!(ulong[]),
        rTrans = readln.chomp.split.to!(ulong[]);
    pRed.sort!"a>b";
    qGreen.sort!"a>b";
    rTrans.sort!"a>b";
    ulong answer = pRed[0..xEatRed].sum + qGreen[0..yEatGreen].sum;
    auto p = xEatRed - 1, q = yEatGreen - 1;
    foreach (trans; rTrans)
    {
        bool replaceRed()
        {
            if (pRed[p] < trans)
            {
                answer += trans - pRed[p];
                p -= 1;
                return false;
            }
            return true;
        }
        bool replaceGreen()
        {
            if (qGreen[q] < trans)
            {
                answer += trans - qGreen[q];
                q -= 1;
                return false;
            }
            return true;
        }
        if ((0 <= p) && (0 <= q))
        {
            if (pRed[p] < qGreen[q])
            {
                if (replaceRed) break;
            }
            else
            {
                if (replaceGreen) break;
            }
        }
        else if (0 <= p)
        {
            if (replaceRed) break;
        }
        else if (0 <= q)
        {
            if (replaceGreen) break;
        }
        else break;
    }
    answer.writeln;
}


Measured memory_bytes: 13000
// atcoder/abc167/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 998244353;

const int N = 4 * 1e5 + 5;

namespace math {
  lli fact[N], finv[N], inv[N];

  void init()
  {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < N; i++){
      fact[i] = fact[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  lli mod_comb(int n, int k)
  {
    assert(n < N && k < N);
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % mod) % mod;
  }

  lli extgcd(lli a, lli b, lli& x, lli& y)
  {
    lli g = a;
    x = 1;
    y = 0;
    if (b != 0) {
      g = extgcd(b, a % b, y, x);
      y -= (a / b) * x;
    }
    return g;
  }

  lli mod_inverse(lli a, lli m)
  {
    lli x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
  }
  // nHm=n+m-1Cm

  lli mod_pow(lli n, int p)
  {
    if (p == 0) return 1;
    if (p == 1) return n;
    lli m = mod_pow(n, p / 2);
    m *= m;
    m %= mod;
    if (p % 2) m = (m * n) % mod;
    return m;
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  math::init();

  int n;
  int m;
  int k;
  while (cin >> n >> m >> k) {
    const int K = 2 * 1e5;
    lli sum = 0;
    for (int i = n - 1 - k; i <= n - 1; ++i) {
      lli x = math::mod_comb(n - 1, i);
      lli y = m * math::mod_pow(m - 1, i);
      y %= mod;
      sum += (x * y) % mod;
      sum %= mod;
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 13020
import java.util.*;

public class Main {

	char[] key;
	char[] cipher;

	void run(){
		Scanner in = new Scanner(System.in);
		int T = in.nextInt();
		while(T-- > 0){
			key = in.next().toCharArray();
			cipher = in.next().toCharArray();
			System.out.println(solve());
		}
	}

	String solve(){
		int M = cipher.length;
		for(int i=key.length-1; i>=0; i--){
			char[] tmp = new char[M];
			if(key[i] == 'J'){
				for(int j=0; j<M; j++){
					tmp[j] = cipher[(j+M-1)%M];
				}
			}
			else if(key[i] == 'C'){
				for(int j=0; j<M; j++){
					tmp[j] = cipher[(j+1)%M];
				}
			}
			else if(key[i] == 'E'){
				tmp = cipher.clone();
				for(int j=0; j<M>>1; j++){
					char t = tmp[j];
					tmp[j] = tmp[j+(M+1)/2];
					tmp[j+(M+1)/2] = t;
				}
			}
			else if(key[i] == 'A'){
				for(int j=0; j<M; j++){
					tmp[j] = cipher[M-j-1];
				}
			}
			else if(key[i] == 'P'){
				for(int j=0; j<M; j++){
					if(Character.isDigit(cipher[j])){
						tmp[j] = (char) ((cipher[j] - '0' + 9)%10 + '0');
					}
					else{
						tmp[j] = cipher[j];
					}
				}
			}
			else if(key[i] == 'M'){
				for(int j=0; j<M; j++){
					if(Character.isDigit(cipher[j])){
						tmp[j] = (char) ((cipher[j] - '0' + 1)%10 + '0');
					}
					else{
						tmp[j] = cipher[j];
					}
				}
			}
			cipher = tmp.clone();
		}
		return String.valueOf(cipher);
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll par[100010];
ll ran[100010];
ll n,m,x[114514],y[114514],z[114514];
ll root(ll x) {
	return par[x] == x ? x : par[x] = root(par[x]);
}
bool same(ll x, ll y) {
	return root(x) == root(y);
}
void unite(ll x, ll y) {
	x = root(x);
	y = root(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (ran[x] == ran[y])ran[x]++;
	}
}
int main() {
	cin>>n>>m;
	for (int i = 0; i < n; i++) par[i] = i;
	for(int i=0;i<m;i++){
		cin>>x[i]>>y[i]>>z[i];
		x[i]--;y[i]--;
		unite(x[i],y[i]);
	}
	map<ll,ll>mp;
	for(int i=0;i<n;i++)mp[root(i)]++;
	cout<<mp.size()<<endl;
	return 0;
}

Measured memory_bytes: 10496
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	char s[10];
	chin(s);
	if(s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3])puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector <ll> a(n);
    rep(i,n){
        cin >> a[i];
    }

    sort(a.begin(),a.end());
    ll s=0,ans=-1;

    rep(i,n-1){
        s+=a[i];
        if(2*s<a[i+1]){
            ans=i;
        }
    }

    cout << n-ans-1 << endl;

    

    return 0;
}

Measured memory_bytes: 1024
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

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

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

string str[100005];
ll cost[3];
vector < char > vec;

bool solve(ll n)
{
	vec.clear();

	for(ll i = 1; i <= n; i++)
	{
		ll u = str[i].front() - 'A';
		ll v = str[i].back() - 'A';

		if(cost[u] == 0 && cost[v] == 0) return 0;

		if(i == n)
		{
			if(cost[v]) vec.push_back(u + 'A');
			else vec.push_back(v + 'A');

			break;
		}

		ll nu = str[i + 1].front() - 'A';
		ll nv = str[i + 1].back() - 'A';

		if(str[i] == str[i + 1])
		{
			if(cost[u] < cost[v]) vec.push_back(u + 'A'), cost[u]++, cost[v]--;
			else vec.push_back(v + 'A'), cost[u]--, cost[v]++;
		}
		else
		{
//			cout << u << " " << v << " " << nu << " " << nv << endl;
			if(v == nu || v == nv)
			{
				if(cost[u]) vec.push_back(v + 'A'), cost[v]++,cost[u]--;
				else vec.push_back(u + 'A'), cost[u]++,cost[v]--;
			}
			else
			{
				if(cost[v]) vec.push_back(u + 'A'), cost[u]++,cost[v]--;
				else vec.push_back(v + 'A'), cost[v]++,cost[u]--;
			}
		}
	}

	return 1;
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n)
    {
		cin >> cost[0] >> cost[1] >> cost[2];

		for(i = 1; i <= n; i++) cin >> str[i];

		if(solve(n) == 0) printf("No\n");
		else
		{
			printf("Yes\n");

			for(auto it: vec) cout << it << "\n";
		}
    }


}





Measured memory_bytes: 6848
#include <stdio.h>
int main (void)
{
    char s[15] ={'\0'};
    char d[15] = {'\0'};
    int len = 0;
    int i;
    int j=0;
    scanf("%s",s);
    while(s[len]){
        len++;
    }   
    for(i=0;i<len;i++){
        if(s[i] =='0' || s[i] == '1'){
            d[j] = s[i];
            j++;
        }
        else if(s[i] =='B'){
            if(j > 0){
                j--;
            }
        }
    }
    d[j] = '\0';
    printf("%s",d);
    return 0;
}

Measured memory_bytes: 128