akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
struct T {
	int to, nxt;
} way[maxn << 1];
int h[maxn], num;
inline void link(int x,int y) {
	way[++num] = {y, h[x]}, h[x] = num;
	way[++num] = {x, h[y]}, h[y] = num;
}
int ans = 1;
int n, m, k;
int fac[maxn], ifac[maxn], inv[maxn];
int dfn[maxn], low[maxn], st[maxn], top, tot;
std::set<int> s[maxn];
inline int calc(std::vector<int>&v) {
	if(v.size() == 2) return k;
	int edge = 0;
	for(int i : v) for(int j : v) {
		edge += i > j && s[i].count(j);
	}
	if(edge == v.size()) {
		int ans = 0;
		for(int i = 0;i < v.size();++i) {
			ans = (ans + pow(k, std::__gcd<int>(i, v.size()))) % mod;
		}
		return ans * inverse(v.size()) % mod;
	} else {
		return (ll) fac[edge + k - 1] % mod * ifac[k - 1] % mod * ifac[edge] % mod;
	}
}
inline void tarjan(int x,int fa = 0) {
	low[x] = dfn[x] = ++ tot; st[++top] = x;
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != fa) {
		if(!dfn[way[i].to]) {
			tarjan(way[i].to, x);
			low[x] = std::min(low[x], low[way[i].to]);
			if(low[way[i].to] >= dfn[x]) {
				std::vector<int> vc(1, x);
				do vc.push_back(st[top]); while(st[top--] != way[i].to);
				ans = (ll) ans * calc(vc) % mod;
			}
		} else {
			low[x] = std::min(low[x], dfn[way[i].to]);
		}
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> k;
	fac[0] = ifac[0] = fac[1] = ifac[1] = inv[1] = 1;
	rep(i, 2, maxn - 1) {
		inv[i] = ll(mod - mod / i) * inv[mod % i] % mod;
		fac[i] = (ll) fac[i - 1] * i % mod;
		ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;
	}
	rep(i, 1, m) {
		int x, y;
		cin >> x >> y;
		link(x, y);
		s[x].insert(y);
		s[y].insert(x);
	}
	rep(i, 1, n) if(!dfn[i]) tarjan(i);
	cout << ans << '\n';
}


Measured memory_bytes: 16768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        String[] str_array = br.readLine().split(" ");

        long ans = 1;
        long cut = Long.parseLong("1000000000000000000");

        Arrays.sort(str_array);

        for(String str : str_array) {

            if("0".equals(str)) {
                pw.println(0);
                pw.close();
                return;
            }

            if(ans > cut / Long.parseLong(str)) {
                pw.println(-1);
                pw.close();
                return;
            }
            ans *= Long.parseLong(str);
        }

        pw.println(ans);
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 50864
N, W = map(int, input().split())
value = []
weight = []
dp = [0 for _ in range(W + 1)]
for i in range(N):
    v, w = map(int, input().split())
    for j in range(W, -1, -1):
        if j >= w:
            dp[j] = max(dp[j], dp[j - w] + v)
        else:
            break
print(dp[W])

Measured memory_bytes: 8044
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int N,K,t[5005];
vector<int> A;
bool dp[5005][10005];
bool ch(int rp)
{
	for(int i=0;i<N;i++)for(int j=0;j<K;j++)dp[i][j]=false;
	for(int i=0,j=0;i<N;i++)
		if(i!=rp)
			t[j++]=A[i];
	dp[0][0]=true;
	int ch_n=N-1;
	for(int i=0;i<ch_n;i++)if(t[i]<K)dp[i][t[i]]=true;
	for(int i=1;i<ch_n;i++)
	{
		for(int j=0;j+t[i]<K;j++)
		{
			dp[i][j+t[i]]|=dp[i-1][j];
		}
	}
	if(K<=A[rp])return 1;
	for(int i=0;i<N-1;i++)
		for(int j=K-A[rp];j<K;j++)
			if(dp[i][j])return 1;
	return 0;
}


int main()
{
	scanf("%d%d",&N,&K);
	for(int i=0;i<N;i++)
	{
		int q;
		scanf("%d",&q);
		A.push_back(q);
	}

	sort(A.begin(),A.end());
	int r=-1,l=N,m;

	while(l-r>1)
	{
		m=(r+l)/2;
		if(ch(m))
			l=m;
		else
			r=m;
	}
	int res=0;

	if(r==-1)
	{
	}
	else
	{
		for(int i=0;i<N;i++)if(A[i]<=A[r])res++;
	}
	printf("%d\n",res);
}


Measured memory_bytes: 48768
n = int(input())
x = 2

listA = []
listB = []
listC = []

for i in range(n):
    a = int(input())
    listA.append(a)
    listB.append(a)

listA.sort()
listB.sort()
    
for i in range(x+2):
    listB.remove(listA[i])
    
    for j in range(x+1):
        listC.append(int(str(listA[i]) + str(listB[j])))
         
    listB.append(listA[i])
    listB.sort()

listC.sort()
print(listC[x])


Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define FOR(i,n) for(int i = 0;i<n;i++)
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const ll MOD=998244353,INF=1ll<<60;

int N;
int used[111];

signed main() {
    IOS();
    cin>>N;
    vint a(N),b(N);
    rep(i,0,N){
        cin>>a[i];
        a[i]--;
        if(a[i]>i){
            cout<<-1<<endl;
            return 0;
        }
    }
    
    rep(i,0,N){
        int idx=-1,tmp=0;
        rep(j,0,N){
            if(used[j])continue;
            if(a[j]==tmp){
                chmax(idx,j);
            }
            tmp++;
            if(tmp==N)break;
        }
        b[i]=a[idx];
        used[idx]=true;
    }
    
    rrep(i,0,N){
        cout<<b[i]+1<<endl;
    }
    cout<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int h, w; cin >> h >> w;
  vector<string> s(h);
  rep(i,h) {
    cin >> s[i];
  }
  vvi u(h, vi(w, 0));
  vvi d(h, vi(w, 0));
  vvi l(h, vi(w, 0));
  vvi r(h, vi(w, 0));
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '.') {
        u[i][j] = 1;
        l[i][j] = 1;
        if (i>0 && s[i-1][j] == '.') {
          u[i][j] += u[i-1][j];
        }
        if (j>0 && s[i][j-1] == '.') {
          l[i][j] += l[i][j-1];
        }
      }

      if (s[h-i-1][j] == '.') {
        d[h-i-1][j] = 1;
        if (i>0 && s[h-i][j] == '.') {
          d[h-i-1][j] += d[h-i][j];
        }
      }

      if (s[i][w-j-1] == '.') {
        r[i][w-j-1] = 1;
        if (j>0 && s[i][w-j] == '.') {
          r[i][w-j-1] += r[i][w-j];
        }
      }
    }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') continue;
      int val = 1;
      if (i>0)   val += u[i-1][j];
      if (i<h-1) val += d[i+1][j];

      if (j>0)   val += l[i][j-1];
      if (j<w-1) val += r[i][j+1];
      // cout << val << " \n"[j==w-1];
      ans = max(ans, val);
    }
  }

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

Measured memory_bytes: 129664
K = int(input())

runrun_pool = [list(range(1,10))]
runrun_num = len(runrun_pool[0])
digit = 1

while runrun_num < K:
    tmp = list()
    for i in runrun_pool[digit-1]:
        if i % 10 == 0:
            tmp.append(i * 10 + i % 10)
            tmp.append(i * 10 + i % 10 + 1)
        elif i % 10 == 9:
            tmp.append(i * 10 + i % 10 - 1)
            tmp.append(i * 10 + i % 10)
        else:
            tmp.append(i * 10 + i % 10 - 1)
            tmp.append(i * 10 + i % 10)
            tmp.append(i * 10 + i % 10 + 1)
    runrun_pool.append(tmp)         
    runrun_num += len(runrun_pool[digit])
    digit += 1

num = K
for i in range(digit-1):
    num -= len(runrun_pool[i])
    
print(runrun_pool[digit-1][num-1])

Measured memory_bytes: 11628
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

const int tx[] = {0,1,0,-1};
const int ty[] = {-1,0,1,0};

int main(){
	int n;
	while(~scanf("%d",&n)){
		int* data = new int[n];
		for(int i=0;i<n;i++){
			scanf("%d",data+i);
		}

		sort(data,data+n);
		int con=0;
		int sum=0;
		for(int i=0;i<n;i++){
			sum += con + data[i];
			con += data[i];
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
	ll n, k;
	cin >> n >> k;
    k = min(k, n-1);
    combination c(n);
    mint ans = 0;
    rep(i,k+1) {
        ans += c(n,i) * c(n-1,i);
    }
	cout << ans.x << endl;
	return 0;
}


Measured memory_bytes: 3328
from collections import defaultdict

n, k = map(int, input().split())

cand_dict = defaultdict(list)
for i in range(1, n + 1):
    if ((i % k) * 2) % k == 0:
        cand_dict[i % k].append(i)

ans = 0
for i in cand_dict.values():
    ans += len(i) ** 3
print(ans)


Measured memory_bytes: 11316
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

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

    for(int i=1;i<10;i++){
        if(N%i==0){
            int S =N/i;
            if(S<10){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <functional>
#include <utility>
#include <vector>
#include <queue>
const int maxn = 500005;
std::vector<int> G[maxn]; int ind[maxn];
inline void add_edge(int u, int v) {
  G[u].push_back(v); ind[v] ++;
}

const int maxno = maxn << 2;
int maxv[maxno];
inline void maintain(int o) {
  maxv[o] = std::max(maxv[o << 1], maxv[o << 1 | 1]);
}
void modify(int o, int L, int R, int p, int v) {
  if(L == R) {
    maxv[o] = v;
  } else {
    int M = (L + R) / 2;
    if(p <= M) {
      modify(o << 1, L, M, p, v);
    } else {
      modify(o << 1 | 1, M + 1, R, p, v);
    }
    maintain(o);
  }
}
int query(int o, int L, int R, int ql, int qr) {
  if(ql <= L && R <= qr) {
    return maxv[o];
  } else {
    int M = (L + R) / 2;
    int ans = 0;
    if(ql <= M) ans = query(o << 1, L, M, ql, qr);
    if(qr > M) ans = std::max(ans, query(o << 1 | 1, M + 1, R, ql, qr));
    return ans;
  }
}
int n;
inline int query(int L, int R) {
  L = std::max(L, 1); R = std::min(R, n);
  if(L > R) return 0;
  return query(1, 1, n, L, R);
}
inline void modify(int p, int v) {
  modify(1, 1, n, p, v);
}

template<typename T>
using Heap = std::priority_queue<T, std::vector<T>, std::greater<T> >;
int P[maxn];
inline void topo() {
  Heap<int> Q;
  for(int i = 1; i <= n; i ++) {
    if(!ind[i]) Q.push(i);
  }
  int cnt = 0;
  while(!Q.empty()) {
    int u = Q.top(); Q.pop();
    P[++ cnt] = u;
    for(int v : G[u]) {
      ind[v] --;
      if(!ind[v]) Q.push(v);
    }
  }
}

int A[maxn], Q[maxn], ans[maxn];
int main() {
  int k; scanf("%d%d", &n, &k);
  for(int i = 1; i <= n; i ++) {
    scanf("%d", &A[i]);
    Q[A[i]] = i;
  }
  for(int i = 1; i <= n; i ++) {
    int th = Q[i];
    int p1 = query(th - k + 1, th);
    int p2 = query(th, th + k - 1);
    if(p1) add_edge(Q[p1], th);
    if(p2) add_edge(Q[p2], th);
    modify(th, i);
  }
  topo();
  for(int i = 1; i <= n; i ++) {
    ans[P[i]] = i;
  }
  for(int i = 1; i <= n; i ++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 46976
int main(void){

    int N,K;
    scanf("%d %d",&N,&K);
    int *h;
    h =(int *)malloc(sizeof(int)*N);
    for(int i=0;i<N;i++){
        scanf("%d",&h[i]);
    }
    int count=0;
    for(int i=0;i<N;i++){
        if(h[i]>=K){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f // -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 2000 + 5;
const int mo = 924844033;

int n, k;
LL f[N][N][2], g[N][N];
LL m[N], t[N], fac[N];

void add_path(int d) {
	for (int j = 0; j <= n; j++) t[j] = m[j];
	for (int j = 1; j <= d / 2; j++)
		for (int p = j; p <= n; p++)
			(m[p] += g[d][j] * t[p - j] % mo) %= mo;
}

int main() {
	read(n), read(k);
	f[0][0][0] = g[0][0] = m[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= i / 2; j++) {
			f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) % mo;
			if (i > 1) f[i][j][1] = g[i - 2][j - 1];
			g[i][j] = (f[i][j][0] + f[i][j][1]) % mo;
		}
	}
	fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mo;
	for (int i = 1; i <= k; i++) {
		int d = (n - i) / k + 1;
		add_path(d); add_path(d);
	}
	LL ans = 0;
	for (int i = 0, d = 1; i <= n; i++, d = -d)
		(ans += 1LL * d * m[i] * fac[n - i] % mo) %= mo;
	printf("%lld\n", (ans + mo) % mo);
	return 0;
}

Measured memory_bytes: 39680
// Problem : D - Bouquet
// Contest : AtCoder Beginner Contest 156
// URL : https://atcoder.jp/contests/abc156/tasks/abc156_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inf LLONG_MAX
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,a,b;cin>>n>>a>>b;
int x=2000005;
factorial(x);
inverse(x);
int ans=(Pow(2,n)-1+md)%md;
int calc1=1,calc2=1;
for(int i=0;i<a;i++)
calc1=(calc1*(n-i))%md;
for(int i=0;i<b;i++)
calc2=(calc2*(n-i))%md;
calc1=(calc1*inv[a])%md;
calc2=(calc2*inv[b])%md;
ans=(ans-calc1+md)%md;ans=(ans-calc2+md)%md;
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 31488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void die() {
    cout << "No" << endl;
    exit(0);
}

void solve() {
    int n;
    cin >> n;
    vector<ii> positives, negatives;
    fori (i, 0, n) {
        string s;
        cin >> s;
        int opening = 0;
        int closing = 0;
        for (auto &c : s) {
            if (c == '(') opening++;
            if (c == ')') {
                if (opening > 0) opening--;
                else closing++;
            }
        }
        if (opening - closing >= 0) positives.emplace_back(closing, opening - closing);
        else negatives.emplace_back(closing, opening - closing);
    }
    sort(begin(positives), end(positives));
    sort(begin(negatives), end(negatives), [] (ii lhs, ii rhs) {
        int a = lhs.first + lhs.second;
        int b = rhs.first + rhs.second;
        return a > b;
    });
    int unmatched_opening = 0;
    for (auto &pos : positives) {
        if (unmatched_opening < pos.first) die();
        unmatched_opening += pos.second;
    }
    for (auto &neg : negatives) {
        if (unmatched_opening < neg.first) die();
        unmatched_opening += neg.second;
    }
    if (unmatched_opening > 0) die();
    cout << "Yes" << endl;
}

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



Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if ((g * 10 + b) % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int n,m,l,i,r,t;
double sum=0;
int iti[100][100];
int ni[100][100];
scanf("%d %d %d",&n,&m,&l);
for(i=0;i<n;i++){
for(r=0;r<m;r++){
scanf("%d",&iti[i][r]);
}
}
for(i=0;i<m;i++){
for(r=0;r<l;r++){
scanf("%d",&ni[i][r]);
}
}
for(i=0;i<n;i++){
for(r=0;r<l;r++){
for(t=0;t<m;t++){
sum+=(double)iti[i][t]*ni[t][r];
}
if(r!=l-1){
printf("%.0lf ",sum);
}else{
printf("%.0lf\n",sum);
}
sum=0;
}
}
return 0;
}

Measured memory_bytes: 708
# coding: utf-8
# Your code here!

A, B = map(int, input().split())

# print(A)
# print(B)

# 6歳以上12歳以下の人はその半額で乗ることができ
# さらに5歳以下の人は無料で乗ることができます。

if A <= 5:
    print(0)
elif A <= 12:
    print(int(B / 2))
else:
    print(B)

Measured memory_bytes: 2940
def main():
    N, M = (int(i) for i in input().split())
    XY = [[int(i)-1 for i in input().split()] for j in range(M)]
    red = [False]*N
    red[0] = True
    cnt = [1]*N
    for x, y in XY:
        cnt[x] -= 1
        cnt[y] += 1
        if red[x]:
            red[y] = True
        if cnt[x] == 0:
            red[x] = False
    print(red.count(True))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61528
if __name__ == "__main__":
    while 1:
        r0,w0,c,r = list(map(int,input().strip().split()))
        if r0 ==w0 ==c ==r ==0:break
        for x in  range(10000):
            y = r0 + r*x - c*w0
            if y >=0 :break
        print(x)

Measured memory_bytes: 7700
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }

ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];


int main(){
    int s;
    cin >> s;
    vector<bool> ok (1000000,false);
    int ans = 1;
    ok[s]= true;
    rep(i,10000){
        if(s%2==0){
            s/=2;
            ans++;
            if(ok[s]) {
                cout << ans <<endl;
                return 0;
            }
            ok[s] = true;
        }
        else{
            s = s*3+1;
            ans++;
            if(ok[s]){
                cout << ans <<endl;
                return 0;
            }
            ok[s] = true;
        }
    }
}

Measured memory_bytes: 3680
#include <stdio.h>

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld",&n);

    long count=0;
    
    while( n > 0 ) {
        if(n%10==2) {
            count ++;
        }
        n = n / 10;
    }

    printf("%d\n", count);

	return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

	int n, i;
	static int a[200001], ans[200001];

	scanf("%d", &n);
	for (i = 2; i <= n; i++)scanf("%d", &a[i]);

	for (i = 0; i <= n; i++) ans[i] = 0;
	for (i = 2; i <= n; i++) ans[a[i]]++;
	for (i = 1; i <= n; i++) printf("%d\n", ans[i]);


	return 0;
}

Measured memory_bytes: 3292
i = gets.split

gets.to_i.times do
  o = gets.split.map { |e| i.index(e) }.join(' ')
  ans =
  case o
  when /1 2|2 4|3 1|4 3/ then i[0]
  when /0 3|3 5|2 0|5 2/ then i[1]
  when /0 1|1 5|4 0|5 4/ then i[2]
  when /0 4|1 0|4 5|5 1/ then i[3]
  when /0 2|2 5|3 0|5 3/ then i[4]
  when /1 3|2 1|3 4|4 2/ then i[5]
  end
  puts ans
end

Measured memory_bytes: 8724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n) cin >> a[i];
  //  ll tketa=41;
  ll x=0;
  for(int i=41; i>=0; i--){
    //  rep(i,41){//rev
    int co=0;
    int cz=0;
    rep(j,n){
      if((1LL<<i)&a[j])cz++;
      else co++;
    }
    //    cout << cz << "  " << co << endl;
    if(cz<co){
      ll xt=x|(1LL<<i);
      //      cout << xt << " <= " << k << endl;
      if(xt<=k){
	x|=(1LL<<i);
      }
    }
    //    cout << bitset<41>(x) << endl;
  }
  ll ans=0;
  rep(i,n){
    ans+=x^a[i]; 
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;

ll dp[11];
ll pow10[11], pow5[11];
int main()
{
  string S; cin >> S;
  reverse(ALL(S));

  pow10[0] = pow5[0] = 1;
  REP(i, 10) {
    pow10[i + 1] = pow10[i] * 10;
    pow5[i + 1] = pow5[i] * 5;
  }

  int N = S.size();
  dp[0] = S[0] - '0';
  REP(i, N) {
    int num = S[i + 1] - '0';
    if (i == 0) {
      dp[1] = 2*(S[0] - '0') + 11*(S[1] - '0');
      continue;
    }
    dp[i + 1] = 2*dp[i] + num*pow10[i + 1]*(9*pow5[i + 1]-1)/(8*pow5[i + 1]);
  }
  cout << dp[N - 1] << endl;

  return 0;
}

Measured memory_bytes: 256
x = int(input())

n = 200
a = [i for i in range(-n, n)]
a5 = [pow(i, 5) for i in range(-n, n)]
for i in range(2*n):
    for j in range(2*n):
        if a5[i] - a5[j] == x:
            print(f"{a[i]} {a[j]}")
            exit()

Measured memory_bytes: 9164
#include <iostream>
#include <stack>
#include <string>

int main() {
  std::string str;
  std::cin >> str;
  std::stack<int> stack;
  std::stack<std::pair<int, int>> stack2;

  for (int i = 0; i < str.size(); i++) {
    auto c = str[i];
    if (c == '\\') {
      stack.push(i);
    } else if (c == '/' && !stack.empty()) {
      int x = stack.top();
      stack.pop();

      auto current = std::make_pair(x, i - x);
      while (!stack2.empty()) {
        auto before = stack2.top();
        if (current.first > before.first) break;
        current.second += before.second;
        stack2.pop();
      }
      stack2.push(current);
    }
  }

  int total = 0;
  int count = 0;
  std::string areas = "";
  while (!stack2.empty()) {
    auto s = stack2.top();
    stack2.pop();
    total += s.second;
    count++;
    areas = " " + std::to_string(s.second) + areas;
  }

  std::cout << total << std::endl;
  std::cout << count++;
  std::cout << areas;
  std::cout << std::endl;
  return 0;
}



Measured memory_bytes: 3392
def examA():
    S = SI()
    cur = 0; ans = 0
    for i,s in enumerate(S):
        if s=="W":
            ans += i-cur
            cur +=1
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()


Measured memory_bytes: 4008
#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

const double PI = acos(-1);
constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class Task{
public:
    void solve(istream& in, ostream& out){
        lint S;
        const lint ten9 = ten(9);
        in>>S;
        lint y3 = (S+ten9-1) / ten9;
        out<<0<<' '<<0<<' '<<ten9<<' '<<1<<' '<<ten9*y3-S<<' '<<y3<<'\n';
    }
};

int main(){
    istream& in(cin);
    ostream& out(cout);
    ios_base::sync_with_stdio(false);
    in.tie(nullptr), out.tie(nullptr);
    Task solver;
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int l;
    cin>>l;
    double d=(double)l/3.0;
    printf("%.12lf\n",d*d*d);
}


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

int main(){
  int n;cin>>n;
  ll ans=0;
  int c=INF;
  rep(i,n-1){
    int b;cin>>b;
    if(c>=b)
    ans+=b;
    else
    ans+=c;
    c=b;
    if(i==n-2)
    ans+=b;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()

n = 26
i = 1
while N-n > 0:
	N -= n
	n *= 26
	i += 1
N -= 1

ans = []
for i in range(i):
	r = N % 26
	ans.append(r)
	N = N // 26

name = ''
for i in reversed(ans):
	name += chr(ord('a')+i)
print(name)


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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int n, m;

int main(){
  cin >> n >> m;
  if(m == n){
    cout << "Yes" << endl;
  }else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
S=input()
cnt_a=0
cnt_b=0
for i in range(N):
    if cnt_a<A+B:
        if S[i]=='a':
            cnt_a+=1
            print('Yes')
        elif S[i]== 'b' and cnt_b<B:
            cnt_b+=1
            cnt_a+=1
            print('Yes')
        else:
            print('No')
    else:
        print('No')

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

int main(){
    int a, b; cin >> a >> b;
    int h = 0;
    
    for(int i = 1;; i++){
        h += i;
        if(i == b - a){
            put(h - a - i);
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

int const INF = 1e9;

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

struct state {
  int score_k;
  int type;
  int last[26];
  int score;
  std::vector<state>::iterator prev;
  bool operator< (state const& rhs) const { return score_k > rhs.score_k; } // reverse order
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  int const B = 840;
  int const K = 3;
  std::vector<int> t(D);
  
  std::vector<std::vector<state>> states(D+1);
  auto beam_step = [&](int d, int k) {
    auto& prev = states[d];
    auto& curr = states[d+1];
    curr.reserve(prev.size()*26);
    int dd = std::min(d+k, D-1);
    for(auto it = prev.begin(); it != prev.end(); ++it) {
      for(int T = 0; T < 26; ++T) {
        curr.push_back(*it);
        state& st = curr.back();
        st.prev = it;
        st.last[T] = d;
        st.type = T;
        st.score_k = st.score + s[d][T];
        for(int cx = 0; cx < 26; ++cx) {
          st.score_k -= c[cx]*(d+dd - 2*st.last[cx])*(dd-d+1)/2;
        }
      }
    }
    std::sort(curr.begin(), curr.end());
    if(curr.size() > B) curr.resize(B);
    for(auto& st: curr) {
      st.score += s[d][st.type];
      for(int cx = 0; cx < 26; ++cx) {
        st.score -= c[cx]*(d - st.last[cx]);
      }
    }
  };
  
  auto beam_search = [&](int k) {
    states.assign(D+1, std::vector<state>());
    states[0].emplace_back();
    states[0][0].score = 0;
    states[0][0].score_k = 0;
    std::fill_n(states[0][0].last, 26, -1);
    for(int d = 0; d < D; ++d) beam_step(d, k);
    auto it = states[D].begin();
    for(int d = D-1; d >= 0; it = it->prev, --d) {
      t[d] = it->type;
    }
  };
  beam_search(K);
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


Measured memory_bytes: 994788
#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 = 100005;
const int MM = 1000000007;

vector<pii> T[MX];
int N;
int cnt[MX];
ll ans = 0;

int get_cnt(int x, int p = -1){
	cnt[x] = 1;
	for(pii c : T[x]){
		if( c.second == p ) continue;
		int t = get_cnt(c.second, x);
		ans += c.first * (min(t, N-t)*2ll);
		cnt[x] += t;
	}
	return cnt[x];
}

int find_root(int x){
	get_cnt(x);
	int cur = x;
	while(1){
		int mx = T[cur][0].second;
		for(pii c : T[cur]) if( cnt[c.second] > cnt[mx] ) mx = c.second;
		if( cnt[mx]*2 <= cnt[cur] ) break;
		cnt[cur] -= cnt[mx];
		cnt[mx] += cnt[cur];
		cur = mx;
	}
	return cur;
}

int main()
{
	scanf("%d", &N);
	for(int i = 1; i < N; i++){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		T[a].emplace_back(c, b);
		T[b].emplace_back(c, a);
	}
	int r = find_root(1);
	int mn = 1e9;
	for(pii c : T[r]){
		if( cnt[c.second]*2 == cnt[r] ){
			return !printf("%lld\n", ans - c.first);
		}
		mn = min(mn, c.first);
	}
	printf("%lld\n", ans - mn);
}


Measured memory_bytes: 11520
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;int h[n],m[n],j=0;fill(m,m+n,0);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  for(int i=0;i<n-1;i++){
    if(h[i]<h[i+1]){
      j++;
    }else{
      m[j]++;
    }
  }
  sort(m,m+n);
  cout << m[n-1] <<endl;
}

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

typedef long long ll;

const int N = 2e5+5;

int n;
ll bit[N] , a[N] , h[N] , resp;

void add(int pos , ll val){
  for( ; pos < N ; pos += pos&-pos) bit[pos] = max(bit[pos],val);
}

ll query(int pos){
  ll r = 0;
  for( ; pos ; pos -= pos&-pos) r = max(r,bit[pos]);
  return r;
}

int main(){
   cin >> n;

   for(int i = 1 ; i <= n ; i++) cin >> h[i];
   for(int i = 1 ; i <= n ; i++) cin >> a[i];
   for(int i = 1 ; i <= n ; i++) resp = max(resp,a[i]+query(h[i])) ,  add(h[i],a[i]+query(h[i]));

   cout << resp << "\n";

}


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

int main() {
  int y,x;
  cin >> y >> x;
  vector<vector<string>> a(y, vector<string>(x));
  for (int i = 0; i < y; i++) {
    string str; 
    cin >> str;
    for (int j=0; j < x; j++) {
      a.at(i).at(j) = str.at(j);
    }
  }
  
  bool n;
  
  //x軸削除
  vector<vector<string>> b;
  for (int i = 0; i < y; i++) {
  	n = false;
     for (int j = 0; j < x; j++ ) {
       if (a.at(i).at(j) == "#") {
         n = true;
         break;
       }
     }
    if (n) b.push_back(a.at(i));
  }
  
  //y軸削除
  int bsize = b.size();
  vector<string> c(bsize);

  for (int i = 0; i < x; i++) {
  	n = false;
     for (int j = 0; j < bsize; j++ ) {
       if (b.at(j).at(i) == "#") {
         n = true;
         break;
       }
     }
    if (n) {
       for (int j = 0; j < bsize; j++ ) {
         string q = b.at(j).at(i);
         c.at(j) += q;
       }
    }
  }

  for (int j = 0; j < bsize; j++ ) {
    cout << c.at(j) << endl;
  }
}

Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
int n, x, y;
int a[2005];

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

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int d = min(j - i, abs(i - x) + abs(j - y) + 1);
            a[d]++;
        }
    }

    for (int i = 1; i < n; i++) {
        cout << a[i] << '\n';
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  bool found = false;
  for (int i = X + 1; i <= Y; ++i) {
    if (i > a.back() && i <= *b.begin()) {
      // trace(i);
      found = true;
      break;
    }
  }
  if (found) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
  
public class Main
{ 
    //By shwetank_verma
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    static int mod=1000000007;
    static boolean primes[]=new boolean[1000007];
    
    static boolean seive(int n){
        Arrays.fill(primes,true);
        primes[0]=primes[1]=false;
        for(int i=2;i*i<=n;i++){
            if(primes[i]==true){
                for(int p=i*i;p<=n;p+=i){
                    primes[p]=false;
                }
            }
        }
        if(n<1000007){
            return primes[n];
        }
        return false;
        
    }
    static int gcd(int a,int b){
        if(b==0)
        return a;
        return gcd(b,a%b);
    }
    static long GCD(long a,long b){
        if(b==0)
        return a;
        return GCD(b,a%b);
    }
    
  
    public static void main(String[] args) 
    { 
        FastReader sc=new FastReader(); 
        try{
           
                
                int n=sc.nextInt();
                int k=sc.nextInt();
                
                int a[]=new int[n];
                for(int i=0;i<n;i++){
                    a[i]=sc.nextInt();
                }
                Arrays.sort(a);
                int s=0;
                for(int i=0;i<k;i++)
                {
                	s+=a[i];
                }
                System.out.println(s);
                
           
            
        }catch(Exception e){
            return;
        }
    } 
}


Measured memory_bytes: 33956
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    long long N;
    cin >> N;
    long long x_pos;
    for(long long i=1;i*i<=N;i++){
        if(N%i==0){
            x_pos = i;
        }else{
        }
    }
    long long ans = x_pos + (N/x_pos) - 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            var list = Input.LongList();

            var one = list.Count(x => x % 2 != 0);
            var four = list.Count(x => x % 4 == 0);
            var two = N - one - four;

            if(two == 0) {
                if(four + 1 >= one) {
                    Console.WriteLine("Yes");
                } else {
                    Console.WriteLine("No");
                }
            } else {
                if(four >= one) {
                    Console.WriteLine("Yes");
                } else {
                    Console.WriteLine("No");
                }
            }
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 22112
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> X(N), R(N);
	for (int i = 0; i < N; ++i) cin >> X[i] >> R[i];
	double l = 0.0, r = *min_element(R.begin(), R.end());
	for (int t = 0; t < 35; ++t) {
		double m = (l + r) * 0.5;
		vector<double> cl(N), cr(N);
		for (int i = 0; i < N; ++i) {
			double d = sqrt(1LL * R[i] * R[i] - m * m);
			cl[i] = X[i] - d;
			cr[i] = X[i] + d;
		}
		vector<double> cs = cl;
		cs.insert(cs.end(), cr.begin(), cr.end());
		sort(cs.begin(), cs.end());
		vector<int> imos(2 * N);
		for (int i = 0; i < N; ++i) {
			int pl = lower_bound(cs.begin(), cs.end(), cl[i]) - cs.begin();
			int pr = lower_bound(cs.begin(), cs.end(), cr[i]) - cs.begin();
			++imos[pl];
			--imos[pr];
		}
		bool ok = false;
		for (int i = 0; i < 2 * N - 1; ++i) {
			imos[i + 1] += imos[i];
			if (imos[i] == N) {
				ok = true;
				break;
			}
		}
		if (ok) l = m;
		else r = m;
	}
	cout.precision(12);
	cout << fixed << r << endl;
	return 0;
}


Measured memory_bytes: 7640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main(){
  int N;
  int now = 1;
  cin >> N;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  for( int i = 0; i < N; i++ ){
    if( A[i] == 0 ){
      cout << 0 << endl;
      return 0;
    }
    if( 1000000000000000000/now < A[i] ){
      cout << -1 << endl;
      return 0;
    }
    now *= A[i];
  }
  cout << now << endl;
}

Measured memory_bytes: 4052