akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int  check(const long long int a,const vector<long long int>&leads, const vector<long long int >&scores) {
	vector<pair<int, int>>ps;
	for (auto l : leads) {
		auto it = lower_bound(scores.begin(), scores.end(), l - a);
		auto jt = upper_bound(scores.begin(), scores.end(), l);
		ps.emplace_back(it - scores.begin(), jt - scores.begin());
	}
	int amax = 0;
	int ans = 0;
	for (auto p : ps) {
		if (amax <= p.first) {
			ans += p.second - p.first;
		}
		else {
			ans += p.second - amax;
		}
		amax = p.second;
	}
	return ans;
}
int main() {
	int N, Q; cin >> N >> Q;
	vector<long long int>scores(N);
	for (int i = 0; i < N; ++i) {
		cin >> scores[i];
	}
	vector<long long int >sorted_scores(scores);
	sort(sorted_scores.begin(), sorted_scores.end());
	vector<long long int>lead_scores;
	for (int i = 0; i < Q; ++i) {
		string st; cin >> st;
		int a; cin >> a; a--;
		if (st == "ADD") {
			lead_scores.push_back(scores[a]);
			sort(lead_scores.begin(), lead_scores.end());
		}
		else if (st == "REMOVE") {
			lead_scores.erase(find(lead_scores.begin(), lead_scores.end(), scores[a]));
		}
		else {
			a++;
			if (check(0, lead_scores, sorted_scores) >= N - a) {
				cout << 0 << endl;
			}
			else if (check(1e15, lead_scores, sorted_scores) < N - a) {
				cout << "NA" << endl;
			}
			else {
				long long int amin = 0;
				long long int amax = 1e13;
				while (amin + 1 != amax) {
					long long int amid = (amin + amax) / 2;
					if (check(amid, lead_scores, sorted_scores) >= N - a) {
						amax = amid;
					}
					else {
						amin = amid;
					}
				}
				cout << amax << endl;
			}
			
		}
	}
	return 0;
}

Measured memory_bytes: 18400
//~raam
//~created : Jun 04, 2020 - 3.29.11 PM IST

using namespace std;
#include "bits/stdc++.h"

#define ll long long

void solve(){
   int a, b, c, k;
   cin >> a >> b >> c >> k;
   if(k <= a){
      cout << k;
   }else
   if(k <= a + b){
      cout << a;
   }
   else{
      cout << (a - (k - (a + b)));
   }
}

int main(){

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

   int t; t=1;
   while(t--)solve();
}


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

int main() {
    long long int n;
    cin >> n;
    long long ans = n+1;
    for(int i=1;(1ll*i*i) <= n; i++)
    {
        if(n % i == 0)
            ans = min(ans, i + n / i);
    }
    cout << (ans-2);
    
    
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int h,i=1,c=0;
  cin>>h;
  while(h)
  {
    h=h/2;
    c=c+i;
    i=i*2;
  }
  cout<<c;
  return 0;
}

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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

// ベクトル要素の列挙
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}

// エラトステネスの篩による素数配列の出力
vector<int> Eratosthenes(int N){
  vector<int> p = {2};
  int sqrtN = sqrt(N);
  for(int i = 3; i <= N; i++){
    p.push_back(i);
    for (int j = 0; p.at(j) <= sqrtN; j++) {
      if(i%p.at(j) == 0) {
        p.pop_back();
        break;
      }
    }
  }
  return p;
}

int main() {
  ll n, k, x = 1, size = 0, spare;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> b(n+1, 0);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    if (a.at(x-1) <= 0) {
      break;
    }
    spare = x;
    x = a.at(x-1);
    a.at(spare-1) = -size;
    b.at(i) = x;
    size++;
  }
  if (k <= size) {
    cout << b.at(k-1) << endl;
    return 0;
  }
  k += a.at(x-1);
  k %= size+a.at(x-1);
  k -= a.at(x-1);
  if (k == 0) {
    k = size;
  }
  cout << b.at(k-1) << endl;
  return 0;
}


Measured memory_bytes: 6492
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void){
    ll n,ans=0;
    cin >> n;

    rep(i, n+1)
    {
        if(i%3==0||i%5==0)continue;
        ans+=i;
    }

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


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

int main() {
	ll n;
	while (cin >> n, n) {
		map<ll, ll>mp;
		map<ll, ll>pos;
		rep(i, n) {
			ll e, p, q; cin >> e >> p >> q;
			mp[e] += p*q; pos[e] = i;
		}
		vector<P>v;
		for (P i : mp)v.push_back(i);
		sort(v.begin(), v.end(), [&](P a, P b) {return pos[a.first] <= pos[b.first]; });
		bool flag = true;
		for (P i : v) {
			if (i.second >= 1000000) {
				cout << i.first << endl;
				flag = false;
			}
		}
		if (flag)puts("NA");
	}
}



Measured memory_bytes: 3172
n=int(input())
a1=["7","5","3"]
a2=[]
a3=[]
a4=[]
for i in range(len(str(n))-1):
    for j in range(len(a3)):
        a4.append(a3[j]+"3")
        a4.append(a3[j]+"5")
        a4.append(a3[j]+"7")
        a3.append(a3[j]+"3")
        a3.append(a3[j]+"5")
        a3[j]=a3[j]+"7"
    for j in range(len(a2)):
        if a2[j][1]=="3":
            a3.append(a2[j][0]+"3")
            a4.append(a2[j][0]+"3")
            a2.append([a2[j][0]+"5","3"])
            a2[j][0]=a2[j][0]+"7"
        if a2[j][1]=="5":
            a3.append(a2[j][0]+"5")
            a4.append(a2[j][0]+"5")
            a2.append([a2[j][0]+"7","5"])
            a2[j][0]=a2[j][0]+"3"
        if a2[j][1]=="7":
            a3.append(a2[j][0]+"7")
            a4.append(a2[j][0]+"7")
            a2.append([a2[j][0]+"5","7"])
            a2[j][0]=a2[j][0]+"3"
    for j in range(len(a1)):
        if a1[j][0]=="7":
            a2.append([a1[j]+"5","3"])
            a2.append([a1[j]+"3","5"])
            a1[j]=a1[j]+"7"
        if a1[j][0]=="5":
            
            a2.append([a1[j]+"7","3"])
            a2.append([a1[j]+"3","7"])
            a1[j]=a1[j]+"5"
        if a1[j][0]=="3":
            a2.append([a1[j]+"5","7"])
            a2.append([a1[j]+"7","5"])
            a1[j]=a1[j]+"3"
count=0
for i in reversed(range(0,len(a4))):
    if len(a4[i])<len(str(n)):
        break
    if int(a4[i])>n:
        count+=1
print(len(a4)-count)

Measured memory_bytes: 6816
#include<stdio.h>
int a[10000];
int main(){
int n;
int c=0;
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
}
int t;
int flag=1;
for(int i=0;flag;i++){
    flag=0;
    for(int j=n-1;j>i;j--){
        if(a[j-1]>a[j]){
              t=a[j];
              a[j]=a[j-1];
              a[j-1]=t;
            flag=1;
            c++;
        }
    }
}
for(int i=0;i<n;i++){
        if(i>0)printf(" ");
printf("%d",a[i]);
}
printf("\n%d\n",c);
return 0;
}

Measured memory_bytes: 2708
#include <iostream>
using namespace std;
int main() {
  int n;
  cin>>n;
  int a[100];
  int min=1000000000;
  int max=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    min=((min>a[i])?a[i]:min);
    max=((max<a[i])?a[i]:max);
  }
  cout<<(max-min);
  return 0;
}

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

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    if(h > w) {
        int tmp = h;
        h = w;
        w = tmp;
    }

    int ans = 0;
    while(1) {
        ans++;
        if(w * ans >= n) break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


void run_case() {
    LL a, b;
    cin >> a >> b;
    LL gcd = __gcd(a, b);
    int ans = 1;
    for(LL i = 2; i*i <= gcd; ++i) {
        if(gcd % i == 0) {
            ans++;
            while(gcd % i == 0) gcd /= i;
        }
    }
    if(gcd > 1) ans++;
    cout << ans;
}


int main() {
    //freopen("input", "r", stdin);
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

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

using namespace std;
using ll = long long;

const ll MAX = 1e6 + 7;
const ll MOD = 1e9 + 7;

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

// テーブルを作る前処理
void ncr_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll ncr(ll n, ll k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  ncr_init();

  ll n, k;
  cin >> n >> k;

  ll b = k;
  ll r = n - k;

  for (ll i = 1; i <= k; i++) {
    ll ans = ncr(r + 1, i) * ncr(b - i + i - 1, i - 1) % MOD;
    ans %= MOD;
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 27092
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main () {
    int b;
    cin>>b;
    map<int,int>mp;
    for(int i=0;i<b;i++){
        int a;
        cin>>a;
        mp[a]++;
        mp[a+1]++;
        mp[a-1]++;
    }
    int A=0;
    for(auto x:mp){
        A=max(A,x.second);
    }
    cout<<A<<endl;
    return 0;
}


Measured memory_bytes: 4736
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
left_minus = 0
right_minus = 0
for i in range(N - 1):
    left = A[i]
    right = A[i + 1]
    over = left + right - left_minus - x
    if over > 0:
        if over <= right:
            right_minus = over
        else:
            right_minus = right
            left_minus += over - right
    else:
        right_minus = 0

    ans += left_minus
    left_minus = right_minus

    if i == N - 2:
        ans+= left_minus

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(a,n);

  bool ok=true;
  sortall(a);
  if(n%2){
    rep(i,(n+1)/2){
      if(i==0){
        if(a[i]!=0) ok=false;
      } else {
        if(a[2*i-1]!=a[2*i] || a[2*i]!=2*i) ok=false;
      }
    }
  } else {
    rep(i,n/2){
      if(a[2*i]!=a[2*i+1] || a[2*i]!=2*i+1) ok=false;
    }
  }
  ll ans=1;
  rep(i,n/2){
    ans*=2;
    ans%=MOD;
  }

  prt((ok ? ans : 0));
}


Measured memory_bytes: 640
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: i64 = input();
    let mut ab: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            let a = input();
            let b = input();
            (a, b)
        })
        .collect();
    ab.sort_by_key(|&(a, b)| a);

    let mut cnt = 0;
    let mut ans = 0;
    for (a, b) in ab {
        cnt += b;
        if cnt >= k {
            ans = a;
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String W=" "+br.readLine().toLowerCase()+" ";
        String T=" ",n;
        while(true){
        	n=br.readLine();
        	if(n.equals("END_OF_TEXT")) break;
        	T+=n+" ";
        }
    	T=T.toLowerCase();
        System.out.println(count(T,W));
	}
	
	private static int count(String str, String reg){
		int c=0,r=0;
		while(true){
		  c=str.indexOf(reg,c);
		  if(c==-1) break;
		  r++;
		  c++;
		}
		return r;
	}
}

Measured memory_bytes: 24516
n = int(input())
l = []
for i in range(n):
  l.append(list(map(int, input().split())))
l = sorted(l, key=lambda x: x[2], reverse=True)
for cx in range(101):
  for cy in range(101):
    flag = True
    cnt = 0
    for x, y, h in l:
      if not cnt:
        H =  h+abs(x-cx)+abs(y-cy)
        cnt = 1
      else:
        if h != max(H-abs(x-cx)-abs(y-cy), 0):
          flag = False
          break
    if flag:
      ans = [cx, cy, H]
      break
  if flag:
    break
    
print(*ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i, n) for (int i=0;i<(n);i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){ 
  int64_t N;
  cin >> N;
  int64_t t = 1;
  int64_t n = 1;
  int64_t e = 1;
  rep(i,N){
    t = t*10;
    t = t%MOD;

    n = n*9;
    n = n%MOD;

    e = e*8;
    e = e%MOD;

  }
  n = 2*n;
  n = n % MOD;
  t = t + e;
  t = t % MOD;
  t = t - n;
  t = t % MOD;
  if(t < 0) t += MOD;
  cout << t << endl;
  return 0;
}




Measured memory_bytes: 3628
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        ab: [(usize1, usize1); n - 1],
        c: [i64; n],
    }
    let mut c = c;
    c.sort();
    let mut g = vec![vec![]; n];
    let mut deg = vec![0; n];
    for &(a, b) in &ab {
        g[a].push(b);
        g[b].push(a);
        deg[a] += 1;
        deg[b] += 1;
    }
    let mut ans = vec![0; n];
    let mut alive = vec![true; n];
    let mut que = VecDeque::new();
    for i in 0..n {
        if deg[i] == 1 {
            que.push_back(i);
        }
    }
    let mut pos = 0;
    let mut tot = 0;
    while let Some(v) = que.pop_front() {
        ans[v] = c[pos];
        if pos >= n - 1 { break; }
        tot += c[pos];
        pos += 1;
        alive[v] = false;
        for &w in &g[v] {
            deg[w] -= 1;
            if deg[w] == 1 {
                que.push_back(w);
            }
        }
    }
    puts!("{}\n", tot);
    for i in 0..n {
        puts!("{}{}", ans[i], if i + 1 == n { "\n" } else { " " });
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main() {
  int N;
  int A , B , C;
  cin >> N;
  C = N / 100;
  N = N % 100;
  B = N / 10;
  N = N % 10;
  A = N;
  cout << A * 1 + B * 1 + C * 1 << endl;
}

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

int X, Y, Z, V[5], e[51], a[51];
// dp[マス][お金] := 確率
double dp[51][5000];

int main(){
	while( cin >> X >> Y >> Z, X || Y || Z ){
		// 初期化
		for(int i = 0; i < 51; i++){
			e[i] = a[i] = 0;
			for(int j = 0; j < 5000; j++){
				dp[i][j] = 0.0;
			}
		}
		
		for(int i = 0; i < X; i++) cin >> V[i];
		for(int i = 0; i < Z; i++){
			int N, E, A;
			cin >> N >> E >> A;
			e[N] = E;
			a[N] = A;
		}
		
		dp[0][0] = 1.0;
		for(int i = 0; i < Y ; i++){
			for(int j = 0; j < 5000; j++){
				if( dp[i][j] > 0.0 ){
					for(int k = 0; k < X; k++){
						int next = i + V[k], next_money = j;
						
						if( e[next] == 1 ){
							next += a[next];
						}else if( e[next] == 2 ){
							next_money += a[next];
						}else if( e[next] == 3 ){
							next_money -= a[next];
						}
						
						if( next_money < 0 ) next_money = 0;
						if( Y <= next ) next = Y;
						
						dp[next][next_money] += dp[i][j] * (1.0 / X);
					}
				}
			}
		}
		double res = 0.0;
		for(int i = 0; i < 5000; i++) res += i * dp[Y][i];
		cout << ((int)floor(res)) << endl;
	} 
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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

	
	int N;
	cin >> N;

	int G = 0;
	rep(i, N) {
		int A, K;
		cin >> A >> K;
		while (A % K) {
			int kari = (A + K - 1) / K;
			int amari = A % K;
			int hiku = (amari + kari - 1) / kari * kari;
			A -= hiku;
		}
		G ^= A / K;
	}
	
	if (G) co("Takahashi");
	else co("Aoki");

	Would you please return 0;
}

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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;

const string YES = "No";

const string NO = "No";

const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll ans = 0;

void solve(long long N, std::vector<long long> d) {
    sort(all(d));
    auto dd = unique(all(d));
    d.erase(dd, d.end());
    cout << d.size() << '\n';
}
signed main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> d(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &d[i]);
    }
    solve(N, std::move(d));

    return 0;
}


Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;
using System.Text.RegularExpressions;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var s = cin.Read;
            var s2 = s + s;
            var p = new Regex(cin.Read);
            Console.WriteLine(p.IsMatch(s2) ? "Yes" : "No");
        }
    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 23508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>
 
using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;
 
const double PI = acos(-1);
const double EPS = 1e-9;
 
const int MX = 10005;
const int MM = 998244353;
 
ll F[MX], I[MX], IF[MX];
 
int main()
{
	I[1] = 1;
	for(int i = 2; i < MX; i++) I[i] = (MM - MM/i) * I[MM%i] % MM;
	F[0] = IF[0] = 1;
	for(int i = 1; i < MX; i++){
		F[i] = F[i-1] * i % MM;
		IF[i] = IF[i-1] * I[i] % MM;
	}
 
	string A, B;
	cin >> A >> B;
 
	int a = 0, b = 0;
	for(int i = 0; i < A.size(); i++){
		if( A[i] == '1' && B[i] == '1' ) a++;
		if( A[i] != B[i] ) b++;
	} b /= 2;
 
	vector<int> Y(MX, 0);
 
	for(int i = 0; i <= b; i++){
		ll m = F[b] * IF[b-i] % MM * IF[i] % MM;
		if( (b-i)%2 ) m = MM-m;
		for(int j = 0; j <= a+b; j++){
			Y[j] = (Y[j] + m * IF[j]) % MM;
			m = m * i % MM;
		}
	}
 
	ll ans = 0;
	for(int i = b; i <= a+b; i++){
		ans = (ans + Y[i]) % MM;
	}
	ans = ans * F[a+b] % MM * F[a] % MM * F[b] % MM;
	printf("%lld\n", ans);
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){


  int a,b,c,d,e,f,j;
  int h[102],hai[102][102];

  scanf("%d",&a);
  for(b = 0; b < a; b++){
    scanf("%d%d",&h[b],&c);
  }

  h[a] = c;
  for(b = 1; b < a+1; b++){
    hai[b][b]=0;
  }

  for(d = 2; d < a+1; d++){
    for(b = 1; b < a-d+2;b++){
      e = b + d - 1;
      hai[b][e] = 1000000000;

      for(f = b; f <= e-1;f++){
	j = (hai[b][f]+hai[f+1][e]+h[b-1]*h[f]*h[e]);
	if(hai[b][e]>j){
	  hai[b][e] = j;
	}
      }
    }
  }
  printf("%d\n",hai[1][a]);
  return 0;
}



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

const int H = 100;
const int W = 100;
const int A = 10;
const int INF = 1 << 29;
const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, 1, 0, -1};
const int usep[4] = {3, 2, 1, 0};
const int useq[4] = {1, 0, 3, 2};

struct state{
  int x, y, d, p, q;
  state(int y=0, int x=0, int d=0, int p=0, int q=0):x(x),y(y),d(d),p(p),q(q){}
  bool operator < (const state &s) const {
    return (p+q) > (s.p+s.q);
  }
};

int h, w, a, sy, sx, gy, gx;
bool G[H][W];

bool check(int y, int x, int d){
  if(y < 0 || y >= h) return false;
  if(x < 0 || x >= w) return false;
  return !G[y][x] && (y != sy || x != sx || d != 0);
}

int solve(){
  bool f[H][W][4][A+1][A+1];
  priority_queue<state> pq;
  state u, u2;

  for(int i=0;i<h*w;i++) for(int j=0;j<4;j++) for(int k=0;k<=a;k++) for(int l=0;l<=a;l++) f[i/w][i%w][j][k][l] = false;
  
  /*
  for(int i=0;i<4;i++) {
    pq.push(state(sy, sx, i, 0, 0));
    f[sy][sx][i][0][0] = true;
  }
  */
  pq.push(state(sy, sx, 2, 0, 0));
  f[sy][sx][2][0][0] = true;

  while(!pq.empty()){
    u = pq.top();
    pq.pop();

    if(u.y == gy && u.x == gx) return u.p + u.q;

    u2 = state(u.y+dy[u.d], u.x+dx[u.d], u.d, u.p, u.q);
    if(check(u2.y, u2.x, u2.d) && !f[u2.y][u2.x][u2.d][u2.p][u2.q]) {
      f[u2.y][u2.x][u2.d][u2.p][u2.q] = true;
      pq.push(u2);
    }
    
    if(u.p < a && (u.y != sy || u.x != sx)){
      u2 = u;
      u2.d = usep[u.d];
      u2.y += dy[u2.d];
      u2.x += dx[u2.d];
      u2.p++;
      if(check(u2.y, u2.x, u2.d) && !f[u2.y][u2.x][u2.d][u2.p][u2.q]) {
        f[u2.y][u2.x][u2.d][u2.p][u2.q] = true;
        pq.push(u2);
      }
    }

    if(u.q < a && (u.y != sy || u.x != sx)){
      u2 = u;
      u2.d = useq[u.d];
      u2.y += dy[u2.d];
      u2.x += dx[u2.d];
      u2.q++;
      if(check(u2.y, u2.x, u2.d) && !f[u2.y][u2.x][u2.d][u2.p][u2.q]) {
        f[u2.y][u2.x][u2.d][u2.p][u2.q] = true;
        pq.push(u2);
      }
    }
  }
  return -1;
}

int main(){
  string str;
  while(cin >> h >> w >> a){
    for(int i=0;i<h;i++){
      cin >> str;
      for(int j=0;j<w;j++){
        G[i][j] = false;
        if(str[j] == 'S'){
          sy = i;
          sx = j;
          //G[i][j] = true;
        } else if(str[j] == 'G'){
          gy = i;
          gx = j;
        } else if(str[j] == '#'){
          G[i][j] = true;
        }
      }
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 5596
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

int main(){
  string s;
  cin>>s;
  bool b[26];
  for(int i = 0; i < 26; i++){
    b[i] = false;
  }
  for(int i = 0; i < s.length(); i++){
    if(b[s[i]-'a']){
      cout<<"no"<<endl;
      return 0;
    }
    else{
      b[s[i]-'a'] = true;
    }
  }
  cout<<"yes"<<endl;
  return 0;
}

  



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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n, m;
	ll ans = 1;
	ll x = 1;
	ll y = 1;
	ll z = 1;
	ll INF = 1000000007;
	ll a, b;

	cin >> n >> m;

	a = min(n, m);
	b = max(n, m);

	if (a + 1 < b) {
		ans = 0;
	}
	else if(a == b){
		REP(i, b) {
			x = (x * (i + 1)) % INF;
		}

		REP(i, a) {
			y = (y * (i + 1)) % INF;
		}

		ans = (x * y * 2) % INF;
	}
	else {
		REP(i, b) {
			x = (x * (i + 1)) % INF;
		}

		REP(i, a) {
			y = (y * (i + 1)) % INF;
		}

		ans = (x * y) % INF;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

void solve(){
    ll n,k;cin>>n>>k;
    vl a(n);rep(i,n)cin>>a[i];

    sort(all(a));

    ll hi=LINF;
    ll lo=-LINF;
    while(hi-lo>1){
        ll mid=(hi+lo)/2;
        ll sum=0;
        rep(i,n){
            if(a[i]>0){
                ll hi1=n;
                ll lo1=-1;
                while(hi1-lo1>1){
                    ll mid1=(hi1+lo1)/2;
                    if(a[i]*a[mid1]<=mid)lo1=mid1;
                    else hi1=mid1;
                }
                sum+=hi1;
                if(i<=lo1)sum--;
            }else{
                ll hi1=n;
                ll lo1=-1;
                while(hi1-lo1>1){
                    ll mid1=(hi1+lo1)/2;
                    if(a[i]*a[mid1]>mid)lo1=mid1;
                    else hi1=mid1;
                }
                sum+=n-hi1;
                if(i>=hi1)sum--;
            }
        }
        if(sum/2>=k)hi=mid;
        else lo=mid;
    }
    cout<<hi<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    solve();
}


Measured memory_bytes: 1792
N = int(input())
S = input()

posDevide = 1
maxMatchWordNum = 0

while posDevide <=  N - 1:
        arrayNum = 0
        matchWordNum = 0
        while arrayNum < posDevide:
                if arrayNum  == S.find( S[ arrayNum ], 0, posDevide):
                        matchWordNum = matchWordNum + 1 if  bool( S.count( S[ arrayNum ], posDevide, N )) else matchWordNum

                arrayNum += 1

        maxMatchWordNum = matchWordNum if matchWordNum > maxMatchWordNum else maxMatchWordNum
        posDevide += 1

print(maxMatchWordNum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

ll n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	ll m = -1;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) m = i;
	}
	string s1 = to_string(m), s2 = to_string(n/m);
	cout << max((int)s1.size(), (int)s2.size()) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define MAX_N 55
using namespace std;

const double EPS = 1e-10;
const double g = 9.8;

int N, V, X, Y;
int L[MAX_N], B[MAX_N], R[MAX_N], T[MAX_N];

double calc(double vy, double t){
  return vy * t - g * t * t /2;
}

double cmp(double lb, double ub, double a){
  if(a < lb + EPS) return -1;
  if(a > ub - EPS) return +1;
  return 0;
}

bool calc_qq(double a, double b, double c, double ans[]){
  double D =  b * b - 4 * a * c;
  if(D < 0 && D > -EPS) D = 0;
  if(D < 0) return false;
  ans[0] = (-b + sqrt(D)) / (2 * a);
  ans[1] = (-b - sqrt(D)) / (2 * a);
  return true;
}

bool check(double qx, double qy){
  double eq_ans[2];
  int a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
  int exist_ans = calc_qq(a, b, c, eq_ans);
  
  if(!exist_ans) return false;
  for(int k = 0; k < 2; k++){

    if(eq_ans[k] <= 0) continue;
    
    double t = sqrt(eq_ans[k]);
    double vx = qx / t, vy = (qy + g * t * t / 2) / t;
    
    double yt = calc(vy, X / vx);
    if(yt < Y - EPS) continue;

    bool ok = true;
    for(int i = 0; i < N; i++){
      //豚より右にある障害物はスキップ
      if(L[i] >= X) continue;
      //豚と鳥の間に障害物がある場合は駄目
      if(cmp(L[i], R[i], X) == 0 && Y <= T[i] && yt >= B[i])
        ok = false;
      //障害物の左右の辺を横断する場合は駄目
      int yL = cmp(B[i], T[i], calc(vy, L[i] / vx));
      int yR = cmp(B[i], T[i], calc(vy, R[i] / vx));
      if(yL == 0 || yR == 0) ok = false;
      //障害物の上下の辺を横断する場合は駄目
      if(abs(yL) == 1 && yL == -yR) ok = false;
      //障害物の底辺から入って底辺から出る場合は駄目
      if(yL < 0 && yR < 0){
        int xH = cmp(L[i], R[i], vx * (vy / g));
        int yH = cmp(B[i], T[i], calc(vy, vy / g));
        if(xH == 0 && yH >= 0) ok = false;
      }
    }
    if(ok) return true;
  }
  return false;
}

int main(){
  scanf("%d %d %d %d", &N, &V, &X, &Y);
  for(int i = 0; i < N; i++){
    scanf("%d %d %d %d", &L[i], &B[i], &R[i], &T[i]);
  }

  for(int i = 0 ; i < N; i++){
    R[i] = min(R[i], X);
  }

  bool ok = check(X, Y);
  for(int i = 0; i < N; i++){
    ok |= check(L[i], T[i]);
    ok |= check(R[i], T[i]);
  }

  puts(ok ? "Yes" : "No");
}


Measured memory_bytes: 2696
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e8;

int main(){
	while(1){
		int n,m,s,g1,g2;
		cin >> n >> m >> s >> g1 >> g2;
		if(n==0) break;
		
		vector<vector<int> > adj(n+1, vector<int>(n+1, inf));
		for(int i=1; i<=n; i++){
			adj[i][i] = 0;
		}
		for(int i=0; i<m; i++){
			int f,t,c;
			cin >> f >> t >> c;
			adj[f][t] = c;
		}
		for(int k=1; k<=n; k++){
			for(int i=1; i<=n; i++){
				for(int j=1; j<=n; j++){
					adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
				}
			}
		}
		
		int ans=inf;
		for(int i=1; i<=n; i++){
			ans = min(ans, adj[s][i]+adj[i][g1]+adj[i][g2]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
from collections import defaultdict as dd
s = input()
#dp[keta][amari] = pattern_num
dp = dd(lambda: dd(lambda: 0))
nums = list(range(0, 10))

for keta in range(1, len(s)+1):
    digit = s[keta-1]
    if digit != "?":
        digit = int(digit)
        if keta == 1:
            dp[keta][digit] = 1
        else:
            for amari, val in dp[keta-1].items():
                dp[keta][(amari * 10 + digit) % 13] += val
                dp[keta][(amari * 10 + digit) % 13] %= 10**9 + 7

    else:
        if keta == 1:
            for digit in nums:
                dp[keta][digit] = 1
        else:
            for digit in nums:
                for amari, val in dp[keta-1].items():
                    dp[keta][(amari * 10 + digit) % 13] += val
                    dp[keta][(amari * 10 + digit) % 13] %= 10**9 + 7

print(dp[len(s)][5] % (10**9 + 7))

Measured memory_bytes: 156676
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
n = ini()
b = ''
while n > 0:
        n -= 1
        b += chr(ord('a') + n%26)
        n = n//26
print(b[::-1])


Measured memory_bytes: 9076
# input
n, m = gets.chomp.split.map(&:to_i)
submits = []
m.times do
  tmp = gets.chomp.split.map(&:to_s)
  tmp[0] = tmp[0].to_i
  submits.push(tmp)
end

ac = Array.new(n+1, 0)
ac_cnt = 0
wa = Array.new(n+1, 0)
wa_cnt = 0

# main
submits.each do |s|
  if s[1] == "WA" and ac[s[0]] == 0 then
    wa[s[0]] += 1
  end
  if s[1] == "AC" and ac[s[0]] == 0 then
    ac[s[0]] += 1
  end
end

# output
(n+1).times do |i|
  if ac[i] == 1 then
    ac_cnt += ac[i]
    wa_cnt += wa[i]
  end
end

puts "#{ac_cnt} #{wa_cnt}"


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

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (999999999/2)
map< string,vector<string> > pas;
map<string,int> mp;

int dfs(string s){
    int ret=0;
    if(pas.find(s)==pas.end()){
        return mp[s];
    }
    else{
        rep(i,pas[s].size()){
            ret+=dfs(pas[s][i]);
        }
    }
    return min(ret,mp[s]);
}

int main(){
    int n,m;
    while(cin>>n&&n){
        pas.clear();
        mp.clear();
        rep(i,n){
            string s;
            int a;
            cin>>s>>a;
            mp[s]=a;
        }
        cin>>m;
        rep(i,m){
            string s;
            cin>>s;
            int k;
            cin>>k;
            rep(j,k){
                string x;
                cin>>x;
                pas[s].pb(x);
            }
        }
        string a;
        cin>>a;
        int sum=dfs(a);
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 131072 * 2;
int N, dat[MX];

int getl(int a, int b, int x, int k, int l, int r){
	//dbg(a, b, x, k, l, r, dat[k]);
	if(r <= a || b <= l || dat[k] < x) return inf;
	if(l + 1 == r) return l;
	
	int m = (l + r) / 2;
	int rl = getl(a, b, x, k * 2 + 1, l, m);
	if(rl != inf) return rl;
	return getl(a, b, x, k * 2 + 2, m, r);
}
int getr(int a, int b, int x, int k, int l, int r){
	if(r <= a || b <= l || dat[k] < x) return -1;
	if(l + 1 == r) return l;
	
	int m = (l + r) / 2;
	int rr = getr(a, b, x, k * 2 + 2, m, r);
	if(rr != -1) return rr;
	return getr(a, b, x, k * 2 + 1, l, m);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	for(N = 1; N < n; N *= 2);
	
	vi p(n);
	rep(i, n){
		cin >> p[i];
		dat[i + N - 1] = p[i];
	}
	for(int i = N - 2; i >= 0; i--) dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
	
	ll ans = 0;
	rep(i, n){
		vi l(2, i), r(2, n);
		r[0] = getl(i + 1, n, p[i], 0, 0, N);
		if(r[0] < n) r[1] = min(n, getl(r[0] + 1, n, p[i], 0, 0, N));
		else r[0] = n;
		
		l[0] = getr(0, i, p[i], 0, 0, N);
		if(l[0] >= 0) l[1] = getr(0, l[0], p[i], 0, 0, N);
		else l[0] = -1;
		
		ans += (ll)p[i] * max(0, i - l[0]) * max(0, r[1] - r[0]);
		ans += (ll)p[i] * max(0, l[0] - l[1]) * max(0, r[0] - i);
		
		//dbg(i, l, r, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[100005];
int dp[100005];
int ans  = 1e9 ;
int n,k;
int main()
{

    //Bottom-Up Approach :
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    for(int i=0;i<n+10;i++)
        dp[i]=1e9;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);

    for(int i = 2;  i<n;i++)
    {
        int x = 1e9 ;
        for(int j=1;j<=k;j++){
            if(i>=j)
            x = min(dp[i-j]+abs(arr[i-j]-arr[i]),x);
            else
                break;
        }
        dp[i]=x;
    }
    cout<<dp[n-1]<<endl;


}


Measured memory_bytes: 4400
S = list(input())

if S[0] != 'A' or S[1] == 'C' or S[-1] == 'C':
    print("WA")
else:
    if S.count('C') == 1:
        flag = True
        for s in S[1:]:
            if s.isupper() and s !='C':
                print("WA")
                flag = False
                break
        if flag:   
            print("AC")
    else:
        print("WA")

Measured memory_bytes: 38384
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() { // YES/NO
    input! {
        n: usize, m: usize,
    }
    let mut l = Vec::new();
    for _ in 0..n {
        input!(k: usize, v: [Usize1; k]);
        l.push(v);
    }
    
    let mut sp = vec![Vec::new(); m];
    for (i, langs) in (0..).zip(&l) {
        for &lang in langs {
            sp[lang].push(i);
        }
    }

    let mut uft = UFT::new(n);
    for ps in sp {
        for (p1, p2) in ps.into_iter().tuple_windows() {
            uft.merge(p1, p2);
        }
    }
    for i in 1..n {
        if uft.root(0) != uft.root(i) {
            println!("NO");
            return;
        }
    }
    println!("YES");
}

#[allow(dead_code)]
/// Union Find Tree
pub struct UFT {
    pub par: Vec<usize>,
    pub rank: Vec<usize>,
}
impl UFT {
    #[allow(dead_code)]
    pub fn new(n: usize) -> Self {
        UFT {
            par: (0..n).collect(),
            rank: vec![0; n],
        }
    }
    #[allow(dead_code)]
    pub fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let p = self.par[x];
            let pp = self.root(p);
            self.par[x] = pp;
            pp
        }
    }
    #[allow(dead_code)]
    pub fn merge(&mut self, x: usize, y: usize) {
        let x = self.root(x);
        let y = self.root(y);
        if x == y {
            return;
        }
        if self.rank[x] < self.rank[y] {
            self.par[x] = y;
        } else {
            self.par[y] = x;
            if self.rank[x] == self.rank[y] {
                self.rank[x] += 1;
            }
        }
    }
}

Measured memory_bytes: 12292
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int N, W;
int w[100], v[100];

long long dp[100001];


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


	cin >> N >> W;
	rep(i, N)cin >> w[i] >> v[i];

	rep(i, 100001)dp[i] = W + 1;

	dp[0] = 0;
	rep(i,N) {
		for (int j = 100000 - v[i]; j >= 0;j--) {
			dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
		}
	}

	int ans = -1;
	for (int i = 100000; i >= 0;i--)if(dp[i]!=W+1) {
		ans = i;
		break;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d %d", $x, $y);
$flg = false; 
if($x <= 50 && $x < $y && $y % 2 == 0){
    for($i=0;$i<=$x;$i++){
        $tmp = ($i * 4) + (($x - $i) * 2);
        if($tmp == $y){
            $flg = true;
            echo "Yes";
            break;
        }
    }
    if($flg == false){
    echo "No";
    }
}else{
    echo "No";
}

?>

Measured memory_bytes: 16096