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

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

int gcd(int a, int b){
    if(a < b) swap(a,b);
    return((a%b == 0 ? b : gcd(b,a%b)));
}

bool divide(int a, int b){
    if( b > a) swap(a,b);
    if(a % b == 0) return true;
    return false;
}

int main(){
    int K;
    cin>>K;
    ll ans = 0;

    for(int a=1; a<=K; a++){
        for(int b=1; b<=K; b++){
            for(int c=1; c<=K; c++){
                if(a == 1 || b == 1 || c == 1){
                    ans += 1;
                    continue;
                }
                
                else {
                    int tmp;
                    tmp = gcd(a,b);
                    tmp = gcd(tmp,c);
                    ans += tmp;
                }                
            }
        }
    }

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

Measured memory_bytes: 3636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

M, D = MAP()
ans = 0
for m in range(1, M+1):
	for d in range(1, D+1):
		if len(str(d)) == 2:
			d1 = int(str(d)[1])
			d10 = int(str(d)[0])
			if 2 <= d1 and 2 <= d10 and d1*d10 == m:
				ans += 1
print(ans)



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

#define int long long

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

int X, A, B;

signed main() {
    cin >> X >> A >> B;
    cout << (X - A) % B << endl;
    return 0;
}


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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	LL n;
	cin>>n;
	VL arr(n);
	rep(i,0,n){
		cin>>arr[i];
	}
	LL ans = 0;
	rep(i,1,n){
		LL diff = arr[i-1] - arr[i];
		if(diff > 0){
			ans += diff;
			arr[i] = arr[i-1];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4808
/* ex3_2
	kanon */
 
#include <stdio.h>


int main(void) {

  //与えられる値を入れる変数を宣言
  int N;
  
  //変数に値を入力する
  scanf("%d", &N);

  //Nの１の位の値で分岐させる
  if(N%10==3){
      printf("bon\n");
  }else if(N%10==0||N%10==1||N%10==6||N%10==8){
      printf("pon\n");
  }else{
      printf("hon\n");
  }

  return 0;
}


Measured memory_bytes: 1644
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 5100;
const ll MOD = 1e9 + 7;

vector<int> eds[MAXN];
int was[MAXN];

int n;
ll gg[MAXN];

vector<ll> dfs1(int v) {
	was[v] = 1;
	vector<ll> vv = {0, 1};
	for (int u: eds[v]) {
		if (was[u])
			continue;
		auto tmp = dfs1(u);
		vector<ll> vv2(vv.size() + tmp.size() - 1);
		for (int i = 0; i < tmp.size(); ++i)
			for (int j = 0; j < vv.size(); ++j)
				vv2[i + j] = (vv2[i + j] + tmp[i] * vv[j]) % MOD;
		vv = vv2;
	}
	for (int i = 2; i < vv.size(); i += 2)
		vv[0] = (vv[0] - gg[i / 2] * vv[i] % MOD + MOD) % MOD;
	return vv;
}

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		eds[a].push_back(b);
		eds[b].push_back(a);
	}
	gg[0] = 1;
	for (int i = 1; i <= n / 2; ++i) {
		gg[i] = (2 * i - 1) * gg[i - 1] % MOD;
	}
	auto ans = dfs1(0);
	cout << (MOD - ans[0]) % MOD << "\n";
	return 0;
}




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

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> xy[n];
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            xy[i].push_back({x - 1, y});
        }
    }

    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        bool h[n];
        rep(i, n) {
            if (bit & (1 << i))
                h[i] = 1;
            else
                h[i] = 0;
        }

        bool ok = true;
        rep(i, n) {
            if (h[i] == 0) continue;
            for (auto e : xy[i]) {
                if (h[e.first] != e.second) ok = false;
            }
        }

        if (ok) ans = max(ans, __builtin_popcount(bit));
    }

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


Measured memory_bytes: 3608
def isPalindrome(n):
  n = str(n)
  for i in range(len(n)//2 + 1):
    if n[i] != n[-(i+1)]:
      return False
  return True

A, B = map(int, input().split())

count = 0
for i in range(A, B+1):
  if isPalindrome(i):
    count += 1

print(count)

Measured memory_bytes: 3060
import collections
import math

n = int(input())
s = list(input() for i in range(n))

for i in range(n):
    new_str_list = sorted(list(s[i]))
    new_str = ''.join(new_str_list)
    s[i] = new_str

c = collections.Counter(s)
cl = list(c.values())
cl = [i for i in cl if i >= 2]
ans = 0
for j in cl:
    ans = ans + math.factorial(j) // (math.factorial(j - 2) * math.factorial(2))

print(ans)



Measured memory_bytes: 19836
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i<=100;i++){
			for(int j=0;j<=100;j++){
				int ashi = i * 2 + j * 4;
				int body = i + j;
				if(X == body && Y == ashi){
					Console.WriteLine("Yes");
					return;
				}
			}
		}
		
		Console.WriteLine("No");
		
		
	}
	int X,Y;
	public Sol(){
		var d = ria();
		X = d[0]; Y = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
string to_str(ll x){string res; while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return res;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n); rep(i,0,n)scanf("%d",&a[i]);
    int ans=0,val=1;
    rep(i,0,n)if(a[i]==val)ans++,val++;
    if(ans==0){printf("-1\n"); return 0;}
    printf("%d\n",n-ans);
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

#define SWAP(x, y) ((x) += (y), (y) = (x) - (y), (x) -= (y))
#define LEFT(x) (2 * x)
#define RIGHT(x) (2 * x + 1)

int heap_size;

void maxHeapify(int *a, int i){
  int l = LEFT(i), r = RIGHT(i), largest;
  if(l <= heap_size && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= heap_size && a[r] > a[largest]) largest = r;
  if(largest != i){
    SWAP(a[i], a[largest]);
    maxHeapify(a, largest);
  }
  return;
}

int main(){
  int a[500005], i;

  scanf("%d", &heap_size);
  for(i = 1; i <= heap_size; ++i) scanf("%d", a + i);

  for(i = heap_size / 2; i > 0; --i) maxHeapify(a, i);

  for(i = 1; i <= heap_size; ++i) printf(" %d", *(a + i));
  puts("");
  return 0;
}

Measured memory_bytes: 2556
def weather_gen():
    while 1:
        yield "Sunny"
        yield "Cloudy"
        yield "Rainy"


def main():
    s = input()
    
    weather = weather_gen()
    
    for _ in range(3):
        if s == next(weather):
            print(next(weather))
            break
            

if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  vector <int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    x -= a[i];
    if (x >= 0)
      ++ret;
    else
      break;
  }
  if (x > 0)
    ret--;
  printf("%d", ret);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int h,w;
string s[60];
int dx[] = {0,1,1,1,0,-1,-1,-1}, dy[] = {1,1,0,-1,-1,-1,0,1};
vector<vector<int>> v(60, vector<int>(60, -1));
int search(int i ,int j){
    int cnt = 0;
    for(int k = 0; k < 8 ; k ++){
        int nx = i + dx[k] , ny = j + dy[k];
        if(nx >= 0 && nx < h && ny >= 0 && ny < w){
            if(s[nx][ny] == '#') cnt++;
        }
    }
    if(i==1 && j==2) cout << endl;
    return cnt;
}
int main(){
    cout << fixed << setprecision(10);
    cin >> h >> w;
    rep(i,h)cin >> s[i];
    rep(i,h){
        rep(j,w){
            if(s[i][j] == '.') {
                v[i][j] = search(i,j);
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(v[i][j] == -1) cout << "#";
            else cout << v[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    int a, p;
    cin >> a >> p;
    cout << (a*3+p)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;
 
int main(){
  ll N,D; cin>>N>>D;
  vector<ll> X(N),Y(N);
  REP(i,N) cin>>X[i]>>Y[i];
  
  int ans = 0;
  REP(i,N) if(sqrt(X[i]*X[i]+Y[i]*Y[i]) <= D) ans++;
  cout<<ans;
}

Measured memory_bytes: 6424
#pragma GCC optimize("Ofast")

#include <algorithm>      //sort,二分探索,など
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <iterator>       //集合演算(積集合,和集合,差集合など)
#include <map>            //map(辞書)
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;

class Card{
    public:
        Card(): suit(0), number(0){};
        ~Card(){};
        char suit;
        int number;
        friend ostream& operator<<(ostream& os, const Card& card){
            os << card.suit << card.number;
            return os;
        }
        bool operator!=(const Card& card){
            if(this->suit == card.suit){
                if(this->number == card.number){
                    return false;
                }
            }
            return true;
        }
};

int bubble_sort(Card A[], int N) {
    int count = 0;
	for (int i = 1; i < N; ++i) {
		bool flag = true;
		while (flag) {
            flag = false;
			for (int j = N - 1; j > 0; --j) {
				Card tmp = A[j - 1];
				if (A[j].number < tmp.number) {
					A[j - 1] = A[j];
					A[j] = tmp;
					flag = true;
                    ++count;
				}
			}
		}
	}
    return count;
}

int selection_sort(Card A[], int N) {
    int count = 0;
	for (int i = 0; i < N; ++i) {
		int minj = i;
        for(int j = i; j < N; ++j){
            if(A[j].number < A[minj].number){
                minj = j;
            }
        }
        if(i != minj){
            swap(A[i], A[minj]);
            ++count;
        }
	}
    return count;
}

// バブルソート(安定)の配列と比較して違いがあれば安定でない
bool is_stable(Card B[], Card S[], int N){
    for(int i = 0; i < N; ++i){
        if(B[i] != S[i]) return false;
    }
    return true;
}

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

    Card B[100];
    Card S[100];
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> B[i].suit >> B[i].number;
        S[i] = B[i];
	}

	bubble_sort(B, N);
    for(int i = 0; i < N; ++i){
        if(i != 0) cout << " ";
        cout << B[i];
    }
    cout << "\nStable\n";
	selection_sort(S, N);
    for(int i = 0; i < N; ++i){
        if(i != 0) cout << " ";
        cout << S[i];
    }
    cout << "\n";
    if(is_stable(B, S, N)){
        cout << "Stable\n";
    }else{
        cout << "Not stable\n";
    }
	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long a=100;
   long long x;
  	cin >> x;
  	int i=0;
  	 
  	while(a<x){
    	a += a/100;
      	
      	i++;
     
    }
  	cout << i << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int num_row, num_col,i,j,count=0;
    bool is=false;
    string input;
    string tmp,tmp2;
    vector<string> matrix;
    vector<string> tmp_matrix;
    vector<string> out_matrix;
    //vector<string> row;

    //take inputs
    cin>>num_row>>num_col;
    for(i=0; i<num_row; i++)
    {
        cin>>input;
        //row.push_back(input);

        matrix.push_back(input);
    }

    count =0;
    //remove column
    for(i=0; i<num_col; i++)
    {
        for(j=0; j<num_row; j++)
        {
            //cout<<"tmpppp "<<tmp<<endl;

            tmp = matrix[j][i];
            if(tmp == ".")
            {
                count++;
                //cout<<"heeeere"<<endl;
            }
        }
        //cout<<"count "<<count<<endl;
        //cout<<"num_row "<<num_row<<endl;
        if(count == num_row)
        {
            is=true;
    //            //cout<<"i "<<i<<endl;
            for(j=0; j<num_row;j++)
            {
                tmp2= matrix.at(j);
                //cout<<"tmp2 "<<tmp2<<endl;
                tmp2.erase(tmp2.begin()+i);
                //cout<<"tmp2 erased "<<tmp2<<endl;

                out_matrix.push_back(tmp2);
                //tmp.erase(matrix[j].begin()+i);
            }
            matrix.clear();
            for(j=0; j<num_row;j++)
            {
                matrix.push_back(out_matrix[j]);
            }
            out_matrix.clear();

            num_col--;
            i--;
        }
        count =0;
    }

        for(j=0; j<num_row; j++)
        {
            out_matrix.push_back(matrix[j]);
        }

    //remove row
    for(i=0; i<num_row; i++)
    {
        count=0;
        tmp = out_matrix[i];
        for(j=0; j<num_col; j++)
        {
            if(tmp[j] == '.')
                count++;
            else
                break;
        }
        if(count == num_col)
        {
            out_matrix.erase(out_matrix.begin()+i);
            num_row--;
            i--;
        }
    }

    //print outputs
    for(i=0; i<num_row; i++)
    {
        for(j=0; j<num_col; j++)
        {
            cout<<out_matrix[i][j];
        }
        cout<<endl;
    }

    return 0;
}


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


//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using vi = vector<int>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Time()	cerr <<'\n' << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define SZ(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define fo(i,k,n) for(ll (i)=(k);(i)<(n);(i)++) 
#define ar array
// no change 

const ll MOD = 1e9+7;   // it is an prime...

template<typename T,typename L>
T power(T a, L b);				// to find reverse modulo its power(a,MOD-2);
template < typename T ,typename L> 
L coefficient(T n, T k);  // computing nCk

//const int MxN = 1e9+5;



void solve(){
	char A;
	cin >> A;
	if(A >='A' && A<='Z'){
		cout << "A";
	}
	else cout << "a";







}
int main() {	
	FASTER;
	int T = 1;
	//cin >> T;		//cmt if one test case
	while(T--)solve();
}


template<typename T,typename L>
T power(T a, L b){
	
	T result = 1;
	while(b){
		if(b&1) result = (result% MOD * a%MOD) % MOD;
	   	a = (a%MOD * a%MOD) % MOD;
   		b/=2;	   
	}
	return result;
}

template < typename T ,typename L> 
L coefficient(T n, T k){  // computing nCk
	k = min(k,(n-k));
	L res = 1;
	for(T i = 0; i< k;i++){
		res *= (n-i);
		res /= (i+1);

	}
	return res;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int x;
    cin>>x;
    bool f=0;
    for(int i=-3000;i<=3000;i++){
        for(int j=-3000;j<=3000;j++)
        {
            if((i*i*i*i*i - j*j*j*j*j) == x)
            {
                f=1;
                cout<<i<<" "<<j<<endl;
                break;
            }
        }
        if(f)
            break;
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int A,B;cin>>A>>B;
    for(int i=0;i<=10000;++i){
        if(static_cast<int>(i*0.08)==A
        &&static_cast<int>(i*0.1)==B){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class T>
inline void out(T a) {
	cout<<a<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
string S;

void input() {
	cin>>S;
	N=S.len;
}

void solve() {
	for(int l=0; l<=7; l++) {
		string T=S;
		T.erase(l,N-7);
		if(T=="keyence") {
			cout<<"YES"<<endl;
			return;
		}
	}
	cout<<"NO"<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3664
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    N = int(input())  # 文字列または整数(一変数)
    answer = 0

    if N == 1:
        print(0)
        return

    ll = factorization(N)

    for l in ll:
        e = 1
        rest_e = l[1]
        while True:
            if rest_e >= e:
                answer += 1
                rest_e -= e
                e += 1
            else:
                break


    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 63452
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	private static final double ANGLE = Math.PI / 180;

	public static void main(String[] args) {
		//?????°?¨????
		double go = 0; //???????????¢????´???¨
		double angle = 0; //?????¢???????§????????´???¨
		double x = 0; //??????????????±??????????????¢
		double y = 0; //?????????????????????????????¢

		while(sc.hasNext()) {
			//?????????????????????","??§?????????????????????????????\??????
			String[] str = sc.next().split(",");

			if(str[0].equals("0") && str[1].equals("0")) { //0,0?????¨???
				break;
			}

			//??´??°????????????
			go = Double.parseDouble(str[0]);

			x += go * Math.sin(angle * ANGLE);
			y += go * Math.cos(angle * ANGLE);

			angle += Double.parseDouble(str[1]);
		}

		System.out.println((int)x);
		System.out.println((int)y);

	}

}

Measured memory_bytes: 25812
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  map<char, bool> museisi;
  string hoge = "ksthp";

  REP(i,5)
    museisi[hoge[i]] = 1;
  hoge = "aiueo";
  map<char, bool> boin;
  REP(i,5)
    boin[hoge[i]] = 1;
  
  string s;
  while(cin>>s,s!="#") {

    vector<bool> musei(s.size());
    bool f = 0;
    REP(i,s.size()-1) {
      if (boin[s[i]] && !musei[i])
        f = 0;
      if (museisi[s[i]]) {
        if (s[i+1] == 'i' || s[i+1] == 'u') {
          if (i==s.size()-2 || museisi[s[i+2]]) {
            if (!f) {
              musei[i+1] = 1;
            f = 1;
            }
          }
        }if (s[i+1] == 'y') {
          if (i<s.size()-2 && (s[i+2] == 'i' || s[i+2] == 'u')) {
            if (i==s.size()-3 || museisi[s[i+3]]) {
              if (!f) {
                musei[i+2] = 1;
                f = 1;
              }
            }
          } else if( i<s.size()-2 && s[i+2] == 'a' || s[i+2] == 'o') {
            char c = s[i+2];
            if (i<s.size()-4 && museisi[s[i+3]] && s[i+4] == c || i<s.size()-5 && museisi[s[i+3]] && s[i+4] == 'y' && s[i+5] == c) {
              if (!f) {
                musei[i+2] = 1;
                f = 1;
              }
            }
          }
        } else if(s[i+1] == 'a' || s[i+1] == 'o') {
            char c = s[i+1];
          if (i<s.size()-3 && museisi[s[i+2]] && s[i+3] == c || i<s.size()-4 && museisi[s[i+2]] && s[i+3] == 'y' && s[i+4] == c) {
            if (!f) {
              musei[i+1] = 1;
              f = 1;
            }
          }
        }
      }
    }
    REP(i,s.size()) {
      if (musei[i])
        cout << "(" << s[i] << ")";
      else
        cout << s[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
#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>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    ll N, K;
    cin >> N >> K;
    N %= K;
    cout << min(N, K - N) << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
const int N = 1005;
int main()
{
    int n, i;
    int a[N]={0};
    scanf("%d", &n);
    
    for(i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    for(i = n-1; i >= 0; i--)
    {
        if(i)
        {
            printf("%d ", a[i]);
        }
        else
        {
            printf("%d\n", a[i]);
        }
        
    }
    

  return 0;
}



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

#define MAX_N 100005

int n ,m;
int a ,b;
vector <int> adj[MAX_N];

int dp[MAX_N] ,dp2[MAX_N];
void pre(int u){
    dp[u] = 1;
    for(int&v : adj[u]){
        adj[v].erase(find(adj[v].begin() ,adj[v].end() ,u));
        pre(v);
        dp[u] = 1LL*dp[u]*(dp[v]+1)%m;
    }
}
void dfs(int u ,int up=1){
    dp2[u] = 1LL*dp[u]*up%m;
    if(adj[u].empty())
        return;
    vector <int> pref(adj[u].size() ,1) ,suff(adj[u].size() ,1);
    for(int i=1; i<adj[u].size(); i++)
        pref[i] = 1LL*pref[i-1]*(dp[adj[u][i-1]]+1)%m;
    for(int i=adj[u].size()-2; ~i; i--)
        suff[i] = 1LL*suff[i+1]*(dp[adj[u][i+1]]+1)%m;
    for(int i=0; i<adj[u].size(); i++)
        dfs(adj[u][i] ,(1LL*up*pref[i]%m*suff[i]+1)%m);
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1; i<n; i++){
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    pre(1) ,dfs(1);
    for(int i=1; i<=n; i++)
        printf("%d\n",dp2[i]);
}


Measured memory_bytes: 17664
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = input()
    res = 0
    for c in n:
        if c=='2':
            res += 1;
    print(res)
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}


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

int main(){
  int i;
  char s[256];

  scanf("%s",s);

  for(i=0; i<=2; i++){
    if(s[i]=='1'){
      s[i]='9';
    }else if(s[i]=='9'){
      s[i]='1';
    }
  }
  printf("%s\n",s);

  return 0;
}


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

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

	int counter_a = 0;
	int counter_b = 0;

	for (int i = 0; i < 3; ++i) {
		if ('A' == s[i]) {
			counter_a++;
		}
		else if ('B' == s[i]) {
			counter_b++;
		}
	}

	if (counter_a != 0 && counter_b != 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;}
using Int = long long;
const char newl = '\n';


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;

  using ll = long long;
  vector<ll> as(n),bs(n);
  for(int i=0;i<n;i++) cin>>as[i]>>bs[i];

  int zero=0;

  using P = pair<ll, ll>;
  map<P, array<int, 4>> mp;

  auto pos=[](ll a,ll b){
    if(b>=0 and a>0) return 0;
    if(a<=0 and b>0) return 1;
    if(b<=0 and a<0) return 2;
    if(a>=0 and b<0) return 3;
    abort();
  };

  auto norm=[&](ll a,ll b){
    ll g=gcd(abs(a),abs(b));
    a/=g;
    b/=g;
    while(pos(a,b)){
      ll na=-b;
      ll nb=+a;
      a=na;
      b=nb;
    }
    return P(a,b);
  };

  for(int i=0;i<n;i++){
    if(as[i]==0 and bs[i]==0){
      zero++;
      continue;
    }
    mp[norm(as[i],bs[i])][pos(as[i],bs[i])]++;
  }

  using M = Mint<int>;
  vector<M> po(n+1,0);
  for(int i=0;i<n;i++)
    po[i+1]=po[i]*2+M(1);

  M ans(1);
  for(auto p:mp){
    auto vs=p.second;
    M res(1);
    res+=po[vs[0]];
    res+=po[vs[1]];
    res+=po[vs[2]];
    res+=po[vs[3]];
    res+=po[vs[0]]*po[vs[2]];
    res+=po[vs[1]]*po[vs[3]];
    ans*=res;
  }

  ans+=M(zero);
  ans-=M(1);
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 22656
N = int(input())
A = list(map(int,input().rstrip().split(" ")))
yuyo = [0] * (N + 1)
nokori = [0] * (N + 2)
A.append(0)
nokori[N + 1] = 0
ans = 0
for i in range(N,-1,-1):
    nokori[i] = nokori[i + 1] + A[i + 1]
ans = 0
if A[0] != 0:
    if A[0] == 1 and N == 0:
        ans = 1
    else:
        ans = -1
else:
    yuyo[0] = 1
    for i in range(1,N + 1):
        yuyo[i] = min(yuyo[i - 1] * 2 - A[i],nokori[i])
        if yuyo[i] < 0:
            ans = -1
            break
if ans == -1:
    print(-1)
else:
    for i in range(N):
        ans += yuyo[i]
    ans += nokori[0]
    print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h.at(i);
    }
    vector<int> cost(n);
    cost.at(0) = 0, cost.at(1) = abs(h.at(0) - h.at(1));
    for (int j = 2; j < n; ++j) {
        cost.at(j) = min(cost.at(j - 1) + abs(h.at(j) - h.at(j - 1)),
                cost.at(j - 2) + abs(h.at(j) - h.at(j - 2)));
    }
    cout << cost.at(n - 1) << endl;
}


Measured memory_bytes: 1024
import scala.io.StdIn.{readLine, readInt}
import scala.collection.mutable.ArrayBuffer

object Main {
  def cross(x0:Double, y0:Double, x1:Double, y1:Double) = x0*y1-x1*y0
  def inner(x0:Double, y0:Double, x1:Double, y1:Double) = x0*x1+y1*y0
  def norm(x:Double, y:Double) = Math.pow(x,2)+Math.pow(y,2)

  def main(args:Array[String]) = {
   val b = new ArrayBuffer[String]
   val p = readLine.split(" ").map(_.toDouble)
   val n = readInt

   val (x0,y0,x1,y1) = (p(0),p(1),p(2),p(3))
   val (x,y) = (x1-x0,y1-y0)

   for(i<-0 until n) {
     val p1 = readLine.split(" ").map(_.toDouble)
     val (x2,y2) = (p1(0)-x0, p1(1)-y0)
     if(cross(x,y,x2,y2) > (1e-10)) b += "COUNTER_CLOCKWISE"
     else if(cross(x,y,x2,y2) < -(1e-10)) b += "CLOCKWISE"
     else if(inner(x,y,x2,y2) < -(1e-10)) b += "ONLINE_BACK"
     else if(norm(x,y) < norm(x2,y2)) b += "ONLINE_FRONT"
     else b += "ON_SEGMENT"
   }
   println(b.mkString("\n"))
  }
}

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

int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	string S,T;
	// 出入力
	cin >> S >> T;
	cout << T+S << "\n";
    return 0;


}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(A);
	READV(B);
	cout<<max(A-2*B,0LL)<<endl;

	return 0;
}

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

int compare_int(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int main(){

	int i, N, *p, *p_ans, count, tmp, tmp_1, tmp_2, flag=0, swap;




	scanf("%d", &N);

	p = (int*)malloc(N * sizeof(int));

	p_ans = (int*)malloc(N * sizeof(int));

	for (i = 0; i < N; i++){
		scanf("%d", &p[i]);
		p_ans[i] = p[i];
	}

	qsort(p_ans, N, sizeof(int), compare_int);



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

		if ((p[i] != p_ans[i]) && flag==0){
			tmp_1 = i;
			flag = 1;
			continue;
		}
		if ((p[i] != p_ans[i]) && flag == 1){
			tmp_2 = i;
			flag++;
		}
	}
	if (flag == 2){
		swap = p[tmp_1];
		p[tmp_1] = p[tmp_2];
		p[tmp_2] = swap;
	}
	for (i = 0; i < N; i++){

		if (p[i] != p_ans[i]){
			printf("NO\n");
			return 0;
		}

	}
	printf("YES\n");
	return 0;

}
    


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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

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

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

const int MAXN = 1e5 + 5;

int fakt[2 * MAXN], inv[2 * MAXN];

int pot(int b, int p){
  if(p % 2){
    return mul(pot(b, p - 1), b);
  }
  else{
    if(p == 0) return 1;
    int tmp = pot(b, p / 2);
    return mul(tmp, tmp);
  }
}

int povrh(int n, int k){
  return mul(fakt[n], pot( mul(fakt[k], fakt[n - k]), mod - 2) );
}

int n, k, a[MAXN];

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

  fakt[0] = 1;
  inv[0] = pot(fakt[0], mod - 2);
  FOR(i, 1, 2 * MAXN){
    fakt[i] = mul(fakt[i - 1], i);
    inv[i] = pot(fakt[i], mod - 2);
  }

  cin >> n >> k;
  REP(i, n){
    cin >> a[i];
  }

  sort(a, a + n);
  int sol = 0;
  REP(i, n){
    // min
    int bigger = n - i - 1;
    if(bigger >= k - 1){
      sol = sub(sol, mul( add(a[i], mod), povrh(bigger, k - 1)));
    }
    // max
    int smaller = i;
    if(smaller >= k - 1)
      sol = add(sol, mul( add(a[i], mod), povrh(smaller, k - 1)));
  }
  cout << sol;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, 3){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const ll mod = 1e9 + 7;
const int n_max = 3030303;

ll fac[n_max];  /// fac[n] = n!
ll finv[n_max]; /// (fac[n] * finv[n]) % MOD = 1
ll inv[n_max];  /// (n * inv[n]) % MOD = 1

void init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, n_max)
    {
        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 nCk(int n, int k)
{
    if (n < k || k < 0 || n < 0)
        return 0;
    return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

int main()
{

    ll X, Y;
    cin >> X >> Y;

    if ((X+Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    init();
    int n = (-X+2*Y)/3;
    int m = ( 2*X-Y)/3;

    if (n < 0 or m < 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << nCk(n+m, n) << endl;
    return 0;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    string s;
    cin>>s;
    int win=0;
    f1(i,0,s.size())
    {
        if(s[i]=='o')
            win++;
    }
    win+=15-s.size();
    if(win>=8)
    {
        cout<<"YES";
    }
    else
        cout<<"NO";
    return 0;
}

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

int n, m, x[100010], d[100010], s;

int main(){
	cin >> n >> m;
	for (int i = 0; i < m; ++i) cin >> x[i];
	if (n >= m){
		cout << 0;
		return 0;
	}
	sort(x, x+m);
	s = 0;
	for (int i = 0; i < m-1; ++i){
		d[i] = x[i+1] - x[i];
		s += d[i];
	}
	sort(d, d+m-1, greater<int>());
	for (int i = 0; i < n-1; ++i){
		s -= d[i];
	}
	cout << s;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<tr1/unordered_map>
using namespace std;
typedef long long ll;
tr1::unordered_map<ll,ll> dp;
int n,a[25];
ll hs(int l,int r,int x,int y){
	return l+100ll*r+10000ll*x+1000000000000ll*y;
}
ll solve(int l,int r,int x,int y){
	if (l+1==r) return 0;
	if (dp[hs(l,r,x,y)]) return dp[hs(l,r,x,y)];
	ll ans=1e18;
	for (int i=l+1;i<=r-1;i++) ans=min(ans,1ll*(x+y)*a[i]+solve(l,i,x,x+y)+solve(i,r,x+y,y));
	return dp[hs(l,r,x,y)]=ans;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	printf("%lld\n",a[1]+a[n]+solve(1,n,1,1));
	return 0;
} 


Measured memory_bytes: 16328
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
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 main(){
  ll n ; cin>> n ;
  string t ; cin>> t ;
  vector<ll> s(n) ;
  rep(i,n){
    if(t[i]=='o') s[i]=1 ;
    else s[i]=0 ;
  }
  int ans[n] ;
  bool ok=1 ;
  bool ko=0 ;
  rep(i,2){
    if(ko) break ;
    ans[0]=i ;
    rep(j,2){
      ans[1]=j ;
      int ss= s[0] ;
      ans[2]= (abs(i+j-ss))%2 ;
      int now=3 ;
      int mow=1 ;
      rep(ww,n-3){
        int qq= s[mow] ;
        ans[now]=(abs(ans[now-1]+ans[now-2]-qq))%2 ;
        now++ ;
        mow++ ;
      }

      if((s[n-2]==(ans[0]+ans[n-2]+ans[n-1])%2)&&
          (s[n-1]==(ans[0]+ans[1]+ans[n-1])%2)){
            ok=0 ;
            ko=1 ;
            break ;
          }
    }
  }

  if(ok) cout<<-1<<endl ;
  else{
    rep(i,n-1){
     if(ans[i+1]==1)  cout<<'S' ;
     else cout<< 'W' ;
    }
    if(ans[0]==1) cout<<'S'<<endl ;
    else cout<<'W'<<endl ;
  }
   return 0 ;
 }



Measured memory_bytes: 4576
# 626~
# 解法700 DPを使う
# dp[i][l] : iまで選択して，i+1ばん目に出した手がlである場合の最大ポイント
# 計算量はO(N*3)になるので問題なし
# dpの更新式 dp[i+k][0] = (dp[i][1]+(R[1],0),dp[i][2]+(R[2],0))

N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
rsp = ['r','s','p']


def janken(my_s,op_s):
    if my_s == 'r' and op_s=='s':
        return R
    if my_s == 's' and op_s=='p':
        return S
    if my_s == 'p' and op_s=='r':
        return P
    return 0


dp = [[0,0,0] for _ in range(N+1)]
# 0: R 1: P 2:Sを出す
for n in range(K):
    dp[n] = [janken(rsp[i],T[n]) for i in range(3)]

for i in range(N-K):
    dp[i+K][0] = max(dp[i][1]+janken(rsp[0],T[i+K]), dp[i][2]+janken(rsp[0],T[i+K]))
    dp[i+K][1] = max(dp[i][2]+janken(rsp[1],T[i+K]), dp[i][0]+janken(rsp[1],T[i+K]))
    dp[i+K][2] = max(dp[i][0]+janken(rsp[2],T[i+K]), dp[i][1]+janken(rsp[2],T[i+K]))
ans = 0
for i in range(K):
    ans += max(dp[N-1-i])
print(ans)


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n, 0);
    vector<int> b(n, 0);
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        a[i] = t;
        b[i] = t;
    }
    sort(b.begin(), b.end());
    int x = n / 2 - 1;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= b[x]) {
            cout << b[x+1] << endl;
        } else {
            cout << b[x] << endl;
        }
    }
}


Measured memory_bytes: 3840
from sys import stdin
import math
import fractions
from collections import deque
import itertools
import bisect

INF = 10 ** 10

MODN = 1000000007

# N段の階段
# a段目の床は壊れている
N, M = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(stdin.readline().rstrip()) for _ in range(M)]

# N段目まで行く総数
dp =[0] * (N+10)

for ai in a:
    dp[ai] = -1 

dp[0] = 1

for i in range(N+1):
    if dp[i] == -1:
        continue

    one_step = i + 1
    two_step = i + 2

    if dp[one_step] != -1:
        dp[one_step] += dp[i]
        
    if dp[two_step] != -1:
        dp[two_step] += dp[i]

print(dp[N] % MODN)

Measured memory_bytes: 475236