akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
// Big two primes
#define X 1001100011100001111ll
#define mod 1000000007
#define ll long long
#define all(a) a.begin(),a.end()
#define sortall(a) sort(all(a))
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define nloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define arrip(a,n)  int a[n]; fo(i, n) cin >> a[i];
#define arrop(n)  fo(i,n) cout<<a[i]<<" ";
#define pb push_back
#define mp make_pair
#define itr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626

#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int>
#define fi first
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vpi vector<pi>
#define sz(s) s.size()
#define bits(n) __builtin_popcount(n)//Count set bits

const int MAXN = (int)((1e5) + 100);
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int max(int a, int b) {if (a > b) return a; else return b;}
int min(int a, int b) {if (a < b) return a; else return b;}


bool even(int n)
{
	if (n & 1)
		return false;
	return true;
}
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("codechefi.txt", "r", stdin);
	freopen("codechefo.txt", "w", stdout);
#endif
	fio;


	string s;
	cin >> s;

	int n = s.length();
	int cnta, cntb;
	cntb = cnta = 0;
	fo(i, n)
	{
		if (s[i] == 'A')
			cnta++;
		else if (s[i] == 'B')
			cntb++;
	}
	if (cnta > 0 && cntb > 0)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
    using namespace std;
    char a[110];
    int main(){
      int r;
      cin >> r >> a;
      if(r%2 == 1){
        printf("No\n");
        return 0;
      }
      for(int i = 0; i < r/2; i++){
        if(a[i]!=a[i+r/2]){
          printf("No\n");
       	  return 0;
        }
      }
      printf("Yes\n");
      return 0;
    }

Measured memory_bytes: 256
#! env/bin/local python3

n = int(input())
a = list(map(int, input().split()))

sub = [i for i in a if i % 2 == 0]

flag = True
for s in sub:
    if not (s % 3 == 0 or s % 5 == 0):
        flag = False

print('APPROVED' if flag else 'DENIED')



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

#define LL long long
#define PLL pair<LL,LL>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n,m,a,b;
	cin >> n >> m;
	vector<vector<LL>> g(n);
	vector<vector<LL>> gt(n);
	for (LL i = 0; i < m; i++){
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		gt[b].push_back(a);
	}
	vector<LL> res(3000,47);
	for (LL i = 0; i < n; i++){
		vector<LL> dist(n,5000);
		dist[i] = 0;
		vector<LL> prev(n);
		prev[i] = -1;
		vector<bool> closed(n,false);
		set<PLL> pq = {{0,i}};
		while (!pq.empty()){
			auto it = pq.begin();
			PLL curr = *it;
			pq.erase(it);
			if (closed[curr.second])
				continue;
			closed[curr.second] = true;
			for (LL v : g[curr.second]){
				if (dist[v] > curr.first+1){
					dist[v] = curr.first+1;
					prev[v] = curr.second;
					pq.insert({dist[v],v});
				}
			}
		}
		for (LL v : gt[i]){
			if (dist[v] > n)
				continue;
			if (dist[v]+1 < res.size()){
				res.clear();
				a = v;
				while (a >= 0){
					res.push_back(a);
					a = prev[a];
				}
			}
		}
	}
	if (res.size() > n){
		cout << "-1\n";
		return 0;
	}
	cout << res.size() << "\n";
	for (LL r : res)
		cout << r+1 << "\n";
}


Measured memory_bytes: 384
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    sum_A = sum(A)
    left, right = sum_A // N, sum_A // N + 1
    loss_1 = sum([(a - left) ** 2 for a in A])
    loss_2 = sum([(a - right) ** 2 for a in A])
    if loss_1 < loss_2:
        print(loss_1)
    else:
        print(loss_2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  set<char> cnt;
  for(ll i=0;i<n;i++) {
    cnt.insert(s[i]);
  }
  if(cnt.size()==n) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

long long gcd(long long a, long long b){
    return b ? gcd(b, a % b) : a;
}

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    long long n, m;
    cin >> n >> m;
    n = gcd(n, m);

    vector<bool> pr(1000001, 1);
    pr[0] = pr[1] = 0;
    vector<int> primes;
    for (long long i = 2; i <= 1000000; i ++){
        if (!pr[i])
            continue;
        primes.PB(i);
        for (long long j = i*i; j <= 1000000; j+=i)
            pr[j] = 0;
    }
    int ans = 1;
    for (long long a : primes){
        if (a * a > n)
            break;
        if (n % a == 0)
            ans++;
        while (n % a == 0)
            n /= a;
    }
    if (n != 1)
        ans++;
    cout << ans;
    return 0;
}  


Measured memory_bytes: 1020
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int N=2*(1e5)+10;
const ll inf=1LL<<60;
ll a[N],sum[N];
int n,m;
ll mx,mn,ans;
ll Abs(ll x){return x<0?-x:x;}
ll Sum(int l,int r){return sum[r]-sum[l-1];}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	int cut1,cut2,cut3;
	scanf("%d",&n);
	sum[0]=0;
	for (int i=1;i<=n;++i) scanf("%lld",a+i),sum[i]=sum[i-1]+a[i];
	cut1=1; cut2=2; cut3=3;
	ans=inf;
	for (;cut2<=n-2;++cut2){
		mx=-inf; mn=inf;
		for (int i=cut1;i<cut2;++i){
			if (Abs(Sum(1,i)-Sum(i+1,cut2))<mn){
				mn=Abs(Sum(1,i)-Sum(i+1,cut2));
				cut1=i;
			}
			else break;
		}
		mn=inf;
		for (int i=cut3;i<n;++i){
			if (Abs(Sum(cut2+1,i)-Sum(i+1,n))<mn){
				mn=Abs(Sum(cut2+1,i)-Sum(i+1,n));
				cut3=i;
			}
			else break;
		}
		mx=max(Sum(1,cut1),max(Sum(cut1+1,cut2),max(Sum(cut2+1,cut3),Sum(cut3+1,n))));
		mn=min(Sum(1,cut1),min(Sum(cut1+1,cut2),min(Sum(cut2+1,cut3),Sum(cut3+1,n))));
		ans=min(ans,mx-mn);
	}
	printf("%lld\n",ans);
}


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


int main() {

    int n;
    cin >> n;
    int i = n / 111;
    if (n % 111 != 0) ++i;
    cout << i * 111 << endl;
    return 0;
}

Measured memory_bytes: 256
class SegmentTree:
    def __init__(self, value, N=0, comp=lambda x,y: x<=y, reverse=False):
        M = max(len(value),N)
        N = 2**(len(bin(M))-3)
        if N < M: N *= 2
        self.N = N
        self.node = [0] * (2*N-1)
        for i in range(N):
            self.node[N-1+i] = i
        self.value = [None] * N
        for i, v in enumerate(value):
            self.value[i] = v
        self.comp = lambda x, y: True if y is None else False if x is None else comp(x,y)^reverse
        for i in range(N-2,-1,-1):
            left_i, right_i = self.node[2*i+1], self.node[2*i+2]
            left_v, right_v = self.value[left_i], self.value[right_i]
            self.node[i] = left_i if self.comp(left_v, right_v) else right_i

    def update(self, n, v):
        self.value[n] = v
        i = (self.N-1) + n
        while i > 0:
            i = (i-1)//2
            left_i, right_i = self.node[2*i+1], self.node[2*i+2]
            left_v, right_v = self.value[left_i], self.value[right_i]
            new_i = left_i if self.comp(left_v, right_v) else right_i
            if new_i == self.node[i] and new_i != n:
                break
            else:
                self.node[i] = new_i

    def at(self, n):
        if n is None:
            return None
        else:
            return self.value[n]

    def query(self, l=0, r=-1):
        return self.at(self.query_index(l,r))

    def query_index(self, l=0, r=-1):
        if r < 0: r = self.N
        L = l + self.N; R = r + self.N
        s = None
        while L < R:
            if R & 1:
                R -= 1
                if self.comp(self.at(self.node[R-1]), self.at(s)):
                    s = self.node[R-1]
            if L & 1:
                if self.comp(self.at(self.node[L-1]), self.at(s)):
                    s = self.node[L-1]
                L += 1
            L >>= 1; R >>= 1
        return s

inpl = lambda: list(map(int,input().split()))

if __name__ == '__main__':
    N, M = inpl()
    A = inpl()
    segt = SegmentTree(A, reverse=True)
    for _ in range(M):
        i = segt.query_index()
        v = segt.at(i)
        segt.update(i, v//2)
    print(sum(segt.at(i) for i in range(N)))

Measured memory_bytes: 70168
a, b, c, d, e, f = map(int, input().split())

w = 0
s = 0
max_s = f * e // (100 + e)
max_a = f // (a * 100)
max_b = f // (b * 100)
max_c = max_s // c
max_d = max_s // d

ans = 0
ans_s = 0
ans_w = 0
for ia in range(max_a + 1):
    for ib in range(max_b + 1):
        temp_w = (ia * a + ib * b) * 100
        if temp_w > f:
            break
        for ic in range(max_c + 1):
            for id in range(max_d + 1):
                temp_s = ic * c + id * d
                if temp_s > min(temp_w * e / 100, f - temp_w):
                    break
                elif temp_s + temp_w > 0:
                    temp = temp_s / (temp_s + temp_w)
                    if temp >= ans:
                        ans = temp
                        ans_s = temp_s
                        ans_w = temp_w

print((ans_w + ans_s), ans_s)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    string s;
    string t;
    string str;
    //cin.ignore();
    long long int i,j;
    vector<vector<long long int> >a(4001);
    for(i=0;i<=4000;i++) a[i]=vector<long long int>(4001,0);
   // cout<<-1;
   // cout<<-1;
   cin>>s>>t; 
    //cout<<s<<endl;
    //cout<<-1<<endl;
    for(i=0;i<=s.length();i++)
    {
        for(j=0;j<=t.length();j++)
        {
            if(j==0||i==0)
            {
                a[i][j]=0;
                continue;
            }
            else
            {
                if(s[i-1]==t[j-1])
                {
                    a[i][j]=a[i-1][j-1]+1;
                    //if(a[i][j]!=a[i-1][j]);
                   // cout<<t[j-1];
                    
                }
                else
                {
                    a[i][j]=max(a[i-1][j],a[i][j-1]);
                }
            }
        }
    }
    //int len;
    //len=a[i-1][j-1];
     i=s.length();
     j=t.length();
     string ans;
    while(i!=0&&j!=0)
    {
    	if(s[i-1]==t[j-1])
    	{
    		ans=ans+s[i-1];
    		i=i-1;
    		j=j-1;
    		
    		
		}
		else if(a[i-1][j]>a[i][j-1])
		{
			i=i-1;
		}
		else
		{
			j=j-1;
		}
	}
	for(i=ans.length()-1;i>=0;i--)
	cout<<ans[i];
}

Measured memory_bytes: 125440
#include <stdio.h>

int main(){
    int input_N, input_K;
    char input_S[51];

    scanf("%d %d", &input_N, &input_K);
    scanf("%s", input_S);

    input_S[input_K - 1] = input_S[input_K - 1] - ('A' - 'a');

    printf("%s", input_S);
}

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

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N), y(M);
    for (int i = 0; i < N; ++i)
    {
        cin >> x[i];
    }
    for (int i = 0; i < M; ++i)
    {
        cin >> y[i];
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    for (int z = -100; z <= 100; z++){
        if(X<z && z<=Y && x[N-1] < z && z <= y[0]){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define int ll
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int f(int x){
	int ans = 1;
	for(int i = 2; i<=x; ++i) ans = mod(ans*i, MOD);
	return ans;
}

// x = 2*a+b   -> 2*x = 4*a + 2*b
// y = 2*b+a
// ------------
//2*x - y = 3*a
// 2*y - x = 3*b
// tot = a+b

int32_t main(){
	fastio;
	int x, y;
	cin>> x>> y;

	if((2*x - y)%3 == 0 && (2*y - x) %3 == 0 && (2*x-y) >=0 && (2*y-x)>=0){
		int a = (2*x-y)/3;
		int b = (2*y-x)/3;
		cout<< mod(mod(f(a+b)*fexp(f(a), MOD-2, MOD), MOD)*fexp(f(b), MOD-2, MOD), MOD)<< endl;
	}
	else cout<< 0<< endl;

	return 0;
}


Measured memory_bytes: 256
import math
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=min(a,min(b,min(c,min(d,e))))
s=math.ceil(n/k)
while s*k<n:
  s+=1
print(5+s-1)

Measured memory_bytes: 38512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
int n, a[1234][1234], b[1234];
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		b[i] = 1;
		for (int j = 1; j <= n - 1; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0, sum = 0;
	while (1) {
		ans++;
		bool c = 0, s[1234] = { 0 };
		for (int i = 1; i <= n; i++) {
			if (b[i] != n && !s[i]) {
				int k = a[i][b[i]];
				if (a[k][b[k]] == i && !s[k]) {
					b[k]++; b[i]++; sum++;
					s[k] = 1; s[i] = 1;	c = 1;
				}
			}
		}
		if (sum == (n * (n - 1) / 2))break;
		if (!c) { cout << "-1\n"; return 0; }
	}
	cout << ans << endl;
}

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

int main()
{
	int N;
	cin >> N;
	vector<vector<int>> a(N, vector<int>(3));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	vector<vector<int>> dp(N, vector<int>(3));
	for (int i = 0; i < 3; i++) dp[0][i] = a[0][i];
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) if (j != k) {
				dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i][k]);
			}
		}
	}
	cout << *max_element(dp.back().begin(), dp.back().end()) << endl;
	return 0;
}


Measured memory_bytes: 11136
N, K = map(int, input().split())
P = list(map(int, input().split()))

s = sum(P[0:K])
m = s
id = 0
for i in range(1, N - K + 1):
    s += (P[i + K - 1] - P[i - 1])
    if s > m:
        id = i
        m = s

ans = 0
for j in range(id, id + K):
    ans += (P[j] + 1) / 2
print(ans)

Measured memory_bytes: 71792
#include<iostream>
#include <algorithm>
#include <cstdlib>
#include<string>
using namespace std;
int main(){
  int n,h,m,s;
  cin >> n;
  h=n/3600;
  m=(n%3600)/60;
  s=n-h*3600-m*60;

  cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> P;

int main(){
    Int N; cin >> N;

    vector<P> infant;
    rep(i,N){
        Int A; cin >> A;
        infant.push_back(P(A, i));
    }

    sort(infant.begin(), infant.end(), greater<P>());

    // dp[l][r] : 左にl人，右にr人振り分けたときの嬉しさの最大値
    vector<vector<Int>> dp(2010 ,vector<Int>(2010,0));

    rep(l,N){
        rep(r,N){
            if(l+r == N) break;
            
            Int A = infant[l+r].first, id = infant[l+r].second;

            dp[l+1][r] = max(dp[l+1][r], dp[l][r] + A*(id-l));
            dp[l][r+1] = max(dp[l][r+1], dp[l][r] + A*((N-1-r)-id));
        }
    }

    Int ans = 0;
    rep(l, N) ans = max(ans, dp[l][N-l]);

    cout << ans << endl;
}

Measured memory_bytes: 34940
#include<bits/stdc++.h>
using namespace std;
int arr[105];

int main() {
	int x;
	for(int i=0;i<3;++i) {
		cin>>x;
		arr[x]++;
	}
	int cnt=0;
	for(int i=1;i<=100;++i) if(arr[i]) cnt++;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

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

const int N = 2e5 + 1 , K = 501;
int n , m , k;
int a[N] , f[N];
bool check(int x){
	int l = 1 , tot = 0;	
	for(int i = n ; i > 0; i--){
		int y = x / f[i];
		tot += max(a[l] - y , 0ll);		
		l++;
	}
	return tot <= k;
}
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> k;

	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1 , a + 1 + n);
	for(int j = 1 ; j <= n; j++)
		cin >> f[j];
	sort(f + 1 , f + 1 + n);

	int l = 0 , r = 1e12 , res = 1e12;
	while(l <= r){
		int m = (l + r) >> 1;
		if(check(m))
			res = m , r = m - 1;
		else l = m + 1;
	}

	ret(res);
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
const int MAX=100000+5;

int n;
pair<int,int> coord[MAX];
vector<int> par(MAX,0);
vector<pair<int,pair<int,int> > > edges;
int root(int x)
{
	while(par[x]!=x)
	{	
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void union1(int x,int y)
{
	int u=root(x);
	int v=root(y);
	par[u]=v;
}
int main()
{
	cin>>n;
	vector<pair<int,int> > xc;
	vector<pair<int,int> > yc;

	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		coord[i]={x,y};
		xc.push_back({x,i});
		yc.push_back({y,i});
	}
	for(int i=1;i<=n;i++)
	{
		par[i]=i;
	}
	sort(xc.begin(),xc.end());
	sort(yc.begin(),yc.end());
	for(int i=0;i<n-1;i++)
	{
		edges.push_back({abs(xc[i].first-xc[i+1].first),{xc[i].second,xc[i+1].second}});
	}
	for(int i=0;i<n-1;i++)
	{
		edges.push_back({abs(yc[i].first-yc[i+1].first),{yc[i].second,yc[i+1].second}});
	}
	long long int sum=0;
	//kruskal
	for(int i=1;i<=n;i++)
		par[i]=i;
	sort(edges.begin(),edges.end());
	for(int i=0;i<edges.size();i++)
	{
		int w=edges[i].first;
		int u=edges[i].second.first;
		int v=edges[i].second.second;
		if(root(u)!=root(v))
		{
			union1(u,v);
			sum+=w;
		}
	}
	cout<<sum<<endl;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int h, m, h2, m2,k;
    cin >> h >> m >> h2 >> m2>>k;
    lint ans=0;
    ans = (h2 - h) * 60 + (m2 - m) -k;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;

int main(){
    ll cnt=0,ans=0;
    string str;
    cin >> str;
    for(ll i=0;i<str.size();i++){
        if(str[i]=='B') cnt++;
        else    ans+=cnt;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/abc134/tasks/abc134_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) { cin >> A[i]; }
    auto cp = A;
    sort(ALLR(cp));
    // 最大値が2つ以上存在するなら、常に最大値を出力
    if (cp[0] == cp[1]) {
        REP(i, N) { cout << cp[0] << "\n"; }
    } else {
        REP(i, N) { cout << (A[i] == cp[0] ? cp[1] : cp[0]) << "\n"; }
    }

    return 0;
}


Measured memory_bytes: 6328
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
static const ll maxLL = (ll) 1 << 62;
const ll MOD = 1000000007, INF = 1e18;

template<typename T1, typename T2>
bool pairCompare(const pair<T1, T2> &firstElof, const pair<T1, T2> &secondElof) {
    return firstElof.second > secondElof.second;
}

int mapMaxValue(std::map<ll, int> m) {
    int max = 0;
    for (std::map<ll, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (max < it->second) max = it->second;
    }
    return max;
}

int main(void) {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<pair<pii, float>> densities;
    int waterA = 0;
    int waterB = 0;
    int saltC = 0;
    int saltD = 0;
    for (int wa = 0; wa <= 30; ++wa) {
        waterA = 100 * a * wa;
        for (int wb = 0; wb <= 30; ++wb) {
            waterB = 100 * b * wb;
            for (int sc = 0; sc <= 100; ++sc) {
                saltC = c * sc;
                for (int sd = 0; sd <= 100; ++sd) {
                    saltD = d * sd;
                    int water = waterA + waterB;
                    int salt = saltC + saltD;
                    if (water + salt <= f && salt <= water * e / 100) {
                        if (water + salt > 0) {
                            float density = (float) (100 * salt) / (float) (water + salt);
                            densities.push_back(make_pair(make_pair(water + salt, salt), density));
                        }
                    }

                }
            }
        }
    }
    sort(densities.begin(), densities.end(), pairCompare<pii, float>);
    cout << densities[0].first.first << " " << densities[0].first.second << endl;
}

Measured memory_bytes: 4852
#include <iostream>

using namespace std;

#define MOD 1000000000+7

int N, M;
long long A[100000 + 10];
long long dp[100000 + 10] ;

int main(void)
{
	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		long long temp;
		cin >> temp;
		A[temp] = 1;
	}

	dp[0] = 1;
	for(int n = 1; n <= N; n++) {
		if(A[n] == 1) {
			continue;
		}
		dp[n] = dp[n - 1];
		if(2 <= n) {
			dp[n] += dp[n - 2];
		}
		dp[n] %= MOD;
	}
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

string s[] = { "SUN", "MON","TUE","WED","THU","FRI","SAT" };

void solve(std::string S){
    int r = 0;
    for (int i = 0; i < 7; ++i) {
        if (S == s[i]) {
            r = i;
        }
    }
    cout << 7 - r << endl;
}

signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

ll power(ll x,ll y,ll mod){
	ll result=1;
	while(y>0){
		if(y&1) result=result*x%mod;
		x=x*x%mod;
        y>>=1;
	}
	return result;
}

ll f(int i){
    return power(10,i,infll);
}

void solve(ll a,ll b,ll p){
    ll ans=0;
    unordered_map<ll,ll> dp;
    dp[a]=1;
    for(ll x=a; x<=b; ++x){
        dp[x]=(dp[x]+dp[x-1]+p)%p;
        ans=(ans+dp[x])%p;

        ll y=x,i=to_string(x).size();
        dp[y+1]=(dp[y+1]+dp[x])%p;
        dp[f(i)]=(dp[f(i)]-dp[x]+p)%p;
        for(;;){
            y*=10;
            ++i;
            if(y>b) break;
            dp[y]=(dp[y]+dp[x])%p;
            dp[f(i)]=(dp[f(i)]-dp[x]+p)%p;
        }
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    while(true){
        ll a,b,p;
        cin >> a >> b >> p;
        if(a==0 and b==0 and p==0) break;
        solve(a,b,p);
    }
    return 0;
}

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

int main(){
  unsigned long int N, A, B, sumFatigue=0;
  unsigned int dist1, dist2;

  cin >> N >> A >> B;
  cin >> dist1;
  
  for(int i=1; i<N; i++){
    cin >> dist2;
    sumFatigue += min((dist2 - dist1) * A, B);
    dist1=dist2;    
  }

  cout << sumFatigue << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int N,K,X=1,i;
	scanf("%d",&N);
	scanf("%d",&K);
	for(i=0;i<N;i++){
		X=(X*2<X+K)?X*2:X+K;
	}
	printf("%d\n",X);
	return 0;
}

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


string S;


void input() {
    cin >> S;
}


int main() {
    input();
    string ans = "No";
    rep(i, 2) {
        if (S[i] != S[i+1]) ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

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

	double r;
	cin >> r;
	
	cout << fixed << setprecision(6) << r * r * PI << " " << 2 * r * PI << "\n";
	
	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll md = 1000000007;
#define rep(i, b) for(i = 0; i < b; i++)
#define fr first
#define sc second
using vl = vector<ll>;
using vvl = vector<vl>;
vl p(1e6+1);

ll ad(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll ml(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

ll pw(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = (n >> 1);
        x = (x*x)%mod;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie();
    int i, n, j;
    for(i = 1; i <= 1e6; ++i) {
    	p[i] = i;
    }
    for(i = 2; i <= 1e3; ++i) {
    	if(p[i] == i) {
    		for(j = i * i; j <= 1e6; j += i) {
    			p[j] = i;
    		}
    	}
    }
    cin >> n;
    vl a(n), f(1e6+1, 0), d(1e6+1, 0), t(1e6+1, 0);
    ll g = -1, c = 0;
    for(int i = 0; i < n; i++, c = 0) {
    	cin >> a[i];
    	g = (g == -1 ? a[i] : __gcd(g, a[i]));
    	while(p[a[i]] > 1) {
    		if(f[p[a[i]]] == 0) {
    			d[c++] = p[a[i]];
    		}
    		f[p[a[i]]]++;
    		a[i] /= p[a[i]];
    	}
    	for(j = 0; j < c; ++j) {
    		t[d[j]]++;
    		f[d[j]] = 0;
    	}
    }
    int pair = 1;
    for(i = 2; i <= 1e6; ++i) {
    	if(p[i] == i) {
    		if(t[i] > 1) {
    			pair = 0;
    			break;
    		}
    	}
    }
    if(pair) {
    	cout << "pairwise coprime\n";
    } else if (g == 1) {
    	cout << "setwise coprime\n";
    } else {
    	cout << "not coprime\n";
    }
    return 0;
}

Measured memory_bytes: 42176
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    REP(i, N+1) cin >> A[i];

    ll ans = 0, d_nodes = A[N];
    vector<ll> max_nodes(N+1);
    max_nodes[0] = 1;
    ll has_next = 1;

    if((N >= 1 && A[0] == 1) || A[0] > 1) {
        cout << -1 << endl;
        return 0;
    }  

    FOR(i, 1, N) {
        max_nodes[i] = min(2 * has_next, 1LL<<60);
        has_next = max_nodes[i] - A[i];
        if((has_next < 0) || (has_next == 0 && i < N)) {
            cout << -1 << endl;
            return 0;
        }
    }

    FORR(i, N-1, 0) {
        ans += d_nodes;
        d_nodes += A[i];
        // if(d_nodes > 2 * max_nodes[i]) {
        //     cout << -1 << endl;
        //     return 0;
        // }
        d_nodes = min(d_nodes, max_nodes[i]);
        // cerr << "depth = " << i << " d_nodes = " << d_nodes << endl;
    }
    ans += d_nodes;
    cout << ans << endl;

    return 0;
}

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

const int N=1e6+50, mod=998244353;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}
inline int mul(int x,int y) {return (long long)x*y%mod;}
inline int power(int a,int b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}
inline int sgn(int x) {return (x&1) ? (mod-1) : 1;}

namespace FFT {
	const int G=3;
	int A[N],B[N],w[N],pos[N],k;
	inline void init(int n) {
		for(k=1;k<=n;k<<=1);
		memset(A,0,sizeof(int)*k);
		memset(B,0,sizeof(int)*k);
		for(int i=1;i<k;i++) pos[i]=(i&1) ? ((pos[i>>1]>>1)^(k>>1)) : (pos[i>>1]>>1);
	}
	inline void dft(int *a) {
		for(int i=1;i<k;i++)
			if(pos[i]>i) swap(a[pos[i]],a[i]);
		for(int bl=1;bl<k;bl<<=1) {
			int tl=bl<<1, wn=power(G,(mod-1)/tl);
			w[0]=1; for(int i=1;i<bl;i++) w[i]=mul(w[i-1],wn);
			for(int bg=0;bg<k;bg+=tl)
				for(int j=0;j<bl;j++) {
					int &t1=a[bg+j], &t2=a[bg+j+bl], t=mul(t2,w[j]);
					t2=dec(t1,t); t1=add(t1,t);
				}
		}
	}
	inline void func() {
		dft(A); dft(B);
		for(int i=0;i<k;i++) B[i]=mul(B[i],A[i]);
		dft(B); const int inv=power(k,mod-2);
		for(int i=0;i<k;i++) B[i]=mul(B[i],inv);
		reverse(B+1,B+k); 
	}
}
struct combin {
	int fac[N],ifac[N];
	combin() {
		fac[0]=1;
		for(int i=1;i<N;i++) fac[i]=mul(fac[i-1],i);
		ifac[0]=ifac[1]=1;
		for(int i=2;i<N;i++) ifac[i]=mul(mod-mod/i,ifac[mod%i]);
		for(int i=2;i<N;i++) ifac[i]=mul(ifac[i-1],ifac[i]); 
	}
	inline int C(int a,int b) {return mul(fac[a],mul(ifac[b],ifac[a-b]));}
} C;

struct poly {
	vector <int> a;
	poly(int d=0,int t=0) {a.resize(d+1); a[d]=t;}
	inline int& operator [](const int &i) {return a[i];}
	inline const int& operator [](const int &i) const {return a[i];}
	inline int deg() const {return a.size()-1;}
	inline poly extend(int k) {poly c=*this; c.a.resize(k); return c;}
	friend inline poly operator *(const poly &a,const poly &b) {
		poly c(a.deg()+b.deg()); FFT::init(c.deg());
		for(int i=0;i<=a.deg();i++) FFT::A[i]=a[i];
		for(int i=0;i<=b.deg();i++) FFT::B[i]=b[i];
		FFT::func();
		for(int i=0;i<=c.deg();i++) c[i]=FFT::B[i];
		return c;
	}
	inline void pt() {
		for(int i=0;i<=deg();i++) cerr<<a[i]<<' '; cerr<<'\n';
	}
};

int n,m,l;
char a[N],b[N];
int main() {
	scanf("%s%s",a,b);
	l=strlen(a);
	for(int i=0;i<l;i++)
		if(a[i]=='1' &&a[i]==b[i]) ++n;
		else if(a[i]=='1') ++m;
	poly g(n+1,0); 
	for(int i=1;i<=n+1;i++) g[i]=C.ifac[i];
	poly f(n+m,0); f[0]=1;
	for(int b=m;b;b>>=1,g=(g*g).extend(n+m+1))
		if(b&1) f=(f*g).extend(n+m+1);
	int ans=0;
	for(int i=m;i<=n+m;i++) {
		int res=mul(mul(f[i],C.fac[i]),C.C(n+m,i));
		res=mul(res,mul(C.fac[n+m-i],C.fac[n+m-i]));
		res=mul(res,C.C(n,i-m));
		res=mul(res,C.fac[i-m]);
		ans=add(ans,res);
	}
	cout<<mul(ans,C.fac[m]);
}

Measured memory_bytes: 15104
// #define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE " "

typedef long long ll;

using namespace std;

const int INF = 1e9;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

/// BEGIN //////////////////////////////////////////////////////////
 
struct Item {
public:
  bool isUsed;
  int v, w;
  Item() { }
  Item(int v, int w): isUsed(false), v(v), w(w) { }
};
  
int main() {
  int N = Scanner::nextInt();
  int W = Scanner::nextInt();
  Item items[101];
  
  REP(i, N) {
    int v = Scanner::nextInt();
    int w = Scanner::nextInt();
    items[i] = Item(v, w);
  }
  
  static int dp[102][10002];
 
  REP(i, N + 1) {
    REP(j, W + 1) {
      if (j < items[i].w) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - items[i].w] + items[i].v);
      }
    }
  }
  PRINT(dp[N][W]);

  return 0;
}

/// END   //////////////////////////////////////////////////////////

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

int main() {
  int N;
  cin >> N ;
  vector<int> A(N);
  int l,c=0;
  
  for (int i=0;i<N;i++){
    cin >> A.at(i);
  }  
  l=A.at(0);

  for (int j=0;j<N;j++){
    c++;
    if (l==2){
      cout << c;break;}
    else {
      l=A.at(l-1);}
  }
  
  if (c==N){
    cout << -1 << endl;}

}

Measured memory_bytes: 3724
# https://drken1215.hatenablog.com/entry/2020/04/05/150900
def abc161_d():
  k = int(input())
  lunlun = []

  def rec(d, val):
    # 答えリストに追加
    lunlun.append(val)
    # 10桁で打ち止め
    if d == 10: return
    # 次の桁を生成
    for j in range(-1, 2):
      add = val % 10 + j
      if 0 <= add and add <= 9:
        rec(d+1, val*10 + add)

  # メイン
  for i in range(1, 10):
    rec(1, i)
  lunlun.sort()
  ans = lunlun[k-1]
  print(ans)

abc161_d()

Measured memory_bytes: 12304
/*program by mangoyang*/
#pragma GCC optimize("Ofast", "inline")
#include<bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int ch = 0, f = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
const int N = 1000005;
int a[N], n, m, p, v;
inline int check(int mid){
    int num = 0; ll tot = 0;
    vector<int> vec;
    for(int i = 1; i <= n; i++)
        if(a[i] <= mid){
            tot += min(mid - a[i], m);
            if(m > mid - a[i])
                vec.push_back(m - mid + a[i]);
        } 
        else num++, tot += m;
    if(num >= p) return 0;
    ll now = 1ll * v * m - tot;
    if(now <= 0) return 1;
    sort(vec.begin(), vec.end(), greater<int>());
    for(int i = 0; i < (int) vec.size(); i++){
        now -= vec[i], num++;
        if(now <= 0) break;
    }
    if(num >= p) return 0;
    return 1;
}
int main(){
    read(n), read(m), read(v), read(p);
    for(int i = 1; i <= n; i++) read(a[i]);
    int l = 0, r = 2e9, res = 2e9;
    while(l <= r){
        int mid = (1ll * l + r) >> 1ll;
        if(check(mid)) res = mid, r = mid - 1;
        else l = mid + 1;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)
        if(a[i] + m >= res) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4456
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  string s;
  cin >>s;
  int ans=0;
  int key=0;
  rep(i,3){
    if(s[i]=='R'){
      ans++;
      key=max(key,ans);
    }else{
      ans=0;
    }
  }
    cout <<key<<endl;
}

Measured memory_bytes: 3628
// AOJ 2406

#include <iostream>
using namespace std;

int main(void)
{
	int n, t, e;
	int data[100];
	cin >> n >> t >> e;
	int left = (t - e), right = (t + e);
	
	for (int i = 0; i < n; i++) cin >> data[i];
	
	for (int i = left; i <= right; i++){
		for (int j = 0; j < n; j++){
			if (i % data[j] == 0){
				cout << j + 1 << endl;
				goto END;
			}
		}
	}
	
	cout << "-1" << endl;
	END: ;
	
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, C;
	cin >> A >> B >> C;
	if (C >= A && C <= B) {
		cout << "Yes" << endl;
	}
	else if(C >= B && C <= A){
		cout << "Yes" << endl;
	} 
	else{
		cout << "No" << endl;
	}

	return 0;
}



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


int main() {
	int n,m; cin>>n>>m;
	vector<int> comp(n);
	for(int i=0; i<n; i++){
		comp[i] = i+1;
	}
	vector<int> arr;
	while(m--){
		int d; cin>>d;
		while(d--){
		int x; cin>>x;
		arr.push_back(x);
		}
	}
	sort(arr.begin(), arr.end());
	arr.resize(unique(arr.begin(), arr.end()) - arr.begin());
	cout<<comp.size() -arr.size()<<endl;
}

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


int main(){
  long n,m,ans=0,a,b; cin>>n>>m;
  long h[n];
  bool ok[n];
  rep(i,n)ok[i]=true;
  
  rep(i,n)cin>>h[i];
  
  rep(i,m){
    cin>>a>>b;
    if(h[a-1]==h[b-1]){ok[a-1]=false;ok[b-1]=false;}
    else if(h[a-1]>h[b-1]){ok[b-1]=false;}
    else{ok[a-1]=false;}
  }
  
  rep(i,n)if(ok[i])ans++;

  cout<<ans<<endl;
}

Measured memory_bytes: 4516
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<list>
#include<set>
#include<stack>
#include<cstdio>
using namespace std;
char n[5];
int k[5];

int jk(int sum); // L-Sを返す
int j;

int main(){
  int cnt;
  int sum;
  int fl;
  while(1){

    scanf("%s",n);

    if(n[0]=='0'&&n[1]=='0'&&n[2]=='0'&&n[3]=='0')break;
    fl = 0;
    for(int i=0;i<3;i++){
      if(n[i] != n[i+1]){
        fl = 1;
      }
    }

    //分解
    if(fl == 1){
      sum = 0;
      j = 1000;
      for(int i=0;i<4;i++){
        k[i] = n[i]-'0';
        sum+= k[i]*j;
        j/=10;
      }

      //操作
      cnt = 0;
      while(sum != 6174){
        cnt++;
        sum = jk(sum);
      }
      cout << cnt << endl;
    }else{
      cout << "NA" << endl;
    }
  }

  return 0;
}

int jk(int sum){
  int ls,l=0,s=0;
  int j;
  j = 1000;
  for(int i=0;i<4;i++){
    k[i] = sum/j;
    sum = sum%j;
    j/=10;
  }
  sort(k,k+4);
  j = 1000;
  for(int i=0;i<4;i++){
    s+=k[i] * j;
    j/=10;
  }

  reverse(k,k+4);
  j = 1000;
  for(int i=0;i<4;i++){
    l+=k[i] * j;
    j/=10;
  }

  ls = l - s;

  return ls;
}



Measured memory_bytes: 3204
import Data.List

solver::[Int]->Int
solver ls = let srtd = sort ls in
            let neg = takeWhile (0>) srtd in
            let swaps = (div (length neg) 2)* 2 in
            let a = ((-2)* (sum (take swaps srtd))) + (sum ls) in
            let b = ((-2)* (sum (take (swaps+2) srtd))) + (sum ls) in
            max a (if swaps+2 <= length ls then b else a)

main::IO()
main=do
  _<-getLine
  dat<-return.map read.words=<<getLine
  print (solver dat)


Measured memory_bytes: 59004
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
   input! {
      n:usize,k:usize,
      mut p:[usize;n]
   }
   p.sort();
   println!("{}", p.iter().take(k).sum::<usize>());
}


Measured memory_bytes: 2128
N, M, Q = [int(v) for v in input().split()]
p = []
q = []
c = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    l, r = [int(v) for v in input().split()]
    c[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] += c[i][j-1]
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] += c[i-1][j]
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for l, r in zip(p, q):
    ans = c[r][r] + c[l-1][l-1] - c[l-1][r] - c[r][l-1]
    print(ans)

Measured memory_bytes: 18372
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<vector<int>>data(405,vector<int>(405,-1));
vector<int>pre(405,0);
int dp(int l,int r){
      if(l==r)return 0;
      int mn=INF;
      for(int x=l+1;x<=r;x++){
            if(data[l][x-1]==-1)data[l][x-1]=dp(l,x-1);
            if(data[x][r]==-1)data[x][r]=dp(x,r);
            mn=min(mn,data[l][x-1]+data[x][r]+pre[r]-pre[l-1]);
      }
      return mn;
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n;
      cin>>n;
      for(int i=1;i<=n;i++)cin>>pre[i];
      for(int i=1;i<=n;i++)pre[i]+=pre[i-1];
      cout<<dp(1,n);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
using namespace std;
 
double a, H, x;

int main() {
	scanf("%lf%lf%lf", &a,&H,&x);
	
	double h = x / (a * a);
	
	if(h > H/2) {
		printf("%lf", atan(2*(H-h)/a) * 180 / M_PI);
	} else {
		printf("%lf", atan(H*H/(2*a*h)) * 180 / M_PI);
	}
		
	return 0;
}


Measured memory_bytes: 256
N = int(input())
red = [list(map(int, input().split())) for _ in range(N)]
blue = [list(map(int, input().split())) for _ in range(N)]
ans = 0
red = sorted(red, key = lambda x:x[1] * -1)
blue = sorted(blue)
for b in blue:
	for r in red:
		if b[0] > r[0] and b[1] > r[1]:
			ans += 1
			red.remove(r)
			break
print(ans)


Measured memory_bytes: 39536
#include <stdio.h>
#include <stdlib.h>
int line[101],line1[101],n,field;
int c(const void *v1,const void *v2){
    return *(int *)v1-*(int *)v2;
}
void search(int target[],int* sum){
    int i;
    for(i=0;i<n;i++){
        if(target[i] > field){
            field=target[i];
            target[i]=0;
            (*sum)--;
            break;
        }
        if(i==n-1)
            field=0;
    }
}
int main(void){
    int i,t,o,turn,sum,sum1;
    for(;turn=0,field=0,scanf("%d",&n),n;){
        sum=sum1=n;
        for(i=0;i<n;i++)
            scanf("%d",&line[i]);
        for(i=1,t=0;i<=2*n;i++)
            for(o=0;o<n;o++){
                if(line[o] == i)
                    break;
                if(o == n-1)
                    line1[t++]=i;
            }
        qsort(line,n,sizeof(int),c);
        qsort(line1,n,sizeof(int),c);
        while(sum != 0 && sum1 != 0)
            turn==0?(search(line,&sum),turn=1):(search(line1,&sum1),turn=0);
        printf("%d\n%d\n",sum1,sum);
    }
    return 0;
}

Measured memory_bytes: 604