akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	constexpr long double initial = 1000000000;
	int n; std::cin >> n;
	std::vector<int> time(n);
	std::vector<double> log(n + 1, 0);
	for (auto i = 0; i < n; ++i) {
		std::cin >> time[i] >> log[i + 1];
		log[i + 1] = std::log10(1 - log[i + 1] / 10);
	}
	for (auto i = 1; i < log.size(); ++i) log[i] += log[i - 1];
	int q; std::cin >> q;
	for (auto i = 0; i < q; ++i) {
		int left, right; std::cin >> left >> right;
		auto from = std::lower_bound(time.begin(), time.end(), left);
		auto until = std::upper_bound(time.begin(), time.end(), right);
		std::cout << std::setprecision(15) << std::fixed << initial * std::pow(10, log[std::distance(time.begin(), until)] - log[std::distance(time.begin(), from)]) << '\n';
	}
}


Measured memory_bytes: 4464
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            Console.WriteLine(check(s) ? "Yes" : "No");
        }
    }
    static bool check(string s)
    {
        var sL = s.Length;
        var a = new string[] { "UU", "RR", "DD", "LL" };
        foreach (var x in a)
            if (sL - s.Replace(x, "").Length > 0) return false;
        return true;
    }
}



Measured memory_bytes: 17908
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+9;
const llint big=(llint)44e12;//ごめん
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int i,n,q;cin>>n;
	vector<int>dp(n+1);
	vector<int>ddp(n+1);
	for(i=1;i<=n;i++){int a;cin>>a;dp[i]=dp[i-1]+a;}
	for(i=1;i<=n;i++){int a;cin>>a;ddp[i]=max(ddp[i-1],dp[i])+a;}
	cout<<ddp[n]<<endl;
	RE;
}

Measured memory_bytes: 256
# D - AtCoder Express 2

import numpy as np

N, M, Q = map(int, input().split())
LR = np.zeros((N+1, N+1))

for _ in range(M):
    l, r = map(int, input().split())
    LR[l,r] += 1

np.cumsum(LR, axis = 0, out = LR)
np.cumsum(LR, axis = 1, out = LR)
    
for _ in range(Q):
    p, q = map(int, input().split())
    print(int(LR[q,q] - LR[p-1,q] - LR[q,p-1] + LR[p-1,p-1]))

Measured memory_bytes: 16308
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
     ios;
     lld n,m;
     cin>>n>>m;
     vector<vector<lld> > qn(m);
     rep(i,0,m-1)
     {
         lld k;
         cin>>k;
         while(k--)
         {
             lld y;
             cin>>y;
             qn[i].pb(y);
         }
     }
     vector<lld> p(m);
     rep(i,0,m-1)
     {
         cin>>p[i];
     }
     lld tem=0;
     lld ans=0;
     while(tem!=pow(2,n))
     {
         int fou=0;
         vector<lld> v(n+1);
         lld y=tem;
         lld i=1;
         while(y>0)
         {
             v[i]=y%2;
             y/=2;
             i++;
         }

         rep(i,0,m-1)
         {
             lld f=0;
             rep(j,0,qn[i].size()-1)
             {
                 f+=v[qn[i][j]];
             }
             if(f%2!=p[i])
             {
                 fou=1;
                 break;
             }
         }
         if(fou==0)
            ans++;
         tem++;
     }
     cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n,k,a, cnt = 0;

    cin>>n>>k;

    for(int i = 0; i < n; i++)
    {
        cin>>a;

        if(a >= k)
            cnt++;
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
    char s[3][80];
    char s_out[3];

    scanf("%s %s %s",s[0],s[1],s[2]);

    for(int i = 0;i < 3;i++){
        s_out[i] = s[i][0] + ('A' - 'a');
    }

    for(int i = 0;i < 3;i++){
        printf("%c",s_out[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
	int x;
	cin >> x;
	int a, b,c;
	a = b = c = 0;
	a = x / 500;
	a *= 1000;
	b = x % 500;
	c = b / 5;
	a += c * 5;
	cout << a << endl;
	return 0;
}

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

int main() {

    int* out;
    out = (int*)malloc(sizeof(int) * 10);
    int cnt = 0;

    while(1){
        int i, j, k;
        int n;
        scanf("%d", &n);

        if(n == 0){
            break;
        } else {
            int *set;
            set = (int*)malloc((sizeof(int) * n));

            for(i = 0; i < n; i++){
                scanf("%d", set + i);
            }

            for(j = 1; j<n; j++){
            int key = set[j];
            i = j-1;
            while(i >= 0 && set[i] > key){
                set[i+1] = set[i];
                i--;
            }
            set[i+1] = key;
        }

        int sum = 0;
        for(k = 1; k < n-1; k++){
            sum += set[k];
        }
            
        free(set);

        if(cnt > sizeof(out)){
            out = (int*)realloc(out, sizeof(int) * cnt * 2);
        }
        out[cnt] = (int)(sum / (n-2));
        cnt++;
    }

}
    int index;
    for(index = 0; index < cnt; index++){
        printf("%d\n", out[index]);
    }
    
    free(out);

    return 0;

}


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int n,m,x;cin>>n>>m>>x;
  vector<int> C(n);
  vector<int> A[20];
  for(int i=0;i<n;i++){
    cin>>C[i];
    for(int j=0;j<m;j++){
      int t;cin>>t;A[i].push_back(t);
    }
  }
  int ans=pow(10,9);
  for(int i=1;i<(1<<n);i++){
    int t=0;
    vector<int> V(m, 0);
    for(int j=0;j<n;j++){
      if(!(i&(1<<j))) continue;
      t+=C[j];
      for(int k=0;k<m;k++){
        V[k]+=A[j][k];
      }
    }
    bool ok=1;
    for(int j=0;j<m;j++){
      if(V[j]<x)ok=0;
    }
    if(ok){
      ans=min(ans, t);
    }
  }
  if(ans==pow(10,9)){
    puts("-1");
  }else{
    cout<<ans<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3664
//#include <bits/stdc++.h>
#include<iostream>
#include<utility>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cfloat>
#include<functional>
#include<string>
#include<numeric>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<chrono>
#include<cctype>
#include<iterator>
#include<bitset>
#include<locale>
#include<chrono>
#include<ctime>
#include<cstring> // for memset
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define all(x) x.begin(),x.end()
#define clr(v,val) memset(v,val,sizeof(v))
#define rep(i,m,n) for(int i=m ; i<n ; i++)
#define forr(i,m,n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define pff push_front
#define re return
#define bit __builtin_popcountll
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int N = 2e5 + 5;
const ll mod = 1e9 + 7;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main() {
	IO;
	string arr[] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	int ans[] = { 7,6,5,4,3,2,1 };
	string s; cin >> s;
	rep(i, 0, 7) {
		if (s == arr[i]) {
			cout << ans[i];
			break;
		}
	}
	
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll n,m;
    cin >> n >> m;
    UnionFind tree(n+m+1); //人1~n 言語n+1~n+m
    // vector<vector<ll>> A(n);
    REP(i,n){
        ll k;
        cin >> k;
        REP(j,k){
            ll x;
            cin >> x;
            tree.unite(i+1, n+x);
        }
    }
    int f= 1;
    int p= tree.root(1);
    // cout << p;
    FOR(i,2,n+1){
        // cout << i << ":" << tree.root(i) << endl;
        if(p!= tree.root(i)) f=0;
    }
    cout << ((f)?"YES":"NO") << endl;

}


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

int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int xa = min(k, a);
  k -= xa;
  int xb = min(k, b);
  k -= xb;
  int xc = k;
  int sum = xa - xc;
  cout << sum << endl;
}

Measured memory_bytes: 3628
# a^n mod p
def exp_by_sq(a, n, p):
    if n == 0:
        exp = 1
    elif n == 1:
        exp = a % p
    elif  n % 2 == 0:
        exp = exp_by_sq(a * a % p, n // 2, p)
    else:
        exp = a * exp_by_sq(a * a % p, (n - 1) // 2, p) % p
    return exp % p

# 入力
n, k = [int(x) for x in input().split()]

p = 10 ** 9 + 7
# Find n * sum_{j = 0..m}{(n choose j)^2 * (n - j)}
m = min(n, k)
# 最初の2項
binom = n # n choose 1  mod p
ans = n * ((n * n - n + 1) % p) % p  # (n choose 0)^2 * (n - 0) + (n choose 1)^2 * (n - 1)
inv = [0, 1]
inv_n = exp_by_sq(n, p - 2, p)  # n^(-1) mod p

for i in range(2, m + 1):
    inv_i = ( inv[p % i] * (p - p//i) ) % p  # inverse of i
    inv.append(inv_i)
    binom = (binom * (n - i + 1) % p) * inv_i % p
    ans = (ans + (binom * binom % p) * (n - i)) % p

ans = ans * inv_n % p
print(ans)


Measured memory_bytes: 52716
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	if ((a <= 0 && b >= 0) || (a >= 0 && b <= 0))
	{
		cout << "Zero" << endl;
	}
	else if (a > 0 && b > 0)
	{
		cout << "Positive" << endl;
	}
	else
	{
		int j = a - b;
		if (j % 2 == 0)
			cout << "Negative" << endl;
		else
			cout << "Positive" << endl;
	}
	return 0;
}

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

using namespace std;

int used[10], number[10], arr1[10], arr2[10], a = 0, b = 0, ct = 0;

void permutation ( int at, int n)
{
	if (at ==  n + 1)
	{  ct++;
	   int ct1 = 0, ct2 = 0;
		for(int i = 1; i <= n; i++)
		{
            if(arr1[i] == number[i]) ct1++;
            if(arr2[i] == number[i]) ct2++;
		}

		if(ct1 == n) a = ct;
		if(ct2 == n) b = ct;
		return ;
	}
	for(int i = 1; i <= n; i++) if(!used[i])
	{
		used[i] = 1;
		number[at] = i ;
		permutation(at + 1, n) ;
		used[i] = 0;
	}
}

int main()
{
    int n; cin  >> n;
	for(int i = 1; i <= n; i++)
    {
      cin >> arr1[i];
    }
    for(int i = 1; i <= n; i++)
    {
      cin >> arr2[i];
    }
    permutation(1,n);

   // cout << a << endl << b << endl << ct << endl;
    cout << abs(a -  b) << '\n';
    return 0;
}


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

using namespace std;
int main(void){
    int n, a, b, sum=0,tmp,x;

    cin >> n >> a >> b;
    for(int i=0;i<=n;i++){
        tmp=0;
        x=i;
        for(int j=10000;j>=1;j/=10){
            tmp+=x/j;
            x-=x/j*j;
        }
        
        if(tmp >= a && tmp <= b){
            sum+=i;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll N; cin>>N;
  vi A(N),B(N);
  rep(i,0,N) cin>>A[i]>>B[i];
  ll ans=0;
  per(i,N-1,0){
    A[i]+=ans;
    ans+=(B[i]-A[i]%B[i])%B[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int N;
    cin >> N;
    int M = N % 10;
    if (M == 3){
        cout << "bon" << endl;
    } else if (M == 0 || M == 1 || M == 6 || M == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){

  int N, D;
  cin >> N >> D;

  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; ++i){
    for (int j = 0; j < D; ++j){
      cin >> X[i][j];
    }
  }


  int val = 0;

  for (int i = 0; i < N; ++i){
    for (int j = i + 1; j < N; ++j){
      int norm = 0;
      for (int k = 0; k < D; ++k){
        int dis = X[i][k] - X[j][k];
        norm += dis * dis;
      }
      bool flag = false;
      for (int k = 0; k <= norm; ++k){
        if (k * k == norm){
          flag = true;
        }
      }
      if (flag) ++ val;
    }
  }

  cout << val << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long int l1;
typedef vector <int> vi;
typedef vector <long long int> v1;
#define pb push_back
#define iter(i,a,b) for(i=a;i<b;i++)

int main()
{
    ios_base::sync_with_stdio(false);      //for fast cin and cout streams
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
{
int a[5];
      int i;
      iter(i,0,5)
        cin>>a[i];
      int count=0;
      iter(i,0,5)
      {
if(a[i]!=0)
  count++;
        else
          break;
      }
      cout<<count+1;
   

}

return 0;
}






Measured memory_bytes: 3604
#include <vector>
#include <iostream>
using namespace std;
vector<vector<int> > adj;
int subsize[200100], c[200100];
int n;

void calc_subsize(int i, int p) {
    int s = 1;
    for (int j : adj[i]) {
        if (j != p) {
            calc_subsize(j, i);
            s += subsize[j];
        }
    }
    subsize[i] = s;
}

void solve(int i, int p, vector<vector<int> >& subs, vector<long long>& ans) {
    int k = c[i] - 1, b = subs[k].size();
    for (int j : adj[i]) {
        if (j != p) {
            solve(j, i, subs, ans);
            int card = subsize[j];
            while (subs[k].size() > b) {
                int s = subs[k].back();
                subs[k].pop_back();
                card -= subsize[s];
            }
            ans[k] -= (long long)card * (card + 1) / 2;
        }
    }
    subs[c[i]-1].push_back(i);
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> c[i];
    adj.resize(n);
    for (int i = 0; i < n-1; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    calc_subsize(0, -1);
    vector<vector<int> > subs(n);
    vector<long long> ans(n, (long long)n * (n + 1) / 2);
    solve(0, -1, subs, ans);
    for (int c = 0; c < n; c++) {
        int card = n;
        for (int s : subs[c]) card -= subsize[s];
        ans[c] -= (long long)card * (card + 1) / 2;
        cout << ans[c] << endl;
    }
}


Measured memory_bytes: 47780
n,k=map(int,input().split())
p=list(map(int,input().split()))
def g(x):
  return (1+x)/2

a=[]
ans=0
f=0
for i in range(k):
  f+=g(p[i])
a.append(f)
ans=f
for i in range(n-k):
  a.append(a[i]+g(p[k+i])-g(p[i]))
  ans=max(ans,a[i+1])
  
print(ans)

  
  


Measured memory_bytes: 71792
n = gets.chomp.to_i
ary = gets.chomp.split(" ").map(&:to_i)

c = 0
max = 0
ary.each_with_index do |v, k|
  if k == 0
    c += 1
    max = v
  else
    if max <= v && ary[k-1] <= v
      c += 1
    end  
    max = v if v > max
  end
end
p c

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<cmath>


using namespace std;



int main() {
	int N;
	int T;
	int c[105];
	int t[105];
	int cmin;
	int tle = 0;
	
	cin >> N >> T;

	for (int i = 0; i < N; i++) {
		cin >> c[i] >> t[i];
	}

	cmin = c[0];
	for (int i = 0; i < N; i++) {
		if (t[i] > T) {
			tle += 1;
		}
		else {
			if (c[i] < cmin) {
				cmin = c[i];
			}
		}
	}

	if (tle == N) {
		cout << "TLE";
	}
	else
	{
		cout << cmin;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, S: str):
    print(S[:K-1] + S[K-1].lower() + S[K:])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;
    std::vector<pair<ll, ll>> v(n);

    rep(i,n){
        ll a,b; cin >> a >> b;
        v[i] = make_pair(b,a);
    }

    sort(v.begin(), v.end());

    ll current_time = 0LL;
    bool possible = true;

    rep(i,n){

        ll a =v[i].second, b=v[i].first;

        current_time+=a;

        if(current_time > b){
            possible=false;
            break;
        }
    }

    if(possible) cout << "Yes\n";
    else cout << "No\n";
    
    
    return 0;
}

Measured memory_bytes: 3328
def solve(n):
    score = 0
    for p in range(1, n+1):
        score += p
        if score >= n:
            break
    x = score - n
    res = list(range(1,x)) + list(range(x+1,p+1))
    return "\n".join(map(str, res))

n = int(input())
print(solve(n))

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int n;
	cin >> n;
	int a[n];
	int s = 0;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		s ^= a[i];
	}
	for(int i : a) cout << (s ^ i) << '\n';

	return 0;
}


Measured memory_bytes: 5164
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=22, mod=1e9+7;
ll dp[ 1<<N ][N];
int mat[N][N],n;

ll calc(int i,int mask){
	if(i==n) return (mask==(1<<n)-1);
	
	ll &res= dp[ mask ][i];
	if(res!=-1) return res;
	res=0;
	
	for(int j=0;j<n;j++){
		if( !( mask>>j&1 ) && mat[i][j] ){
			res+=calc(i+1, mask|(1<<j));
			if(res>=mod)res-=mod;
		}
	}
	
	res%=mod;
	return res;
}

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>mat[i][j];
	memset(dp,-1,sizeof dp);
	
	cout<<calc(0,0);
}

// check for any potential overflow before submitting


Measured memory_bytes: 721280
# -*- coding: utf-8 -*-

s = input()

head = s[:2]
tail = s[2:]

result = ['MMYY', 'YYMM', 'AMBIGUOUS', 'NA']
judge = [0, 0]
months = [f'{m:02}' for m in range(1, 13)]
if head in months:
    judge[0] += 1
if tail in months:

    judge[1] += 1


if sum(judge) == 2:
    print(result[2])

elif sum(judge) == 0:
    print(result[3])
else:
    print(result[judge.index(1)])


Measured memory_bytes: 9072
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main(){
    FIN;
    ll N,M;
    cin >> N >> M;
    vector<ll> H(N);
    rep(i,0,N) cin >> H[i];
    vector<bool> ans(N,true);

    for(ll i=0;i<M;i++){
        int a,b; cin >> a >> b;
        a--; b--;
        if(H[a] > H[b]) ans[b] = false;
        else if(H[a] < H[b]) ans[a] = false;
        else{
            ans[a] = false;
            ans[b] = false;
        }
    }

    ll A = 0;
    for(ll i=0;i<N;i++)
        if(ans[i]) A++;

    cout << A << endl;

    return 0;
}


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

int main() {
  int n, a;
  set<int> s;
  cin >> n;
  REP(i, n) {
    cin >> a;
    if (s.find(a) != s.end()) {
      cout << "NO" << endl;
      return 0;
    }
    s.insert(a);
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int n = sc.nextInt();
	static String sugoroku = "";
	public static void main(String[] args) {
		inputSugoroku();
		solveSugoroku();

	}
	private static void solveSugoroku() {
		int dice = 0;
		String[] safes = sugoroku.split("0");

			for(int i = 0; i < safes.length; i++) {
				dice = Math.max(dice, safes[i].length());
			}
		System.out.println(dice + 1);
	}
	private static void inputSugoroku() {
		StringBuilder sb = new StringBuilder();

			for(int i = 0; i < n; i++) {
				sb.append(sc.nextInt());
			}

		sugoroku = sb.toString();

	}

}


Measured memory_bytes: 26452
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))


Measured memory_bytes: 146404
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int M = in.nextInt();
      int C = in.nextInt();
      int[] B = new int[M];

      for (int i = 0; i < B.length; ++i) {
        B[i] = in.nextInt();
      }

      int countSol = 0;
      for (int i = 0; i < N; ++i) {
        int sum = C;
        for (int j = 0; j < M; ++j) {
          sum += B[j] * in.nextInt();
        }
        
        if (sum > 0) {
          ++countSol;
        }
      }

      System.out.println(countSol);
    }
  }
}

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

typedef long long int ll;
typedef long double ld;

ll n;
ld dp[3007];

int main() {
    memset(dp, 0.0, sizeof(dp));
    cin >> n;

    dp[0] = 1;
    for(ll i = 0; i < n; ++i) {
        ld temp;
        cin >> temp;

        for(ll j = i + 1; j >= 0; --j) {
            if(j == 0) dp[j] = dp[j] * (1.0 - temp);
            else dp[j] = dp[j - 1] * temp + dp[j] * (1.0 - temp);
        }
    }

    //for(ll i = 0; i <= n; ++i) cout << dp[i] << ' ';

    ld ans = 0;
    for(ll i = 0; i <= n; ++i) {
        if(i > n - i) ans += dp[i];
    }

    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
		int cnt = 0;
		for(int i =a;i<=b;i++){
			if(i%c==0){
				cnt++;
			}
		}
		printf("%d",cnt);
}

Measured memory_bytes: 1736
program main
integer :: n,t,m=10000
integer,allocatable :: c(:),t2(:)
integer :: i
read(*,*)n,t
allocate(c(n),t2(n))
do i=1,n
	read(*,*)c(i),t2(i)
end do

do i=1,n
	if (t2(i) <= t) then
    	m = min(m,c(i))
    end if
end do
if (m == 10000) then
	write(*,*)'TLE'
else
	write(*,*)m
end if
end program

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

int main()
{
	int N;
	int A[100010]={},B[100010]={},C[100010]={};
	lint a,c;
	lint ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)cin >> A[i];
	for(int i=0;i<N;i++)cin >> B[i];
	for(int i=0;i<N;i++)cin >> C[i];
	
	sort(A,A+N);
	sort(B,B+N);
	sort(C,C+N);
	
	for(int i=0;i<N;i++)
	{
		a=lower_bound(A,A+N,B[i])-A;
		c=(C+N)-upper_bound(C,C+N,B[i]);
		ans+=a*c;
	}
	cout << ans << endl;
	return 0;
}


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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int ,int> PII;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int N = 2e3 + 1e2, Len = 1e4 + 1e3;

bitset<Len> dp[N]; char str[N][Len], ans[Len];
int n, k, len[N];

vector<PII> trans[2]; 

int main () {

	File();

	n = read(); k = read();

	For (i, 1, n)
		scanf ("%s", str[i] + 1), len[i] = strlen(str[i] + 1);

	dp[n + 1][0] = true;
	Fordown (i, n, 1)
		dp[i] = dp[i + 1] | (dp[i + 1] << len[i]);

	int cur = 0;
	For (i, 1, n)
		if (dp[i + 1][k - len[i]])
			trans[cur].pb(mp(i, 1));

	For (i, 1, k) {

		char res = 'z';
		for (PII to : trans[cur]) {
			chkmin(res, str[to.fir][to.sec]);
		}
		ans[i] = res;

		int pos = n;
		for (PII to : trans[cur]) {
			if (str[to.fir][to.sec] == res) {
				if (to.sec < len[to.fir])
					trans[cur ^ 1].pb(mp(to.fir, to.sec + 1));
				else
					chkmin(pos, to.fir);
			}
		}

		int rest = k - i;
		For (j, pos + 1, n) {
			if (rest >= len[j] && dp[j + 1][rest - len[j]])
				trans[cur ^ 1].pb(mp(j, 1));
		}
		trans[cur].clear(); cur ^= 1;

		while (trans[cur].size() > (int)3e3) trans[cur].pop_back();

	}
	printf ("%s\n", ans + 1);

	return 0;

}


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

using namespace std;

int main()
{
    long long int a, b;
    long long int div, rem;
    double divd, a_d, b_d;
    scanf("%lld %lld",&a, &b);
    a_d = a / 1.00;
    b_d = b / 1.00;
    div = a / b;
    if(div == 0)
    {
        rem = a;
    }
    else
    {
        rem = a % b;
    }
    divd = a_d / b_d;
    printf("%lld %lld %.5lf\n", div, rem, divd);
    return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)
//円周率: M_PI

int main() {
    int n,k; cin >> n >> k;
    vector<int> su(n+1);
    rep(i,k){
        int d; cin>>d;
        rep(j,d){
            int a; cin>>a;
            su[a]=1;
        }
    }
    int cnt=0;
    rep(i,n){
        if(su[i+1]==1) ++cnt;
    }
    cout << n-cnt << endl;
}





Measured memory_bytes: 3600
#include <stdio.h>
int main(){
	long long int a,b,c,d,e,k;
	scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&k);
	if ((b-a) > k || (c-b) > k|| (d-c) > k|| (e-d) > k|| (c-a) > k || (d-a)>k || (e-a) > k|| (d-b) > k||(e-b)>k || e-c > k){
		printf(":(");
	}
	else{
		printf("Yay!");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

#define MAXN (100000+6)
using ll = long long int;

struct union_find {
  std::vector<int> parent, rank;
  std::vector<int> size;

  union_find(int n) : parent(n), rank(n), size(n) {
    for (int i = 0; i < n; i++) {
      parent[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  int root(int x) {
    if (parent[x] == x) {
      return x;
    } else {
      parent[x] = root(parent[x]);
      return parent[x];
    }
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x == y) {
      return;
    }

    // rank and size only means for root nodes
    if (rank[x] < rank[y]) {
      parent[x] = y;
      size[y] += size[x];
    } else if (rank[x] > rank[y]) {
      parent[y] = x;
      size[x] += size[y];
    } else {
      parent[x] = y;
      rank[y] += 1;
      size[y] += size[x];
    }
  }

  void debug() {
    std::cout << "UNION-FIND --- " << std::endl;
    for (int p : parent) {
      std::cout << p << " ";
    }
    std::cout << std::endl;

    for (int p : rank) {
      std::cout << p << " ";
    }
    std::cout << std::endl;

    for (int p : size) {
      std::cout << p << " ";
    }
    std::cout << std::endl;


    std::cout << "-------------- " << std::endl;
  }
};


int main() {
  using namespace std;

  ll N, M;
  std::vector<int> A(MAXN), B(MAXN);

  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
  }

  union_find uf(static_cast<int>(N));
  ll convenience = 0;

  vector<ll> cs(static_cast<size_t>(M));

  for (ll i = M - 1; i >= 0; i--) {
    cs[i] = (N * (N - 1)) / 2 - convenience;

    int a = A[i] - 1;
    int b = B[i] - 1;

    if (uf.same(a, b)) {
      continue;
    }
    convenience += uf.size[uf.root(a)] * uf.size[uf.root(b)];
    uf.unite(a, b);
  }

  for (ll c : cs) {
    cout << c << endl; 
  }
  return 0;
}


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

string but[10] = {"", "',.!?", "abcABC", "defDEF", "ghiGHI",
                  "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV",
                  "wxyzWXYZ" };

string conv(string &s,int p,int st) {
    if(p == s.length()) return "";
    int cnt = 0;
    while(p < s.length() && s[p] == st + '0') {
        cnt++;p++;
    }

    if(st == 0) return string(cnt-1,' ') + conv(s,p,s[p]-'0');
    return string(1,but[st][(cnt-1)%(but[st].length())])
        + conv(s,p,s[p]-'0');
}

int main() {
    string s;
    while(cin>>s) {
        cout<<conv(s,0,s[0]-'0')<<endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
char hlw[100001]; int fzy=0;
int main()
{
    cin>>hlw;
    for(int i=1; i<strlen(hlw); i++)
    if(hlw[i]!=hlw[i-1]) fzy++;
    printf("%d\n", fzy);
    return 0;
}

Measured memory_bytes: 384
/*************************************************************************
	> File Name: A.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Created Time: 2020/4/19 20:32:13
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
int num[200005];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int n,a;
	scanf("%d",&n);
	For(i,2,n){
		scanf("%d",&a);
		num[a]++;
	}
	For(i,1,n) printf("%d\n",num[i]);
	return 0;
}


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

int num = 0;
int n, m;

vector< pair<int, int> > v[500500];
void add_edge(int a, int b, int c1, int c2){
//	cout << a << " to " << b << endl;
	v[a].push_back(make_pair(b, c1));
	v[b].push_back(make_pair(a, c2));
}

map< pair<int, int>, int > mp;
int get_num(int v_num, int c_num){
	pair<int, int> now = make_pair(v_num, c_num);
	if(mp.count(now)) return mp[now];
	mp[now] = num++;
//	cout << mp[now] << " and " << v_num << endl;
	add_edge(mp[now], v_num, 0, 1);
	return mp[now];
}

int dist[500500];
bool upd[500500];

int main(){
	scanf("%d%d", &n, &m);
	num = n;
	mp.clear();
	rep(i, m){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--, b--;
		int v1 = get_num(a, c);
		int v2 = get_num(b, c);
		add_edge(v1, v2, 0, 0);
	}
	deque< pair<int, int> > dq;
	memset(dist, 0x3f, sizeof(dist));
	dq.clear();
	dist[0] = 0;
	dq.push_back(make_pair(0, 0)); 
	while(!dq.empty()){
		pair<int, int> now = dq.front(); dq.pop_front();
		if(now.second != dist[now.first]) continue;
		upd[now.first] = 1;
//		cout << now.first << endl; 
		rep(i, v[now.first].size()){
			if(upd[v[now.first][i].first]) continue;
			if(v[now.first][i].second == 0){
				dist[v[now.first][i].first] = dist[now.first];
				dq.push_front(make_pair(v[now.first][i].first, dist[now.first]));
			} else {
				dist[v[now.first][i].first] = dist[now.first] + 1;
				dq.push_back(make_pair(v[now.first][i].first, dist[now.first] + 1));
			}
		}
	}
	if(dist[n-1] >= 1000000000) cout << "-1" << endl;
	else cout << dist[n-1] << endl;
	return 0;
} 

Measured memory_bytes: 58624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
    	s: chars
    }
    println!("{}", if (s[0]==s[1])&&(s[1]==s[2]){ "No"} else {"Yes"});
}


Measured memory_bytes: 4352
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if directed==False:
            pt[t[i]-1].append(s[i]-1)
    return pt

N = I()
a,b = Line(N-1,2)
d = defaultdict(int)

pt = edges_to_pt(a,b,N)
for i in range(N-1):
    x = min(a[i],b[i])
    y = max(a[i],b[i])
    d[(x-1)*N+(y-1)] = i

ans = [0]*(N-1)
used = [False]*N
used[0] = True

color = [0]*N
q = [0]
c = 1
while q:
    q1 = []
    for i in q:
        c = 1
        for j in pt[i]:
            if used[j]==False:
                if c==color[i]:
                    c += 1
                color[j] = c
                used[j] = True
                ans[d[min(i,j)*N+max(i,j)]] = c
                c += 1
                q1.append(j)
    q = q1

print(max(ans))
for i in range(N-1):
    print(ans[i])

Measured memory_bytes: 93144
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc){
        int n = sc.ni();
        int[] ar = sc.niArr0(n);
        Arrays.sort(ar);

        int l = n / 2 - 1, r = n / 2;

        out.println(ar[r] - ar[l]);
    }

    static class MyScanner{
        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
        }

        MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc(){
            return nn().charAt(0);
        }

        int ni(){
            return Integer.parseInt(nn());
        }

        long nl(){
            return Long.parseLong(nn());
        }

        double nd(){
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
        }

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
        }

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); 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() {
    int n,m;
    cin >> n >> m;
    vector<P> d(n),e(n);
    vector<vector<P>> edges(n);
    vector<int> c(n,-1),w(m,1e9);
    for (int i = 0;i < n;++i) {
        scanf("%d",&d[i].first);
        d[i].second = i;
    }
    e = d;
    for (int i = 0;i < m;++i) {
        int u,v;
        scanf("%d%d",&u,&v);
        u--;v--;
        edges[u].push_back(P(v,i));
        edges[v].push_back(P(u,i));
    }
    sort(d.begin(),d.end());
    for (int i = 0;i < n;++i) {
        // cout << i << " ";
        bool ok = false;
        for (P& p : edges[d[i].second]) {
            if (e[p.first].first <= d[i].first) {
                // cout << d[i].first << " " << d[i].second << " " << p.first << " " << p.second << endl;
                ok = true;
                if (c[d[i].second] < 0) {
                    if (c[p.first] < 0) {
                        c[d[i].second] = 0;
                        c[p.first] = 1;
                    } else {
                        c[d[i].second] = (1^c[p.first]);
                    }
                }
                if (c[p.first] < 0) c[p.first] = (1^c[d[i].second]);
                if (c[p.first] != c[d[i].second] && w[p.second] == 1e9) w[p.second] = d[i].first;
                /*
                if (c[p.first] < 0) {
                    c[p.first] = (1^c[d[i].second]);
                    w[p.second] = d[i].first;
                }*/
                break;
            }
        }
        if (ok == false) {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i = 0;i < n;++i) cout << (c[i] ? "B" : "W");
    cout << endl;
    for (int i = 0;i < m;++i) cout << w[i] << "\n";
}

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

int main(){
	int height[10];
	// input
	for(int i = 0; i < 10; i++){
		cin >> height[i];
	} 
	// sort
	sort(height, height + 10, greater<int>());
	// output
	for(int i = 0; i < 3; i++){
		cout << height[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int main(){

    long long ans ,d=1000000007;
    int N,X[27]={};
    string S,a="0abcdefghijklmnopqrstuvwxyz";
    cin>>N;
    cin>>S;

    for(int i=1;i<=26;i++){
        //文字ループ
        X[i]=1;
        for(int j=0;j<S.length();j++){
            //a[i]と一致でインクリメント
            if(S[j]==a[i]){
                X[i]++;
            }
        }
    }

    ans=1;
    for(int i=1;i<=26;i++){
        if(X[i]>0){
            ans*=X[i];
            ans%=d;
        }
    }
    ans-=1;

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

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

using namespace std;

typedef long long ll;
const ll INF = 1LL << 60;

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

    cin >> N;

    vector< vector<ll> > M;
    M.resize(N);

    for (ll i = 0; i < N; ++i) {
        M[i].clear();
    }

    for (ll i = 0; i < N-1; ++i) {
        ll a;
        ll b;

        cin >> a >> b;
        a--;
        b--;

        M[a].push_back(b);
        M[b].push_back(a);
    }

    ll K;
    vector<ll> P;

    P.resize(N);
    fill(P.begin(), P.end(), -1);

    cin >> K;

    for (ll i = 0; i < K; ++i) {
        ll v;
        ll p;
        
        cin >> v >> p;
        v--;

        P[v] = p;
    }

    vector< pair<ll, ll> > R;
    R.resize(N);

    function<pair<ll, ll> (ll, ll)> dfs = [&](ll u, ll p) {
        ll mv = -INF; // min 
        ll xv = INF;  // max

        for (ll nu: M[u]) {
            if (nu != p) {
                pair<ll, ll> rv = dfs(nu, u);

                mv = max(mv, rv.first);
                xv = min(xv, rv.second);
            }
        }

        if (P[u] >= 0) {
            mv = max(mv, P[u]);
            xv = min(xv, P[u]);
        }

        R[u] = make_pair(mv, xv);
        return make_pair(mv-1, xv+1);
    };

    dfs(0, -1);

    //for (ll i = 0; i < N; ++i) {
    //    cout << "i: " << i << ", p: " << P[i] << ", range: " << R[i].first << ", " << R[i].second << endl;
    //}
    //cout << endl;


    function<void (ll, ll)> dfs2 = [&](ll u, ll p) {
        if (p >= 0) {
            R[u].first = max(R[u].first, R[p].first-1);
            R[u].second = min(R[u].second, R[p].second+1);
        }

        for (ll nu: M[u]) {
            if (nu != p) {
                dfs2(nu, u);
            }
        }

    };

    dfs2(0, -1);

    //for (ll i = 0; i < N; ++i) {
    //    cout << "i: " << i << ", p: " << P[i] << ", range: " << R[i].first << ", " << R[i].second << endl;
    //}
    //cout << endl;

    bool B = true;

    for (ll i = 0; i < N; ++i) {
        if ((abs(R[i].first) % 2 != abs(R[i].second) % 2) || (R[i].first > R[i].second)) {
            B = false;
        }
    }

    if (B) {
        cout << "Yes" << endl;
        for (ll i = 0; i < N; ++i) {
            cout << R[i].first << endl;
        }
    } else {
        cout << "No" << endl;
    }



    return 0;
}


Measured memory_bytes: 16512
#include <stdio.h>
#include <math.h>

int main(void){
	int n;
	double x1,y1,x2,y2,x3,y3,a,b,c,s,ss,sina,r,px,py;
	scanf("%d",&n);
	while (n--){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		a = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
		b = sqrt(pow(x1-x3,2)+pow(y1-y3,2));
		c = sqrt(pow(x2-x3,2)+pow(y2-y3,2));
		s = (a+b+c)/2;
		ss = sqrt(s*(s-a)*(s-b)*(s-c));
		sina = 2*ss/b/c;
		r = a/sina/2;
		a = a*a; b = b*b; c = c*c;
		px = (a*(b+c-a)*x3 + b*(a+c-b)*x2+c*(a+b-c)*x1)/16/pow(ss,2);
		py = (a*(b+c-a)*y3 + b*(a+c-b)*y2+c*(a+b-c)*y1)/16/pow(ss,2);
		printf("%.3f %.3f %.3f\n", px, py, r);
	}
	return 0;
}

Measured memory_bytes: 664