akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.Deque;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ab = br.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        
        if (a+b==15) {
            System.out.println("+");
        }
        else if (a*b==15) {
            System.out.println("*");
        }
        else {
            System.out.println("x");
        }
        
        
    }
}


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

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

  string s, t;
  cin >> s >> t;
  t.pop_back();
  if (s == t) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

signed main(){
	int a, b, x;
	scanf("%lld%lld%lld", &a, &b, &x);
	if(a+b >= x && a <= x)printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A,B,C,X,counter=0;
    cin >> A >> B >> C >> X;
    for(int a = 0; a < A+1; a++)
    {
        for(int b = 0; b < B+1; b++)
        {
            int c = (X - a*500 - b*100)/50;
            //cout << a << " " << b << " " << c << " " << 500*a+100*b+50*c << endl;
            if(c >= 0 && c <= C)
            {
                counter++;
            }
        }
    }
    cout << counter << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};


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

    UnionFind uni(2*100000+5);

    for(int i=1; i<=N; ++i){
        int k; cin >> k;
        for(int j=0; j<k; ++j){
            int l; cin >> l;
            uni.connect(i, l+1e5);
        }
    }

    bool flg = true;
    for(int i=2; i<=N; ++i) if(uni.root(1) != uni.root(i)) flg = false;
    
    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    int l[m], r[m];
    for (int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
    }
    int lmax = l[0], rmin = r[0];
    for (int i = 1; i < m; i++) {
        if (lmax < l[i]) lmax = l[i];
        if (rmin > r[i]) rmin = r[i];
    }

    int res = rmin - lmax + 1;
    if (res > 0) cout << res << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 4432
/*input
1
1000
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
 ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int arr[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin>>n;
    double s=0;
    REP(i,n){
        double x;
        cin>>x;
        s+=(1.0/x);
    }
    cout<<fixed<<setprecision(5)<<1.0/s<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    string s;
    map<string,int> A;
    rep(i,n){
        cin>>s;
        A[s]++;
    }
    cout<<"AC x "<<A["AC"]<<"\n";
    cout<<"WA x "<<A["WA"]<<"\n";
    cout<<"TLE x "<<A["TLE"]<<"\n";
    cout<<"RE x "<<A["RE"]<<"\n";
}

Measured memory_bytes: 3652
N, M = map(int, input().split())
lst_1_to_i = [False] * N
lst_i_to_N = [False] * N
ans = "IMPOSSIBLE"


for _ in range(M):
    a, b = map(int, input().split())
    if a == 1:
        lst_1_to_i[b] = True
    if b == N:
        lst_i_to_N[a] = True


for x, y in zip(lst_1_to_i, lst_i_to_N):
    if x and y:
        ans = "POSSIBLE"


print(ans)

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

int main()
{
	string n;
	while(getline(cin,n))
	{
		for(int i=0;i<26;i++)
		{
			string ans;
			for(int j=0;j<n.size();j++)
			{
				ans+=n[j];
				if('a'<=ans[j]&&ans[j]<='z')
				{
					ans[j]-=i;
					if(ans[j]<'a') ans[j]+=26;
				}
			}
			if(ans.find("the")!=-1||ans.find("this")!=-1||ans.find("that")!=-1)
			{
				cout<<ans<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int a[3];
    REP(i,3) cin >> a[i];
    sort(a,a+3);
    if(a[0] + a[1] == a[2]) fin("Yes");
    else fin("No");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll calc(ll x) {
   ll ans=1,cnt;
   for (ll i=2;i*i<=x;i++)
        if (x%i==0) {
        	cnt=0;
            while (x%i==0) x/=i,cnt++;
            ans=ans*(cnt+1);
        }
    if (x>1) ans=ans*2;
    return ans;
}
int main() {
	ll ans,i,m,p;
	cin>>n; m=n;
	if (n==2) {
		cout<<1<<endl;
		return 0;
	}
	ans=calc(n-1); p=0;
	for (i=2;i*i<=n;i++) if ((n-1)%i) {
		m=n;
		while (m%i==0) m/=i;
		if (m%i==1) ans++;		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n int
	fmt.Fscan(read, &n)

	var H int
	fmt.Fscan(read, &H)
	for i := 0; i < n-1; i++ {
		var h int
		fmt.Fscan(read, &h)

		if H > h {
			fmt.Fprintln(write, "No")
			return
		}

		if H < h {
			H = h - 1
		}
	}
	fmt.Fprintln(write, "Yes")
}


Measured memory_bytes: 3072
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize k:usize)(list:[i64]));
    let mut k = k;
    let mut sei = Vec::new();
    let mut hu = Vec::new();
    for x in list {
        if x > 0 {
            sei.push(x);
        } else if x < 0 {
            hu.push(-x);
        } else {
            k -= 1;
        }
    }

    if k == 0 {
        return 0.to_string();
    }

    hu.reverse();

    let mut min = <i64>::max_value();
    //正方向にb
    for a in 0..k + 1 {
        let b = k - a;

        if sei.len() >= a && hu.len() >= b {
            let a_sum = if a == 0 { 0 } else { sei[a - 1] };
            let b_sum = if b == 0 { 0 } else { hu[b - 1] };

            /*let c_sum = if a == 0 || b == 0 {
                0
            } else {
                std::cmp::min(sei[a - 1], hu[b - 1])
            };*/

            min = std::cmp::min(min, std::cmp::min(a_sum * 2 + b_sum, a_sum + b_sum * 2));
        }
    }
    min.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "5 3\n-30 -10 10 20 50" => "40",
    test2: "3 2\n10 20 30" => "20",
    test3: "1 1\n0" => "0",
    test4: "8 5\n-9 -7 -4 -3 1 2 3 4" => "10",
}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


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

  int n = sz(s);
  if (s[0]==s[n-1]){
    if (n%2){
      cout << "Second" << endl;
    }
    else{
      cout << "First" << endl;
    }
  }
  else{
    if (n%2){
      cout << "First" << endl;
    }
    else{
      cout << "Second" << endl;
    }
  }

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 512
#!/usr/bin/env python3
#ABC45 C
s = list(input())
n = len(s)

ans = 0
S = []
for i in range(2*n-1):
    if i % 2 == 0:
        S.append(s[i//2])
    else:
        S.append('')

for i in range(2**(n-1)):
    b = [0]*(n-1)
    for j in range(n-1):
        if (i>>j) & 1:
            b[j] = 1
    x = S.copy()
    k = 0
    for j in range(n-1):
        if b[j] == 1:
            x[k+1] = '+'
        k += 2
    preans = ''
    for j in range(2*n-1):
        if x[j] != '+':
            preans += x[j]
        if x[j] == '+' or j == 2*n-2:
            ans += int(preans)
            preans = ''
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int
main()
{
        int n, p;
        int i;
        int nd[50], w, step;

        while (scanf("%d %d", &n, &p), (n != 0) && (p != 0)) {
                for (i = 0; i < n; i++)
                        nd[i] = 0;
                nd[n] = -1;
                w = p;
                for (step = 0; step < 1000000; step++) {
                        if (w != 0) {
                                nd[step % n]++;
                                w--;
                        } else {
                                w = nd[step % n];
                                nd[step % n] = 0;
                        }
                        if (nd[step % n] == p)
                                break;
                }
                printf("%d\n", step % n);
        }

        return 0;
}

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

int main(){
    while(true){
        ll H, W;
        cin >> H >> W;
        if(H == 0 && W == 0){ break; }

        REP(i, H){
            REP(j, W){
                if((i + j) % 2 == 0){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3092
def check(N, K):
    if K <= (N - 1)*(N-2) /2:
        k = int((N - 1)*(N-2)/2 - K)
        print(N-1 + k)
        for i in range(2, N+1):
            print(1, i)
        l = 2
        r = 3
        if k != 0:
            for i in range(k):
                if l > N or r > N:
                    break
                print(l, r)
                r+=1
                if r == N+1:
                    l+=1
                    r=l+1
        return
    else:
        print(-1)
        return


if __name__ == "__main__":
    N, K = map(int, input().split())
    check(N, K)


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
string s;
ll c[5];
int main() {
	ll i,j,ans,cnt=0;
	cin>>n>>s;
	for (i=0;i<n;i++)
		if (s[i]=='R') c[0]++;
		else if (s[i]=='G') c[1]++;
		else c[2]++;
	ans=c[0]*c[1]*c[2];
	for (i=1;i<=n;i++) 
		for (j=0;j<n-i-i;j++)
			if (s[j]!=s[j+i]&&s[j]!=s[j+i+i]&&s[j+i]!=s[j+i+i])
				cnt++;
	cout<<ans-cnt<<endl;
	return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int64_t i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> A(N);
  vector<int64_t> ASUM(2e5 + 1, 0);
  rep(i, N) {
    cin >> A[i];
    ASUM[A[i]]++;
  }
  for (int i = 2e5; i > 0; --i) {
    ASUM[i - 1] += ASUM[i];
  }

  sort(A.rbegin(), A.rend());
  vector<int64_t> B(N + 1, 0);
  rep(i, N) { B[i + 1] = B[i] + A[i]; }

  int64_t left = 0;
  int64_t right = 2e5 + 1;
  while (left + 1 < right) {
    int64_t mid = left + (right - left) / 2L;
    int64_t L = 0;
    rep(i, N) { L += ASUM[max(0L, mid - A[i])]; }
    if (M <= L)
      left = mid;
    else
      right = mid;
  }

  int64_t answer = 0;
  int64_t L = 0;
  rep(i, N) {
    int64_t v = max(0L, right - A[i]);
    int64_t t = max(0L, min(ASUM[v], M - L));
    answer += B[t] + t * A[i];
    L += t;
  }
  answer += left * (M - L);
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)
 
ll ceili(ll a, ll b)
{
	if(a%b==0LL) return ll(a/b);
	return 1 + ll(a/b);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

    ll ans=0LL;
    int n;
    cin>>n;

    ll curmax;
    cin>>curmax;
    n--;

    while(n--)
    {
    	ll a;
    	cin>>a;
    	if(a<curmax) ans += curmax-a;
    	else curmax=a;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 3640
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]

# Cについて大きい順にソート
BC.sort(key=lambda x: x[1], reverse=True)

temp = []
for i in range(M):
        # CiをBi個追加
    temp += [BC[i][1]] * BC[i][0]
    if len(temp) > N:
        break

A += temp
A.sort(reverse=True)

print(sum(A[:N]))


Measured memory_bytes: 35896
import java.util.*;

class Main {
	public static void main(String[] args) {
		Comparator<Long> comparator = new Comparator<Long>() {
		    @Override
		    public int compare(Long o1, Long o2) {
		        return Long.compare(o2, o1);
		    }
		};
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		ArrayList<PriorityQueue<Long>> kind = new ArrayList<PriorityQueue<Long>>();
		for (int i=0;i<N;i++) {
			PriorityQueue<Long> queue = new PriorityQueue<Long>(comparator);
			kind.add(queue);
		}
		for (int i=0;i<N;i++) {
			int t = Integer.parseInt(sc.next());
			long d = Long.parseLong(sc.next());
			kind.get(t-1).add(d);
		}

		// best: most delicious of each kind
//		PriorityQueue<Long> best = new PriorityQueue<Long>(comparator);(o1, o2) -> o2.compareTo(o1)
		PriorityQueue<Long> best = new PriorityQueue<Long>((o1, o2) -> o2.compareTo(o1));
		// remain : remain without best
//		PriorityQueue<Long> remain = new PriorityQueue<Long>(comparator);
		PriorityQueue<Long> remain = new PriorityQueue<Long>((o1, o2) -> o2.compareTo(o1));

		for (int i=0;i<N;i++) {
			if (!kind.get(i).isEmpty()) {
				best.add(kind.get(i).peek());
				kind.get(i).remove();

				while (!kind.get(i).isEmpty()) {
					remain.add(kind.get(i).peek());
					kind.get(i).remove();
				}
			}
		}

		ArrayList<Long> bsum = new ArrayList<Long>();
		bsum.add(0L);
		long bsum_value=0L;
		while (!best.isEmpty()) {
			long tmp = bsum_value+best.peek();
			bsum.add(tmp);
			bsum_value=tmp;
			best.remove();
		}

		ArrayList<Long> rsum = new ArrayList<Long>();
		rsum.add(0L);
		long rsum_value=0L;
		while (!remain.isEmpty()) {
			long tmp = rsum_value+remain.peek();
			rsum.add(tmp);
			rsum_value=tmp;
			remain.remove();
		}

		long ans = 0L;
		for (int x=1;x<=K;x++) {
			if (x>=bsum.size()) {
				break;
			}
			if (K-x >= rsum.size()) {
				continue;
			}
			ans = Math.max(ans, (long)(bsum.get(x)+rsum.get(K-x)+(long)x*x));
		}
//		System.out.println(bsum);
//		System.out.println(rsum);
		System.out.println(ans);
	}
}

Measured memory_bytes: 74080
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int next_ch;
	string str;
	cin >> next_ch >> str;
	for (int i = 0; str[i]; i++) {
		if (str[i] + next_ch > 'Z')
			str[i] -= 26;
		cout << char(str[i] + next_ch);
			
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d || (abs(a-b) <=d &&abs(b-c)<d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
    int N;
    cin >> N;
    double A, ans;
    rep(i, N) {
        cin >> A;
        ans += 1 / A;
    }
    cout << setprecision(10) << 1 / ans << endl;
}

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

long gcd(long a, long b) {

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

}

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int g = A[0];

  for (int i = 1; i < N; i++) {
    g = gcd(g, A[i]);
  }

  cout << g << endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define P 1000000007
#define ll long long
#define ld long double
#define N (1<<17)
#define pii pair<int, int>
#define F first
#define S second

using namespace std;

int n, k;
int a[101];
ll d[101][2*N];

int main(){

	cin >> n >> k;

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

	d[0][k]++;

	for(int i=1; i<=n; i++){
		for(int j=0; j<=a[i]; j++) d[i][0] = (d[i][0]+d[i-1][j])%P;
		for(int j=1; j<=k; j++){
			d[i][j] = (d[i][j-1]-d[i-1][j-1]+d[i-1][j+a[i]]+P)%P;
		}
	}

	cout << d[n][0] << endl;

	return 0;

}


Measured memory_bytes: 205056
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <ctime>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

struct edge{int to, cost;};
vector<edge> e[100000];
int n;
double p, ex;

double dfs1(int now, int past){
	double res = 0;
	REP(i,e[now].size()){
		int next = e[now][i].to, ct = e[now][i].cost;
		if (next == past) continue;
		res += p * (ct + dfs1(next, now));
	}
	return res;
}

double dfs2(int now, int past){
	double res = ex;
	REP(i,e[now].size()){
		int next = e[now][i].to, ct = e[now][i].cost;
		if (next == past) continue;
		res += p * (ct + dfs2(next, now));
	}
	return res;	
}

int main() {
	cin >> p >> n;
	REP(i,n-1){
		int x, y;
		edge eg;
		scanf("%d %d %d", &x, &y, &eg.cost);
		x--;
		y--;
		eg.to = y;
		e[x].push_back(eg);
		eg.to = x;
		e[y].push_back(eg);
	}
	ex = dfs1(0,-1);
	printf("%.10f\n", dfs2(0,-1));

    return 0;
}

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

#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 REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int n, a;
  cin >> n >> a;
  vector<int> x(n); REP(i, n) cin >> x[i];

  vector< vector< vector<llong> > > dp(n+1, vector<vector<llong>>(n+1, vector<llong>((n+1)*a, 0)));
  dp[0][0][0]=1;

  REP(j,n) {
    REP(k,j+1) {
      REP(t,(n+1)*a) {
        if (t >= x[j]) {
          dp[j+1][k+1][t] = dp[j][k+1][t] + dp[j][k][t-x[j]];
        } else {
          dp[j+1][k][t] = dp[j][k][t];
        }
      }
    }
  }

  llong ans=0;
  for(int i=1; i<=n; i++) {
    ans+=dp[n][i][i*a];
  }
  cout << ans << endl;

}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 53248
N,K=map(int,input().split())
alist=list(map(int,input().split()))
#print(alist)

memo={0:False}
def isOK(x):
  if x in memo:
    return memo[x]
  
  num_cut=0
  for a in alist:
    num_cut+=-(-(a-x)//x)
    if num_cut>K:
      memo[x]=False
      return False  
    
  memo[x]=True
  return True

l=1
r=max(alist)+1
while l<=r:
  mid=(l+r)//2
  
  if not isOK(mid-1) and isOK(mid):
    print(mid)
    break
  elif isOK(mid-1):
    r=mid
  else:
    l=mid

Measured memory_bytes: 104172
#include <iostream>

using namespace std;

// Using while loop to solve this time

int main(int argc, char const *argv[])
{
    long long base = 100;
    // Other people don't include this interest variable
    float interest = 0.01;
    long long years = 0;

    long long target; //103
    cin >> target;

    // How many years it take to get to or above target;

    while (true)
    {
        if (base >= target)
        {
            cout << years << "\n";
            return 0;
        }
        base += base * 0.01;
        ++years;
    }
    return 0;
}


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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 根のときはpar[i]=i
    vector<int> node_num;

    //最初は全てが根であるとして初期化
    UnionFind(int N) : par(N), node_num(N, 1) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    // xとyの木を併合
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        node_num[rx] += node_num[ry];
        node_num[ry] = node_num[rx];
    }
    
    int get_node_num(int x) {
        int rx = root(x);
        return node_num[rx];
    }
    
     // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main(void){
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind tree(n);
    vector<int> tomo(n, 1);
    vector<vector<int>> block(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree.unite(a, b);
        tomo[a]++; tomo[b]++;
    }
    rep(i, k) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    
    rep(i, n) {
        int node_num = tree.get_node_num(i);
        node_num -= tomo[i];
        rep(j, block[i].size())
            if (tree.same(i, block[i][j]))
                node_num--;
        
        cout << node_num << " ";
    }
}

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

using namespace std;
typedef long long ll;

int main(void)
{
  ll N,M,V,P;
  cin>>N>>M>>V>>P;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());

  ll res = P;
  ll sum = A[P-1];
  for(ll i=P;i<N;i++){
    if(A[P-1]<= A[i]+M){
      if((A[i]+M)*(i+1-P)-sum >= M*(V-P-(N-1-i))){
        //cout<<(A[i]+M)*(i+1-P)-sum<<" "<<M*(V-P-(N-1-i))<<endl;
        res++;
      }
      else{
        break;
      }
    }
    sum += A[i];
  }

  cout<<res<<endl;

}

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

using namespace std;

typedef struct
{
    char ch;
    int num;
}Card;

Card a[100010],b[100010],c[100010];

int part(int l,int r)
{
    int x=a[r-1].num;

    int i=l-1;
    for(int j=l;j<r-1;j++)
    {
        if(a[j].num<=x)
        {
            swap(a[++i],a[j]);
        }
    }
    swap(a[++i],a[r-1]);

    return i;
}
void quick_sort(int l,int r)
{
    if(l+1<r)
    {
        int idx=part(l,r);
        quick_sort(l,idx);
        quick_sort(idx+1,r);
    }
}

void mg(int l,int r)
{
    int mid=(l+r)/2;
    int tmp=0;
    int i,j;
    for(i=l,j=mid;i<mid&&j<r;)
    {
        if(b[i].num>b[j].num)
        {
            c[tmp++]=b[j++];
        }else
        {
            c[tmp++]=b[i++];
        }
    }

    while(i<mid)
    {
        c[tmp++]=b[i++];
    }

    while(j<r)
    {
        c[tmp++]=b[j++];
    }

    for(i=l;i<r;i++)
    {
        b[i]=c[i-l];
    }
}

void merge_sort(int l,int r)
{
    if(l+1==r)
    {
        return;
    }

    int mid=(l+r)/2;

    merge_sort(l,mid);
    merge_sort(mid,r);

    mg(l,r);
}

int main()
{
    int n;

    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            getchar();
            scanf("%c %d",&a[i].ch,&a[i].num);
            b[i]=a[i];
        }

        quick_sort(0,n);
        merge_sort(0,n);

        bool flag=true;
        for(int i=0;i<n&&flag;i++)
        {
            if(a[i].ch!=b[i].ch||a[i].num!=b[i].num)
            {
                flag=false;
            }
        }

        if(flag)
        {
            cout<<"Stable"<<endl;
        }else
        {
            cout<<"Not stable"<<endl;
        }

        for(int i=0;i<n;i++)
        {
            printf("%c %d\n",a[i].ch,a[i].num);
        }
    }

    return 0;
}



Measured memory_bytes: 5568
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=3025;
const int inf=0x3f3f3f3f;
int n,m;
int w[maxn];
char str[maxn],str_[maxn];
ll v[maxn];
ll val[maxn];
ll dp[maxn][maxn];
int main()
{
	cin>>str+1;
	cin>>str_+1;
    int len = strlen(str+1),len_ = strlen(str_+1);
    for(int i = len;i>=1;--i)
    {
        for(int j = len_;j>=1;--j)
        {
            if(str[i]==str_[j])  dp[i][j] = dp[i+1][j+1]+1;
            else dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    int l = 1,r = 1;
    while(l<=len&&r<=len_)
    {

        if(str[l]==str_[r])
        {
            printf("%c",str[l]);
            l++,r++;
        }
        else if(dp[l][r]==dp[l+1][r]) l++;
        else r++;
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 73936
k=int(input())
s=input()
l=list(s)
n=len(l)
l1=[]
if n<=k:
    print(s)
else:
    for i in range(k):
        l1.append(l[i])
    l1.append(".")
    l1.append(".")
    l1.append(".")
    print("".join(l1))

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

int main() {
	while(1){
		int n, x;
		cin >> n >> x;
		if(n == 0 && x == 0) break;
		int ans = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j < i; j++){
				for(int k = 1; k < j; k++){
					if(i+j+k == x) ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#data = [input() for x in range(0, 1, 1)]

ws = input()

N = int(ws.split(" ")[0])
A = int(ws.split(" ")[1])
B = int(ws.split(" ")[2])

sums = 0

for i in range(0, N + 1, 1):
  
  num = 0
  
  
  for v in list(str(i)):
    num += int(v)
    
  if num >= A and num <= B:
    sums += i
  else:
    pass
  
print(sums)
    

Measured memory_bytes: 3060
N = int(input())
N_ = str(N)
n = len(N_)

if n == 1:
    print(N)
    exit()

for i in range(1, n):
    if N_[i] != '9':
        break
else:
    ans = int(N_[0]) + 9*(n-1)
    print(ans)
    exit()

ans = int(N_[0])-1 + 9*(n-1)
print(ans)

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

int maxn=110;
const long double pi = acos(-1.0);
int n;
long double x[110], y[110], ans;
long double solve() {
	long double r = rand(), nx, ny, ax=0, ay=0;
	r /= RAND_MAX;
	r *= 2*pi;
	for (int i = 0; i < n; ++i) {
		nx = cos(r)*x[i]-sin(r)*y[i];
		ny = sin(r)*x[i]+cos(r)*y[i];
		if (nx >= 0) {
			ax += nx;
			ay += ny;
		}
	}
	return sqrt(ax*ax+ay*ay);
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> x[i] >> y[i];
	for (int i = 0; i < 10000; ++i)
		ans = max(ans, solve());
	cout << setprecision(13) << ans;
}

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

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> sw(n, 0);
  int p = 0, ans = 0;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    while (x--) {
      int y;
      cin >> y;
      y--;
      sw[y] += (1 << i);
    }
  }
  // for (auto&& u : sw) cout << u << ((&u < &sw.back()) ? " " : "\n");

  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    p += (x << i);
  }

  // cout << p << endl;

  for (int bit = 0; bit < 1 << n; bit++) {
    int tmp = 0;
    for (int i = 0; i < n; i++) {
      if ((bit >> i) & 1) tmp ^= sw[i];
    }
    if (tmp == p) ans++;
  }
  cout << ans << endl;
  return 0;
}


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



int main(){
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for (int b = 1; b <= n; b++){
        ans += max(0, b - k) * (n / b) + max(0, n % b + 1 - k);
        if (k == 0) ans--;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	for (int i = 0; i <= (N / 7); i++) {
		for (int j = 0; j <= (N / 4); j++) {
			int n = 7 * i + 4 * j;
			if (n == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define maxn 2005
#define pii pair<int,int>
using namespace std;
int l[maxn],r[maxn];
int n;
char c1[maxn],c2[maxn];
int z1,z2;
pii p[maxn];
int cnt;
int mx[maxn];
int ans;

int main(){
	scanf("%s",c1+1);
	scanf("%s",c2+1);
	n=strlen(c1+1);
	z1=z2=1;
	for(int i=1;i<=n;i++){
		if(c1[i]=='1')z1=0;
		if(c2[i]=='1')z2=0;
	}
	if(z2){
		if(!z1)printf("-1\n");else printf("0\n");
		return 0;
	}

	memset(l,0x3f,sizeof(l));
	memset(r,0x3f,sizeof(r));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(c2[j]=='0')continue;
			l[i]=min(l[i],(i-j+n)%n);
			r[i]=min(r[i],(j-i+n)%n);
		}
	}
	ans=0x3f3f3f3f;
	for(int k=0;k<n;k++){
		cnt=0;
		for(int i=1;i<=n;i++){
			int x=(i+k-1)%n+1;
			if(c1[i]!=c2[x])p[++cnt]=pii(l[i],r[i]);
		}
		sort(p+1,p+cnt+1);
		memset(mx,0,sizeof(mx));
		for(int i=cnt;i;i--){
			int x=p[i].first;
			mx[x]=max(mx[x],p[i].second);
		}
		for(int i=n;i>=0;i--){
			mx[i]=max(mx[i],mx[i+1]);
		}
		for(int L=0;L<n;L++){
			int R=max(mx[L+1],k);
			ans=min(ans,L*2+2*R-k+cnt);
		}
	}
	for(int k=0;k<n;k++){
		cnt=0;
		for(int i=1;i<=n;i++){
			int x=(i-k+n-1)%n+1;
			if(c1[i]!=c2[x])p[++cnt]=pii(l[i],r[i]);
		}
		sort(p+1,p+cnt+1);
		memset(mx,0,sizeof(mx));
		for(int i=cnt;i;i--){
			mx[p[i].first]=max(mx[p[i].first],p[i].second);
		}
		for(int i=n;i>=0;i--){
			mx[i]=max(mx[i],mx[i+1]);
		}
		for(int L=k;L<n;L++){
			int R=mx[L+1];
			ans=min(ans,2*L+2*R-k+cnt);
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	p := PrimeFactors(n)
	d := make(map[int]int)
	ans := 0
	xs := make([]int, 1000000)
	for i := 1; i < len(xs); i++ {
		xs[i] = xs[i-1] + i
	}
	for i := 0; i < len(p); i++ {
		d[p[i]]++
	}
	for _, v := range d {
		z := sort.SearchInts(xs, v)
		if xs[z] == v {
			ans += z
		} else {
			ans += z - 1
		}
	}
	fmt.Println(ans)
}
func PrimeFactors(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}
	if n > 2 {
		pfs = append(pfs, n)
	}
	return
}


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

const int MAX = 2100000;
const int MOD = 1e9 + 7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll powMod(ll x, ll k) {
  if (k == 0) return 1;
  if (k % 2 == 0)
    return powMod(x * x % MOD, k / 2);
  else
    return x * powMod(x, k - 1) % MOD;
}

int main() {
  COMinit();
  int K;
  cin >> K;
  string S;
  cin >> S;
  int N = K + S.size();
  ll ans = 0, tmp = 0;
  for (int i = S.size(); i <= N; i++) {
    ans += COM(i - 1, S.size() - 1) * powMod(25, i - S.size()) % MOD *
           powMod(26, N - i) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

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

 using namespace std;
 typedef long long ll;

 int main() {
   int A, B;
   cin >> A >> B;

   int ans = -1;

   for (int i = 1; i < 10000; i++) {
     if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
       ans = i;
       break;
     }
   }

   cout << ans << endl;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    
    set<int> water_set, sugar_set;

    //water
    for(int i=0;i<30;i++){
        for(int j=0;j<=30;j++){
            if(i==0&&j==0) continue;
            int w = 100*a*i+100*b*j;
            if(w<=f)water_set.insert(w);
        }
    }

    //sugar
    for(int i=0; i<=3000;i++){
        for(int j=0; j<=3000;j++){
            int s = c*i+d*j;
            if(s<=f)sugar_set.insert(s);
        }
    }
    
    double maxratio = -1.0;
    int sw=0,s=0;
    for(int x:water_set){
        for(int y:sugar_set){
            if(x+y>f)continue;
            if((x/100)*e<y)continue;
            double ratio = (double)y/(x+y);
            if(maxratio<ratio){
                maxratio = ratio;
                sw = (x+y);s = y;
            }
        }
    }
    cout << sw << " " << s << endl;
    return 0;
}  

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

main(){
  string str; cin >> str;
  vector<pair<char, int> > v;
  str += 'X';
  int cnt = 1;
  char pre = str[0];
  for ( int i = 0; i < str.size(); i++ ){
    if ( pre != str[i] ){
      v.push_back(make_pair(pre, cnt));
      cnt = 1;
    } else {
      cnt++;
    }
    pre = str[i];
  }

  int maxv = 0;
  for ( int i = 0; i <= (int)v.size()-3; i++ ){
    if ( v[i].first == 'J' &&
	 v[i+1].first == 'O' &&
	 v[i+2].first == 'I' ){
      if ( v[i+1].second <= v[i].second &&
	   v[i+1].second <= v[i+2].second ){
	maxv = max(maxv, min(v[i].second, min(v[i+1].second, v[i+2].second)));
      }
    }
  }

  cout << maxv << endl;
  
}

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n); for(long long i=p;i<n;++i)
#define rofn(i,p,n); for(long long i=p;i>n;--i)
#define pb push_back
#define pi pair
#define vi vector
#define ump unordered_map
void solve(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	cout<<max(a*c,max(a*d,max(b*d,b*c)));
	// if(d<0 && b<0){
	// 	cout<<a*c;
	// 	return ;
	// }
	// if(d<0){
	// 	cout<<a*d;
	// 	return ;
	// }
	// if(b<0){
	// 	cout<<b*c;
	// 	return ;
	// }
	// if(b==0 || d==0){
	// 	cout<<a*c;
	// 	return ;
	// }
	// if()
	// cout<<b*d;
}
int main()
{
	fast;
	// int test;
	// cin >> test;
	// while(test--){
		solve();
	// 	cout<<"\n";
	// }
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    std::deque<char> deq;
    int count=0;
    for (int i=0;i<s.size();i++) {
        if (deq.empty()==true) {
            deq.emplace_back(s.at(i));
        } else {
            if ( (deq.back()=='0'&&s.at(i)=='1')||(deq.back()=='1'&&s.at(i)=='0') ) {
                count+=2;
                deq.pop_back();
            } else {
                deq.emplace_back(s.at(i));
            }
        }
    }
    cout<<count<<endl;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> lines(h);
    for (int i = 0; i < h; ++i) {
        cin >> lines[i];
    }

    for (int i = 0; i < h; i++) {
        string line = lines[i];
        cout << line << endl;
        cout << line << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int cnt = 0;
    for (int i=0; i<N; i++) {
        cin >> a[i];
        if ((a[i] % 2 == 1) && ((i+1) % 2 == 1)) {
            cnt ++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cassert>

typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::max;
using std::min;
using std::abs;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 5000000000000;
//typedef std::pair<int, int> P;
struct edge { int to;double cost; };
#define VMAX 1010

     ll N,M;
     ll A,B,C;
     ll K[101],P[11];
     ll ans;
     char S[100];
int main() {
    cin>>N;
    REP(i,N){cin>>K[i];}
    ans=INF;
    EREP(k,100){
        ll a=0;
        REP(i,N){
            a+=(K[i]-k)*(K[i]-k);
        }
        ans=min(a,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define itr(macro_v,i) macro_v.begin()+i
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> pos(0);
    if(s[0]=='<'){
        pos.push_back(0);
    }
    for(int i=0; i<n; i++){
        if(s[i]=='>' and s[i+1]=='<'){
            pos.push_back(i+1);
        }
    }
    if(s[n-1]=='>'){
        pos.push_back(n);
    }
    // dump(pos)
    vector<pair<int,int>> A(n+1, make_pair(0,0));
    for(auto p : pos){
        // d(p)
        if(p==0){
            int idx = p;
            while(s[idx]=='<'){
                A[idx+1].first = A[idx].first + 1;
                idx++;
            }
        }
        else if(p==n){
            int idx = p;
            while(s[idx-1]=='>'){
                A[idx-1].second = A[idx].second + 1;
                idx--;
            }
        }
        else{
            int idx = p;
            while(s[idx]=='<'){
                A[idx+1].first = A[idx].first + 1;
                idx ++;
            }
            idx = p;
            while(s[idx-1]=='>'){
                A[idx-1].second = A[idx].second +1;
                idx --;
            }
        }
    }
    ll ans = 0;
    for(int i=0; i<=n; i++){
        ans+= max(A[i].first, A[i].second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5660
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int a, b;
    cin >> a >> b;
    int sum = 0;
    for(int i = a; i <= b; i++){
        string s = to_string(i);
        bool flag = true;
        for(int j = 0; j < s.size(); j++){
            if(s[j] != s[s.size() - j - 1]){
                flag = false;
                break;
            }
        }
        if(flag){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256