akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
int const N = 1e6+5;
int const mod = 1e9+7;
using namespace std;

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll counter=0;
void prime_fuct(ll x){
    for (ll i = 2; i * i <= x; i++){
        if(x%i==0){
            while (x % i == 0){
                x /= i;
            }
            counter++;
        }
    }
    if(x != 1){
            counter++;
    }
    cout<<counter+1;
}

void solve(){
	ll a,b;
    cin>>a>>b;
    prime_fuct(gcd(a,b));
}

int main()
{
  int t;
	t=1;
     while(t--)
    {

		solve();

    }
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  int n,k;
  cin>>n>>k;
  int ans=0;
  for(int i=k;i<=n+1;i++)
  {
    int z=((n*(n+1))/2)%mod;
    z-=(((n-i)*(n-i+1))/2)%mod;
    z+=mod;
    z%=mod;
    int z2=((i*(i-1))/2-1+mod)%mod;
    ans+=(z-z2+mod)%mod;
    ans%=mod;
  }
  cout<<ans;
 
// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

class disjoint_set {
    vector<int> p;
public:
    int count;
    disjoint_set(int n) : p(n, -1), count(0) {}
    int root(int i) { return p[i] >= 0 ? p[i] = root(p[i]) : i; }
    bool same(int i, int j) { return root(i) == root(j); }
    int size(int i) { return -p[root(i)]; }
    void merge(int i, int j) {
        count++;
        i = root(i), j = root(j);
        if (i == j) return;
        if (p[i] > p[j]) swap(i, j);
        p[i] += p[j], p[j] = i;
    }
    int size(int i, int j) {
        if(same(i,j)) return size(i);
        else return size(i) + size(j);
    }
};

int main(){
    int N,M; cin >> N >> M;
    vector<ll> p(N);
    rep(i,N){
        cin >> p[i];
        p[i]--;
    }

    vector<ll> x(M),y(M);
    rep(i,M){
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }

    disjoint_set uf(N);
    rep(i,M){
        uf.merge(x[i],y[i]);
    }

    int ans = 0;
    rep(i,N){
        if(uf.same(i,p[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;

#define L 1000000000

int main(){
	int n, k;
	cin>>n>>k;
	vector<vector<int>> a(n);
	rep(i, n) a[i]=vector<int>(n);
	rep(i, n) rep(j, n) cin>>a[i][j];

	vector<string> s(n);
	rep(i, n) rep(j, n) s[i]+=".";

	mcf_graph<int, ll> g;
	int hb=2, vb=hb+n, ab=vb+n;
	auto build=[&]{
		g=mcf_graph<int, ll>(n*n+n+n+2);
		rep(i, n) g.add_edge(0, hb+i, k, 0);
		rep(i, n) rep(j, n) g.add_edge(hb+i, ab+(i*n+j), 1, L-a[i][j]);
		rep(i, n) rep(j, n) g.add_edge(ab+(i*n+j), vb+j, 1, 0);
		rep(j, n) g.add_edge(vb+j, 1, k, 0);
	};

	build();
	auto vp=g.slope(0, 1);
	ll mx=0, mf;
	for(auto p : vp){
		ll c=(ll)p.first*L-p.second;
		if(c>mx){
			mx=c;
			mf=p.first;
		}
	}

	build();
	g.flow(0, 1, mf);
	for(auto e : g.edges()) if(hb<=e.from && e.from<hb+n){
		int i=(e.to-ab)/n, j=(e.to-ab)%n;
		if(e.flow) s[i][j]='X';
		else s[i][j]='.';
	}

	cout<<mx<<endl;
	rep(i, n) cout<<s[i]<<endl;
	return 0;
}


Measured memory_bytes: 4312
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]

idx_flag = True

for i in range(N):
  if xyh[i][2] > 0:
    idx_flag = False
    idx = i
    break

if idx_flag:
  H = 1
  for i in range(101):
    for j in range(101):
      flag = True
      for k in range(N):
        cnt = 1 - abs(i-xyh[k][0]) - abs(j-xyh[k][1])
        if cnt > 0:
          flag = False
      if flag:
        print(i, j, H)
        exit(0)

for i in range(101):
  for j in range(101):
    flag = True
    h = abs(i-xyh[idx][0]) + abs(j-xyh[idx][1]) + xyh[idx][2]
    for k in range(N):
      cnt = abs(i-xyh[k][0]) + abs(j-xyh[k][1]) + xyh[k][2]
      if xyh[k][2] == 0:
        if cnt > h:
          continue
      if h != cnt:
        flag = False
    if flag:
      print(i, j, h)
      exit(0)

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

#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)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */

int main() {
	int N,K;
	cin >> N >> K;
	ll ans = -1e12;

	static ll V[52] = {};
	static ll S[52] = {};
	FORq(i,1,N){
		cin >> V[i];
		S[i] = S[i-1] + V[i];
	}

	FORq(a,0,K){
		FORq(b,0,K){

			ll nans = 0;

			if (a+b > K) continue;
			if (a+b > N) continue;
			priority_queue<ll, vector<ll>, greater<ll> > Q;
			FORq(i,1,a){
				Q.push(V[i]);
				nans += V[i];
			}

			FORq(j,N-b+1,N){
				Q.push(V[j]);
				nans += V[j];
			}
			REP(i,K-a-b){
				if (Q.empty()) break;
				ll x = Q.top(); Q.pop();
				if (x > 0) break;
				nans -= x;
			}


			chmax(ans,nans);
		}
	}

	cout << ans << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int a;
 cin >> a;
 double b[a];
 double ans = 0;
 rep(i,a){
     cin >> b[i];
    ans += 1/b[i];
 }

cout<<fixed<<setprecision(14)<< 1/ans << endl;
return 0;
}

Measured memory_bytes: 256
<?php
  list($age, $fee) = explode(" ", fgets(STDIN));

  echo $fee*check_discount_fee($age);
  echo "\n";

  function check_discount_fee($age){
    if($age >= 13){
      return 1;
    }elseif($age >= 6){
      return 0.5;
    }else{
      return 0;
    }
  }
?>

Measured memory_bytes: 3828
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const M: i64 = std::i64::MAX;

fn main() {
    let (N, W) = read!(usize, i64);
    let T = read![i64, usize; N];
    let V = T.iter().map(|&(_, v)| v).sum::<usize>();

    // dp[i][v] = w : 品物 0..i の組み合わせで、価値の合計が v のとき、最小の重み w
    let mut dp = vec![vec![M; V + 1]; N + 1];
    dp[0][0] = 0;

    for i in 0..N {
        let (dw, dv) = T[i];

        for v in 0..V + 1 {
            dp[i + 1][v] = min(dp[i + 1][v], dp[i][v]);

            if dp[i][v] != M {
                let v2 = v + dv;
                if v2 <= V {
                    dp[i + 1][v2] = min(dp[i + 1][v2], dp[i][v] + dw);
                }
            }
        }
    }

    debug!(dp);

    let m = (0..V + 1)
        .rev()
        .filter_map(|v| {
            let w = dp[N][v];
            if w <= W {
                Some(v)
            } else {
                None
            }
        })
        .next()
        .unwrap();

    println!("{}", m)
}


Measured memory_bytes: 106748
N = int(input())
 
def divisor_num(n):
    ans = 0
    for i in range(1, n + 1):
        if n % i == 0:
            ans += 1
    return ans
 
ans = 0
for i in range(1, N + 1):
    if i % 2 != 0 and divisor_num(i) == 8:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 1000000000000000007
 
using namespace std;
#define prime 1000000007
 
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << endl;

pair<double, double> v[1010];

double de(pair<double, double> a, pair<double, double> b){
	return sqrt((a.ff-b.ff)*(a.ff-b.ff) + (a.ss-b.ss)*(a.ss-b.ss));
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		double x, y; cin >> x >> y;
		v[i] = {x, y};
	}

	double sum = 0;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < n; ++j){
			if(i == j) continue;
			sum += de(v[i], v[j]);
		}
	}
	cout << setprecision(10) << fixed << sum/((double)n) << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
W,H,M=[int(_) for _ in input().split()]
HW=[[int(_) for _ in input().split()]for i in range(M)]
yoko = [0]*W
tate = [0]*H
for hw in HW:
    yoko[hw[0]-1]+=1
    tate[hw[1]-1]+=1

my=max(yoko)
mt =max(tate)
ans = mt+my

cu=yoko.count(my)*tate.count(mt)
c = 0

for hw in HW:
    if yoko[hw[0]-1]==my and tate[hw[1]-1]==mt:
        c+=1
if c== cu:
    ans-=1
print(ans)


Measured memory_bytes: 125784
N, M, K, = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    # Aの机から０冊読んだ時の時間がa[0]、1冊読んだ時の時間がa[1]・・となるような配列
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M
# Aの机からi冊(0~N)読んだ時に、Bの机からj冊読めるか
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47500
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 1e5+5;
int N, a[MAX], pd[MAX];

int main(int argc, char ** argv) {
	pd[0] = (1 << 30);
	scanf("%d", &N);
	REP(i, 1, N) scanf("%d", &a[i]);
	REP(i, 2, N) {
		pd[i] = pd[i-1] + abs(a[i]-a[i-1]);
		pd[i] = min(pd[i], pd[i-2] + abs(a[i]-a[i-2]));
	}
	printf("%d\n", pd[N]);
	return 0;
}


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

int main()
{ 
	string s;
	cin >> s;
	string d[4] = { "dream","dreamer","erase","eraser" };
	for (int i = 0; i < 4; i++) {
		reverse(d[i].begin(), d[i].end());
	}
	reverse(s.begin(), s.end());
	bool flag = true;
	bool ans = true;
	while (flag) {
		bool f2 = false;
		for (int i = 0; i < 4; i++) {
			if (i == 0 || i == 2) {
				if (d[i] == s.substr(0, 5)) {
					f2 = true;
					s.erase(0, 5);
				}
			}
			else if (i == 1) {
				if (d[i] == s.substr(0, 7)) {
					f2 = true;
					s.erase(0, 7);
				}
			}
			else if(i==3){
				if (d[i] == s.substr(0,6)) {
					f2 = true;
					s.erase(0, 6);
				}
			}
		}
		if (f2 == false) {
			ans = false;
			flag = false;
		}
		if (s == "") {
			flag = false;
		}
	}
	if (ans==true) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define printF printf

using namespace std;

const int IINF = INT_MAX;
const int MAX_M = 10010;
int n,m,p,d[MAX_M],sum[MAX_M*3],sp;

void fix(){
  vector<int> arr;
  rep(i,m) arr.push_back(d[i]); 
  arr.push_back(p);
  sort(arr.begin(),arr.end());
  arr.erase(unique(arr.begin(),arr.end()),arr.end());
  m = arr.size();
  rep(i,m) d[i] = arr[i];
}

void ridiculous_initer(){
  sum[0] = 0;
  REP(i,1,m) sum[i] = sum[i-1] + abs(d[i]-d[(i-1+m)%m]);
  sum[m] = sum[m-1] + abs( n - d[m-1] ) + d[0];
  REP(i,1,m) sum[m+i] = sum[m+i-1] + abs(d[i]-d[(i-1+m)%m]);
  sum[2*m] = sum[2*m-1] + abs( n - d[m-1] ) + d[0];
  REP(i,1,m) sum[2*m+i] = sum[2*m+i-1] + abs(d[i]-d[(i-1+m)%m]);
}

int getCost(int ep){
  int mini = IINF;
  int eXsp = sp + m, eXep = ep + m;
  if( ep < sp ) { ep = eXep; eXep = ep + m; }
  int cost1,cost2;
  // left side
  cost1 = sum[eXsp] - sum[ep+1];
  cost2 = sum[eXep] - sum[eXsp];
  mini = min(mini,cost1*2+cost2);
  // right side
  cost1 = sum[eXep-1] - sum[eXsp];
  cost2 = sum[eXsp] - sum[ep];
  mini = min(mini,cost1*2+cost2);
  
  return mini;
}

void compute(){
  int eXsp = sp + m;
  int mini = IINF;
  rep(ep,m) if( ep != sp ) mini = min(mini,getCost(ep));
  if( mini == IINF ) mini = 0;
  printF("%d\n",mini*100);
}

int main(){
  scanf("%d %d %d",&n,&m,&p);
  rep(i,m) scanf("%d",d+i);

  fix();
  sp = -1;
  rep(i,m) if( d[i] == p ) { sp = i; break; }
  assert( sp != -1 );
  
  ridiculous_initer();
  
  compute();

  return 0;
}

Measured memory_bytes: 1472
#include<stdio.h>
int main(){
	char m[16]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
	char n;
	int ans=0;
	for(int i=0;i<16;i++){
		scanf("%c",&n);
		if(n!=m[i]){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

int n;
vector<long>dp;
vector<vector<long>>x(n, vector<long>(n));
long ans=0;
long mod = 1000000007;

void comb(int n,int r,int count,int point) {
	static long index[21];
	if (point > n)return;
	if (count == r) {

		int p = 0;
		for (int i = 0; i < r; i++) {
			p += (1 << index[i]);
		}
		for (int i = 0; i < n; i++) {
			int l = p & ~(1 << i);
			if (p!=l && x.at(r-1).at(i)==1) {
				dp.at(p) = (dp.at(p)+dp.at(l))%mod;
			}
		}
		return;
	}
	index[count] = point;
	comb(n, r, count+1, point + 1);
	comb(n, r, count, point + 1);
}

int main()
{
	cin >> n;
	x=vector<vector<long>>(n,vector<long>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> x.at(i).at(j);
		}
	}
	dp = vector<long>(1 << n, 0);
	dp.at(0) = 1;
	for (int i = 1; i <= n; i++) {
		comb(n, i, 0, 0);
	}
	cout << dp.at((1 << n) - 1) << endl;
}

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

int main(){
  int ans=0;
  int shorti=0;
  for(int i=0; i<5; i++){
    int A;
    cin >> A;
    ans+=(A+9)/10*10;
    if(A%10!=0) shorti=max(shorti, 10-A%10);
  }
  ans=ans-shorti;
  cout << ans << endl;
}

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

class node {
public:
	int d = -1, f = -1, k, v[100];
};

int cnt = 1;
node V[101];

void Serch(int u) {
	V[u].d = cnt; cnt++;

	for (int i = 0; i < V[u].k; i++) {
		if (V[V[u].v[i]].d < 0) {
			Serch(V[u].v[i]);
		}
	}

	V[u].f = cnt; cnt++;
}

int main() {
	int n, u;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u; cin >> V[u].k;
		for (int j = 0; j < V[u].k; j++) {
			cin >> V[u].v[j];
		}
	}

	for (int i = 1; i <= n; i++) {
		if (V[i].d < 0) Serch(i);
	}

	for (int i = 1; i <= n; i++) cout << i << " " << V[i].d << " " << V[i].f << endl;
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 100007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 1e6+1;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846



signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    string s;
    cin>>s;
    if(s=="ARC"){
    	cout<<"ABC"<<endl;
    }
    else{
    	cout<<"ARC"<<endl;
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, R; cin >> N >>R;
    if(N>=10) cout << R << endl;
    else {
        cout << R + 100*(10-N) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

string s, t;
bool ok;
void f(int depth, string &ret) {
	if (depth == 0)return;
	f(depth - 1, ret);
	for (auto &it : t) {
		ret += it;
		if (ret.size() > s.size()) {
			ok = false;
			return;
		}
		f(depth - 1,ret);
	}
}
string g(int depth) {
	ok = true;
	string ret = "";
	f(depth, ret);
	if(ok)return ret;
	else return "";
}
bool check(string x) {
	if (x.size() == 0)return false;
	int n = s.size();
	int m = x.size();
	int j = 0;
	for (int i : range(n)) {
		if (s[i] == x[j])j++;
		if (j == m)return true;
	}
	return false;
}
int main() {
	while (cin >> s >> t) {
		int ub = s.size() + 1;
		int lb = 0;
		while (ub - lb > 1) {
			const int mid = (lb + ub) / 2;
			string x = g(mid);
			(check(x) ? lb : ub) = mid;
		}
		cout << lb << endl;
	}
	return 0;
}



Measured memory_bytes: 6576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	string S;
  	cin>>S;
  	int count=0;
  	rep(i,S.size()-1){
     	 if(S[i]!=S[i+1]) count++;
    }
  	cout<<count<<endl;
}

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

N,M = map(int, input().split())

# E[i] := 頂点 i と結ばれている頂点の集合
E = [set() for _ in range(N+1)]
for _ in range(M):
    a,b = map(int, input().split())
    E[a].add(b)
    E[b].add(a)

ans = 0

# まだ訪れていない頂点を訪れていき、全て訪問できたら +1.
# 現在地 n, 次の候補の集合 nexts, 訪問済みの集合 visited
def dfs(n, nexts, visited):
    v = visited + [n]
    if len(v) == N:
        global ans
        ans += 1
    else:
        for i in nexts:
            dfs(i, set([j for j in E[i] if j not in v]), v)

def main():
    dfs(1, E[1], [])
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
 
int v[10000], w[10000];
int dp[10001];
int main(){
    int N, W, ans = 0; cin >> N >> W;
    for(int i=0; i<N; i++) cin >> v[i] >> w[i];
    for(int i=0; i<N; i++) {
        for(int j=W; j>=0; j--) {
            if(j-w[i] >= 0) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
            ans = max(ans, dp[j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3128
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = stdin.readline().rstrip()
    K = II() - 1
    ans = []
    for i in range(len(s)):
        for k in range(K+1):
            b = s[i:i + k + 1]
            ans.append(b)
    ans = list(set(ans))
    ans.sort()
    print(ans[K])
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


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

void dfs_init();
void dfs(int u);

int n,**List,*deg,*d,*f;
bool **M;
string *color;
int vertex;
int tm;

int main(){
	cin>>n;
	List = new int*[n]; M = new bool*[n]; deg = new int[n]; color = new string[n]; d = new int[n]; f = new int[n];
	for(int i=0;i<n;i++) List[i] = new int[n]; for(int i=0;i<n;i++) M[i] = new bool[n];
	for(int i=0;i<n;i++){
		List[i] = List[i]-1;
		M[i] = M[i]-1;
	}
	List = List-1; M = M-1; deg = deg-1; color = color-1; d = d-1; f = f-1;

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)
			M[i][j] = false;
		deg[i] = 0; d[i] = 0; f[i] = 0;
	}
	
	int k;
	for(int i=1;i<=n;i++){
		cin>>vertex>>k;
		for(int j=1;j<=k;j++){
			cin>>List[vertex][j];
			M[vertex][List[vertex][j]] = true;
		}
	}

	dfs_init();

	for(int i=1;i<=n;i++){
		cout<<i<<" "<<d[i]<<" "<<f[i]<<endl;
	}

	for(int i=1;i<=n;i++){
		delete [] (List[i]+1); delete [] (M[i]+1);
	}
	delete [] (List+1); delete [] (M+1);
	delete [] (deg+1); delete [] (color+1); delete [] (d+1); delete [] (f+1);
	cin.get(); cin.get();
}

void dfs_init(){
	for(int i=1;i<=n;i++) color[i] = "WHITE";
	tm = 0;
	for(int i=1;i<=n;i++){
		if(color[i]=="WHITE"){
			dfs(i);
		}
	}
}

void dfs(int u){
	color[u] = "GRAY";
	d[u] = ++tm;
	for(int v=1;v<=n;v++){
		if(M[u][v]==false) continue;
		if(color[v]=="WHITE"){
			dfs(v);
		}
	}
	color[u] = "BLACK";
	f[u] = ++tm;
}

Measured memory_bytes: 3208
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = B[A[0] - 1]

for idx in range(1, N):
    ans += B[A[idx] - 1]
    if (A[idx] - A[idx - 1]) == 1:
        ans += C[A[idx - 1] - 1]

print(ans)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

class Main{

	static char[][] map;
	//	static int N;
	//	static int M;
	static boolean flag;
	static int ans;



	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		int N =sc.nextInt();

		int[] X = new int[N];


		for(int i = 0;i < N;i++){
			X[i] = sc.nextInt();
		}
		int[] sub = X.clone();
		Arrays.sort(sub);


		for(int i = 0;i < N;i++){
			if(sub[N/2] > X[i] )

				System.out.println(sub[N/2]);
			else{
				System.out.println(sub[(N/2)-1]);

			}
		}
	}



}




class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 93196
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string s;
    rep(i,tx-sx) s+='R';
    rep(i,ty-sy) s+='U';
    rep(i,tx-sx) s+='L';
    rep(i,ty-sy) s+='D';
    s+='D';
    rep(i,tx-sx+1) s+='R';
    rep(i,ty-sy+1) s+='U';
    s+='L';s+='U';
    rep(i,tx-sx+1) s+='L';
    rep(i,ty-sy+1) s+='D';
    s+='R';
    cout<<s<<endl;
    return 0;
}

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

using namespace std;
const int MAXN = 500;
int H, W, h, w;

int a[MAXN][MAXN];
int main() {
    ios_base::sync_with_stdio(0);
    cin >> H >> W >> h >> w;

    int l = (W/w) * (H/h);

    if (l * w * h == W * H) { 
        cout << "No\n";
        return 0;
    }

    int p = W*H - l*w*h;
    int K = l/p + 1;
    int L = -(w*h-1)*K-1;

    cout << "Yes\n";
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if ((i+1)%h == 0 && (j+1)%w == 0) cout << L << " ";
            else cout << K << " ";
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

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

  ll ans = 0;
  for (int i = n-1; i >= 0; i--) {
    ll remainder = (a[i] + ans) % b[i];
    if (remainder == 0) continue;
    else ans += b[i] - remainder;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 1792
s=list(input())
t=input()

fin=[]

flag=0
for i in range(len(s)-len(t)+1):
    if(s[i]==t[0] or s[i]=='?'):
        ind=0
        f=1
        for j in range(i,i+len(t)):
            if(s[j]!='?' and s[j]!=t[ind]):
                f=0
                break
            ind+=1
        ind=0
        temp = s[:]
        if(f==1):
            flag=1
            for j in range(i,i+len(t)):
                if(s[j]=='?'):
                    temp[j]=t[ind]
                ind+=1
            fin.append(temp)
if(flag==0):
    print('UNRESTORABLE')
else:
    for i in range(len(fin)):
        for j in range(len(fin[i])):
            if(fin[i][j]=='?'):
                fin[i][j]='a'
    fin.sort()
    print(''.join(fin[0]))


Measured memory_bytes: 3064
#include<stdio.h>

#define MAX_SIZE (1200)
#define MAX_ALPHABET_SIZE (26)

int main(void)
{
        char str[MAX_SIZE];

        int i;
        int alphabet_count[MAX_ALPHABET_SIZE] = {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        };

        while(scanf("%s", str) != EOF){

                for(i=0; i < MAX_SIZE; i++){
                        if(str[i] == '\0'){
                                break;
                        }

                        if((0x40 < str[i] && str[i] < 0x5b)
                                ||(0x60 < str[i] && str[i] < 0x7b)){
                                alphabet_count[(str[i] & 0x1f) - 1]++;
                        }
                }
        }

        for(i=0; i < MAX_ALPHABET_SIZE; i++){
                printf("%c : %d\n", 'a' + i, alphabet_count[i]);
        }

        return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  string s;
  cin>>s;
  vector<char> c;
  for(int i=0;i<(int)s.size();i++) 
    c.push_back(s[i]);
  reverse(c.begin(),c.end());
  for(int i=0;i<(int)s.size();i++) 
    cout<<c[i];
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3116
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

count=0
for i in range(0,N-2):
    if x[i]==y[i]:
        if x[i+1]==y[i+1]:
            if x[i+2]==y[i+2]:
                count = count+1
            else:
                pass
        else:
            pass
    else:
        pass

if count>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9196
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>

using namespace std;
using LLI = long long int;

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//int gcd(int x, int y) {
//	int tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

int main(void) {
	string S;
	cin >> S;
	int cnt1 = 0, cnt0 = 0,res = 0;
	for (int i = 0; i < S.size();i++) {
		if (S[i] == '0') {
			cnt0++;
		}
		else {
			cnt1++;
		}
	}
	if (cnt1 >= cnt0) {
		res = S.size() - (cnt1 - cnt0);
	}
	else
	{
		res = S.size() - (cnt0 - cnt1);
	}
	if (S.size() == 1) {
		cout << 0 << endl;
	}
	else {
		cout << res << endl;
	}
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){


	int x, y, z; cin >> x >> y >> z;

	swap(x, y);
	swap(x, z);

	cout << x << ' ' << y << ' ' << z << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import math

def main():
    N = int(input())
    ans = False
    for i in range(N+1):
        x = math.floor(i * 1.08)
        if x == N:
            print(i)
            ans = True
            break
    if not ans:
        print(':(')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main{
    final static long mod = 1000000007;
    //
    public static void main(String[] args){
        Scanner sc= new Scanner(System.in);
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    double c = sc.nextDouble();
    double d = b - c / a / a;
    if(2 * d <= b){
        double ans = Math.atan(2 * d / a) / Math.PI * 180;
        System.out.println(ans);
    }else{
        double ans = 90 - Math.atan((c / (a * a * b / 2) * a) / b) / Math.PI * 180; 
        System.out.println(ans);
    }
    }
    
}



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

int main()
{
	int64_t n, m;
	cin >> n >> m;
	vector<int64_t> as(m), bs(m);
	for (int64_t i = 0; i < m; i++)
	{
		cin >> as[i] >> bs[i];
		as[i]--;
		bs[i]--;
	}

	dsu d(n);
	for (int64_t i = 0; i < m; i++)
	{
		d.merge(as[i], bs[i]);
	}

	cout << max<int64_t>(0, int64_t(d.groups().size()) - 1) << endl;

	return 0;
}

Measured memory_bytes: 9104
from math import factorial


def get_rank(l, n):
    s = 0
    es = set(range(1, n + 1))
    for i, e in enumerate(l):
        s += len([j for j in es if j < e]) * factorial(n - (i + 1))
        es -= set([e])
    return s + 1


def main():
    n = int(input())
    p = [int(i) for i in input().split(' ')]
    q = [int(i) for i in input().split(' ')]

    print(abs(get_rank(p, n) - get_rank(q, n)))


main()


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int k;
    string s;
    cin>>k>>s;
    if(s.size()>k){
        rep(i,k){
            cout<<s[i];
        } 
        cout<<"...";
        }
    else cout<<s;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3628
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7
import heapq

def main():
    N, M = MAP()
    A = [-int(i) for i in input().split()]
    heapq.heapify(A)
    for mm in range(M):
        minv = heapq.heappop(A)
        heapq.heappush(A, minv / 2)
    print(sum([int(x) for x in A]) * -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95360
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=101234;

int n,a[nmax],b[nmax];
ll res;
vector<pair<int,int> > v2;

bool cmp(pair<int,int>& a,pair<int,int>& b){
    return a.first>b.first;
}


int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d %d",&a[i],&b[i]);
        v2.pb({a[i]+b[i],i});
    }
    sort(v2.begin(),v2.end(),cmp);
    for(int i=0;i<n;++i){
        if(i&1)
            res-=b[v2[i].second];
        else
            res+=a[v2[i].second];
    }
    printf("%lld",res);
    return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	REP(i,N){
		cin >> a[i];
	}
	bool f=true;
	REP(i,N){
		if(a[i]%2==0){
			if(a[i]%3==0||a[i]%5==0){
				continue;
			}
			else{
				f=false;
			}
		}
	}
	if(f)cout <<"APPROVED"<<endl;
	else cout << "DENIED" <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

ll dp[60][60][3000];

int main() {
	int N, A;
	cin >> N >> A;
	vector<int> x(N);
	rep(i,N)
		cin >> x[i];
	sort(x.begin(), x.end());
	dp[0][0][0] = 1;
	rep(i,N) {
		rep(j,N) {
			rep(k,3000) {
				dp[i+1][j][k] += dp[i][j][k];
				if(x[i] + k < 3000)
					dp[i+1][j+1][k+x[i]] += dp[i][j][k];
			}
		}
	}

	ll res = 0;
	rep(i,N) {
		res += dp[N][i+1][A*(i+1)];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 60160
n = int(input())
dict = {}
for _ in range(n):
    s = [x for x in input()]
    s.sort()
    s = "".join(s)
    dict[s] = dict.get(s, 0) + 1
ans = 0
for k in dict:
    v = dict[k]
    ans += int(v * (v-1) /2)
print(ans)

Measured memory_bytes: 101888
using System;
using System.Linq;

namespace A___Libra
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_B_C_D = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = A_B_C_D[0];
            var B = A_B_C_D[1];
            var C = A_B_C_D[2];
            var D = A_B_C_D[3];

            Console.WriteLine(A + B == C + D ? "Balanced" : (A + B > C + D ? "Left" : "Right"));
        }
    }
}


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

int main(){
    string s;
    int licznik = 0;
    cin >> s;
    for(int i=0; i<s.length(); i+=2) {
        if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
            licznik++;
        }
    }
    for(int i=1; i<=s.length(); i+=2) {
        if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
            licznik++;
        }
    }
    if(licznik == s.length()) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

long calc_floor_max(long A, long B, long N);

int main(void) {
    long A, B, N;
    
    std::cin >> A >> B >> N;
    std::cout << calc_floor_max(A, B, N) << std::endl;
    
    
    
    return 0;
}

long calc_floor_max(long A, long B, long N) {
    long p_A, r_A, r_x;
    
    p_A = A / B;
    r_A = A % B;
    
    if(N < B) {
        r_x = N;
    } else {
        r_x = B - 1;
    }
    
    return p_A*r_x + std::floor(r_A*r_x/B);
}


Measured memory_bytes: 3592
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 5e5 + 5;
const int M = 17 + 5;
const int W = 1000 + 5;
const int OO = 2e9;
const int mod = 1e9 + 7;

int n,a[N],b[N],cnt;

void init() {
}

int main() {

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

    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }

    sort(b,b+n);

    for (int i = 0; i < n; ++i) {
        if(a[i]!=b[i]) ++cnt;
    }

    cout << (cnt>2 ? "NO" : "YES") << '\n';

    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class BIT():
    def __init__(self, n, p):
        self.p = p
        i = 1
        while 2**i <= n:
            i += 1
        self.H = i
        self.N = 2**i
        self.A = [0] * self.N

    def find(self, i):
        r = 0
        while i:
            r += self.A[i]
            r %= self.p
            i -= i & (i-1) ^ i
        return r

    def update(self, i, x):
        while i < self.N:
            self.A[i] += x
            self.A[i] %= self.p
            i += i & (i-1) ^ i

    def total(self):
        return self.find(self.N-1)

    def query(self, a, b):
        return self.find(b-1) - self.find(a-1)

def main():
    rr = []

    def f(a,b,p):
        aa = list(range(a,b+1))
        sa = sorted(map(str,aa))
        l = len(aa)
        d = {}
        for s,i in zip(sa, range(l)):
            d[int(s)] = i

        seg = BIT(l+2, p)
        for c in aa:
            t = seg.find(d[c]+1)
            seg.update(d[c]+1, (t+1) % p)

        return seg.total() % p

    while 1:
        n,m,l = LI()
        if n == 0:
            break
        rr.append(f(n,m,l))

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 39732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int N;
    cin >> N;
    int ls[128] = {};
    REP (i, 0, N) {
        char c;
        cin >> c;
        ls[c]++;
    }
    int ans = 0;
    for (int a : ls) {
        ans += (a > 0);
    }
    cout << (ans == 3 ? "Three" : "Four") << endl;
    return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
s = x+y
if s%3 !=0:
    print(0)
    exit()
kai = s // 3
p = x - kai
q = y - kai

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(kai,p,mod)

print(a)

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

vector<vector<int>> G;

int dp[100001];

int grundy(int v, int pre)
{
    if (~dp[v]) return dp[v];

    int g = 0;
    for (auto u : G[v]) {
        if (u == pre) continue;
        g ^= (grundy(u, v) + 1);
    }

    return dp[v] = g;
}


int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    G.resize(N);
    rep(i, N-1) {
        int X, Y;
        cin >> X >> Y;
        X--, Y--;
        G[X].push_back(Y);
        G[Y].push_back(X);
    }

    memset(dp, -1, sizeof(dp));
    cout << (grundy(0, -1) != 0 ? "Alice" : "Bob") << endl;
}

Measured memory_bytes: 12416