akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll MOD = 998244353; 

int main(){
	int n; cin >> n;
	string s; cin >> s;
	ll res = 1;
	int rcnt = 0;
	int bcnt = 0;
	int gcnt = 0;
	for (int i = 0; i < s.size(); i++){
		char ch = s[i];
		//check the different possible orders 
		if (ch == 'R'){
			//if green and blue are both more common
			if ((gcnt <= rcnt) && (bcnt <= rcnt)){
				res *= (n - rcnt);
			}
			if ((gcnt > rcnt) && (bcnt <= rcnt)){
				res *= (gcnt - rcnt);
			}
			if ((gcnt <= rcnt) && (bcnt > rcnt)){
				res *= (bcnt - rcnt);
			}
			if ((gcnt > rcnt) && (bcnt > rcnt)){
				res *= (min(gcnt, bcnt) - rcnt);
			}
		}
		if (ch == 'G'){
			if ((rcnt <= gcnt) && (bcnt <= gcnt)){
				res *= (n - gcnt);
			}
			if ((rcnt > gcnt) && (bcnt <= gcnt)){
				res *= (rcnt - gcnt);
			}
			if ((rcnt <= gcnt) && (bcnt > gcnt)){
				res *= (bcnt - gcnt);
			}
			if ((rcnt > gcnt) && (bcnt > gcnt)){
				res *= (min(bcnt, rcnt) - gcnt);
			}
		}
		if (ch == 'B'){
			if ((gcnt <= bcnt) && (rcnt <= bcnt)){
				res *= (n - bcnt);
			}
			if ((gcnt > bcnt) && (rcnt <= bcnt)){
				res *= (gcnt - bcnt);
			}	
			if ((gcnt <= bcnt) && (rcnt > bcnt)){
				res *= (rcnt - bcnt);
			}
			if ((gcnt > bcnt) && (rcnt > bcnt)){
				res *= (min(rcnt, gcnt) - bcnt);
			}
		}
		res %= MOD;
		if (ch == 'R') rcnt++;
		if (ch == 'B') bcnt++;
		if (ch == 'G') gcnt++;
	}
	cout << res << endl;
}


Measured memory_bytes: 900
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
typedef long long ll;
int main() {
    int x,y;
    cin >> x >> y;
    int flag = 0;
    for(int i=0;i<=x;i++){
        if((4*i)+(2*(x-i)) == y){
            flag = 1;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;
 
int N;
ll T[1001];
int main(){
 
  cin>>N;
  for(int i=0;i<N;i++)cin>>T[i];
  if(N==1)cout<<T[0]<<endl;
  else{
    sort(T,T+N);
    ll res=0;
    while(1){
      if(N==3){
        res+=T[0]+T[1]+T[2];
        break;
      }
      else if(N==2){
        res+=T[1];
        break;
      }
      else{
        if(T[1]*2-T[0]<T[N-2])res+=T[0]+2*T[1]+T[N-1];
        else res+=T[N-1]+2*T[0]+T[N-2];
        N-=2;
      }
    }
    cout<<res<<endl;
  }
   
  return 0;
}


Measured memory_bytes: 1188
A, B, C, D = map(int, input().split())

while A > 0 or C > 0 :
    C = C - B
    if C <= 0 :
        print('Yes')
        break
    else :
        A = A - D
        if A <= 0 :
            print('No')
            break
        else :
            continue


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

def LIS(L):
    from bisect import bisect
    seq = []
    for a in L:
        pos = bisect(seq, a)
        if len(seq) <= pos:
            seq.append(a)
        else:
            seq[pos] = a
    return len(seq)

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
print(LIS(a[::-1]))


Measured memory_bytes: 50012
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = -1
for i in range(N):
    x -= a[i]
    if x<=0:
        if x==0:
            ans = i+1
        else: 
            ans = i
        break
print(ans if ans!=-1 else N-1)


Measured memory_bytes: 38256
h,w,a,b=map(int,input().split())
x=0
y=1
for i in range(b):
    for j in range(a):
        print(x,end='')
    for j in range(w-a):
        print(y,end='')
    print()
for i in range(h-b):
    for j in range(a):
        print(y,end='')
    for j in range(w-a):
        print(x,end='')
    print()

Measured memory_bytes: 5364
/* Filename: AGC018A.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		while (input.hasNext()) {
			int N = input.nextInt();
			int K = input.nextInt();
			int[] A = new int[N];
			int maxA = -1;
			boolean isPossible = false;

			for (int i = 0; i < A.length; ++i) {
				A[i] = input.nextInt();
				maxA = Math.max(maxA, A[i]);

				if (K == A[i]) {
					isPossible = true;
				}
			}

			if (K < maxA) {
				int gcdAll = A[0];
				for (int i = 1; i < A.length; ++i) {
					if (K % GCD(gcdAll, A[i]) == 0) {
						isPossible = true;
						break;
					}
				}
			}

			if (isPossible) {
				System.out.println("POSSIBLE");
			} else {
				System.out.println("IMPOSSIBLE");
			}
		}
	}

	private static int GCD(int a, int b) {
		return b == 0 ? a : GCD(b, a % b);
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            res += a.at(i);
        } else {
            res -= a.at(i);
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef long long ll;
ll const mod = 998244353;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string s;
    cin >> s;
    int n = s.size(),r = 0;
    vector<vector<ll>> dp(2*n+1,vector<ll>(2*n+1,0));
    dp[0][0] = 1;
    for (int i = 0;i < 2*n;++i) {
        if (i < n) {
            if (s[i] == '0') r += 2;
            else if (s[i] == '1') r += 1;
        }
        for (int j = 0;j <= i+1;++j) {
            if (j && j <= r) dp[i+1][j] = dp[i][j-1];
            if (i+1-j <= min(2*i+2,2*n)-r) dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
        }
    }
    cout << dp[2*n][r] << endl;
    return 0;
}

Measured memory_bytes: 125440
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	string str,tmp;
	int ans=0;
	while(cin >> str)
	{
		tmp=str;
		reverse(tmp.begin(),tmp.end());
		if(str==tmp)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < 19; i++) {
        if (s[i] == ',') {
            s[i] = ' ';
        }
    }
    cout << s;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll x[n],y[n],h[n];for(ll i=0;i<n;i++)cin>>x[i]>>y[i]>>h[i];
    ll idx=-1;for(ll i=0;i<n;i++)if(h[i]>=1)idx=i;
    if(idx==-1){
        ll mx=0;
        for(ll i=0;i<n;i++)mx=max(mx,x[i]+y[i]);
        cout<<"0 0 "<<mx<<"\n";
        return 0;
    }
    for(ll cx=0;cx<=100;cx++){
        for(ll cy=0;cy<=100;cy++){
            ll H = h[idx] + abs(x[idx]-cx) + abs(y[idx]-cy);
            H=max(0ll,H);
            bool f=1;
            for(ll i=0;i<n;i++){
                ll val = H - abs(x[i]-cx) - abs(y[i]-cy);
                val=max(0ll,val);
                if(val!=h[i])f=0;
            }
            if(f)return cout<<cx<<" "<<cy<<" "<<H , 0;
        }
    }
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[] count = new long[100001];
        long sum = 0;
        for (int i = 0; i < a.Length; i++)
        {
            count[a[i]]++;
            sum += a[i];
        }

        var q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            var bc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var b = bc[0];
            var c = bc[1];
            sum -= count[b] * b;
            sum += count[b] * c;
            count[c] += count[b];
            count[b] = 0;
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 45240
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#define lint long long
#define db double
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
#define N 100010
using namespace std;
int id[2][N],del[N],p[5];struct seg{int v[2];}s[N];
inline int Lcmp(int a,int b) { return s[a].v[0]>s[b].v[0]; }
inline int Rcmp(int a,int b) { return s[a].v[1]<s[b].v[1]; }
inline int gabs(int x) { return x<0?-x:x; }
int main()
{
//	freopen("data.in","r",stdin),freopen("std.out","w",stdout);
	int n;scanf("%d",&n);lint ans=0,t;
	for(int i=1;i<=n;i++) scanf("%d%d",&s[i].v[0],&s[i].v[1]);
	for(int i=1;i<=n;i++) id[0][i]=id[1][i]=i;
	sort(id[0]+1,id[0]+n+1,Lcmp),sort(id[1]+1,id[1]+n+1,Rcmp);
//	for(int i=1;i<=n;i++) debug(id[0][i])sp,debug(id[1][i])ln;
	for(int dir=0,x;dir<=1;dir++)
	{
		memset(del,0,sizeof(del)),p[0]=p[1]=1,t=x=0;
		for(int d=dir,i,q=1;max(p[0],p[1])<=n&&q<=3*n;d^=1,q++)
		{
			while(p[d]<=n&&del[id[d][p[d]]]) p[d]++;
			if(p[d]>n) break;i=id[d][p[d]];
			if(!d&&x>=s[i].v[0]) continue;
			if(d&&x<=s[i].v[1]) continue;
			del[i]=1,t+=gabs(s[i].v[d]-x),x=s[i].v[d];
//			debug(d)sp,debug(p[d])sp,debug(i)sp,debug(x)sp,debug(t)ln;
		}
		ans=max(ans,t+=gabs(x));
//		debug(t)ln;
	}
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 2176
import java.util.Scanner;


	public class Main {
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			
			if(s.equals("ABC")) {
				System.out.println("ARC");
			}else {
				System.out.println("ABC");
			}
			
			
		}
		
		
	}


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

int  main()
{
	int n,k; cin >> n >> k;
	string s; cin >> s;
	s[k-1] += 32;
	cout << s << endl;
	return (0);
}


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


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for (int i = 0; i < n; i++) {
        cout << g[i].size() << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ruia=[0]
ruib=[0]
mx=0
for (i,j) in zip(a,range(n)):
  ruia.append(ruia[j]+i)

for (i,j) in zip(b,range(m)):
  ruib.append(ruib[j]+i)
ans=0
for i in range(n+1):
  if ruia[i] > k:
    break
  while ruib[m] > k - ruia[i]:
    m -= 1
  ans = max(ans, i + m)
print(ans)



Measured memory_bytes: 134112
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n, x[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &x[i]);
	}
	int min = (1 << 31) - 1, d;
	for (int p = 1; p <= 100; p++)
	{
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			d = p - x[i];
			sum += d * d;
		}
		min = sum < min ? sum : min;
	}
	printf("%d", min);
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static int N;
	int a[]=new int[N];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		int a[]=new int[N];
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		a[N-1]=a[N-1]/2;
		for(int i=1;i<N;i++) {
			a[0]+=a[i];
		}
		System.out.println(a[0]);
	}
}

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

int main()
{
    int n;
    cin >> n;
    long long a[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    
    long long head = 0;
    long long prev = 0;
    for(int i=0; i<n; i++){
        if(i%2 == 0){
            int j = i/2;
            if(i == n-1) 
                head += max(abs(a[j] - a[0]), abs(a[j]- prev));
            else
                if(i!=0) head += abs(a[j] - prev);
            prev = a[j];
        }else{
            int j = n-1-i/2;
            if(i == n-1)
                head += max(abs(a[j] - a[0]), abs(a[j] - prev));
            else 
                head += abs(a[j] - prev);
            prev = a[j];
        }
        //cout << prev << ": "  << head << endl;
    }
    
    long long tail = 0;
    prev = 0;
        for(int i=0; i<n; i++){
        if(i%2 != 0){
            int j = i/2;
            if(i == n-1) 
                tail += max(abs(a[j] - prev), a[n-1] - a[j]);
            else 
                tail += abs(a[j] - prev);
            prev = a[j];
        }else{
            int j = n-1-i/2;
            if(i == n-1)
                tail += max(abs(a[j] - prev), a[n-1] - a[j]);
            else 
                if(i!=0) tail += abs(a[j] - prev);
            prev = a[j];
        }
        //cout << prev << ": "  << tail << endl;
    }
    
    //cout << head << " " << tail << endl;
    cout << max(head, tail) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

int main() {
    int n;
    read(n);
    REP(i,1,100000) if(1LL*i*(i+1)/2>=n) {
        printf("%d\n",i);return 0;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
lim = 1
for i in range(N): lim *= (i+1)
Prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,\
    53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

Ans = 0
for i in range(23):
    for j in range(i+1, 24):
        for k in range(j+1, 25):
            a, b, c = Prime[i], Prime[j], Prime[k]
            d, e, f = (a**4)*(b**4)*(c**2), (a**4)*(b**2)*(c**4), (a**2)*(b**4)*(c**4)
            if d <= lim and lim%d == 0: Ans += 1
            if e <= lim and lim%e == 0: Ans += 1
            if f <= lim and lim%f == 0: Ans += 1
for i in range(24):
    for j in range(i+1, 25):
        a, b = Prime[i], Prime[j]
        d, e, f, g = (a**24)*(b**2), (a**2)*(b**24), (a**4)*(b**14), (a**14)*(b**4)
        if d <= lim and lim%d == 0: Ans += 1
        if e <= lim and lim%e == 0: Ans += 1
        if f <= lim and lim%f == 0: Ans += 1
        if g <= lim and lim%g == 0: Ans += 1
for i in range(5):
    if Prime[i] ** 74 <= lim and lim % (Prime[i]**74) == 0: Ans += 1
print(Ans)

Measured memory_bytes: 3188
def main():
    n = int(input())
    s = ['' for _ in range(n)]
    for i in range(n):
        s[i] = input()

    ac = 0
    wa = 0
    tle = 0
    re = 0
    for i in range(n):
        if s[i] == 'AC':
            ac += 1
        elif s[i] == 'WA':
            wa += 1
        elif s[i] == 'TLE':
            tle += 1
        elif s[i] == 'RE':
            re += 1

    print(f'AC x {ac}')
    print(f'WA x {wa}')
    print(f'TLE x {tle}')
    print(f'RE x {re}')


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    vector<ll>arr(n);
    for(int i = 0; i < n; i++) cin >> arr[i];
    ll ans = 1;
    bool check = false;
    bool zero = false;
    for(auto v : arr){
        if(v == 0) {
            ans = 0; 
            zero = true;
            break;
        }
        if((double)log10(v) + (double)log10(ans) > (double)18){
            check = true;
            ans = -1;
        }else{
            if(ans != -1 || ans != 0)ans = ans*v;
        }
    }
    if(check == false && ans <= (ll)1e+18) cout << ans << endl;
    else if(zero )cout << ans << endl;
    else cout << - 1 << endl;
    
    return 0;
}   


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

const int MAX = 1000001; 
int factor[MAX] = { 0 }; 

void generatePrimeFactors() 
{ 
	factor[1] = 1;  
	for (int i = 2; i < MAX; i++) 
		factor[i] = i; 

	for (int i = 4; i < MAX; i += 2) 
		factor[i] = 2; 

	for (int i = 3; i * i < MAX; i++) {  
		if (factor[i] == i) {  
			for (int j = i * i; j < MAX; j += i) { 
				if (factor[j] == j) 
					factor[j] = i; 
			} 
		} 
	} 
} 

int calculateNoOFactors(int n) 
{ 
	if (n == 1) 
		return 1; 

	int ans = 1; 
	int dup = factor[n]; 
	int c = 1; 
	int j = n / factor[n]; 

	while (j != 1) { 
		if (factor[j] == dup) 
			c += 1; 
		else { 
			dup = factor[j]; 
			ans = ans * (c + 1); 
			c = 1; 
		} 
 
		j = j / factor[j]; 
	} 

	ans = ans * (c + 1); 

	return ans; 
} 

int main() 
{
	generatePrimeFactors(); 
    long long sum = 0;
	int n;
    cin>>n;
	for (int i = 1; i < n; i++) 
    {
      sum += calculateNoOFactors(n - i);
    }
  cout<<sum<<"\n";

	return 0; 
} 


Measured memory_bytes: 7492
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let k: usize = sc.read();
    let mut a: Vec<usize> = sc.vec(n);
    a.sort();

    if is_required(0, &a, k) {
        println!("0");
        return;
    }

    let mut ok = n;
    let mut ng = 0;
    while ok - ng > 1 {
        let m = (ok + ng) / 2;
        if is_required(m, &a, k) {
            ok = m;
        } else {
            ng = m;
        }
    }
    println!("{}", ok);
}

fn is_required(pos: usize, a: &[usize], k: usize) -> bool {
    if a[pos] >= k {
        return true;
    }
    let mut can = vec![false; k];
    can[0] = true;
    for (i, &a) in a.iter().enumerate() {
        if i == pos {
            continue;
        }
        for cur in (0..k).rev() {
            if can[cur] && cur + a < k {
                can[cur + a] = true;
            }
        }
    }
    for i in 0..k {
        if can[i] && i + a[pos] >= k {
            return true;
        }
    }
    false
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
using System;
using System.Linq;
using static System.Math;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var a = input[0];
        var b = input[1];
        var c = input[2];
        var d = input[3];

        Console.WriteLine(Max(Max(a * c, a * d), Max(b * c, b * d)));
    }
}


Measured memory_bytes: 28180
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,m; cin>>n>>m;
	bool s[n+5], t[n+5]; CLR(s); CLR(t);
	rep(i,m){
		int a,b; cin>>a>>b;
		if(a==1) s[b]=true;
		if(b==n) t[a]=true;
	}
	for(int i=2;i<n;i++){
		if(s[i]&&t[i]) return cout<<"POSSIBLE"<<endl,0;
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}


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

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let t: usize = itr.next().unwrap().parse().unwrap();

    let mut c = 1;
    let mut ans = 0;
    while c * a <= t {
        c += 1;
        ans += b;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, Q, A[100000], B[100000], C[100000], t[100000];
bool f;
ll M;

int par(int x) {
	if (t[x] < 0)return x;
	return t[x] = par(t[x]);
}

bool u(int x, int y) {
	x = par(x);
	y = par(y);
	if (x == y)return false;
	if (t[x] < t[y]) {
		t[x] += t[y];
		t[y] = x;
	}
	else {
		t[y] += t[x];
		t[x] = y;
	}
	return true;
}


int main() {
	cin >> N >> M >> Q;
	for (int i = 0; i < Q; ++i) {
		cin >> A[i] >> B[i] >> C[i];
	}
	for (int i = 0; i < N; ++i) {
		t[i] = -1;
	}
	for (int i = 0; i < Q; ++i) {
		if (!C[i]) {
			M -= u(A[i], B[i]);
		}
		else f = true;
	}
	ll c = 0;
	for (int i = 0; i < N; ++i) {
		if (t[i] < 0) {
			++c;
		}
	}
	for (int i = 0; i < Q; ++i) {
		if (C[i] && par(A[i]) == par(B[i])) {
			cout << "No" << endl;
			return 0;
		}
	}

	if (c*(c - 1) / 2 < M) {
		cout << "No" << endl;
		return 0;
	}
	else{
		if (!f)--c;
		if (M < c) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a>b)? a : b 
int rsort(double &a,double &b)
{
  return a>b;
}
int main()
{
	int n,k;
  	cin>>n>>k;
  	vector<double>a(n);
  	for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }  
  sort(a.begin(),a.end(),rsort);
  if(!k)
  {
    cout<<(long long)a[0]<<endl;
    return 0;
  }
  double l=0;
  double r=1e9;
  
  int t=100;
  while(t--)
  {
    double mid=(l+r)/2;
    long long cut=0;
    for(int i=0;i<n;i++)
    {
   		cut+=(long long)(a[i]/mid);
    }
    if(cut<=k) r=mid;
    else l=mid;
    //cout<<l<<" "<<r<<endl;
  }
  cout<<(long long)ceil(l)<<endl;
  
  return 0;
}
    

Measured memory_bytes: 4680
#include <bits/stdc++.h>
#define double long double

using namespace std;

int main()
{
    //freopen("INP.INP", "r", stdin);
    //freopen("OUT.OUT", "w", stdout);

    double x1, y1, x2, y2;

    cin >> x1 >> y1 >> x2 >> y2 ;

    int q;

    cin >> q;
    while (q--) {
        double x0, y0;
        cin >> x0 >> y0;

        double xM, yM;

        double alpha = x0 * (x2 - x1) + y0 * (y2 - y1);
        double beta = x1 * (y2 - y1) - y1 * (x2 - x1);
        double a = x2 - x1, b = y2 - y1;

        /*if (a != 0) xM = (alpha - (beta * a * b + alpha * b) / (a * a + b * b)) / a;
        else xM = x1;

        if (b != 0) yM = (beta * a + alpha) / (a * a + b * b);
        else yM = y1;*/

        if (a != 0) xM = (alpha - (alpha * b * b - beta * a * b) / (a * a + b * b)) / a;
        else xM = x1;

        if (b != 0) yM = - (((beta * a) - (alpha * b)) / (a * a + b * b));
        else yM = y1;

       // cerr << "alpha, beta: " << alpha << " " << beta << '\n';

       // cerr << "a, b: " << a << " " << b << '\n';

        cout << fixed << setprecision(10) << xM << " " << yM << '\n';
    }
    return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll n; cin >> n;

    vector<int> mod;
    while(1) {
        mod.push_back((n-1) % 26);
        if (n <= 26) break;
        n = (n-1) / 26;
    }
    reverse(mod.begin(), mod.end());

    string ans = "";
    FOR(i, 0, mod.size()) {
        ans += ('a' + mod[i]);            
    }
    cout << ans << endl;
}

signed main() {
    solve();
    return 0;
}

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

int main(){
  int n, tak, aok;
  cin >> n >> tak >> aok;
  --tak; --aok;
  vector<vector<int>> tre(n,vector<int>(0));
  for(int i=0; i<n-1; ++i){
    int a, b;
    cin >> a >> b;
    --a; --b;
    tre[a].push_back(b);
    tre[b].push_back(a);
  }
  vector<int> tmov(n,-1);
  vector<int> amov(n,-1);
  queue<int> que;
  que.push(aok);
  amov[aok] = 0;
  while(!que.empty()){
    int x = que.front();
    que.pop();
    for(int a:tre[x]){
      if(amov[a] != -1) continue;
      amov[a] = amov[x] + 1;
      que.push(a);
    }
  }
  que.push(tak);
  tmov[tak] = 0;
  while(!que.empty()){
    int x = que.front();
    que.pop();
    for(int a:tre[x]){
      if(tmov[a] != -1) continue;
      tmov[a] = tmov[x] + 1;
      if(tmov[a] >= amov[a]) continue;
      que.push(a);
    }
  }
  int ans = 0, nans;
  for(int i=0; i<n; ++i){
    if(tmov[i] == -1) continue;
    ans = max(ans, amov[i]-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s,t;cin>>s>>t;
    int ans=1001;
    int same=0;
    int T=t.size();
    int S=s.size();
    rep(i,S-T+1){//スタート地点がi番目
        int k=i;
        rep(j,T){
            if(s.at(k)==t.at(j)){
                same++;
            }
            k++;
        }
        ans=min(ans,T-same);
        same=0;
    }
    cout<<ans<<endl;

}


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

int main() {
	int a=0,b=0,n,T,cas=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();++i) {
		if(s[i]=='+') a++;
		else if(s[i]=='-') b++;
	}
	cout<<a-b<<endl;
	return 0;
}

//G

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

int main(){
	int n,m;
	cin>>n>>m;

	vector<int> g[m+1];

	for(int i = 0; i < n; i++){
		int a,b;
		cin>>a>>b;
		if(a>m) continue;
		g[m-a].push_back(b);
	}

	priority_queue<int> q;
	long long res = 0;
	for(int i = m-1; i>=0; i--){
		for(int b: g[i]){
			q.push(b);
		}
		if(q.empty()) continue;
		res+=q.top();
		q.pop();
	}

	cout<<res;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9 + 7;
pair<ll, ll>s4[4] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
pair<ll, ll>s8[8] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, 1}, {1, 0}, {1, -1}};

void judge() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void solve() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i])
            ans++;
    }
    cout << ans << nl;
}

signed main() {
    judge();
    boost;
    solve();
}


Measured memory_bytes: 3816
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(string S){
  string key = "keyence";
  for (int i = 0; i < S.size(); i++) {
    for (int j = i; j < S.size()+1; j++) {
      bool flag = true;
      int idx = 0;
      for (int k = 0; k < S.size(); k++) {
        if (k < i || j <= k) {
          if (idx > key.size() || key[idx] != S[k]) {
            flag = false;
            break;
          } else {
            idx++;
          }
        }
      }
      if (flag && idx == 7) {
        std::cout << "YES" << std::endl;
        return;
      }
    }
  }
  std::cout << "NO" << std::endl;
}

int main(){
  string S;
  cin >> S;
  solve(S);
  return 0;
}


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

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int tmp; cin >> tmp;
        if(tmp != i)ans++;
    }
    if(ans == 2 || ans == 0)cout << "YES";
    else cout << "NO";
    return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int a, b;
    cin >> a >> b;
    if(a < b) {
        for(int i=0; i<b; i++) {
            cout << a;
        }
    } else {
        for(int i=0; i<a; i++) {
            cout << b;
        }
    }
    cout << endl;
    return 0;
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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


signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N, K; cin >> N >> K;
    vi l(N); REP(i, N) cin >> l[i];
    sort(RALL(l));
    int ans = 0;
    REP(i, K) ans += l[i];
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
  long n;
  cin >> n;
  vvl left(n+1);
  vvl right(n+1);
  vvl data(n);
  long cntl = 0;
  long cntr = 0;
  long base = 0;
  rep(i,n){
    long k,l,r;
    cin >> k >> l >> r;
    k--;
    if(l > r){
      base += r;
      left.at(k).push_back(l-r);
      cntl++;
    }else{
      base += l;
      int pos = n-2-k;
      if(n-2-k < 0) pos = n;
      right.at(pos).push_back(r-l);
      cntr++;
    }
  }
  long ans = base;
  
  priority_queue<long, vl, greater<long>> que;
  rep(i,n){
    for(long v : left.at(i)){
      que.push(v);
    }
    while(que.size() > i+1){
      que.pop();
    }
  }
  while(que.size()){
    ans += que.top();
    que.pop();
  }
  priority_queue<long, vl, greater<long>> que2;
  rep(i,n){
    for(long v : right.at(i)){
      que2.push(v);
    }
    while(que2.size() > i+1){
      que2.pop();
    }
  }
  while(que2.size()){
    ans += que2.top();
    que2.pop();
  }
  cout << ans << endl;
}

int main(){
  int t;
  cin >> t;
  rep(i,t) Main();
}

Measured memory_bytes: 24220
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666;
int n,a[N];//,b[N];
void ls(){
	static int v[N];rep(i,1,n)v[i]=a[i];
	sort(v+1,v+n+1);
	rep(i,1,n)a[i]=lower_bound(v+1,v+n+1,a[i])-v;
}
int main() {
	read(n);rep(i,1,n)read(a[i]);//ls();
//	rep(i,1,n)printf("qaq %d\n",a[i]);
	int l=1,r=n,res=n;
	while(l<=r){
		int mid=(l+r)>>1;//memset(b,0,sizeof(b));
		bool gg=0;priority_queue<int>heap;map<int,int>b;
		rep(i,1,n){
			/*if(a[i-1]<a[i]){
				assert(heap.empty()||heap.top()<=a[i-1]);
			//	while(!heap.empty()&&heap.top()>a[i-1])b[heap.top()]=0,heap.pop();
			}else*/
			if(a[i-1]>=a[i]){
				if(mid==1){gg=1;break;}
				int j;for(j=a[i];j>=1;j--)if(b[j]<mid-1)break;if(!j){gg=1;break;}
			//	printf("find %d <%d>\n",j,a[i]);
				b[j]++;rep(k,j+1,a[i])b.erase(k);heap.push(j);//erase(j+1..a[i])
				while(!heap.empty()&&heap.top()>j)b[heap.top()]=0,heap.pop();
			}
		//	rep(j,1,(heap.empty()?0:heap.top()))printf("%d ",b[j]);puts("");
		}
		if(!gg)res=mid,r=mid-1;else l=mid+1;
	}
	cout<<res;
	return 0;
}


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

int main (){
    int A, B = 0;
    cin >> A >> B;
    string S;
    cin >> S;
    int flag = 0;
    int count = 0;
    for (int i = 0; i < S.size(); i++)
    {
        if(S[i] == '-'){
            flag++;
        }
    }
    if(flag== 1 && S[A] =='-'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
    int n, s1 = 0, s2 = 0;
    char t1[105], t2[105];
    scanf("%d", &n);
    while (n--) {
        scanf("%s", t1);
        scanf("%s", t2);
        if (strcmp(t1, t2) > 0) s1 += 3;
        if (strcmp(t1, t2) == 0) s1++, s2++;
        if (strcmp(t1, t2) < 0) s2 += 3;
    }
    printf("%d %d\n", s1, s2);
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
vi g[12525];
int c[12525];
int ans[12525];
int it;

void dfs(int p, int bef){
    ans[p] = c[it++];
    for(int to : g[p])if(to!=bef){
        dfs(to,p);
    }
}

int main(){
    scanf("%d",&n);
    REP(i,n-1){
        int a,b;
        scanf("%d%d",&a,&b);
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    REP(i,n)scanf("%d",c+i);
    sort(c,c+n);
    reverse(c,c+n);
    it = 0;
    dfs(0,-1);
    int sum = 0;
    REP(p,n)for(int q : g[p]){
        sum += min(ans[p],ans[q]);
    }
    sum /= 2;
    printf("%d\n",sum);
    REP(i,n)printf("%d%c",ans[i]," \n"[i==n-1]);
    return 0;
}


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

int main(){
    int n; 
    cin >> n;
    int l[n], sum = 0;
    for(int i = 0; i < n; i++){
        cin >> l[i];
        sum += l[i];
    }
    sort(l, l + n);
    cout << (sum > 2 * l[n-1] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int d[100];
int main()
{
	int num;
	cin >> num;
	int mini = 100000;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		int r = 0;
		for (;;)
		{
			if (z % 2 == 0)r++;
			else break;
			z /= 2;
		}
		mini = min(mini, r);
	}
	printf("%d\n", mini);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, mx[100007];
long long res;
vector<pair<int, int> >e[100007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs(int w, int f, int v)
{
	int sz = 1;
	for (int i = e[w].size() - 1; i >= 0; i--)
		if (e[w][i].first != f)
		{
			int s = dfs(e[w][i].first, w, e[w][i].second);
			mx[w] = max(mx[w], s);
			sz += s;
		}
	mx[w] = max(mx[w], n - sz);
	res += 2LL * v * min(sz, n - sz);
	return sz;
}
int main()
{
	n = read();
	for (int i = 2; i <= n; i++)
	{
		int a = read(), b = read(), c = read();
		e[a].push_back(make_pair(b, c));
		e[b].push_back(make_pair(a, c));
	}
	dfs(1, 0, 0);
	for (int i = 1; i <= n; i++)if (mx[i] <= (n / 2))
		for (int j = i + 1; j <= n; j++)if (mx[j] <= (n / 2))
			for (int k = e[i].size() - 1; k >= 0; k--)
				if (e[i][k].first == j)
				{
					cout << res - e[i][k].second << endl;
					return 0;
				}
	int mn = 1e9;
	for (int i = 1; i <= n; i++)if (mx[i] <= (n / 2))
	{
		for (int k = e[i].size() - 1; k >= 0; k--)
			mn = min(mn, e[i][k].second);
	}
	cout << res - mn << endl;
	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n >> k;
	REP(i, n)
	{
		ll a;
		cin >> a;
		v.push_back(a);
		sum += v[i];
	}
	sort(RALL(v));
	REP(i, n)
	{
		w = 0;
		FOR(j, i, n)
		{
			w += v[j];
			if (w >= k)
			{
				h = max(h, j + 1);
				w -= v[j];
			}
		}
	}
	if (sum < k)
	{
		cout << n << endl;
	}
	else
	{
		cout << n - h << endl;
	}
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
vvi g;
int N;
int K=0;
vi color;
map<pi,int> mp;

void bfs(int s){
    queue<int> q;
    q.push(s);
    vb used(N,0);
    used[s]=1;
    vector<int> cs(N,0);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        int curr=1;
        for(auto to:g[v]){
            if(used[to]){
                continue;
            }
            if(curr==cs[v]){
                curr++;
            }
            cs[to]=mp[make_pair(to,v)]=mp[make_pair(v,to)]=curr++;
            used[to]=1;
            q.push(to);
        }
    }
}




int main(){
    cin>>N;
    g.resize(N);
    vpi mpair;
    color.assign(N,-1);
    F0R(i,N-1){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
        mpair.emplace_back(a,b);
    }
    F0R(i,N){
        int z=g[i].size();
        K=max(K,z);
    }
    bfs(0);
    out(K);
    for(int i=0;i<mpair.size();i++){
        out(mp[mpair[i]]);
    }
}


Measured memory_bytes: 20084
/*

Coded and Decoded by : Yash Kapoor

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

// s.find_by_order(index);
// s.order_of_key(value);

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll, ll>
#define vl vector<ll>
#define sl set<ll>
#define vll vector<pll>
#define ml map<ll, ll>
#define mll map<pll, ll>
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define sz(x) (ll) x.size()
#define dl '\n'
#define elasped_time  1.0 * clock() / CLOCKS_PER_SEC
//#define why (ll)1000000007
#define why (ll)998244353
#define lp(i, a, b) for (ll i = a; i < b; ++i)
#define lpr(i, a, b) for (ll i = a; i >= b; i--)
#define lpd(i, x) for (auto i : x)
#define ios                                                                                                            \
  ios_base::sync_with_stdio(false);                                                                                    \
  cin.tie(0);                                                                                                          \
  cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base, ll power)
{
  ll result = 1;
  while (power) {
    if (power % 2)
      result = (result * base) % mod;
    base = (base * base) % mod;
    power /= 2;
  }
  return result;
}

ll inverse(ll base, ll mod) { return fast_power(base, mod - 2); }
int test = 1;
vl adj[200005];
vl visited(200005);
ll c,n,m;
ll dp[100005];
void dfs(ll node){
  visited[node] = 1;
  dp[node] = 0;
  for(auto i:adj[node]){
    if(!visited[i]){
      dfs(i);
    }
    dp[node] = max(dp[node], 1 + dp[i]); 
  }
}

void solve() {
  cin >> n >> m;
  for(ll i = 0; i < m; i++){
    ll x,y; cin >> x >> y;
    adj[x].push_back(y);
  }
  lp(i,0,n+1) dp[i] = 0;
  ll mx = 0;
  for(ll i = 1; i <= n; i++){
    if(!visited[i])
    dfs(i);
  }
  for(ll i = 1; i <= n; i++){
    mx= max(mx,dp[i]);
  }
  cout << mx << dl;
} 

int main()
{
  // #ifndef ONLINE_JUDGE 
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  ios 
  ll t = 1;
  //cin >> t;
  while (t--) 
  {
    //cout << "Case #" << test++ << ": ";
    solve();
  }
  //cerr<<endl<<"समय गुज़रा : "<<elasped_time<<dl;
}

Measured memory_bytes: 15204
#include<iostream>
using namespace std;
int main(){
    int H,W;
    string a;
    cin >> H >> W;
    for(int i=0;i<=H+1;i++){
        if(i==0 || i==H+1){
            for(int j=0;j<=W+1;j++)cout << '#';
        }
        else{
            cin >> a;
            cout << '#' << a << '#';
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const A = parseInt(input.split(" ")[0]);
  const B = parseInt(input.split(" ")[1]);
  for(var i = 1; i < 10001; i++) {
    var taxA = parseInt(i * 0.08)
    var taxB = parseInt(i * 0.1)
    if (taxA == A && taxB == B) {
      console.log(i)
      return
    }
  }
  console.log(-1)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7616