akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int[] n = new int[3];
        for (int i=0;i < 3 ;i++ ) {
            n[i] = Integer.parseInt(sc.next());
        }
        
        Arrays.sort(n);
        
        int ans = 10*n[2]+n[1]+n[0];
        
        System.out.println(ans);
        
    }
}

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

int main(){
    int N,i=1,cnt=0;
    string S;
    cin >> S;
    N = S.size();
    while(i<S.size()){
        if(S[i]!=S[i-1] && i>0){
            cnt += 2;
            S = S.erase(i-1,2);
            i -= 1;
        }
        else ++i;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include <queue>
#include<cstdio>
#include<algorithm>
#include<iostream>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i = 0; k < (ll)n ,i++)

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a)cout << k << endl;
	else if (k <= a + b)cout << a << endl;
	else cout << a - (k - a - b) << endl;
	return 0;
}






Measured memory_bytes: 3192
S = gets.chomp

c = S.size

until c.zero?
  if S[c - 5, 5] == 'erase' || S[c - 5, 5] == 'dream'
    c -= 5
  elsif S[c - 6, 6] == 'eraser'
    c -= 6
  elsif S[c - 7, 7] == 'dreamer'
    c -= 7
  else
    puts 'NO'
    exit
  end
end

puts 'YES'


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
int n,sum=0;
cin>>n;
int d[n];
for(int i=0;i<n;i++){
  cin>>d[i];
  for(int j=i+1;j<n;j++){
    cin>>d[j];
    sum+=d[i]*d[j];
  }
}
  cout<<sum<<endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

char S[MX];
bool n, s, w, e;

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>(S+1);
    for(int i=1; S[i]!=0; i++){
        if(S[i]=='N') n=true;
        if(S[i]=='S') s=true;
        if(S[i]=='W') w=true;
        if(S[i]=='E') e=true;
    }
    bool ans=(!(n^s)) && (!(e^w));
    cout<<(ans ? "Yes" : "No");
    return 0;
}

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

int main()
{
    int n,x;
    cin>>n>>x;
    int m[110];
    int ans=0;
    for(int i=0;i<n;i++){
         cin>>m[i];
         ans++;
         x-=m[i];
    }
sort(m,m+n);
    if(x) ans+=x/m[0];
   cout<<ans<<endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int sum=0;
  for(int i=0; i<N; i++){
    cin >> a.at(i);
    sum+= a.at(i);
  }
  int ave=sum/N;
  int ans=0; int ant=0;
  for(int i=0; i<N; i++){
    ans+=(a.at(i)-ave)*(a.at(i)-ave);
    ant+=(a.at(i)-ave-1)*(a.at(i)-ave-1);
  }
  ans=min(ans, ant);
  cout << ans << endl;
}

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

using namespace std;

long long ans,num,s[100010];

int main()
{
    int n,i,m,a;
    cin >> n >> m;
    for(i = 1; i <= n; i ++)
    {
        scanf("%d",&a);
        s[i] = (s[i-1] + a) % m;
    }
    sort(s+1,s+n+1);
    for(i = 1; i < n; i ++)
    {
        if(s[i] == s[i+1]) ans ++;
        else
        {
            ans ++;
            if(s[i] == 0)
            num += ans * (ans+1) / 2;
            else
            num += ans * (ans-1) / 2;
            ans = 0;
        }
    }
    if(s[n] == s[n-1]) ans ++;
    if(s[n-1] == 0)
        num += ans * (ans+1) / 2;
    else
        num += ans * (ans-1) / 2;
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;


int main() {
    string s, p;
    int k;
    bool found = false;
    getline(cin, s);
    getline(cin, p);

    s = s + s;
    for (int i = 0; i < s.length(); i++) {
        k= i;
        found = false;
        for (int j = 0; j < p.length(); j++) {
            if (s[k++] != p[j]) {
                break;
            }
            else if (j==p.length()-1) found = true;

        }
        if (found) break;
    }
    if (found) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3220
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-15 07:28:50
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int x, a, b; cin >> x >> a >> b;
  int pass = b - a;

  if (pass <= 0) {
    cout << "delicious" << endl;
  } else if (pass <= x) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }

  return 0;
}

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

#define FOR(i, a, b) for (long long i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

typedef long long LL;

LL a[10001];
LL b[10001];

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

    LL N, count, sub_count, sub_a_count=0, sub_b_count=0;
    LL a_count=0;
    LL b_count=0;
    cin >> N;
    REP(i, N){
        cin >> a[i];
        a_count += a[i];
    }
    REP(i, N){
        cin >> b[i];
        b_count += b[i];
    }
    count = b_count - a_count;
    REP(i, N){
        if (a[i] > b[i]){
            sub_b_count += a[i] - b[i];
        }
    }
    REP(i, N){
        if (a[i] < b[i]){
            sub_a_count += LL((b[i] - a[i] + 1) / 2);
        }
    }
    if (count >= 0 && sub_a_count <= count){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

char la(string s){
  return s[0] - 'a' + 'A';
}
int main(int argc, char const *argv[]) {
  string a, b, c;
  std::cin >> a >> b >> c;
  string ans = "";
  ans = ans + la(a)+la(b)+la(c);
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
    double a, b;
    cin >> a >> b;
    double h, m;

    double pi = 2.0 * asin(1.0);
    double unit = pi / 180.0;
    cin >> h >> m;
    h = h * 60 + m;
    m *= 6;
    h = h / (double)720 * 360;
    double cc = h - m;
    if (cc < 0)
        cc += 360;

    cc = min(cc, 360 - cc);
    cc = unit * cc;
    // cout << cc << endl;

    double ans = a * a + b * b - 2 * a * b * cos(cc);

    cout << fixed << setprecision(10) << sqrt(ans) << endl;

    // cout << h << "  " << m << endl;
}

Measured memory_bytes: 4224
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

long a, b, k;
int x = 0;
int main()
{
	scanf("%ld %d %ld", &a,&b,&k);

	for (long i = k; i > 0; i--) {
		if (x == 0) {
			if (a % 2 == 0) {
				b += a / 2;
				a /= 2;
			}
			else {
				a--;
				b += a / 2;
				a /= 2;
			}
			x++;
		}
		else {
			if (b % 2 == 0) {
				a += b / 2;
				b /= 2;
			}
			else {
				b--;
				a += b / 2;
				b /= 2;
			}
			x--;
		}
	}
	printf("%ld %ld\n", a, b);
}

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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
    ll k; cin >> k;
    ll ans = 0;
    rep(i,1,k){
        rep(j,1,k){
            rep(p,1,k){
                ans += __gcd(i,__gcd(j,p));
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
//0の場合のアレンジに注意
template<class T>
T gcd(T a,T b){
    if(a == 0)return b;
    else if(b == 0)return a;
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}

template<class T = ll>
T in(){T x;cin >> x;return x;}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll N = in(),T = in();
    vector<ll> vec(N);
    vecin(vec);
    ll ans = 0;
    rep(i,N){
        if(i == N - 1)ans += T;
        else{
            ans += min(vec[i + 1] - vec[i],T);
        }
    }
    cout << ans << "\n";
}

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

int main(){
	cout.precision(13);
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int ans[3][3];
	cin >> ans[0][0] >> ans[0][1] >> ans[1][1];
	int s = ans[1][1] * 3;
	ans[0][2] = s - ans[0][0] - ans[0][1];
	ans[1][0] = s - 2 * ans[0][0] - ans[0][1] + ans[1][1];
	ans[1][2] = 2 * ans[0][0] + ans[0][1] - 2* ans[1][1];
	ans[2][0] = ans[0][0] + ans[0][1] - ans[1][1];
	ans[2][1] = s - ans[0][1] - ans[1][1];
	ans[2][2] = s - ans[0][0] - ans[1][1];
	for(int i = 0;i < 3;++i)
	{
		for(int j = 0;j < 3;++j)
			cout << ans[i][j] << ' ';
		cout << '\n';
	}
}


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

using namespace std;

int main() {
  int x, y; cin >> x >> y;
  x--, y--;
  int pos[] = {300000, 200000, 100000};
  int ans = 0;
  if(x <= 2) ans += pos[x];
  if(y <= 2) ans += pos[y];
  cout << ans + (x == 0 and y == 0) * 400000 << '\n';
}

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

int main(){
  int n;
  cin >> n;
  vector<pair<string, int>> playlist(n);
  for (int i = 0; i < n; i++) {
    string s;
    int t;
    cin >> s >> t;
    playlist.at(i).first = s;
    playlist.at(i).second = t;
  }

  string playing;
  cin >> playing;
  int ans = 0;
  for (int i = n-1; i > 0; i--) {
      if (playlist.at(i).first == playing) break;
      ans += playlist.at(i).second;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

VL node;
int n;
VVI e;
vector<bool> visited;

void dfs(int now, LL point){
    node[now]+=point;
    visited[now]=true;
    for(auto next : e[now]){
        if(visited[next]){
            continue;
        }
        dfs(next, node[now]);
    }

}

void Main()
{
    int q;cin>>n>>q;

    e.resize(n);
    REP(i,n-1){
        int a,b;cin>>a>>b;
        a--;b--;
        e[a].PB(b);
        e[b].PB(a);
    }

    node.resize(n);
    REP(i,q){
        int p,x;cin>>p>>x;
        p--;
        node[p] += x;
    }

    visited.resize(n,false);
    dfs(0,0);

    REP(i,n){
        if(i!=0) cout<<" ";
        cout<<node[i];
    }
    cout<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 24320
#include <stdio.h>

#define MAX_LEN 20

int main(){
	char buf[MAX_LEN];
	int y1,y2,i,cnt;
	int first=1;
	while(fgets(buf,MAX_LEN,stdin)!=NULL){
		if(sscanf(buf,"%d %d",&y1,&y2)<2){
			fprintf(stderr,"error:invalid input\n");
		}else if((y1==0)&&(y2==0)){
			break;
		}else{
			if(first){
				first = 0;
			}else{
				printf("\n");
			}
			cnt=0;
			for(i=y1;i<=y2;i++){
				if(((i%4==0)&&(i%100!=0))||(i%400==0)){
					printf("%d\n",i);
					cnt++;
				}
			}
			if(cnt==0)printf("NA\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define piii pair<int,pair<int,int> >
#define pii pair<int,int>
#define ll long long
pii a[100005];
bool comp(pair<int,int> a, pii b){
    return a.second<b.second;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m,x,y;
    cin>>n>>m;
    for(int i=0;i<m;i++){
            cin>>x>>y;
            a[i]={x,y};
    }
    int ma=0,ans=0;
    sort(a,a+m,comp);
    for(int i=0;i<m;i++){
        if(a[i].first>=ma){
            ma=a[i].second;
            ans++;
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef int ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

void recursive_debug(string) { cerr << endl; }

template<class H,class... T>
void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}

template<class T,class U>
ostream& operator<<(ostream& ost, const pair<T,U> &p) {
    ost << "(" << p.first << ", " << p.second << ")";
    return ost;
}

template<class T>
ostream& operator<<(ostream &ost, const vector<T> &v) {
    ost << "[";
    for(T t : v) ost << t << ",";
    ost << "]";
    return ost;
}

struct State {
    ll score;
    vector<int> last;
    vector<int> types;
    bool operator<(const State& rhs) const {
        return (score < rhs.score);
    }
    bool operator>(const State& rhs) const {
        return (score > rhs.score);
    }
};


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, M = 26;
    cin >> D;
    vector<ll> c(M);
    rep(i,M) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(M));
    rep(d,D) rep(i,M) cin >> s[d][i];

    set<State> cur_states = {{0, vector<int>(M, -1), {}}};
    size_t SIZE = 950;

    rep(d,D) {
        set<State> nxt_states;
        for (auto &cur_itr : cur_states) {
            State state = cur_itr;
            ll minus_score = 0;
            rep(i,M) {
                minus_score -= c[i] * (d - state.last[i]);
            }
            rep(i,M) {
                State nxt_state;
                nxt_state.score = state.score + s[d][i] + minus_score + c[i] * (d - state.last[i]);
                nxt_state.last = state.last;
                nxt_state.last[i] = d;
                nxt_state.types = state.types;
                nxt_state.types.push_back(i);
                
                nxt_states.insert(nxt_state);
                if (nxt_states.size() > SIZE) {
                    nxt_states.erase(nxt_states.begin());
                }
            }
        }

        cur_states = std::move(nxt_states);
    }

    for (int t : cur_states.begin()->types) {
        cout << t+1 << endl;
    }
    // debug(cur_states[0].score);

    return 0;
}


Measured memory_bytes: 7332
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
  int n,m;cin>>n>>m;
  if(n>=m){
    cout << 0 << endl;
    return 0;
  }
  int x[m];
  fol(i,m)cin>>x[i];
  sort(x,x+m);
  ll ans = 0LL;
  int a[m-1];
  fol(i,m-1){
    a[i] = abs(x[i]-x[i+1]);
    ans += a[i];
  }
  sort(a,a+m-1);
  fol(i,n-1){
    ans -= a[m-2-i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <algorithm>
using namespace std;

int N = 0;
int ans = 1;
vector<int> arr(200000);

void solve() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int temp = 0;
		cin >> temp;
		arr[i] = temp;
	}

	int prev_min = arr[0];
	for (int i = 1; i < N; i++) {
		if (prev_min > arr[i]) {
			ans++;
			prev_min = arr[i];
		}
	}
	cout << ans << endl;
}


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

Measured memory_bytes: 1024
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }
int main(){
int N;
cin >> N;
vector<long long> A1(N);
vector<long long> A2(N);
for(int i = 0; i < N; i++){
	cin >> A1[i];
}
for(int i = 0; i < N; i++){
	cin >> A2[i];
}
long long sum1 = A1[0];
long long sum2 = accumulate(A2.begin(),A2.end(),0);
long long ans = 0;
if(N == 1)ans = sum1+sum2;
for(int i  = 1; i < N; i++){
ans = max(ans,sum1+sum2);
sum1 += A1[i];
sum2 -= A2[i-1];

}
cout << ans << endl;
}

Measured memory_bytes: 256
input = gets.split.map(&:to_i).first
count = 0
1.step(6, 2) do |n|
  # puts 10**n
  if input >= (10 ** n)
    count += (10 ** n) - (10 ** (n - 1))
  elsif input >= (10 ** (n - 1))
    count += input - (10 ** (n - 1)) + 1
    break
  end
end

puts count


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

ll com2(int x){
    return (ll)x * ((ll)x-1) / 2;
}

int main(){
    int n;
    cin >> n;
    vector<ll> sum(n+1);
    sum.at(0)=0;
    rp(i,n){
        ll a;
        cin >> a;
        sum.at(i+1)=sum.at(i)+a;
    }
    sort(sum.begin(),sum.end());
    queue<int> streak;
    int count=0;
    rp(i,n){
        if(sum.at(i)==sum.at(i+1)){
            count++;
            continue;
        }
        if(sum.at(i)!=sum.at(i+1)){
            if(count>0) streak.push(count+1);
            count=0;
        }
    }
    if(count>0) streak.push(count+1);
    ll answer=0;
    while(!streak.empty()){
        answer += com2(streak.front());
        streak.pop();
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

using namespace std;

typedef long long int lli;

int main() {
    string S, T;
    cin >> S >> T;
    int s = S.size(), t = T.size();
    string ans = string(s, 'z');
    bool upd = false;
    REP (i, 0, s - t + 1) {
        bool flg = true;
        REP (j, 0, t) {
            if (S[i + j] == '?') continue;
            if (S[i + j] != T[j]) flg = false;
        }
        if (flg) {
            string tmp = S.substr(0, i) + T + S.substr(i + t, s);
            for (char &c : tmp) {
                if (c == '?') c = 'a';
            }
            if (tmp < ans) {
                ans = tmp;
                upd = true;
            }
        }
    }
    cout << (upd ? ans : "UNRESTORABLE") << endl;
    return 0;
}

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

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
    int N,C,K;
    cin >> N >> C >> K;
    vector<int> tim(N);
    rep(i,N){
        cin >> tim.at(i);
    }
    int cnt = 0;
    int bus = 0;
    
    sort(tim.begin(),tim.end());
    int now = tim.at(0);
    
        for(int i = 0;i < N;i++){
                cnt++;
                if(tim.at(i)-now > K || cnt > C) {
                    bus++;
                    cnt = 1;
                    now = tim.at(i);
                    //cout << i <<endl;
                }
        }
        cout << bus + 1 <<endl;
    
}

Measured memory_bytes: 640
//01背包(超大背包)
//用dp[i]表示得到当前价值i的最小体积为dp[i]
#include<bits/stdc++.h>
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 105; 
const int M = 100050;
long long f[M];//滚动数组
long long v[N];//价值
int w[N];//重量
int n,m;
 
int main()
{
 	cin>>n;//物品种数
	cin>>m;//背包容量
	for(int i = 1;i<=n;++i){
		cin>>w[i]>>v[i];
	}
    
    memset(f,INF,sizeof(f));
    f[0] = 0;
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1e5;j>=v[i];j--){
            f[j]=min(f[j],f[j-v[i]]+w[i]);
            if(f[j]<=m){
                ans=max(ans,j);
            }
        }
    }
    cout<<ans<<endl;

	return 0;
} 

Measured memory_bytes: 4400
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const ll MOD = 998244353;

ll bpow(ll a, ll n)
{
    if(n == 0)
        return 1;

    if(n % 2 == 0) {
        ll cur = bpow(a, n / 2);
        return (cur * cur) % MOD;
    }

    return (a * bpow(a, n - 1)) % MOD;
}

void calc(ll N, vector<ll>& fact, vector<ll>& inv)
{
    fact.resize(N + 1);
    inv.resize(N + 1);

    fact[0] = inv[0] = 1;

    ll cur = 1;
    for(ll p = 1; p <= N; p++) {
        cur = (cur * p) % MOD;
        fact[p] = cur;
        inv[p] = bpow(cur, MOD - 2);
    }
}

ll comb(ll n, ll k, const vector<ll>& fact, const vector<ll>& inv)
{
    if(k > n)
        return 0;

    return (fact[n] * ((inv[k] * inv[n - k]) % MOD)) % MOD;
}

int main()
{
    ll N, A, B, K;
    cin >> N >> A >> B >> K;

    vector<ll> fact;
    vector<ll> inv;

    calc(N, fact, inv);

    ll out = 0;

    for(ll a = 0; a <= N; a++) {
        ll t = (K - a * A);
        if(t < 0 || t % B)
            continue;
        ll b = t / B;
        ll cur = (comb(N, a, fact, inv) * comb(N, b, fact, inv)) % MOD;
        out = (out + cur) % MOD;
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;
const int MAX_N = 100010;

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

    vector<vector<int>> G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
    }

    int sv, tv;
    cin >> sv >> tv;
    sv--;  tv--;

    vector<vector<int>> dist(MAX_N, vector<int>(3, INF));
    queue<pair<int, int>> Q;
    
    Q.push(make_pair(sv, 0));
    dist[sv][0] = 0;
    while(!Q.empty()) {
        int v = Q.front().first;
        int l = Q.front().second;
        Q.pop();
        for(auto u : G[v]) {
            int nl = (l+1)%3;
            if(dist[u][nl] != INF) {
                continue;
            }
            dist[u][nl] = dist[v][l] + 1;
            Q.push(make_pair(u, nl));
        }
    }

    int ans = dist[tv][0];
    if(ans == INF) {
        ans = -1;
    }
    else {
        ans /= 3;
    }

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

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    int ans = 0;
    for(int i=0;i<m;i++){
        cin >> x[i];
    }
    if(n >= m){
        cout << 0 << endl;
    }
    else{
        sort(x.begin(),x.end());
        vector<int> diff(m);
        for(int i=1;i<m;i++){
            diff[i] = x[i]-x[i-1];
        }
        int diff_sum = 0;
        sort(diff.rbegin(),diff.rend());
        for(int i=n-1;i<m;i++){
            diff_sum += diff[i];
        }
        cout << diff_sum << endl;
    }
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

vector<int> enum_div(int n)
{
	std::vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

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

    vector<int> a(n+1,0);
    vector<int> b(n+1);
    REP(i,n) {
        int tmp;
        cin >> tmp;
        b[i+1] = tmp;;
    }

    vector<int> ans;
    for(int i=n;i>=1;i--){
        int cnt = 0;
        for(int j = i;j <= n;j += i) cnt += a[j];

        if(b[i]!=cnt%2) {
            a[i] = 1;
            ans.push_back(i);
        }
    }

    pl(ans.size())
    if(ans.size()>0){
        REP(i,ans.size()) cout << (i==0?"":" ") << ans[i];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
/*
	In the name of Allah.
*/
 
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define gap ' '
#define INF 999999
 
const int MAXN = 2 * 1e5 + 5;
const int MAX = 2 * 1e6 + 10;

int main(){
	int n; cin >> n;
	ll ans = 0;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	vector<int> b(MAX);
	vector<bool> good(MAX, true);
	for(int i = 0; i < n; ++i){
		b[a[i]]++;
	}
	for(int i = 1; i < MAX; ++i){
		if(b[i] != 0){
			for(int j = i+i; j < MAX; j+=i){
				good[j] = false;
			}
		}
	}
	for(int i = 0; i < MAX; ++i){
		if(good[i] and b[i] == 1){
			++ans;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11816
#include <cstdio>
#include <cstring>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int n;
char s[20001];
int a[20001];
int x[20001];
int y[20001];
int b[20001];

int main(){
	scanf("%s", s);
	n = strlen(s);

	rep(i, n){
		a[i + 1] = a[i] + (s[i] == '\\' ? -1 : s[i] == '/');
	}
	rep(i, n){
		x[i + 1] = max(x[i], a[i + 1]);
	}
	y[n] = a[n];
	for(int i = n - 1; i >= 0; --i){
		y[i] = max(y[i + 1], a[i]);
	}
	rep(i, n + 1){
		b[i] = min(x[i], y[i]);
	}

	int s = 0;
	rep(i, n){
		s += (b[i] - a[i]) + (b[i + 1] - a[i + 1]);
	}
	printf("%d\n", s / 2);
	s = 0;
	vector<int> v;
	rep(i, n){
		s += (b[i] - a[i]) + (b[i + 1] - a[i + 1]);
		if(b[i + 1] == a[i + 1] && s != 0){
			v.push_back(s / 2);
			s = 0;
		}
	}
	printf("%d", (int)v.size());
	for(int w: v){
		printf(" %d", w);
	}
	putchar('\n');
	return 0;
}

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

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

  int ans = 0;
  for (int i = 0; i < N + 1; i++) {
    if (i % 2 == 1) {
      int count = 0;
      for (int j = 1; j < i + 1; j++) {
        if (i % j == 0) {
          count += 1;
        }
      }
      // cout << count << endl;
      if (count == 8) {
        ans += 1;
      }
    }
  }
  cout << ans << endl;
}

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

int main () {
  int N; cin >> N;
  string s[N];
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  
  int M; cin >> M;
  string t[M];
  for (int j = 0; j < M; j++) {
    cin >> t[j];
  }
  
  int Xmax = 0;
  string word;
  for (int u = 0; u < N; u++) {
    word = s[u];
    int ans = 0;
    
    for (int x = 0; x < N; x++) {
      if (word == s[x]) {
        ans++;
      }
    }
    for (int y = 0; y < M; y++) {
      if (word == t[y]) {
        ans--;
      }
    }
    
    Xmax = max(Xmax, ans);
    
  }
  
  cout << Xmax << endl;
        
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll maxx=-1e18;
	maxx=max(maxx,a*c);
	maxx=max(maxx,a*d);
	maxx=max(maxx,b*c);
	maxx=max(maxx,b*d);
	cout<<maxx<<endl;

	



    int ab;
    cin>>ab;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  map<char,int> mp;
  char march[] = {'M','A','R','C','H'};

  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    mp[s[0]]++;
  }

  long long ans=0;
  for (int bit = 0; bit < (1<<5); bit++)
  {
    set<char> top;
    for (int i = 0; i < 5; i++)
    {
      if(bit&(1<<i)){
        top.insert(march[i]);
      }
    }
    if(top.size()==3){
      long long tmp = 1;
      for(auto c:top){
        tmp*=(long long) mp[c];
      }
      ans+=tmp;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<PII, null_type, less<PII>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to k'th element (0-based), order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int N = 2500 + 10;

struct Edge {
    int vertex, cost;
};

int n, m, p;
vector<Edge> fwd[N];
vector<int> bwd[N];
bool reachable_from_n[N];
LL dis[N];

void dfs(int u) {
    reachable_from_n[u] = true;
    for (int v : bwd[u]) {
        if (!reachable_from_n[v]) {
            dfs(v);
        }
    }
}

void bellman_ford() {
    for (int u = 1; u <= n; u++) {
        dis[u] = LINF;
    }
    dis[1] = 0;
    REP(rep, n-1) {
        for (int u = 1; u <= n; u++) {
            if (dis[u] == LINF)
                continue;
            for (Edge e : fwd[u]) {
                int v = e.vertex;
                int c = e.cost;
                if (dis[u] + c < dis[v]) {
                    dis[v] = dis[u] + c;
                }
            }
        }
    }
}

bool negative_cycle() {
    for (int u = 1; u <= n; u++) {
        if (dis[u] == LINF)
                continue;
        for (Edge e : fwd[u]) {
            int v = e.vertex;
            int c = e.cost;
            if (dis[u] + c < dis[v]) {
                if (reachable_from_n[v]) {
                    return true;
                }
            }
        }
    }
    return false;
}

int main() {
    cin >> n >> m >> p;
    REP(rep, m) {
        int u, v, c;
        cin >> u >> v >> c;
        fwd[u].push_back({v, p - c});
        bwd[v].push_back(u);
    }
    dfs(n);
    bellman_ford();
    if (negative_cycle()) {
        cout << -1 << endl;
    } else {
        cout << max(-dis[n], 0LL) << endl;
    }
}






























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

int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  sort(a,a+N,greater<int>());
  int Alice=0, Bob=0;
  for (int i=0; i<N; i++) {
    if (i%2==0) {
      Alice+=a[i];
    } else {
      Bob+=a[i];
    }
  }
  cout << Alice-Bob << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 200010;
const int offset = 100002;

long long tree[N];
long long threshold;
int in[offset + 5];
int n;

long long query(int k) {
    long long s = 0;
    while(k >= 1) {
        s += tree[k];
        k -= k&-k;
    }
    return s;
}

void add(int k, int v) {
    while(k < N) {
        tree[k] += v;
        k += k&-k;
    }
}


bool f(int x) {
    memset(tree, 0, sizeof tree);
    long long cnt = 0;
    int sum = offset;
    add(offset, 1);
    for(int i = 1; i <= n; i++) {
        if(in[i] >= x) sum++;
        else sum--;
        cnt += query(sum);
        add(sum, 1);
    } 

    return cnt >= threshold;
}

int main() {
    scanf("%d", &n);
    int maxa = 0;
    for(int i = 1; i <= n; ++i) {
        scanf("%d", in + i);
        maxa = max(in[i], maxa);
    }

    threshold = n * 1LL * (n + 1) / 2LL;
    threshold = (threshold + 1LL) / 2LL;

    int ans = 0;
    for(int b = maxa; b >= 1; b /= 2) {
        while(ans + b <= maxa and f(ans + b)) ans += b;
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
#include <queue>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef queue<int> QI;

const LL mod=1000000007;
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int main(){
    LL A,B,C;
    cin>>A>>B>>C;
    if(A%2 &&B%2 &&C%2){
        LL X=A*B,Y=B*C,Z=A*C;
        cout<<min(min(X,Y),Z)<<endl;
    }else{
        cout<<0<<endl;
    }
	return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(a!=c){
        cout << 1 << endl;
    }else
        cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3588
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: u64,
    }

    let mut i: u64 = 0;
    let mut sum: u64 = 0;
    let ans = loop {
        if x <= sum + i {
            break i;
        }
        sum += i;
        i += 1;
    };

    println!("{}", ans);
}


Measured memory_bytes: 2180
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
const int maxn=100010;
int n,m;
vector<int>g[maxn];
int vis[maxn];
int ans;
int x[maxn],y[maxn];
int a[maxn],d[maxn];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int k=0;
	for(int i=1;i<n;i++){
		if(a[i]+a[i+1]>=m){ k=i;break; }
	}
	if(!k){ puts("Impossible");return 0; }
	puts("Possible");
	for(int i=1;i<k;i++) printf("%d\n",i);
	for(int i=n-1;i>k;i--) printf("%d\n",i);
	printf("%d",k);
	return 0;
}

Measured memory_bytes: 3584
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include<string>
using namespace std;

int main() {

#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	int N,D;
	cin >> N;
	vector<int> X(N);
	vector<bool> used(N, false);
	string s;
	cin >> s;
	for (int i = 0; i < N; i++){
		X[i] = (s[i] == '1');
	}
	cin >> D;
	for (int i = 0; i < N; i++){
		if (used[i] == false && X[i] == 0 && D>0){
			used[i] = true;
			D--;
			X[i] = 1;
		}
	}
	for (int i = N-1; i >=0; i--){
		if (used[i] == false && X[i] == 1 && D>0){
			used[i] = true;
			D--;
			X[i] = 0;
		}
	}
	for (auto& i : X)cout << i; cout << endl;
	

	
	
	return 0;
}

Measured memory_bytes: 3148
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
#define sz(v) v.size()
const int INF = 1e9 + 1273;
void solve(){
    int n;
    ll k;
    cin>>n>>k;
    vi v(n);
    for(int i = 0; i < n; i++) cin>>v[i];

    ll ans=0;
    for(int i = 0; i < n-1; i++){
        for(int j = i+1; j < n; j++){
            if(v[i]>v[j]) ans+=((k*(k+1))/2)%1000000007;
            else if(v[i]<v[j]) ans+=((k*(k-1))/2)%1000000007;
        }
    }
    cout<<ans%1000000007;
}
int main(){
    int T=1;        //! COMMENT IF THERE IS NO TEST CASES
    //cin>>T;             
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  ll L, R;
  cin >> L >> R;
  R = min(R, L+4038);
  int ans = 20000;
  for (ll i = L; i < R; i++){
    for (ll j = i+1; j <= R; j++){
      int x = i*j%2019;
      ans = min(x, ans);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b >= c) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
n,t=map(int, input().split())
c_list,t_list=[],[]
for i in range(n):
  x,y=map(int, input().split())
  c_list.append(x)
  t_list.append(y)
cost=1001
for i in range(n):
  if t_list[i]<=t and c_list[i]<cost:
    cost=c_list[i]
print(cost if cost<1001 else "TLE")

Measured memory_bytes: 9180
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

LL fac[500005],inv[500005];

LL kpw(LL x,LL y){
	LL ans = 1,tmp = x;
	while(y){
		if(y & 1) ans = (ans * tmp) % N;
		tmp = (tmp * tmp) % N;
		y >>= 1;
	}
	return ans;
}

LL comb(LL x,LL y){
	return (((fac[x] * inv[y]) % N) * inv[x - y]) % N;
}

void init(){
	fac[0] = 1; for(LL i = 1;i <= 500000;i ++) fac[i] = (fac[i - 1] * i) % N;
	for(LL i = 0;i <= 500000;i ++) inv[i] = kpw(fac[i],N - 2);
}

int main() {
	LL n,k,ans = 0; init();
	cin >> n >> k;
	if(k >= n) k = n - 1;
	for(LL i = 0;i <= k;i ++) ans = (ans + (comb(n,i) * comb(n - 1,i)) % N) % N;
	cout << ans << endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector <int> data1(N);
    vector <int> data2(N);

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

    sort(data1.begin(),data1.end());
    reverse(data1.begin(),data1.end());

    for (int i = 0; i < N; i++){
        if (data1[0] == data2[i]){
            cout << data1[1] << endl;
        }
        else {
            cout << data1[0] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	map<pii, int> m;
	rep(i, 6) {
		int a, b;
		cin>>a>>b;
		if(a > b) swap(a, b);
		m[{a, b}]++;
	}
	map<int, int> m2;
	for(auto& p : m) if(p.se & 1) {
		cout<<"no"<<endl;
		return 0;
	}else m2[p.fi.fi]+=p.se, m2[p.fi.se]+=p.se;
	vi v;
	for(auto& p: m2) rep(i, p.se/4) v.pb(p.fi);
	if(v.size()!=3) {
		cout<<"no"<<endl;
		return 0;
	}
	int a = v[0], b = v[1], c = v[2];
	if(m.count({a, b}) && m.count({b, c}) && m.count({a, c})) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,k,ans=0,count;
  cin>>n>>k;
  vector<pair<long long int,long long int>> v;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    v.emplace_back(a,b);
  }
  sort(v.begin(),v.end());
  for(auto p:v){
    
    ans+=p.second;
    if(ans>=k){
      cout<<p.first<<endl;
      return 0;
    }
  }
  
  
}
///////////////////////////

Measured memory_bytes: 2420