akhauriyash/Code-Regression huggingface dataset:
N = gets.to_i
S = gets.chomp.split(" ").map(&:to_i).sort.reverse

Gen = Array.new(N+1, 0)
Gen[0] = 1
nxt = Array.new(N+1, 0)
ls = S[0]
ans = true
S.each{|s|
  if ls != s then
    wk = 0
    (N+1).times{|i|
      wk += nxt[i]
      next if wk == 0
      nxt[i] = 0
      Gen[i] += wk
    }
  end
  ls = s
  idx = Gen.index{|g| g != 0}
  (ans = false; break) if idx.nil?
  Gen[idx] -= 1
  nxt[idx + 1] += 1 if idx < N
}

puts ans ? 'Yes' : 'No'


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

int main() {
    int n;
    cin >> n;
    set<pair<int, int>> es;
    vector<pair<int, int>> ps;
    if (n % 2) {
        for (int i = 1; i < n; i++) {
            int a = i, b = n - i;
            if (a > b) break;
            ps.emplace_back(a, b);
        }
        ps.emplace_back(n, -1);
    } else {
        for (int i = 1; i < n; i++) {
            int a = i, b = n + 1 - i;
            if (a > b) break;
            ps.emplace_back(a, b);
        }
    }

    for (int i = 0; i < ps.size(); i++) {
        for (int j = i + 1; j < ps.size(); j++) {
            int as[] = {ps[i].first, ps[i].second};
            int bs[] = {ps[j].first, ps[j].second};
            for (int a = 0; a < 2; a++) {
                for (int b = 0; b < 2; b++) {
                    if (as[a] != -1 && bs[b] != -1) {
                        es.insert({min(as[a], bs[b]), max(as[a], bs[b])});
                    }
                }
            }
        }
    }
    cout << es.size() << '\n';
    for (auto &p : es) {
        cout << p.first << ' ' << p.second << '\n';
    }
}

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

int main() {
	// 変数の宣言
	int N, A, B;

	// 値の取得
	cin >> N >> A>> B;

	// 判定
	if (N*A<B)
	{
		// プランAが安い場合
		cout << N*A;
	}else
	{
		// プランBが安い場合
		cout<< B;
	}
	
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());

		for (int i = 0; i < k; i++) {

			if (b <= a) {
				b *= 2;
				continue;
			}

			if (c <= b) {
				c *= 2;
				continue;
			}

		}

		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 35620
#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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, K;
vector<int> cx;

ll dp[102][512345], dp2[102][512345];

int main() {
	cin >> N >> K;
	
	for (ll i = 1; i * i <= N; i++) {
		cx.push_back(i + 1);
		if (i * i < N) cx.push_back(N / i + 1);
	}
	cx.push_back(1);
	sort(ALL(cx));
	
	dp[0][0] = 1;
	REP(i, K + 1) {
		dp2[i][0] = dp[i][0] * (cx[1] - cx[0]) % MOD;
		FOR(j, 1, cx.size() - 1) dp2[i][j] = (dp2[i][j - 1] + dp[i][j] * (cx[j + 1] - cx[j]) % MOD) % MOD;
		if (i < K) {
			REP(j, cx.size() - 1) {
				dp[i + 1][j] = dp2[i][upper_bound(ALL(cx), N / cx[j]) - cx.begin() - 1];
			}
		}
	}
	
	cout << dp2[K][cx.size() - 2] << endl;
	
	return 0;
}


Measured memory_bytes: 514044
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::cin >> N;
	
	N = (N + 110) / 111 * 111;
	std::cout << N << "\n";
}


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

inline int dis(pair<int,int> x, pair<int,int> y) {
    return abs(x.first-y.first) + abs(x.second - y.second);
}

int main(void) {
    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int,int>> ra(h*w);
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++) {
            int a;
            cin >> a;
            a--;
            ra[a] = pair<int,int>(i,j);
        }

    vector<vector<int>> tran(h*w, vector<int>(20));

    for(int x=0; x+d<h*w; x++) {
        tran[x][0] = dis(ra[x], ra[x+d]);
    }
    for(int i=1; d*(1<<i-1)<h*w; i++) {
        for(int x=0; x+d*(1<<i-1)<h*w; x++) {
            tran[x][i] = tran[x][i-1] + tran[x+d*(1<<i-1)][i-1];
        }
    }

    int q;
    cin >> q;
    for(int i=0; i<q; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        long res = 0;
        int n = (r-l)/d;
        for(int i=0; (1<<i)<=n; i++) {
            if(!((1<<i)&n)) continue;
            res += tran[l][i];
            l += d*(1<<i);
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 12416
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char* argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,ir;
	cin>>n>>ir;
	if(n>=10)cout<<ir;
	else cout<<ir+100*(10-n);
	return 0;
}

Measured memory_bytes: 256
from math import floor

def main():
    a, b = map(int, input().split())
    
    ans = -1
    for i in range(1, 1001):
        if floor(i * 0.08) == a and floor(i * 0.1) == b:
            ans = i
            break
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
ll sum;
ll p[100000];
vector<P> v;
set<ll> S;

auto ptr(auto itr, ll p){
    if(p > 0){
        for(int i=0;i<p;i++) itr++;
    }
    if(p < 0){
        for(int i=0;i<(-p);i++) itr--;
    }
    return itr;
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        ll tmp;
        cin >> tmp;
        v.push_back({tmp,i});
    }
    sort(v.rbegin(),v.rend());
    S.insert(v[0].second);
    S.insert(-1);
    S.insert(N);
    sum = 0;
    for(int i=1;i<N;i++){
        ll n = v[i].first;
        ll ind = v[i].second;
        auto ep = S.upper_bound(ind);
        ll s_ind,e_ind;
        s_ind = *(ptr(ep,-1));
        e_ind = *(ptr(ep,0));
        if(s_ind == -1){
            ll v_ind = *(ptr(ep,1));
            sum += (ind + 1) * (v_ind - e_ind) * n;
            //cout << s_ind << " [" << ind << "] " << e_ind << " " << v_ind << endl;
            S.insert(ind);
            continue;
        }
        if(e_ind == N){
            ll v_ind = *(ptr(ep,-2));
            sum += (N - ind) * (s_ind - v_ind) * n;
            //cout << v_ind << " " << s_ind << " [" << ind << "] " << e_ind << endl;
            S.insert(ind);
            continue;
        }
        ll vs_ind = *(ptr(ep,-2));
        ll ve_ind = *(ptr(ep,1));
        //cout << vs_ind << " " << s_ind << " [" << ind << "] " << e_ind << " " << ve_ind << endl;
        sum += (ind - s_ind) * (ve_ind - e_ind) * n;
        sum += (e_ind - ind) * (s_ind - vs_ind) * n;
        S.insert(ind);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 9364
from math import ceil

def divisors(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return res

n = int(input())
divs = divisors(n)
divs.sort()
lim = ceil(len(divs) / 2)
ans = 11

for i in range(lim):
    a = divs[i]
    b = divs[(-1) * (i + 1)]
    f = max(len(str(a)), len(str(b)))
    ans = min(ans, f)

print(ans)


Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;
typedef pair<string, string> pss;

# define MAX 100 
int n, m;
int v[100];

struct union_find {
	int rnk[MAX], par[MAX];

	union_find(int n) { for (int i = 0; i < n; i++) rnk[i] = 1, par[i] = i; }

	int find(int x) {
		if (x == par[x]) return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (rnk[x] > rnk[y]) par[y] = x;
		else {
			par[x] = y;
			if (rnk[x] == rnk[y]) rnk[y]++;
		}
	}
	bool same(int x, int y) {
		x = find(x); y = find(y);
		return x == y;
	}
};

int main()
{
	cin >> n >> m;
	vector<int>a(m), b(m);
	rep(i, m) {
		int A, B;
		cin >> A >> B;
		A--;
		B--;
		a[i] = A;
		b[i] = B;
	}

	int res = 0;
	for (int i = 0; i < m; i++) {
		union_find uf(n);
		for (int j = 0; j < m; j++) {
			if (i == j)continue;
			uf.unite(a[j], b[j]);
		}
		int ans = 0;
		for (int j = 0; j < n; j++) {
			ans += (uf.find(j) == j);
		}
		res += ans - 1;
	}
	cout << res << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e5 + 10;
const ll mod = 998244353;

ll qpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int N, M, K;
ll fac[MAX], inv[MAX];
void init() {
    fac[0] = 1;
    for (int i = 1; i <= (int)2e5; i++) {
        fac[i] = i * fac[i - 1] % mod;
        inv[i] = qpow(fac[i], mod - 2);
    }
}

ll C(ll n, ll m) {
    if (m == 0 || n == m) return 1;
    if (m > n) return 0;
    if (m == 1) return n;
    return fac[n] * inv[m] % mod * inv[n - m] % mod;
}


int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    init();
    scanf("%d%d%d", &N, &M, &K);
   ll ans = 0;
    for (int k = 0; k <= K; k++)
        ans = (ans + 1ll * M * C(N - 1, k) % mod * qpow(M - 1, N - 1 - k) % mod) % mod;
    printf("%lld\n", ans);


    return 0;
}

Measured memory_bytes: 6952
#include <iostream>

void dwrite(int i){
	std::cout << i << std::endl;
}

int main(){
	std::string m[3], w;
	while(std::cin >> m[0], m[0][0] != '0'){
		for(int i=1;i<3;i++)std::cin >> m[i];
		w = "NA";
		for(int i=0;i<3;i++){
			if(m[i][0] + m[i][1] - m[i][2] * 2 == 0 && m[i][0] - '+')w = m[i][0];
			if(m[0][i] + m[1][i] - m[2][i] * 2 == 0 && m[0][i] - '+')w = m[0][i];
		}
		if(m[0][0] + m[1][1] - m[2][2] * 2 == 0 && m[0][0] - '+')w = m[0][0];
		if(m[0][2] + m[1][1] - m[2][0] * 2 == 0 && m[0][2] - '+')w = m[0][2];
		
		std::cout << w << '\n';
	}
}

Measured memory_bytes: 0
N=int(input())
A=[0]+list(map(int,input().split()))+[0]

money=0
for i in range(N+1):
    money+=abs(A[i+1]-A[i])

for j in range(N):
    print(money-abs(A[j+1]-A[j])-abs(A[j+2]-A[j+1])+abs(A[j+2]-A[j]))

Measured memory_bytes: 13920
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string a;
  cin >> a;
  cout << (a.find('9') != string::npos ? "Yes" : "No") << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>

int main() {
    const long long mod = 1000000007;
    long long ret = 0;
    std::string s;
    std::cin >> s;
    std::vector<long long> p3(s.size()), q(s.size()), an(s.size());
    std::deque<long long> a, b;

    p3[0] = 1;
    q[0] = (s[0] == '?' ? 1 : 0);
    an[0] = (s[0] == 'A' ? 1 : 0);
    for (auto i = 1ll; i < s.size(); i++) {
        p3[i] = (p3[i - 1] * 3) % mod;
        q[i] = q[i - 1] + (s[i] == '?' ? 1 : 0);
        an[i] = an[i - 1] + (s[i] == 'A' ? 1 : 0);
    }

    auto qtotal = q[s.size() - 1];
    auto qa = 0ll, qb = 0ll, ta = 0ll;

    for (auto i = 0ll; i < s.size(); i++) {
        if (s[i] == 'A') {
            a.push_back(i);
            qa += q[i];
        } else if (s[i] == 'B') {
            b.push_back(i);
            qb += q[i];
            ta += an[i];
        } else {
            if (i < 2) continue;

            ret = (ret + (a.size() * q[i - 1] - qa) * p3[std::max(0ll, qtotal - (s[i] == 'C' ? 1 : 2))]) % mod;
            ret = (ret + qb * p3[std::max(0ll, qtotal - (s[i] == 'C' ? 1 : 2))]) % mod;
            ret = (ret + ta * p3[std::max(0ll, qtotal - (s[i] == 'C' ? 0 : 1))]) % mod;

            if (q[i - 1] > 1) ret = (ret + (((q[i - 1] * (q[i - 1] - 1) / 2) % mod) * p3[qtotal - 2 - (s[i] == 'C' ? 0 : 1)]) % mod) % mod;
        }
        //std::cout << i << ":" << ret << std::endl;
    }

    std::cout << ret % mod << std::endl;

    return 0;
}

Measured memory_bytes: 3200
import java.util.*;

public class Main{
public static void main(String... args){
Scanner sc = new Scanner(System.in);
String a=sc.next();
String b=sc.next();
int ab=Integer.parseInt(a+b);
for(int i=1;i<=Math.sqrt(100100);i++){
if(i*i==ab){
System.out.println("Yes");return;
}
}
System.out.println("No");
}
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

lldo r;

int main() {
	cout << setprecision(10);
	cin >> r;
	cout << 3.141592653589793238462643383279 * 2 * r << endl;
	return 0;
}

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

string S;
int main(){
	while(1){
		cin >> S;
		if(S[0] == '0') break;
		long long ans = 0;
		for(int i=0;i<S.size();i++){
			ans += S[i] - '0';
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3164
import java.util.*;
public class Main {
  static int mod = 1_000_000_007;
  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      int redCnt = n - k;
      long[] res = new long[k+1];
      long sum = 0L;
      for(int i = 1; i <= k; i++) {
        System.out.println(comb(redCnt + 1, i) * comb(k - 1, i - 1) % mod);
      }
  }

  private static long comb(int a, int b) {
    if(a == 0 || b == 0) return 1;

    long factA = 1L;
    for(int i = (a - b + 1); i <= a; i++)
      factA = factA * i % mod;

    long factB = 1L;
    for(int i = 1; i <= b; i++)
      factB = factB * i % mod;

    long res = factA * modPow(factB, mod - 2) % mod;
    return res; 
  }

  private static long modPow(long a, long b) {
    if(b == 0) return 1L;
    if(b == 1) return a % mod;
    long res = modPow(a, b / 2) % mod;
    if(b % 2 == 1)
      return ((res * res % mod) * a) % mod;
    return (res * res % mod);
  }
}

Measured memory_bytes: 22228
class Array
  def cumsum; s = 0; map{|k| s += k } end
end

n = gets.to_i
a = gets.to_s.split.map{|t|t.to_i}

s = a.reduce(0){|s,t|s+t}
ans = a.cumsum.map{|e| (s-2*e).abs }.min

puts ans

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}


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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<vector<int>> vvi;           // intの2次元vector
typedef vector<vector<double>> vvd;        // doubleの2次元vector
typedef vector<vector<ll>> vvll;           // llの2次元vector
typedef vector<vector<ld>> vvld;           // ldの2次元vector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* main */
void Main(void)
{
    int r, c;
    cin >> r >> c;
    int g[100][100];
    memset(g, 0, sizeof(g));
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> g[i][j];
        }
    }
    int ans[101][101];
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            ans[i][j] = g[i][j];
        }
    }
    for (int i = 0; i < r; i++)
    {
        int sum = 0;
        for (int j = 0; j < c; j++)
        {
            sum += ans[i][j];
        }
        ans[i][c] = sum;
    }
    for (int i = 0; i <= c; i++)
    {
        int sum = 0;
        for (int j = 0; j < r; j++)
        {
            sum += ans[j][i];
        }
        ans[r][i] = sum;
    }
    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j <= c; j++)
        {
            cout << ans[i][j];
            if (j != c)
            {
                cout << " ";
            }
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}



Measured memory_bytes: 3296
#include <cstdio>

using namespace std;

int main(){
	
	double v,t,y;
	int N;
	
	while (scanf("%lf",&v)!=EOF){
	
		t=v/9.8;
		y=4.9*t*t;
		N=(int)(y+5)/5;
		
		printf("%d\n",N+1);
	}
		
	return 0;
}
 

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

int main() {
    int A, B;
    cin >> A >> B;
    if (9 <= A || 9 <= B) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

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

ll N;

void solve(string s, char mc)
{
	if (s.size() == N)
	{
		std::cout << s << std::endl;
		return;
	}

	for (char c = 'a'; c <= mc + 1; ++c)
	{
		solve(s + c, max(mc, c));
	}
}

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
	solve("a", 'a');
	
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  priority_queue<pair<ll, int>> q;
  rep(i, N) q.push({B[i], i});
  ll ans = 0;
  while(!q.empty()) {
    auto ele = q.top(); q.pop();
    ll val = ele.first;
    int i = ele.second;
    if(val-A[i] && val-A[i] < B[(i+N-1)%N]+B[(i+1)%N]) {
      cout << -1 << "\n";
      return 0;
    }
    ll rem = (val-A[i])%(B[(i+N-1)%N]+B[(i+1)%N]);
    ll cur = (val-A[i])/(B[(i+N-1)%N]+B[(i+1)%N]);
    ans += cur;
    B[i] = A[i]+rem;
    if(rem) q.push({B[i], i});
  }
  cout << ans << "\n";
  return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int x, a, b;
    cin >> x >> a >> b;

    cout << (x-a)%b << endl;
    return 0;
}


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

typedef long long ll;

typedef pair<int, pair<int, int> > p;

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

    int N;
    cin >> N;

    vector<ll> x(N);

    ll a = 0;
    ll b = 0;

    cin >> a;

    for(int i = 1; i < N; i++) {
        cin >> x[i];
        b += x[i];
    }

    ll ans = abs(a - b);

    for(int i = 1; i < N - 1; i++) {
        a += x[i];
        b -= x[i];
        ans = min(ans, abs(a - b));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
H = list(map(int, input().split()))
neib = {}

for n in range(N):
    neib[n]=[]

#print(neib)
#print()
for m in range(M):
    A, B = map(int, input().split())
    neib[A-1].append(H[B-1])
    neib[B-1].append(H[A-1])
    
count = 0
#print(neib)
#print()

for k, v in neib.items():
    if len(v)==0:
        count += 1
    elif H[k] > max(v):
        count += 1
print(count)

Measured memory_bytes: 31768
#include <bits/stdc++.h>
using namespace std; 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reprev(i,a,b) for(int i=b-1;i>=a;i--)
#define all(c) c.begin(),c.end()
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vin(a,n) vi a(n); rep(i,0,n) cin>>a[i];
#define vout(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
#define mapp map<int,int>
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define inf LLONG_MAX
#define pi 3.1415926535897932384626
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)

bool comps(const pair<int,int> &a, const pair<int,int> &b) {return (a.second<b.second);} 

int power(int x, unsigned int y)
{ 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
}

int powerp(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}

signed main()
{
    IOS
    int n;
    cin>>n;
    int a[n],b[n];
    rep(i,0,n)
    {
        cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    int ans;
    if(n%2==0)
    {
        long double m1,m2;
        m1=a[n/2-1]+a[n/2];
        m2=b[n/2-1]+b[n/2];
        m1/=2; m2/=2;
        ans=(m2-m1)*2+1;
    }
    else
    {
        int m1,m2;
        m1=a[(n-1)/2];
        m2=b[(n-1)/2];
        ans=m2-m1+1;
    }
    cout<<ans;
    return 0;
}

// vector<vector<int>> adj;
// vector<bool> visited;
// void dfs(int v) 
// {
//     visited[v] = true;
//     for (int u : adj[v]) 
//     {
//         if (!visited[u])
//         {
//             dist[u].ff=dist[v].ff+1;
//             dist[u].ss=u;
//             dfs(u);
//         }
//     }
// }
// int binarySearch(int l, int r) 
// { 
//     while (l <= r) { 
//         int m = l + (r - l) / 2; 
  
//         //ignore left half 
//         if (!check(m)) 
//             l = m + 1; 
  
//         //ignore right half 
//         else
//             r = m - 1; 
//     }   
//     return l;
// }

Measured memory_bytes: 6768
import math
while True:
    N=int(input())
    if N==0:
        break
    data=list(map(int,input().split()))
    m=sum(data)/N
    goukei=0
    for i in data:
        goukei+=(i-m)**2
    a=math.sqrt(goukei/N)
    print(a)


Measured memory_bytes: 5692
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    string s1,s2,s3;

    cin >> s1 >> s2 >> s3;
    cout << char(toupper(s1[0])) << char(toupper(s2[0])) << char(toupper(s3[0])) << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    string S;
    char c;
    deque<char> deq;
    int Q, q, f;
    bool rev = false;
    cin >> S;
    cin >> Q;
    for (int i = 0; i < S.size(); i++) {
        deq.push_back(S[i]);
    }

    for (int i = 0; i < Q; i++) {
        cin >> q;
        if (q == 2) {
            cin >> f >> c;

            if (rev) {
                if (f == 1) {
                    deq.push_back(c);
                } else {
                    deq.push_front(c);
                }
            } else {
                if (f == 1) {
                    deq.push_front(c);
                } else {
                    deq.push_back(c);
                }
            }
        } else {
            rev = !rev;
        }
    }

    if (rev) {
        reverse(deq.begin(), deq.end());
    }
    for (int i = 0; i < deq.size(); i++) {
        cout << deq[i];
    }
    cout << endl;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<map>

using namespace std;

typedef pair<string, int> P;
const int MAX = 10001;
const int SIZE = 4;
int dp[MAX], N, T;
char grid[SIZE][SIZE];
vector<P> word;
map<string, int> able;
int dh[] = {1,0,-1,0,1,1,-1,-1};
int dw[] = {0,1,0,-1,1,-1,1,-1};

void input(){
  cin >> N;
  word.resize(N);
  for(int i = 0; i < N; i++){
    cin >> word[i].first >> word[i].second;
    able[word[i].first] = 0;
  }
  for(int i = 0; i < SIZE; i++) for(int j = 0; j < SIZE; j++) cin >> grid[i][j];
  cin >> T;
}

void rec(const int& h, const int& w, const string& s, const int& used){
  if(able.count(s)) able[s]++;
  if(s.length() == 8) return;
  for(int i = 0; i < 8; i++){
    int nh = h+dh[i], nw = w+dw[i];
    if(nh < 0 || nh >= SIZE || nw < 0 || nw >= SIZE) continue;
    if(used & (1 << (4*nh+nw))) continue;
    rec(nh, nw, s+grid[nh][nw], used | (1<<(4*nh+nw)));
  }
}

void find(){
  for(int h = 0; h < SIZE; h++)
    for(int w = 0; w < SIZE; w++)
      rec(h,w,string(1,grid[h][w]),(1<<(4*h+w)));
}

void solve(){
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  
  for(int i = 0; i < (int)word.size(); i++)
    for(int t = T; t >= 0; t--)
      if(dp[t] != -1){
	int lim = able[word[i].first];
	for(int q = 1; q <= lim; q++)
	  if(t+q*(int)word[i].first.length() <= T) dp[t+q*word[i].first.length()] = max(dp[t+q*word[i].first.length()], dp[t]+q*word[i].second);
	  else break;
      }

  int res = 0;
  for(int i = 0; i <= T; i++) res = max(res, dp[i]);
  cout << res << endl;
}
int main(){
  input();
  find();
  solve();
  return 0;
}

Measured memory_bytes: 1280
// You may see me struggle,but you will never see me quit!
#include <bits/stdc++.h>
 using namespace std;
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define pb                      push_back
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define asort(c)                sort(all(c)) 
#define lbpos(x,v)              (int)(lower_bound(all(v),x)-v.begin())//=v.size()==>No LB 
#define ubpos(x,v)              (int)(upper_bound(all(v),x)-v.begin())//=v.size()==>No UB
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  long double                 ld;
#define debug(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";
}


int32_t main()
{
  FIO;
 

  int a,b;
  cin>>a>>b;
  if(a>=b)
    swap(a,b);

  if(a<=0 and b>=0)
    cout<<"Zero";
  else if(a>0)
    cout<<"Positive";
  else
  {
     int d=abs(a)-abs(b)+1;
     if(d&1)
      cout<<"Negative";
    else
      cout<<"Positive";
  }
  timer();
  return 0;
}  

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

int main() {
    register bool flag;
	for (register char ch; ch != '\n'; ) {
		flag |= (ch = getchar()) == 'C';
		if (ch == 'F' && flag) {
			return puts("Yes"), 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    X, N = ZZ()
    P = set(ZZ())
    sa, ans = 200, 0
    for i in range(105):
        if i in P: continue
        if abs(X-i) < sa:
            sa = abs(X-i)
            ans = i
    print(ans)

    return

if __name__ == '__main__':
    main()


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

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

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

    return arr
N = int(input())
if N == 1:
    print(0)
    exit()
count = 0
lis = factorization(N)
for l in lis:
    num = l[1]
    for i in range(1,l[1]+1):
        if i > num:
            break
        num -= i
        i += 1
        count += 1
print(count)

Measured memory_bytes: 9492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	
	const long long INF = 1LL << 60;
	
	int n; cin >> n;
	
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	//sort(a.begin(),a.end());
	
	
	//vector<int> cost(n,10000000);
	
	ll cost[100010];
	rep(i,100010) cost[i]=INF;
	
	
	cost[0]=0;
	
	
	/*
	for(int i=2;i<n;i++){
		
		cost[i]=min(cost[i],abs(a[i]-a[i-1])+cost[i-1]);
		cost[i]=min(cost[i],abs(a[i]-a[i-2])+cost[i-2]);
	}
	*/
	for (int i=1;i<n;i++) {
        chmin(cost[i], cost[i - 1] + abs(a[i] - a[i - 1]));
        if (i > 1) chmin(cost[i], cost[i - 2] + abs(a[i] - a[i - 2]));
    }



	cout << cost[n-1] << '\n';
	return 0;

}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n,m;
	cin>>n>>m;
	vector<vector<long long>> kankei(n);

	for(long long i=0;i<m;i++){
		long long a,b;
		cin>>a>>b;
		kankei.at(a-1).push_back(b-1);
		kankei.at(b-1).push_back(a-1);
	}

	long long ans=0;
	vector<bool> seen(n,false);

	for(long long i=0;i<n;i++){
		if(seen.at(i)) continue;
		long long pre=0;
		queue<long long> que;
		que.push(i);

		while(!que.empty()){
			pre++;
			long long now=que.front();
			seen.at(now)=true;
			que.pop();

			for(auto next:kankei.at(now)){
				if(seen.at(next)==false){
					que.push(next);
					seen.at(next)=true;
				}
			}
		}

		chmax(ans,pre);
	}

	cout<<ans<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 16904
import math
N, K = map(int, input().split())
a = list(map(int, input().split()))
x = 0
if K == 0:
    x = 0
else:
    for i in range(41)[::-1]:
        cnt_1 = 0
        for _a in a:
            if _a & 2**i == 2**i:
                cnt_1 += 1
        if cnt_1 <= len(a)/2 and (x + 2**i) <= K:
            x += 2**i

ans = 0
for _a in a:
    ans += x ^ _a
print(ans)

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

int main() {
  int64_t Q, H, S, D;
  int64_t N;
  cin >> Q >> H >> S >> D >> N;

  int64_t ans = 0;
  int64_t m = min(4 * Q, min(2 * H, S));
  if (D < m * 2) {
    ans += (N / 2) * D;
    N = N%2;
  }
  ans += N * m;
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    map<ll,ll> m1,m2;
    for (int i = 0; i < n; ++i)
    {
        m1[i+1-a[i]]++;
        m2[i+1+a[i]]++;
    }
    ll ans=0;
    for (int i = 0; i < n; ++i)
    {
        ans+=m2[i+1-a[i]];
    }
    cout << ans;
    }

Measured memory_bytes: 39492
#include <cstdio>
using namespace std;

int n;
bool b[31] = { false };

int main(){
	for (int i = 0; i < 28; i++) {
		scanf("%d", &n);
		b[n] = true;
	}
	for (int i = 1; i <= 30; i++) {
		if (!b[i])
			printf("%d\n", i);
	}

	return 0;
}

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

using ll = long long;

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

  if (A>B && A>C && B<C){
    cout << "Yes" << endl;
    return 0;
  }
  if (A<B && A<C && B>C){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	long long sum;
	
	scanf("%d", &n);
	
	sum = n;
	n--;
	while (n != 0){
		sum *= n;
		n--;
	}
	
	printf("%lld\n", sum);
	
	return (0);
}

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

int main()
{
    int n;
    cin>>n;
    string s[n];
    int nnn[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
        nnn[i]=s[i].size();
        sort(s[i].begin(),s[i].end());
    }
    int c[n+1][26]={};
    char x;
    for(int i=0;i<n;i++){
        for(int j=0;j<nnn[i];j++){
            x=s[i][j];
            char y='a';
            for(int k=0;k<26;k++){
                if(x==y){
                    c[i][k]++;
                }
                y++;
            }
            
        }
        for(int k=0;k<26;k++){
                c[0][k]=min(c[0][k],c[i][k]);
        }
    }
    string ans="";
    char z='a';
    for(int i=0;i<26;i++){
        for(int j=0;j<c[0][i];j++){
            ans=ans+z;
            
        }
        z++;
        //cout<<c[0][i];
    }
    cout<<ans<<endl;



}

Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

MOD = (10 ** 9) + 7

INF = 10 ** 10

MAX = 510000

def com_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def com(n, k):
    if n < k:
        return 0
    if (n < 0) or (k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


if __name__ == "__main__":
    # K個の青ボールとN-K個の赤ボール
    # 同じ色のボールは区別可能
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    
    fac = [0] * MAX
    finv = [0] * MAX
    inv = [0] * MAX

    com_init()

    for i in range(1, K+1):
        ans = com(N-K+1, i) * com(K-1, i-1) % MOD
        print(ans)

Measured memory_bytes: 80108
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int sum = 0;
	vec c(b);
	for (int i = 0; i < b; i++) {
		cin >> c[i];
		sum += c[i];
	}
	if (sum > a) cout << "-1" << endl;
	else cout << a - sum << endl;
}


Measured memory_bytes: 3672
#include <stdio.h>

int main() 
{
    int A[5];
    for (int i=0;i<5;i++) {
        scanf("%d",&A[i]);
    }
    for (int i=0;i<5;i++) {
        if(A[i] == 0){
            printf("%d\n",i+1);
        }
    }
    return 0;
}

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

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

int n;
cin >> n;
long double arr[n];
for(int i = 0; i < n; i++){
     cin >> arr[i];
}
sort(arr,arr+n);
for(int i = 1; i < n; i++){
     arr[i] = (arr[i]+arr[i-1])/2;
 }
cout << fixed << setprecision(6) << arr[n-1] << '\n';

	return 0;
}

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

int main(){
    vector<int> nums(3);
    for (int i=0;i<3;i++){
        cin >> nums[i];
    }
    sort(nums.begin(), nums.end());

    nums.resize(distance(nums.begin(), unique(nums.begin(), nums.end())));
    if (nums.size() == 2){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    for (;;) {
        double q;
        scanf("%lf", &q);
        if (q == -1) return 0;
        double x = q/2;
        while (fabs(x*x*x-q) >= 0.00001*q) {
            x = x-(x*x*x-q)/(3*x*x);
        }
        printf("%.6f\n", x);
    }
}

Measured memory_bytes: 0
x, k, d = map(int, input().split())
if x < 0:
  x *= -1
if x >= k * d:
  print(x - (k * d))
else:
  k -= x // d
  x = x % d
  if k % 2 == 0:
    if x < abs(x - (2 * d)):
      print(x)
    else:
      print(abs(x - 2 * d))
  else:
    if abs(x - d) < abs(x + d):
      print(abs(x - d))
    else:
      print(abs(x + d))

Measured memory_bytes: 9100
n,*a=map(int,open(0).read().split())
a.sort()
d=len(a)//2
flag=0
if len(a)%2==1:
    b=a[:d+1]
    c=a[d+1:]
    flag=1
else:
    b=a[:d]
    c=a[d:]
l=[]
for i in range(d):
    l.append(c[i])
    l.append(b[i])
if flag:
    if abs(l[-1]-b[-1])>abs(l[0]-b[-1]):
        l.append(b[-1])
    else:
        l.insert(0,b[-1])
print(sum(abs(l[i+1]-l[i])for i in range(n-1)))


Measured memory_bytes: 14452
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
const ll INF = 1e15;

struct P {
  ll x, y;
  bool operator<(const P& rhs) const {
    return (x == rhs.x) ? (y < rhs.y) : (x < rhs.x);
  }
};

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

  ll W, H;
  int N;
  while (cin >> W >> H >> N) {
    vector<P> ps(N);
    vector<ll> xsorted(N), ysorted(N);
    for (int i = 0; i < N; ++i) {
      cin >> ps[i].x >> ps[i].y;
      xsorted[i] = ps[i].x;
      ysorted[i] = ps[i].y;
    }
    sort(begin(xsorted), end(xsorted));
    sort(begin(ysorted), end(ysorted));
    vector<P> candidates;
    for (int i = 0; i < min(3, N); ++i) {
      for (int j = 0; j < min(3, N); ++j) {
        candidates.push_back({xsorted[(N - 1) / 2 + (i + 1) % 3 - 1],
                              ysorted[(N - 1) / 2 + (j + 1) % 3 - 1]});
      }
    }
    pair<ll, P> ans = {INF, {INF, INF}};
    for (P c : candidates) {
      ll maxDist = -1, totalDist = 0;
      for (int i = 0; i < N; ++i) {
        ll dist = abs(ps[i].x - c.x) + abs(ps[i].y - c.y);
        totalDist += dist;
        maxDist = max(maxDist, dist);
      }
      ans = min(ans, make_pair(2 * totalDist - maxDist, c));
    }
    cout << ans.first << endl << ans.second.x << " " << ans.second.y << endl;
  }
}

Measured memory_bytes: 4176
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long ll;
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vp vector<pii>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define INF 1e9
#define LLINF 1e18
#define PI (acos(-1))
#define MOD 1e9+7
 
int main(){
	int n;
	cin >> n;
	string str;
	cin >> str;
	int ans = 1;
	for(int i = 1; i < n; i++){
		if(str[i - 1] != str[i]) ans++;
	}
	cout << ans << endl;
	
	return 0;
}
	
	
	
	
	
	

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

int main()
{
    bool f[27]={};
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(!f[s[i]-'a'])
        {
            f[s[i]-'a']=true;
        }
        else
        {
            cout<<"no";
            return 0;
        }
    }
    cout<<"yes";
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second


signed main(){
  int n,s=0;
  cin>>n;
  while(n--){
    int a;
    cin>>a;
    if(a%2==0)s++;
  }
  cout<<s<<endl;
}



Measured memory_bytes: 3124
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    cin>>s;
    int st=0;
    bool f=false;
    int ans=0;
    rep(i,s.length()){
        if(s[i]=='('&&!f)st++;
        if(s[i]=='*')f=true;
        if(s[i]==')'&&st){
            st--;
            if(f)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3240