akhauriyash/Code-Regression huggingface dataset:
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
    while(t--){
      ll n,i,j;
      cin>>n;
      long double dp[n+1][n+1],arr[n];
      fr(i,0,n)
      cin>>arr[i];
      ms(dp,0);
      dp[0][0]=1;
      fr(i,0,n)
      {
      	fr(j,0,i+1)
      	{
      		dp[i+1][j+1]+=arr[i]*dp[i][j];
      		dp[i+1][j]+=(1.0-arr[i])*dp[i][j];
      	}
      }
      long double ans=0;
      fr(i,(n+1)/2,n+1)
      ans+=dp[n][i];
      cout<<fixed<<setprecision(10)<<ans;
    }
  return 0;
  }



Measured memory_bytes: 140928
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
 
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
        
    string s;
    set<char> st;
    void solve()
    {
        cin>>s;
        fo(i,0,3)
        st.insert(s[i]);
        if(st.size()==1)cout<<"No";
        else cout<<"Yes"<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }

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

#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
int main()
{
        fast;
    
       long double a,b;
       cin>>a>>b;
        ll c=round(a*b*100);
        cout<<fixed<<setprecision(0)<<c/100<<endl;
}


Measured memory_bytes: 3780
#include <stdio.h>

int main(){
	int x,y,i,ex;
	for (i=1;i=1;){
	scanf("%d %d",&x,&y);
		if (x>y){
			ex=x;
			x=y;
			y=ex;
		}
		if (x!=0||y!=0){
		printf ("%d %d\n",x,y);
		}
		if (x==0&&y==0){
			break;
		}
	}
	return 0;
}

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

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

    int ans = INT_MAX;
    rep (i, N) {
        int c, t;
        cin >> c >> t;
        if (t <= T && ans > c) ans = c;
    }
    cout << (ans == INT_MAX ? "TLE" : to_string(ans)) << endl;

    return 0;
}

Measured memory_bytes: 256
import math

def main():
    Q = int(input())
    #エラトステネスのふるい
    is_prime = [True]*(10**5+1)
    is_prime[0], is_prime[1] = False, False
    for i in range(2, int(math.sqrt(10**5))+1):
        if not is_prime[i]:
            continue
        for j in range(i*2, 10**5+1, i):
            is_prime[j] = False
            
    a = [0]*(10**5+1) #2017-likeな数字かどうかを判定する配列
    for i in range(1, 10**5+1):
        if is_prime[i] and is_prime[(i+1)//2]:
            a[i] = 1
            
    s = [0] * (10**5+1) #累積和
    for i in range(10**5):
        s[i+1] = s[i] + a[i]
    
    for _ in range(Q):
        l, r = map(int, input().split())
        print(s[r+1]-s[l])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7892
s = int(input())

x = s // 100
y = s % 100

if (x > 12 or x == 0) and 1 <= y <= 12:
    print('YYMM')
elif 1 <= x <= 12 and (y > 12 or y == 0):
    print('MMYY')
elif 1 <= x <= 12 and 1 <= y <= 12:
    print('AMBIGUOUS')
else:
    print('NA')

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(n);
        llin(k);
        if(k>n*(n-1)/2-n+1){
                sal(-1)
                return 0;
        }
        sal(n*(n-1)/2-k)
        FOR(i,2,n){
                says(1)
                sal(i)
        }
        ll j=2;
        ll l=1;
        FOR(i,1,n*(n-1)/2-k-n+1){
                says(j)
                sal(j+l)
                l++;
                if(j+l>n){
                        l=1;
                        j++;
                }
        }
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(int, "i", int, "j");

void main() {
    int n;
    scan(n);

    auto ans = solve(n);
    writeln(ans.length);
    foreach (p ; ans) {
        writefln("%d %d", p.i, p.j);
    }
}

Pair[] solve(int n) {
    auto h = (n + 1) / 2 * 2;
    auto w = (n + 2) / 3 * 3;

    Pair[] ans;

    foreach (j ; 0 .. w / 3) {
        foreach (i ; 0 .. h / 2) {
            int x = 2 * i + (j % 2);
            int y = 3 * j + 1;

            if (x < n && y < n) {
                ans ~= Pair(x, y);
            }
        }
    }

    foreach (j ; 0 .. (w + 5) / 6) {
        if (6*j + 3 < n) {
            ans ~= Pair(0, 6*j + 3);
        }
        if (6*j + 5 < n) {
            ans ~= Pair(0, 6*j + 5);
        }
    }

    foreach (i ; 0 .. n) {
        if ((i + n - 1) % 2) {
            ans ~= Pair(i, n - 1);
        }
    }

    ans = ans.sort().uniq.array;

    return ans;
}





















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(K);
    if (K == 1){
        cout << 0 << endl;
    }else{
        cout << (N - K) << endl;
    }
}


Measured memory_bytes: 256
from collections import deque
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = deque([[0,-1]])
  while z:
    j,b = z.popleft()
    for yj in y[j]:
      if yj != b:
        z.append([yj,j])
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Measured memory_bytes: 117964
import sys
from operator import itemgetter, attrgetter
N = int(input())
AB = []
for _ in range(N):
  AB.append(tuple(map(int, input().split())))
AB.sort(key = itemgetter(1))

Asum = 0
for i in range(N):
  Asum += AB[i][0]
  if Asum > AB[i][1]:
    print("No")
    sys.exit()
print("Yes")

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N;
  cin >> N;
  vi32 a(N);
  cin >> a;
  sort(all(a));
  int min_a = 1e9, max_a = 0;
  rep(i, N) amin(min_a, a[i]);
  rep(i, N) amax(max_a, a[i]);
  if (abs(min_a - max_a) >= 2) {
    no();
  }
  if (min_a == max_a) {
    if (2 * min_a <= N) {
      yes();
    } else if (min_a + 1 == N) {
      yes();
    } else {
      no();
    }
  } else {
    int x = 0, y = 0;
    rep(i, N) {
      x += a[i] == min_a;
      y += a[i] == max_a;
    }
    if (x > min_a) {
      no();
    }
    int rest = max_a - x;
    if (2 * rest <= y) {
      yes();
    } else {
      no();
    }
  }
}


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

using namespace std;

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

int main(){
  int n, k;
  cin >> n >> k;
  int r = 0;
  REP(i, n){
    int a;
    cin >> a;
    if(a >= k) ++r;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF (1<<28)
 
int MATRIX_CHAIN_ORDER(int p[], int n) {
  int i,j,k,l,q;
  int m[102][102];
  for(i = 1; i <= n; ++i)
    m[i][i] = 0;
  for(l = 2; l <= n; ++l) {
    for(i = 1; i <= n-l+1; ++i) {
      j = i+l-1;
      m[i][j] = INF;
      for(k = i; k <= j-1; ++k) {
        q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
        if(q < m[i][j]) {
          m[i][j] = q;
        }
      }
    }
  }
  return m[1][n];
}
 
int main() {
  int i;
  int n;
  int p[102];
  scanf("%d", &n);
  for(i = 1; i <= n; ++i) {
    scanf("%d %d", p+i-1, p+i);
  }
  printf("%d\n", MATRIX_CHAIN_ORDER(p,n));
  return 0;
}


Measured memory_bytes: 2112
r, g, b, n = map(int, input().split())
cnt = 0
nr = 0
while nr * r <= n:
    m = n - nr * r
    ng = 0
    while ng * g <= m:
        l = m - ng * g
        if not l % b:
            cnt += 1
        ng += 1
    nr += 1
print(cnt)

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

const int M = 1e6 + 1;

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

    int n;
    cin >> n;
    int occurences[M] = {}, ans = 0;

    while (n--) {
        int x;
        cin >> x;
        occurences[x]++;
    }

    for (int i = 1; i <= M; i++)
        if (occurences[i])
            for (int j = i + i; j <= M; j += i)
                occurences[j] = 0;
    for (int x : occurences)
        ans += (x == 1);

    cout << ans << '\n';
}


Measured memory_bytes: 7544
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
1 < (I=(0..25).select{C[_1]==0}).size and S.each {|s;z|
  I.each {|i| if i!=(z||=i); s[z]<s[i] ? (s[z]=0; z=i) : (s[i]=0) end }
}
L,M,N = [-1]*27,8,3
def calc(d,n)
  s,x = S[d],0
  t = (0..25).map {s[_1] > 0 ? C[_1]*(d-L[_1])+s[_1] : 0}
  i = (0..25).max_by(M){t[_1]}.max_by {|i|
    next t[i]  if n == 0 || t[i]==0 || d+1 >= D
    l,L[i] = L[i],d
    c = calc(d+1,n-1) >> 5
    L[i] = l
    x < c ? x=c : c
  }
  ((t[i]+x) << 5) + i
end
D.times { p 1 + i=calc(_1,N)&31; L[i]=_1 }

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

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

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

int main() {
  int N; cin >> N;
  int X; cin >> X;
  int cnt = 1;
  vector<int> L(N+2);
  for(int i = 0; i < N; ++i){
    int a; cin >> a;
    L.at(i) = a;
  }
  
  int sum = 0;
  for(int j; j < N; ++j){
    sum += L.at(j);
    if(sum <= X) cnt++;
  }
  
  cout << cnt <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{ 
  ll n,k;
  cin>>n>>k;
  if(n<k)
  {
    cout<<min(n,abs(n-k));
    return 0;
  }
  ll res=n%k;
   n=n%k;
  res=min(res,abs(n-k));
  cout<<res;
  return 0;
}
  

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int i, j, n, q;
    int s[10000];
    int t[500];
    int flag = 0;
    int count = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++){

        scanf("%d", &s[i]);

    }
    scanf("%d", &q);

    for(i = 0; i < q; i++){

        scanf("%d", &t[i]);

    }

    for(i = 0; i < q; i++){

            j = 0;
            flag = 0;

        while(flag == 0 && j < n - 1){

            if(s[j] == t[i]){
                count++;
                flag = 1;
            }
            j ++;
        }
    }
    printf("%d\n", count);

    return 0;
}


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

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int cs[26]={};
    char c;
    while(cin>>c){
        c=tolower(c);
        if(isalpha(c))cs[c-'a']++;
    }
    for (int i = 0; i < 26; i++){
        printf("%c : %d\n",i+'a',cs[i]);
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<long long, long long>;

long long n;
vector<p> v;

bool solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].se >> v[i].fi;
  if(solve())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  sort(v.begin(), v.end());
  long long now = 0;
  for(int i = 0; i < n; ++i) {
    if(now + v[i].se <= v[i].fi)
      now += v[i].se;
    else
      return 0;
  }
  return 1;
}

Measured memory_bytes: 3328
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
X = int(input())
x = X**(0.2)
x = int(x)
x = max(x,1)
flag = 0
for A in range(1,10*x):
    if flag == 1:
        break
    for B in range(-10*x,A+1):
        if A ** 5 - B ** 5 == X:
            print(A,B)
            flag = 1
            break

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const bool compare(const pair<int, int>& p1, const pair<int, int>& p2) {
    return p1.first+p1.second > p2.first+p2.second;
}

int32_t main() {

    int n; cin >> n;

    vector<pair<int, int>> ab(n);
    for(int i = 0; i < n; ++i) cin >> ab[i].first >> ab[i].second;

    sort(ab.begin(), ab.end(), compare);

    int ret = 0;
    for(int i = 0; i < n; ++i) {
        if(i%2 == 0) ret += ab[i].first;
        else ret -= ab[i].second;
    }

    cout << ret << endl;
    
    return 0;
}


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

#define ll long long

const ll MXN = 3e3 + 10;

ll n;
ll A[MXN], dp[MXN][MXN][2];

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> A[i];

    for(int i = 1; i <= n; i ++){
        dp[i][i][0] = A[i];
        dp[i][i][1] = -A[i];
    }
    for(int i = 1; i < n; i ++){
        dp[i][i + 1][0] = max(A[i] - A[i + 1], A[i + 1] - A[i]);
        dp[i][i + 1][1] = min(A[i] - A[i + 1], A[i + 1] - A[i]);
    }

    for(int len = 3; len <= n; len ++){
        for(int l = 1, r = len; r <= n; l ++, r ++){
            dp[l][r][0] =  max(dp[l + 1][r][1] + A[l], dp[l][r - 1][1] + A[r]);
            dp[l][r][1] =  min(dp[l + 1][r][0] - A[l], dp[l][r - 1][0] - A[r]);
        }
    }

    cout << dp[1][n][0];
    return 0;
}
//! N.N


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

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

using namespace std;

int main(void){
  string S, T;
  int i, n;
  int length, count = 0;

  cin >> S;
  cin >> T;

  length = S.size();

  rep(i, length){
    if(S[i] != T[i]){
      count++;
    }
  }

  cout << count;

  return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	   c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
char s[MAXN];
int top,N;
void Solve() {
    scanf("%s",s + 1);
    N = strlen(s + 1);
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(s[i] == 'T') {
            if(top) --top;
            else ++ans;
        }
        else {
            ++top;
        }
    }
    ans += top;
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 110000;

int n, m, sta[N], vis[N];
pii bom[N];
vector<pii> to[N];
vector<int> ans;

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

inline void addEdg(int x, int y, int id) {
	to[x].push_back(mp(y, id)), to[y].push_back(mp(x, id));
	return;
}

void dfs(int now) {
	vis[now] = 1;
	for (auto &v : to[now]) {
		if (vis[v.first]) continue;
		dfs(v.first);
		if (sta[v.first])
			sta[now] ^= 1, ans.push_back(v.second);
	}
	return;
}

int main() {
	int x, y;
	read(n), read(m);
	for (R int i = 1; i <= n; ++i) read(bom[i].first), read(bom[i].second);
	sort(bom + 1, bom + 1 + n);
	for (R int i = n, s = 0; i; --i)
		sta[i] = bom[i].second ^ bom[i + 1].second;
	for (R int i = 1; i <= m; ++i) {
		read(x), read(y);
		x = upper_bound(bom + 1, bom + 1 + n, mp(x - 1, 1)) - bom - 1;
		y = upper_bound(bom + 1, bom + 1 + n, mp(y, 1)) - bom - 1;
		if (x == y) continue;
		addEdg(x, y, i);
	}
	for (R int i = 0; i <= n; ++i) {
		if (vis[i]) continue;
		dfs(i);
		if (sta[i] && i) return printf("-1\n"), 0;
	}
	sort(ans.begin(), ans.end());
	printf("%d\n", ans.size());
	for (auto &k : ans) printf("%d ", k);
	return 0;
}

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

void exchange( int* a, char* b, int x, int y )
{
    int temp1 = a[x];
    a[x] = a[y];
    a[y] = temp1;

    char temp2 = b[x];
    b[x] = b[y];
    b[y] = temp2;
}

int partition( int* a, char* b, int p, int r )
{
    int x = a[r];
    int i = p - 1;

    for( int j = p; j <= r - 1; j++ )
    {
        if( a[j] <= x )
        {
            i = i + 1;
            exchange( a, b, i, j );
        }
    }
    exchange( a, b, i + 1, r );

    return i + 1;
}

void quickSort( int* a, char* b, int p, int r )
{
    if( p < r )
    {
        int q = partition( a, b, p, r );
        quickSort( a, b, p, q - 1 );
        quickSort( a, b, q + 1, r );
    }
}

void merge( int* a, char* b, int left, int mid, int right )
{
    int LS = mid - left + 1;
    int RS = right - mid + 1;

    int L[LS], R[RS];
    char L2[LS], R2[RS];

    for( int i = 0; i < LS - 1; i++ )
    {
        L[i] = a[i+left];
        L2[i] = b[i+left];
    }
    for( int i = 0; i < RS - 1; i++ )
    {
        R[i] = a[i+mid];
        R2[i] = b[i+mid];
    }

    L[LS-1] = 2000000000;
    R[RS-1] = 2000000000;

    int i = 0, j = 0;
    for( int k = left; k < right; k++ )
    {
        if( L[i] > R[j] )
        {
            a[k] = R[j];
            b[k] = R2[j];
            j++;
        }
        else
        {
            a[k] = L[i];
            b[k] = L2[i];
            i++;
        }
    }
}

void mergeSort( int* a, char* b, int left, int right )
{
    if( left + 1 < right )
    {
        int mid = ( left + right ) / 2;
        mergeSort( a, b, left, mid );
        mergeSort( a, b, mid, right );
        merge( a, b, left, mid, right );
    }
}

int main()
{
    int n;

    cin >> n;

    int a1[n+1], a2[n+1];
    char b1[n+1], b2[n+1];

    for( int i = 1; i <= n; i++ )
    {
        cin >> b1[i];
        b2[i] = b1[i];
        cin >> a1[i];
        a2[i] = a1[i];
    }

    quickSort( a1, b1, 1, n );              //安定かどうかわからない
    mergeSort( a2, b2, 1, n + 1);           //安定なソート

    bool judge = true;

    for( int i = 1; i <= n; i++ )           //mergeSortの結果とquickSortの結果を比較して、安定かどうかを判定
    {
        if( b1[i] != b2[i] )
        {
            judge = false;
            break;
        }
    }

    if( judge == true )
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;

    for( int i = 1; i <= n; i++ )           //quickSortの結果を出力
    {
        cout << b1[i] << " ";
        cout << a1[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4456
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# from pprint import pprint

s = tuple(sys.stdin.readline().rstrip())

length = len(s)

# print(length)

minA = length
maxZ = 0

for i in range(length):
  # print("{}: {}".format(i, s[i]))
  if i < minA and s[i] == "A":
    minA = i
  
  if s[i] == "Z":
    maxZ = i

print(maxZ - minA + 1)

Measured memory_bytes: 4840
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#define int long long
#define P pair<int,int>
#define V vector<int>
#define rep(i,n) for(int i=0;i<n;++i)
#define vsort(vec) sort(vec.begin(),vec.end())
#define end system("PAUSE");return 0
using namespace std;
signed main() {
	string s;
	cin >> s;
	if (s.substr(0, 3) == "key"&&s.substr(s.size()-4, 4) == "ence")cout << "YES" << endl;
	else if (s.substr(0, 7) == "keyence")cout << "YES" << endl;
	else if (s.substr(0, 1) == "k"&&s.substr(s.size() - 6, 6) == "eyence")cout << "YES" << endl;
	else if (s.substr(0, 2) == "ke"&&s.substr(s.size() - 5, 5) == "yence")cout << "YES" << endl;
	else if (s.substr(0, 4) == "keye"&&s.substr(s.size() - 3, 3) == "nce")cout << "YES" << endl;
	else if (s.substr(0, 5) == "keyen"&&s.substr(s.size() - 2, 2) == "ce")cout << "YES" << endl;
	else if (s.substr(0, 6) == "keyenc"&&s.substr(s.size() - 1, 1) == "e")cout << "YES" << endl;
	else cout << "NO" << endl;

	end;
}


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

int main() {
    int H,W;
    cin >> H >> W;
    char S[50][50];
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            cin >> S[i][j];
        }
    }
    for(int i=0; i<H; ++i) {
        for(int j=0; j<W; ++j) {
            bool flag = false;
            if(S[i][j] == '.') continue;
            if(i > 0 && S[i-1][j] == '#') flag = true;
            if(i + 1 < H && S[i+1][j] == '#') flag = true;
            if(j > 0 && S[i][j-1] == '#') flag = true;
            if(j + 1 < W && S[i][j+1] == '#') flag = true;
            if(!flag) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != i+1) {
            count++;
        }
    }
    if (count < 3) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 384
import numpy as np
n =int(input())
strl = [list(input()) for i in range(n)]

count =0
pt = {}
for i in range(n):
    sal = strl[i]
    sal.sort()
    temp = "".join(sal)
    if temp in pt.keys():
        tempc = pt[temp]
        count +=tempc
        pt[temp]= tempc+1
    else:
        pt[temp]= 1
print(count)

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    string s[n];
    rep(i, n) {
        cin >> s[i];
        s[i] += s[i];
    }
    ll ans = 0;
    rep(num, n) {
        bool result = true;
        rep(index_h, n) {
            rep(index_w, n) {
                if (s[index_h][index_w + num] != s[index_w][index_h + num]) {
                    result = false;
                }
            }
        }
        if (result) {
            ans++;
        }
    }
    cout << n * ans << endl;
    return 0;
}



Measured memory_bytes: 3896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

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


Measured memory_bytes: 256
#include <stdio.h>
int n;
int f(int now,int w){
    return now+w*n;
}
int max(int a,int b){
    if(a<b)return b;
    return a;
}
int main(){
    int m,dp[1010000],v,w;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)dp[f(0,i)]=0;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&v,&w);
        for(int j=0;j<=m;j++){
            if(j<w)dp[f(i,j)]=dp[f(i-1,j)];
            else dp[f(i,j)]=max(dp[f(i-1,j)],dp[f(i-1,j-w)]+v);
        }
    }
    printf("%d\n",dp[f(n,m)]);
}

Measured memory_bytes: 6576
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
 
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
 
 
int H, W;
vector<vector<int> > a;
 
typedef pair<int,int> pint;
typedef pair<pint,pint> ppint;
 
int main() {
    while (cin >> H >> W) {
        a.assign(H, vector<int>(W, 0));
        int odd = 0;
        for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) {
            cin >> a[i][j];
            if (a[i][j] & 1) ++odd;
        }
        vector<ppint> res;
 
        int num = 0;
        int x = 0, y = 0;
        for (int iter = 0; iter < W*H; ++iter) {
            if (a[x][y] & 1) ++num;
            
            int nx = x, ny = y;
            if (x % 2 == 0) {
                if (ny == W-1) ++nx;
                else ++ny;
            }
            else {
                if (ny == 0) ++nx;
                else --ny;
            }
            if (num & 1) {
                if (num < odd) res.push_back(ppint(pint(x, y), pint(nx, ny)));
            }
            x = nx, y = ny;
        }
        
        cout << res.size() << endl;
        for (auto p : res) {
            cout << p.first.first+1 << " " << p.first.second+1 << " " << p.second.first+1 << " " << p.second.second+1 << endl;
        }
    }
}
 

Measured memory_bytes: 5232
#include<iostream>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;

  	int popCount=0;
  	int items[N];
  	float sumVote=0;
  
	int i;
  	for(i=0;i<N;i++){
      int vote;
      cin >> vote;
      
      items[i]=vote;
      sumVote += vote;
    }
  
  	float MinLine = (sumVote/(4*M));
  
  	for(i=0;i<N;i++){
      if(items[i] >= MinLine)popCount++;
    }
  
  	if(popCount >= M)cout << "Yes";
  	else cout << "No";
  
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll n,m,k,l,g,i,h,w,a1,a2,a3,a4,a5,a6,a,b,c;
    	cin>>a>>b;
    	lld x,y;
    	repi(i,1,1255)
    	{
    		x=(8*i*1.00)/100; y=(10*i*1.00)/100;
    		a1=x; a2=y;
    		if(a1==a && a2==b)
    		{
    			cout<<i;
    			return 0;
			}
		}
    	cout<<-1;
    	
    	
    	
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,k;
ll a[110];
ll dp[100010];//dp[i]=0⇔手番の人が負け
int main(){
	scanf("%lld%lld",&n,&k);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,1,k+1){
		int flag=0;
		//1つでも負け状態に遷移出来るなら価値
		rep(j,0,n)if(a[j]<=i&&dp[i-a[j]]==0){
			flag=1;
			break;
		}
		dp[i]=flag;
	}
	puts(dp[k]?"First":"Second");
	return 0;
}

Measured memory_bytes: 896
/*

どこが間違っていますか？

-----実行結果-----
1 1 1
3
*/
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<memory>

using namespace std;
int main() {
	int N;
	cin >> N;
	int i = 0; // カウンタ変数 
	int sum = 0;
	int l; int r;
	vector<int> data(N);
	while (i < N) {
		//カウンタ変数であるIがNより小さい間は繰り返す 
		cin >> l >> r;
		//R番目の席からL番目の席を引くことで何人座ったか求める
		sum += r - l+1;//サムに座った人数を加算
		i++;//IがN回までひとつづつ増える
	}
	cout << sum << endl;
}

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

#define pb push_back
#define mp make_pair
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     ll a,b,c,k;
     cin>>a>>b>>c>>k;
    if(k<=a)
    cout<<k;
    else if(k<=a+b)
    cout<<a;
    else
    cout<<2*a+b-k;
		 
		 
	  
}


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

int cmpint(const void* n1, const void* n2)
{
    if (*(int*)n1 > * (int*)n2) {
        return 1;//降順なら-1
    }
    else if (*(int*)n1 < *(int*)n2) {
        return -1;//降順なら1
    }
    else {
        return 0;
    }
}

int main() {
    int a[200001] = {};
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    qsort(a, n, sizeof(int), cmpint);
    for (int i = 0; i < n; i++) {
        if (a[i] == a[i + 1]) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
ll k,a[200000];

ll f(ll i,ll n) {
    if(i < 0)
        return n;

    ll x = f(i - 1,n);
    return x - x % a[i];
}

ll g(ll n) {
    return f(k - 1,n);
}

ll bins1() {
    ll l = 0,r = 2*1e14;

    while(r - l > 1) {
        ll m = (r + l) / 2;

        if(g(m) >= 2) {
            r = m;
        }else {
            l = m;
        }
    }
    return r;
}

ll bins2() {
    ll l = 1,r = 2*1e14;

    while(r - l > 1) {
        ll m = (r + l) / 2;

        if(g(m) <= 2) {
            l = m;
        }else {
            r = m;
        }
    }
    return l;
}

int main(){
    cin >> k;
    REP(i,k)
        cin >> a[i];

    ll a = bins1();
    ll b = bins2();

    if(a > b) {
        cout << -1 << endl;
    }else {
        cout << a << " " << b << endl;
    }
    return 0;
}



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

#define endl '\n'

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

    int n; cin >> n;
    long long a[n], freq[n+1];
    long long ans=0;
    memset(freq, 0, sizeof freq);
    for (int i=0; i<n; i++){
        cin >> a[i];
        freq[a[i]]++;
    }

    for (int i=1; i<=n; i++){
        if (!freq[i]) continue;
        ans += freq[i]*(freq[i]-1)/2;
    }
    for (int i=0; i<n; i++){
        cout << ans - max(0LL, freq[a[i]]*(freq[a[i]] - 1)/2LL) + 
                max(0LL, (freq[a[i]] - 1)*(freq[a[i]] - 2)/2LL) << endl;
    }
}

Measured memory_bytes: 5760
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 1000000007;

#define M 1000000007

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> V(n);
    for (auto & v : V) {
        cin >> v;
    }

    ll res = 0;
    auto r =  min(n,k);
    for (ll left = 0; left <= r; ++left) {
        for (ll right = 0; left+right <= r; ++right) {
            priority_queue<ll, vector<ll>, greater<ll>> q;
            ll cur = 0;
            //cerr << "left = " << left << ", right = " << right << endl;
            //cerr << "Diggin: ";
            for (ll i = 0; i < left; ++i) {
                //cerr << V[i] << ",";
                cur += V[i];
                q.push(V[i]);
            }
            for (ll i = 0; i < right; ++i) {
                //cerr << V[n-1-i] << ",";
                cur += V[n-1-i];
                q.push(V[n-1-i]);
            }
            //cerr << endl;
            //cerr << "Drop: ";
            for (ll i = 0; !q.empty() && i + left + right < k; ++i) {
                auto v = q.top();
                if (v >= 0) {
                    break;
                }
                //cerr << v << ",";
                cur -= v;
                q.pop();
            }
            //cerr << endl;
            //cerr << "Get: " << cur << endl;
            res = max(res, cur);
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

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

  ll ans = 0;
  FOR(i,1,N+1){
    if(i%3 == 0){}
    else if(i%5 == 0){}
    else ans += i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3652
n = int(input())
h = list(map(int, input().split()))

dp = [10000] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2])
print(dp[n-1])

Measured memory_bytes: 13924
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 110

int main(){
  string s[3];
  int a[3] = {};
  
  cin >> s[0] >> s[1] >> s[2];

  int turn = 0;
  
  while(1){
    if(s[turn][a[turn]]=='\0'){
      printf("%c\n","ABC"[turn]);
      break;
    }
    turn = s[turn][a[turn]++]-'a';
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pii pair<ll, ll> 
#define pb push_back
#define mod (1e9+7)
#define debug(x) cerr<< #x << " is " <<x<<endl;
#define debug2(x) cerr<<#x<< " is\n"; for (auto &i:x) {cout<<i<<' '; } cout<<endl;
#define f first
#define s second
using namespace std;

int dp[100005];

int dfs(int x, vector<vector<int> > &graph){
	if (dp[x]) return dp[x];
	for (int v: graph[x]){
		dfs(v,graph);
		dp[x]=max(dp[x],1+dp[v]);
	}
	if (dp[x]==0) dp[x]++;
	return dp[x];
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m; cin>>n>>m;
    vector<vector<int> > graph(n+1);
    vector<int> indeg (n+1,0);
    for (int i=0; i<m; i++){
    	int a, b; cin>>a>>b;
    	graph[a-1].pb(b-1);
    	indeg[b-1]++;
    }
    queue<int> n0;
    for (int i=0; i<n; i++){
    	if (indeg[i]==0) {
    		graph[n].pb(i);
    		indeg[i]++;
    	}
    }

    cout<<dfs(n,graph)-2<<endl;
}

Measured memory_bytes: 11264
while true
    n = gets.to_i
    break if n == 0
    arr, arr2 = [], [5, 7, 5, 7, 7]
    n.times{arr << gets.chomp.length}
    start, match = 0, false
    while true
        i, q = start, -1
        while true
            sum, q, i = arr[i], q + 1, i + 1
            while sum < arr2[q]
                sum += arr[i]
                i += 1
            end
            if sum == arr2[q]
                if q == 4
                    match = true
                    break
                end
            else
                break
            end
        end
        break if match
        start += 1
    end
    puts start + 1
end



Measured memory_bytes: 6876