akhauriyash/Code-Regression huggingface dataset:
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var S string

func main() {
	sc.Split(bufio.ScanWords)
	//X: 最初のマス
	S = nextStr()

	m := make(map[string]int, len(S))
	ans := "yes"
	for i := 0; i < len(S); i++ {
		s := string(S[i])
		//mapにkeyが存在するか判定
		if _, ok := m[s]; ok {
			ans = "no"
			break
		} else {
			m[s] = 1
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
using namespace std;

//long long a[100000];
//long long b[100000];

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

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

long long T[100];
long long orgT[100];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> T[i];
        orgT[i] = T[i];
    }

    if(N == 1){
        cout << T[0] << endl;
        return 0;
    }

    long long tmp = lcm(T[0], T[1]);
    for(int i = 2; i < N; i++){
        tmp = lcm(tmp, T[i]);
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int MOD;
int N;
int dp[5050][5050]; // diff, penalty sum

void compute(int L)
{
	for (int i = 0; i <= N; ++i) for (int j = 0; j <= N; ++j) dp[i][j] = 0;
	dp[0][0] = 1;

	for (int i = 0; i < L; ++i) {
		int mxd = N / (L - i);
		for (int j = 0; j <= mxd; ++j) {
			for (int k = 0; k <= N; ++k) {
				if (dp[j][k] && k + L - i <= N) {
					ADD(dp[j + 1][k + (L - i)], dp[j][k]);
				}
			}
		}
	}
}

int ls[5050];

int main()
{
	scanf("%d%d", &N, &MOD);

	i64 ans;
	if (N % 2 == 0) {
		compute(N / 2);
		for (int i = 1; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) ADD(dp[i][j], dp[i - 1][j]);
		}
		for (int i = 0; i <= N; ++i) ls[i] = dp[N][i];
		for (int j = 1; j <= N; ++j) ADD(ls[j], ls[j - 1]);
		compute(N / 2 - 1);
		for (int i = 1; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) ADD(dp[i][j], dp[i - 1][j]);
		}
		ans = 0;
		for (int i = 1; i <= N; ++i) {
			i64 tmp = 0;
			for (int j = 0; j < i; ++j) {
				// left penalty sum < i - j
				ADD(tmp, (i64)dp[N - i][j] * ls[i - j - 1]);
			}
			ADD(ans, tmp);
		}
	} else {
		compute(N / 2);
		for (int i = 1; i <= N; ++i) {
			for (int j = 0; j <= N; ++j) ADD(dp[i][j], dp[i - 1][j]);
		}
		for (int i = 0; i <= N; ++i) ls[i] = dp[N][i];
		for (int j = 1; j <= N; ++j) ADD(ls[j], ls[j - 1]);
		ans = 0;
		for (int i = 1; i <= N; ++i) {
			i64 tmp = 0;
			for (int j = 0; j < i; ++j) {
				// left penalty sum < i - j
				ADD(tmp, (i64)dp[N - i][j] * ls[i - j - 1]);
			}
			ADD(ans, tmp);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 98944
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,y = mii()
y = y//1000
ans=[]
for a in range(n+1):
    for b in range(n-a+1):
        
        c = n-a-b
        #print(a,b,c)
        if a*10+b*5+c == y:
            ans = [a,b,c]

if len(ans)==0:
    print("-1 -1 -1")
else:
    print(str(ans[0])+" "+str(ans[1])+" "+str(ans[2]))


Measured memory_bytes: 65768
#-*- coding: utf-8 -*-
import numpy as np

def main(p):
    all = np.sum(p);
    app = list(map(lambda x: -1*(x - all), p));
    print(np.min(app));

if __name__ == '__main__':
    times = list(map(int,input().split()));
    main(times);

Measured memory_bytes: 12504
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    string t, h;
    int n, t_len, h_len, itr, t_score, h_score;
    t_score = 0;
    h_score = 0;
    cin >> n;
    for (int i=0; i<n; ++i){
        cin >> t >> h;
        itr = 0;
        t_len = t.length();
        h_len = h.length();
        while(true){
            if(itr < t_len && itr < h_len){
                if(t[itr] > h[itr]){
                    t_score += 3;
                    break;
                }
                else if(t[itr] < h[itr]){
                    h_score += 3;
                    break;
                }
                else {
                    itr++;
                }
            }
            // draw
            else if(itr == t_len && itr == h_len){
                t_score++;
                h_score++;
                break;
            }
            else {
                if(t_len > h_len){
                    t_score += 3;
                    break;
                }
                else if(h_len > t_len){
                    h_score += 3;
                    break;
                }
            }
        }
    }
    cout << t_score << " " << h_score << endl;
    return 0;
}



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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(1LL<<n);
    multiset<ll> st;
    REP(i, 1LL<<n) cin >> a[i], st.insert(a[i]);
    sort(ALL(a), greater<>());

    vector<ll> b(1LL<<n);
    b[0] = a[0];
    st.erase(st.find(a[0]));
    for(ll i=2; i<=(1LL<<n); i*=2) {
        ll idx = 0;
        REP(j, i/2) {
            // b[idx]-1以下で残りの中から最も大きいものは?
            // for(auto k: st) cout << k << " ";
            // cout << endl;
            auto itr = st.upper_bound(b[idx]-1);
            if(itr == st.begin()) {
                cout << "No" << endl;
                return 0;
            }
            itr--;
            b[idx+i/2] = *itr;
            st.erase(itr);
            idx++;
        }
    }
    sort(ALL(b), greater<>());
    // cout << b << endl;

    bool flag = true;
    REP(i, 1LL<<n) {
        if(a[i] != b[i]) flag = false;
    }

    if(flag) cout << "Yes" << endl;
    else {
        cout << "No" << endl;
    }

    return 0;
}


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



int main(){
  string S; cin>>S;
  if(S.at(0)==S.at(1)&&S.at(1)==S.at(2)&&S.at(2)==S.at(3))
    cout<<"No";
  else if(S.at(0)==S.at(1)&&S.at(2)==S.at(3))
    cout<<"Yes";
  else if(S.at(0)==S.at(2)&&S.at(1)==S.at(3))
    cout<<"Yes";
  else if(S.at(0)==S.at(3)&&S.at(1)==S.at(2))
    cout<<"Yes";
  else
    cout<<"No";
}


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

#define ff first
#define ss second
#define pb push_back
#define int long long

void dfs(int i,vector<int> adj[],vector<bool> &vis,int dp[]){
	//cout<<i<<"-";
	vis[i]=1;
	
	for(int j=0;j<adj[i].size();j++){
		int node=adj[i][j];
		if(!vis[node])
		dfs(node,adj,vis,dp);
		
		dp[i]=max(dp[i],1+dp[node]) ;
	}
}


signed main(){


#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
#else
// online submission
#endif


int n,e;
cin >> n >> e;

vector<int> adj[n+1];

for(int i=0;i<e;i++){
	int a,b;
	cin >> a >> b;
	adj[a].push_back(b) ;
}


vector<bool> vis(n+1,false);
int dp[n+1]={0};

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

int ans=INT_MIN;
for(int i=1;i<=n;i++)
ans=max(ans,dp[i]);

cout<<ans;
    
	
	return 0;
    
}




Measured memory_bytes: 13064
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


void testcase(){
	int n;
	cin >> n;
	cout << (1000 - n % 1000)%1000 << "\n";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  string s=a+b;
  int ans=stoi(s);
  int k=(int)sqrt((double)ans);
  if(k*k==ans) cout <<"Yes" << endl;
  else cout <<"No" << endl;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int,input().split()))
a1 = []
a2 = []
for i in range(n):
    if i % 2 == 0:
        a1.append(v[i])
    else:
        a2.append(v[i])

a1 = Counter(a1)
a2 = Counter(a2)

a1 = a1.most_common()
a2 = a2.most_common()

if a1[0][0] == a2[0][0]:
    if len(a1) == 1 and len(a2) == 1:
        print(int(n/2))
    else:
        if a1[1][1] > a2[1][1]:
            print(n-a1[1][1]-a2[0][1])
        else:
            print(n-a1[0][1]- a2[1][1])
else:
    print(n - a1[0][1] - a2[0][1])


Measured memory_bytes: 18656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 300005, M = 998244353;

ll n, a, b, k, fac[N] = {1}, fi[N] = {1};

ll calc (ll A, ll B) {
	if(!B) return 1;
	ll R = calc(A, B/2);
	R = R * R % M;
	if(B&1) R = R * A % M;
	return R;
}

ll comb (ll A, ll B) {
	return fac[A] * fi[B] % M * fi[A-B] % M;
}

int main()
{
	cin >> n >> a >> b >> k;
	for(ll i=1;i<=n;i++) {
		fac[i] = fac[i-1] * i % M;
		fi[i] = calc(fac[i], M-2);
	}
	ll ans = 0;
	for(ll i=0;i<=n;i++) {
		ll X = k - a * i;
		if(X >= 0 && X % b == 0 && X/b <= n) {
			ans += comb(n, i) * comb(n, X/b);
			ans %= M;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;
ll a[1000],idx;
void primeFactors(ll n){
	idx=0;  
    while (n % 2 == 0){  
        a[idx++]=2;
        n = n/2;  
    }  
    for (int i = 3; i <= sqrt(n); i = i + 2){  
        while (n % i == 0){  
            a[idx++]=i;
            n = n/i;  
        }  
    }  
    if (n > 2)  
        a[idx++]=n;
}  



int main(){
	ll n;
	cin>>n;
	primeFactors(n);
	map<ll,ll> mp;
	for(ll i=0; i<1000; i++){
		if(a[i]!=0) mp[a[i]]++;
	}
	for(auto i: mp){
		for(ll j=1; j<=14; j++){
			if(i.second>=j){
				ans++;
				i.second -=j;
			}
		}
	}
	cout<<ans<<endl;
}


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

int main()
{int N;
 int a=10e5+1;
 int C[a];
 cin >> N;
 int sum=0;
 for(int i=0; i<N; i++){
   cin >> C[i];
   sum += C[i];
   sum %= 2;
 }
 if(sum%2==1) cout << "NO" << endl;
 else cout << "YES" << endl;
 
 
}

Measured memory_bytes: 2560
#include<cstdio>
long long const maxn=1e9+7;
long long n,a,b,ans,bina,binb,binna,binnb;
long long check(long long a,long long p) {
	long long m=1,tmp=a;
	while (p) {
		if (p%2) m=m*tmp%maxn;
		tmp=tmp*tmp%maxn;
		p/=2; 
	}
	return m;
}
int main() {
	scanf("%lld%lld%lld",&n,&a,&b);
	ans=check(2,n)+maxn-1;
	ans%=maxn;
	bina=1;binb=1;binna=1;binnb=1;
	for (int i=1;i<=a;++i) bina=bina*i%maxn;
	for (int i=1;i<=b;++i) binb=binb*i%maxn;
	for (int i=n-a+1;i<=n;++i) binna=binna*i%maxn;
	for (int i=n-b+1;i<=n;++i) binnb=binnb*i%maxn;
	bina=check(bina,maxn-2);
	binb=check(binb,maxn-2);
	ans+=maxn+maxn-bina*binna%maxn-binb*binnb%maxn;
	ans%=maxn;
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define ff first
#define ss second
#define ll long long
#define ld long double
#define ull unsigned long long
#define bp(x) __builtin_popcount(x)
#define pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define endl "\n"
typedef vector<int> vi;
typedef vector< pair<int,int> > vii;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector< pair<ll,ll> > vll;
void nikal_pehli_fursat_mai(){
  string s;
  cin>>s;
  ll temp=0;
  int n=(int)s.size();
  fi(0,n){
    temp+=(s[i]-'0');
  }
  if(temp%9){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

int main(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc=1; 
  //cin>>tc;
  while(tc--){
    nikal_pehli_fursat_mai();
  }
}


Measured memory_bytes: 3700
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int a,b;
        a=scan.nextInt();
        b=scan.nextInt();
        if(a-b*2>=0) System.out.println(a-b*2);
        else System.out.println(0);
    }
}

Measured memory_bytes: 21844
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp::min;
use std::i32;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

struct Problem {
    keynum: i32,
    boxnum: i32,
    keylist: Vec<i32>,
    costlist: Vec<i32>,
    opennum: i32,
    memo: Vec<Vec<i32>>,
}

impl Problem {
    fn solve(&mut self, index: usize, open: i32) -> i32 {
        let mut res = 0;
        if self.memo[index][open as usize] > 0 {
            return self.memo[index][open as usize];
        }
        if index as i32 == self.keynum-1 {
            return i32::MAX;
        } else if self.open_cal(open, index) == self.opennum {
            res = min(self.costlist[index], self.solve(index+1, open));
        } else {
            let newopen = self.open_cal(open, index);
            let mut newval = self.solve(index+1, newopen);
            if newval != i32::MAX {
                newval = newval + self.costlist[index];
            }
            res = min(newval, self.solve(index+1, open));
        }
        self.memo[index][open as usize] = res;
        return res;
    }

    fn open_cal(&self, open: i32, index: usize) -> i32 {
        return self.keylist[index] | open;
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.read();
    let m: usize = sc.read();

    let mut v = Vec::new();
    let mut a = vec![0; m];

    for i in 0..m {
        a[i as usize] = sc.read();
        let b: usize = sc.read();

        let mut c = 0;
        for j in 0..b {
            let num: i32 = sc.read();
            if num == 1 {
                c = c + 1;
            } else {
                c = c + (2 << (num-2));
            }
        }
        v.push(c);
    }

    let mut o = 0;
    if n == 1 {
        o = 1;
    } else {
        o = (2 << (n-1)) - 1;
    }

    let memo = vec![vec![0; 2 << (n as i32)]; m];
    let mut p = Problem {
        boxnum: n as i32,
        keynum: m as i32,
        keylist: v,
        costlist: a,
        opennum: o,
        memo: memo,
    };

    let result = p.solve(0, 0);
    if result == i32::MAX {
        println!("-1");
    } else {
        println!("{}", result);
    }
}

Measured memory_bytes: 41212
n = gets.to_i

ab = []
f = Array.new(n+1){[]}
(n-1).times do |i|
    a, b = gets.split.map(&:to_i)
    f[a] << i
    f[b] << i
    ab << [a, b]
end

ans = Array.new(n-1)
que = [1]
color = Array.new(n+1){[]}
mc = 0

while x = que.shift
    c = 1

    f[x].each do |i|
        next if ans[i]
        y = ab[i][0] == x ? ab[i][1] : ab[i][0]

        while c == color[x][0]
            c += 1
            color[x].shift
        end

        ans[i] = c
        color[y] << c
        mc = c if mc < c
        que << y
        c += 1
    end
end

puts mc, ans

Measured memory_bytes: 27900
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    Scanner sc = new Scanner(System.in);

    //???????????¨?????????????§????????¨??????????
	public int calculateAngleFromTime(String currnetTIme){
    	//hour??¨minite?????\????????????
		String hourAndMinite[] = currnetTIme.split(":");
		int hour = Integer.parseInt(hourAndMinite[0]);
		int minite = Integer.parseInt(hourAndMinite[1]);
		
		//???????????¨?????????????§????????¨??????????????????????????????§?¨??????????????§???????2???????????????
		int angle = Math.abs((hour*60+minite - minite*12));
		//????§???¨????§???????????°???????????????????
		angle = Math.min(angle, 720-angle);
		
		return angle;
	}

	//?¨??????????????§????????????£?????????????????????????±??????????
	public String answer(int angle) {
		if(angle < 60){
			return "alert";
		} else if(angle >= 180){
			return "safe";
		} else {
			return "warning";
		}
    }

    void run(){
    	int n = sc.nextInt();
    	for(int i= 0; i< n; i++){
    		int angle = calculateAngleFromTime(sc.next());
    		String output = answer(angle);
    		System.out.println(output);
    	}
    }

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

Measured memory_bytes: 29252
import math

a, b, angle = map(int,input().split())
sin_C = math.sin(math.radians(angle))
cos_C = math.cos(math.radians(angle))
c = math.sqrt((a**2 + b**2) - 2 * a * b * cos_C)
S = (a * b * sin_C) / 2
L = a + b + c
H = S *2 / a 
print("{} {} {}".format(S, L, float(H)))


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

int main(){
  string n;
  cin >> n;
  if (n[1] == n[2]) {
      if(n[1] == n[0] || n[2] == n[3]) cout << "Yes" << endl;
      else cout << "No" << endl;
  }
  else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3640
n = int(input())
p = str(tuple(map(int, input().split())))
q = str(tuple(map(int, input().split())))

import itertools

n_l = [ i+1 for i in range(n) ]
d = {}
for i, v in enumerate(itertools.permutations(n_l)):
    d[str(v)] = i
print(abs(d[p]-d[q]))

Measured memory_bytes: 14628
#include <bits/stdc++.h>
using namespace std;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl

#define lli long long int
#define ull unsigned long long int
#define mod 1000000007



int main()
{
    IOS;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    int dp[n][3];
    dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            if(j==0)
            dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i];
            else if(j==1){
                dp[i][j]=max(dp[i-1][0],dp[i-1][2])+b[i];
            }else dp[i][j]=max(dp[i-1][0],dp[i-1][1])+c[i];
        }
    }

    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    return 0;
}

Measured memory_bytes: 5832
#include<bits/stdc++.h>
using namespace std;
long long n,a[1003],b[1003];
long long Dis(long long x,long long y){
	return fabs(x)+fabs(y);
}
pair<long long,long long>lrud(long long x,long long y){
	long long a=pow(2,30);
	while(a){
		pair<long long,long long>c[4]={make_pair(Dis(x+a,y),0),make_pair(Dis(x-a,y),1),make_pair(Dis(x,y+a),2),make_pair(Dis(x,y-a),3)};
		sort(c,c+4);
		if(c[0].second==0)x+=a,cout<<"L";
		if(c[0].second==1)x-=a,cout<<"R";
		if(c[0].second==2)y+=a,cout<<"D";
		if(c[0].second==3)y-=a,cout<<"U";
		a/=2;
	}
	return make_pair(x,y);
}
int main(){
	cin>>n;
	for(long long i=0;i<n;i++)cin>>a[i]>>b[i];
	for(long long i=1;i<n;i++)if(int(fabs(a[i]+b[i]))%2!=int(fabs(a[i-1]+b[i-1]))%2){cout<<-1<<' ';return 0;}
	if((a[0]+b[0])%2==0){
		cout<<32<<endl;
		long long xx=pow(2,30),cnt=0;
		while(xx!=1)cout<<xx<<' ',xx/=2,cnt++;
		cout<<1<<' '<<1<<endl;
		for(long long i=0;i<n;i++){
			pair<long long,long long>x=lrud(a[i],b[i]);
			if(x.first==1)cout<<"R";
			if(x.first==-1)cout<<"L";
			if(x.second==1)cout<<"U";
			if(x.second==-1)cout<<"D";
			if(x.first==2)cout<<"RR";
			if(x.first==-2)cout<<"LL";
			if(x.second==2)cout<<"UU";
			if(x.second==-2)cout<<"DD";
			if(!x.first&&!x.second)cout<<"LR";
			cout<<endl;
		}
	}else{
		cout<<"31\n";
		long long xx=pow(2,30);
		while(xx!=1)cout<<xx<<' ',xx/=2;
		cout<<"1\n";
		for(long long i=0;i<n;i++)
		{
			pair<long long,long long>x=lrud(a[i],b[i]);
			if(x.first==1)cout<<"R";
			if(x.first==-1)cout<<"L";
			if(x.second==1)cout<<"U";
			if(x.second==-1)cout<<"D";
			cout<<endl;
		}
	}
}

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

int main(){
    
    int N;
    cin >> N;
    double arr[N];
    
    for(int i=0;i<N;i++){
        cin >> arr[i];
    }
    
    vector<vector<double>>dp(N, vector<double>(N+1, 0));
    dp[0][0] = 1-arr[0];
    dp[0][1] = arr[0];
    
    
    for(int i=1;i<N;i++){
        for(int j=0;j<=N;j++){
            dp[i][j] = dp[i-1][j]*(1-arr[i]);
            if(j>0)
                dp[i][j] += dp[i-1][j-1]*(arr[i]);
        }
    }

    double ans = 0;
    for(int i= (N+1)/2; i<=N;i++){
        ans += (double)dp[N-1][i];
    }
    
    // for(int i=0;i<N;i++){
    //     for(int j=0;j<=N;j++)
    //         cout << dp[i][j] <<" ";
    //     cout << endl;
    // }
    cout << setprecision(10)<< ans <<endl;
	return 0;
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n,a,b,c,d;  cin>>n>>a>>b>>c>>d;

    rep(i, n){
        ll j = n-1-i;
        if(c*i-d*j <= b-a && b-a <= i*d-j*c){
            puts("YES");
            return 0;
        }
    }
    puts("NO");


    return 0;

}

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

int main()
{
string a ;
cin >> a ;
ll res[26]={};
rep(i,a.size()){
  res[a[i]-'a']++;
}
rep(i,26){
  if(res[i]>1)
  ans+=(res[i])*(res[i]-1)/2 ;
}
cout << a.size()*(a.size()-1)/2-ans+1 << endl;
return 0;
}


Measured memory_bytes: 640
N, K = map(int, input().split())
A = sorted([int(a) for a in input().split()])
P = 10**9+7

fa = [1]
for i in range(1, N + 2): fa.append(fa[-1] * i % P)
fainv = [pow(fa[-1], P-2, P)]
for i in range(1, N + 2)[::-1]: fainv.append(fainv[-1] * i % P)
fainv = fainv[::-1]

C = lambda a, b: fa[a] * fainv[b] * fainv[a-b] if 0 <= b <= a else 0
print(sum([(C(i, K-1) - C(N-i-1, K-1)) * A[i] % P for i in range(N)]) % P)

Measured memory_bytes: 19136
#include <cstdio>  
#include <algorithm>
using namespace std;  
int main() { 	
	int a,b,c;
	int d, e, f;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
	if(e-a>f){
		printf(":(");
	}
	else {
		printf("Yay!");
	}
	
	
}






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


#define all(x) x.begin(),x.end()

using i32 = int_fast32_t;
using ui32 = uint_fast32_t;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using ll = i64;
using pi = pair<i32, i32>;
using pll = pair<i64, i64>;
using vi = vector<i32>;
using vll = vector<i64>;

int Main(){
    int N;
    ll K;
    cin >> N >> K;
    vll A(N);
    for(auto &a:A) cin >> a;
    ll X = 0;
    for(int i=40;i>=0;i--){
        int c = 0;
        for(auto a:A) if((a>>i)&1) c++;
        if(c*2 < N && X+(1LL<<i) <= K) X += 1LL<<i;
    }
    for(auto &a:A) a ^= X;
    cout << accumulate(all(A), 0LL) << endl;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int l=1;
    int r=1000000000;
    while(r!=l){
        int c=(r+l)/2;
        int now=k;
        rep(i,n){
            now-=((a[i]+c-1)/c)-1;
        }
        if(now>=0) r=c;
        else l=c+1;
    }
    cout << r << endl;
return 0;
}


Measured memory_bytes: 4000
#define _USE_MATH_DEFINES

#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

int main(void) {

	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double deg_a = h / 12 + m / 60 * 1 / 12;
	double deg_b = m / 60;
	deg_a *= M_PI * 2;
	deg_b *= M_PI * 2;

	if (deg_a < deg_b) {
		swap(deg_a, deg_b);
		swap(a, b);
	}

	double answer = a * a + b * b- 2 * a * b * cos(deg_a - deg_b);

	cout << setprecision(10) << sqrt(answer) << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, P;
	string S;
	cin >> N >> P >> S;
	int ans = 0;


	//reverse(S.begin(), S.end());

	if (P == 2) {
		REP(i, N) {
			int a = S[i] - '0';
			if (a % 2 == 0) {
				ans += i + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}
	if (P == 5) {
		REP(i, N) {
			int a = S[i] - '0';
			if (a % 5 == 0) {
				ans += i + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}

	
	reverse(S.begin(), S.end());

	int ten = 1;
	map<int, int>mp;
	
	int sum = 0;
	mp[0]++;
	REP(i, N) {

		int a = S[i] - '0';
		a *= ten;
		a %= P;
		sum += a;
		sum %= P;

		ans += mp[sum];
		mp[sum]++;






		ten *= 10;
		ten %= P;
	}


	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 1044
using System;
using System.Collections.Generic;

class Program
{

    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();
        int[] S = new int[N];

        var D = new Dictionary<char, int>() {{'R', 0}, {'G', 1}, {'B', 2}};
        for(int i=0; i<N; ++i) S[i]=D[s[i]];

        int[,] X = new int[3,N];
        int[] nC = new int[] {0, 0, 0};
        for(int i=N-1; i>=0; --i) {
            for(int j=0; j<3; ++j) X[j, i] = nC[j];
            ++nC[S[i]];
        }

        long ans=0;
        for(int i=0; i<N-2; ++i) {
            for(int j=i+1; j<N-1; ++j) {
                if(S[i]==S[j]) continue;
                
                int r = 3-S[i]-S[j];
                ans += X[r, j];
                
                int k = 2*j-i;
                if (k<N && S[k]==r) --ans;
            }
        }

        Console.WriteLine(ans);

    }

}


Measured memory_bytes: 18000
#include<iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
     char s[10001];
     int a[1001],b[1001];
     int n;
     cin>>n;
     for (int i=0;i<n;++i) cin>>s[i];
     int max=-99999;
     int sum=0;
     for (int i=0;i<n;++i)
     {
         memset(a,0,sizeof(a));
         memset(b,0,sizeof(b));
         sum=0;
          for (int j=0;j<=i;++j)
          {
              int num; num=s[j];
              a[num]++;
           }
           for (int k=i+1;k<n;++k)
           {
                    int num;
                       num=s[k];
                       b[num]++;
           }
           for (int j=97;j<=122; ++j)
           {
               //cout<<a[j]<<" "<<b[j]<<endl;
               if (a[j]>0&&b[j]>0)
                   ++sum;
           }
           if (max<sum) max=sum;
      }
      cout<<max<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 200001
ll q[N] = {0, 1}, f[N], h[N], n, c;
double slope(int i, int j) {
    return (f[i] - f[j] + h[i] * h[i] - h[j] * h[j]) / 2.0 / (h[i] - h[j]);
}
int main() {
    scanf("%lld%lld", &n, &c);
    for (int i = 1; i <= n; i++) scanf("%lld", &h[i]);
    int l = 1, r = 1;
    for (int i = 2; i <= n; i++) {
        while (l < r && slope(q[l], q[l + 1]) <= h[i]) l++;
        f[i] = f[q[l]] + (h[i] - h[q[l]]) * (h[i] - h[q[l]]) + c;
        while (l < r && slope(q[r - 1], q[r]) >= slope(q[r], i)) r--;
        q[++r] = i;
    }
    printf("%lld\n", f[n]);
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int H,W;
  cin >> H >> W;
  vvi graph(H, vi(W));
  vvi wqh(W, vi());
  vvi hqw(H, vi());
  for(int x = 0; x<H; x++){
    for(int y = 0; y<W; y++){
      char t;
      cin >> t;
      graph[x][y]=t;
      if(t=='#'){
        hqw[x].push_back(y);
        wqh[y].push_back(x);
      }
    }
  }
  int oup = -INF;
  vvi val(H, vi(W));
  for(int x = 0; x<H; x++){
    for(int y = 0; y<W; y++){
      if(graph[x][y]!='#'){
        //max distance to ground
        vi::iterator h_up = upper_bound(wqh[y].begin(), wqh[y].end(), x);
        int h_uv;
        if(distance(h_up, wqh[y].end())==0){
          h_uv = H-x-1;
        }
        else
          h_uv = *h_up-x-1;
        //max distance to right
        vi::iterator w_up = upper_bound(hqw[x].begin(), hqw[x].end(), y);
        int w_uv;
        if(distance(w_up, hqw[x].end())==0){
          w_uv = W-y-1;
        }
        else
          w_uv = *w_up-y-1;
        //max distance to ceil
        vi::iterator h_down = lower_bound(wqh[y].begin(), wqh[y].end(), x);
        int h_dv;
        if(distance(wqh[y].begin(), h_down)==0){
          h_dv=x;
        }
        else{
          h_down--;
          h_dv = x-*h_down-1;
        }
        //max distance to ceil
        vi::iterator w_down = lower_bound(hqw[x].begin(), hqw[x].end(), y);
        int w_dv;
        if(distance(hqw[x].begin(), w_down)==0){
          w_dv=y;
        }
        else{
          w_down--;
          w_dv = y-*w_down-1;
        }
        oup = max(oup, w_dv+h_dv+w_uv+h_uv);
        val[x][y] = w_dv+h_dv+w_uv+h_uv;


      }
    }
  }
//  for(int x=0; x<H; x++){
//    for(int y = 0; y<W; y++){
//      cout << val[x][y] << " ";
//    }
//    cout << endl;
//  }
//  for(int x = 0; x<H; x++){
//    for(int y = 0; y<W; y++){
//      if(tgraph[x][y]!='#'){
//        //max distance to ground
//        vi::iterator h_up = upper_bound(twqh[y].begin(), twqh[y].end(), x);
//        int h_uv;
//        if(distance(h_up, twqh[y].end())==0){
//          h_uv = H-x-1;
//        }
//        else
//          h_uv = *h_up-x-1;
//        //max distance to right
//        vi::iterator w_up = upper_bound(thqw[x].begin(), thqw[x].end(), y);
//        int w_uv;
//        if(distance(w_up, thqw[x].end())==0){
//          w_uv = W-y-1;
//        }
//        else
//          w_uv = *w_up-y-1;
//        oup = max(oup, val[H-1-x][W-1-y]+h_uv+w_uv);
//      }
//    }
//  }
  cout << oup+1 << endl;
  return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n,i;
	cin >> n;
	for ( i = 1;i*(i+1)/2 < n; i++) {
	}
	for (int j = 1; j <= i; j++) {
		if (j == i*(i+1)/2 - n) {
			continue;
		}
		cout << j << endl;
	}
	return 0;
}


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

const int INF = 1001001001;

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(0); vector<int> f(0);
  for(int i=0;i<n;i++){
    int input; cin >> input;
    a.push_back(input);
  }
  for(int i=0;i<n;i++){
    int input; cin >> input;
    f.push_back(input);
  }
  sort(a.begin(),a.end());
  sort(f.rbegin(),f.rend());
  ll l = -1, r = 1e12;
  while(l+1<r){
    ll c = (l+r)/2;
    bool ok = [&]{
      ll s = 0;
      for(int i=0;i<n;i++){
        s +=  max(0ll,a.at(i)-(c/f.at(i)));
      }
      return s<=k;
    }();
    if(ok) r = c; else l = c;
  }
  cout << r << endl;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B;
    cin >> A >> B;
    int ans = (A-1)*(B-1);
    print(ans);
}


Measured memory_bytes: 256
import math
n = int(input())
mod = 10**9+7

def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

p = []
for i in range(1,n+1):
	if is_prime(i):
		p.append(i)
ans = 1
for i in p:
	s = 0
	x = i
	while x <= n:
		s += n//x
		x *= i
	ans *= (s+1)
	ans %= mod
print (ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=1e5+4;

int main()
{	
	int n; scn(n);

	ll a[n],xor_sum=0;

	rep(i,0,n)
	{
		lscn(a[i]);

		if(i>1)
		xor_sum^=a[i];
	}

	if((a[0]^a[1])==xor_sum)
	{
		pri(0); return 0;
	}

	ll val=a[0]+a[1]-xor_sum;

	if(val<0 or val%2==1)
	{
		pri(-1); return 0;
	}

	ll must_have = (a[0]+a[1]-xor_sum)/2;

	if((xor_sum & must_have) != 0)
	{
		pri(-1); return 0;
	}

	// cout<<must_have<<" "<<xor_sum<<endl;

	for(int i=40;i>=0;i--)
	if(xor_sum&(1LL<<i) and must_have+(1LL<<i) <= a[0])
	must_have+=(1LL<<i);

	// cout<<xor_sum<<" "<<must_have<<endl;

	if(must_have > a[0] or must_have==0)
	{
		pri(-1); return 0;
	}

	lpri(a[0]-must_have);

	return 0;
}                   

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

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int mini = 0;

    if (A + B >= N)
    {
        mini = (A + B) - N;
    }

    cout << min(A, B) << " " << mini << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cmath>
#include <iostream>
#include <iomanip>

using namespace std;
int main(void){
    double r;
    cin >> r;
    
    double area = M_PI * r * r;
    double circumference = 2 * M_PI * r;
    
    cout << fixed << setprecision(6);
    cout << area << " " << circumference << endl;
    
    return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define il inline
#define vd void
#define mod 1000000007
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int f[3010][3010][2];
il int add(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int main(){
	int n=gi(),m=gi();
	f[0][0][1]=1;for(int i=1;i<=n;++i)f[0][i][0]=1;
	for(int i=0;i<m;++i)
		for(int j=0;j<=n;++j)
			for(int k=0;k<2;++k){
				if(j)add(f[i+1][j][k|(j==1)],f[i][j][k]);//黑换黑
				if(j^n)add(f[i+1][j][k],f[i][j][k]);//白换白
				if(j)add(f[i+1][j-1][k|(j==1)],f[i][j][k]);//黑换白
				if(j^n)add(f[i+1][j+1][k],f[i][j][k]);//白换黑
			}
	int ans=0;
	for(int i=0;i<=n;++i)add(ans,f[m][i][1]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 70784
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){

    ll X = 0;
    cin >> X;

    vector<ll > dp(100010, -1);
    dp[0] = 0;

    vector<ll > product(6, 0);
    product[0] = 100;
    product[1] = 101;
    product[2] = 102;
    product[3] = 103;
    product[4] = 104;
    product[5] = 105;

    for(ll i = 0; i < 100001; i++){
        if(dp[i] != -1){
            for(ll j = 0; j < 6; j++){
                if(i + product[j] <= 100001){
                    dp[i+product[j]] = max(dp[i]+1, dp[i+product[j]]);
                }
            }
        }
    }

    if(dp[X] == -1){
        cout << "0" << endl;
    }else{
        cout << "1" << endl;
    }

}

Measured memory_bytes: 1024