akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if ((A < C && C < B) || (B < C && C < A)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() 
{
    //input
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];

    //a -> ascending order
    sort(a.begin(), a.end());
    //f -> descending order
    sort(f.rbegin(), f.rend());

    ll left = -1;
    ll right = 1e12;

    //2-minute search
    while (1 < right - left)
    {
        ll mid = (left + right) / 2;
        bool ok = [&] 
        {
            ll Difference = 0;
            rep(i, n) 
            {
                Difference += max(0ll, a[i] - mid / f[i]);
            }
            return Difference <= k;
        }();
        if (ok) right = mid; else left = mid;   
    }

    //output
    cout << right << endl;
    return 0;
}

Measured memory_bytes: 1792
//master
import java.io.*;
import java.util.*;
public class Main {
    static int[][] memo;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        for(int i = 1; i<=1000; i++) {
            int k = i*n;
            if(k>=b && k<=c) {
                p("OK");
                return;
            }
        }
        p("NG");
}

    public static <T> void p(T message) {
        System.out.println(message);
    }

    public static <T> void pe(T message) {
        System.err.println(message);
    }

    public static <T> void pp(T message) {
        System.out.print(message);
    }
    
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 25312
#include <iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
    
    int r,D,x;
    cin >> r >> D >>x;
    
    
    for(int i=1;i<=10;i++){
        x = r*x-D;
        cout << x<<endl;
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
data = []
for i in range(N):
    A, B = map(int, input().split())
    data.append((A, B))

data = sorted(data, key=lambda x: x[0])
count = 0
total = 0
for d in data:
    count += d[1]
    if count >= M:
        total += d[0] * (d[1] - (count - M))
        break
    else:
        total += d[0] * d[1]
print(total)

Measured memory_bytes: 18932
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <time.h>
#define ll unsigned long long
#define ull unsigned long long
#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 mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define e 2.71828
using namespace std;
const int N = 1e6 + 500;
const int M = 35000;
const int MAX = 3800;
const ull inv = 500000004;
const double g = 9.80;
const double PI = acos( -1.0 );
ll f[N], su[MAX];
bool vis[M];
int cnt;

void init(){
    f[0] = 1;
    for( int i = 1; i < N; i++ )
        f[i] = i*f[i-1]%MOD;
    cnt = 1;
    mem( vis, 1 );
    vis[0] = vis[1] = 0;
    for( ll i = 2; i < M; i++ ){
        if( vis[i] ){
            su[cnt++] = i;
            for( ll j = i*i; j < M; j+=i )
                vis[j] = 0;
        }
    }
}


ll q_pow( ll x, ll y, ll mod ){
    if( y == 0 ) return 1ll;
    x %= mod;
    ll ret = 1ll;
    while( y ){
        if( y&1 ) ret = ret*x % mod;
        x = x*x % mod;
        y /= 2ll;
    }
    return ret;
}

int main(){
    ll n, m, ct, ans;
    init();
    //cout << ( 35000 * 35000 ) << endl;
    while( scanf( "%lld %lld", &n, &m ) != EOF ){
        ans = 1;
        for( int i = 1; su[i]*su[i]<=m; i++ ){
            ct = 0;
            while( m%su[i] == 0 ){
                m/=su[i];
                ct++;
            }
            if( ct ){
                ans = ( ( ( ans * f[n+ct-1] % MOD ) * q_pow( f[n-1], MOD - 2, MOD ) % MOD )*q_pow( f[ct], MOD - 2, MOD ) ) % MOD;
            }
            if( m <= 1 ) break;
        }
        if( m > 1 )
            ans = ans * n % MOD;
        printf( "%lld\n", ans );
    }
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define INF 1000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

ll N, M, V, P;
vector<ll> A;
bool check(ll m)
{
  if (A.at(m) + M < A.at(P - 1))
  {
    return false;
  }
  ll s = 0;
  s += M * (P - 1 + N - m);
  for (int i = P - 1; i < m; ++i)
  {
      s += max(0ll, A.at(m) + M - A.at(i));
  }
  if (s >= M * V)
  {
    return true;
  }
  return false;
}


int main()
{
  cin >> N >> M >> V >> P;
  A = vector<ll>(N);
  for (ll i = 0; i < N; ++i)
  {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  // cout << "A" << endl;
  // for (ll i = 0; i < N; ++i)
  // {
  //   cout << A.at(i) << ' ';
  // }
  // cout << endl;
  ll l = -1, r = N;
  ll m;
  while (l + 1 != r)
  {
    m = (l + r) / 2;
    if (check(m))
    {
      l = m;
    }
    else
    {
      r = m;
    }
  }
  cout << l + 1 << endl;
  // cout << "l" << l << endl;
}


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

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int count_1 = 0;
    rep(i, N){
        if(A[i] % 2 == 1 || (A[i] % 3 == 0 || A[i] % 5 == 0)) count_1++;
    }

    if(count_1 == N) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

long long n, x, ans = 4e18;
long long a[2005];
long long b[2005];

int main()
{
    scanf("%lld%lld", &n, &x);
    for(long long i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(long long i = 0; i < n; i++)
    {
        long long ans2 = i * x;
        for(long long j = 0; j < n; j++)
        {
            ans2 += a[j];
            b[j] = min(a[j], a[(j - 1 + n) % n]);
//            b[j] = min(b[j], a[j - i + n] % n);
        }
        for(long long j = 0; j < n; j++) a[j] = b[j];
        ans = min(ans, ans2);
    }
    printf("%lld", ans);
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, c, d[30][30], s[500][500], x[3][30], y[3][30];

int main() {
	cin >> n >> c;
	inc(i, c) {
	inc(j, c) {
		cin >> d[i][j];
	}
	}
	inc(i, n) {
	inc(j, n) {
		cin >> s[i][j];
		s[i][j]--;
	}
	}
	
	inc(i, n) {
	inc(j, n) {
		x[(i + j) % 3][s[i][j]]++;
	}
	}
	
	inc(i, 3) {
	inc(j, c) {
	inc(k, c) {
		y[i][k] += x[i][j] * d[j][k];
	}
	}
	}
	
	int ans = n * n * 1000 + 1, v = 0;
	inc(i, c) {
	inc(j, c) {
	inc(k, c) {
		if(i == j || j == k || k == i) { continue; }
		setmin(ans, y[0][i] + y[1][j] + y[2][k]);
	}
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1280
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	int n;
	while(cin >> n){
		int ans = 0;
		for(int a = 0; a <= 9; a++){
			for(int b = 0; b <= 9; b++){
				for(int c = 0; c <= 9; c++){
					for(int d = 0; d <= 9; d++){
						if(a + b + c + d == n)ans++;
					}
				}
			}
		}
		cout << ans << '\n';
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3100
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vector
#include <set> // set
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#include <iomanip> //cout<<setprecision(n)
#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

template<typename T,T MOD = 1000000007>
struct Mint{
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
  
  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}
  
  Mint inv(){return pow(MOD-2);}
  
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
  
  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  
  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};

void MSOL_C() {
  ll n,a,b,c;
  std::cin >> n >> a >> b >> c;
  Mint<ll> An(a);
  An = An.pow(n);
  Mint<ll> Bn(b);
  Bn = Bn.pow(n);
  Mint<ll> Amn(1),Bmn(1);
  Mint<ll> mCn(1);
  Mint<ll> sum(0);
  Mint<ll> n100(100-c);
  n100 = n100.pow(n);
  Mint<ll> c100(100-c);
  for(ll m = n;m<2*n;m++) {
    sum += (An*Bmn+Bn*Amn)*mCn*m*100/(c100*n100);
    n100*=c100;
    Amn*=a;Bmn*=b;
    mCn=mCn*m/(m-n+1);
  }
  std::cout << sum.v << std::endl;
}

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

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

int main(){
    ll H,N,i,j,div;
    cin>>H>>N;
    vector<ll> A(N),B(N);
    vector<vector<ll>> dp(N,vector<ll>(H));
    for(i=0;i<N;i++)cin>>A[i]>>B[i];

    for(i=0;i<N;i++){
        for(j=0;j<H;j++){
            div=(j+1)/A[i];
            if((j+1)%A[i]!=0)div++;
            if(i==0){
                dp[i][j]=B[i]*div;
            }else{
                if((j+1)<=A[i]){
                    dp[i][j]=min(dp[i-1][j],B[i]);
                }else{
                    dp[i][j]=min(dp[i-1][j],dp[i][j-A[i]]+B[i]);
                }
            }
        }
    }

    cout<<dp[N-1][H-1]<<endl;
}

Measured memory_bytes: 80256
//https://beta.atcoder.jp/contests/abc115/tasks/abc115_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main(){
    int N;
    cin>>N;
    vector<int> h(N);
    cin>>h;
    sort(ALL(h));
    int ret=h.back()/2;
    h.pop_back();
    for(auto it:h)ret+=it;
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    if (k%7==0) {k=k/7;}
    if (k%2==0 || k%5==0) {cout<<-1<<endl;}
    else {
    int a=1%k;
    int l=1;
    while (a>0) {
		a=(10*a+1)%k;
		l++;
		}
	cout<<l<<endl;}
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll A,B,C,E,D;
  cin >>  A>>B;
  rep(i,101){
    rep(j,101){
      if(i+j==A && i*2+j*4==B){
        cYes;
        return 0;
      }
    }
  }
  cNo;
}

Measured memory_bytes: 3636
N,M = map(int,input().split(' '))
list_sum = []

"""考え方
下記の8パターンを計算し、もっとも値が大きいものを採用する。

x,y,zそれぞれで合計値が「最大」、「最小」のパターン。
つまり、下記のこと。
x+y+z
x+y-z
x-y+z
x-y-z
-x+y+z
-x+y-z
-x-y+z
-x-y-z
"""

list_1 = []
list_2 = []
list_3 = []
list_4 = []
list_5 = []
list_6 = []
list_7 = []
list_8 = []

for n in range(N):
  x,y,z = map(int,input().split(' '))
  
  ## それぞれのlistに格納
  list_1.append(x+y+z)
  list_2.append(x+y-z)
  list_3.append(x-y+z)
  list_4.append(x-y-z)
  list_5.append(-x+y+z)
  list_6.append(-x+y-z)
  list_7.append(-x-y+z)
  list_8.append(-x-y-z)


## それぞれのlistをソート
list_1.sort(reverse=True)
list_2.sort(reverse=True)
list_3.sort(reverse=True)
list_4.sort(reverse=True)
list_5.sort(reverse=True)
list_6.sort(reverse=True)
list_7.sort(reverse=True)
list_8.sort(reverse=True)


## 合計値を取得
p1 = sum(list_1[:M])
p2 = sum(list_2[:M])
p3 = sum(list_3[:M])
p4 = sum(list_4[:M])
p5 = sum(list_5[:M])
p6 = sum(list_6[:M])
p7 = sum(list_7[:M])
p8 = sum(list_8[:M])

ans = max(p1,p2,p3,p4,p5,p6,p7,p8)

print(ans)

Measured memory_bytes: 3444
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    int n;
    scanf("%d\n",&n);
    int a[100005]={};
    for(int i=2;i<500;i++)if(i*(i-1)/2<=100000)a[i*(i-1)/2]=i;
    if(a[n]==0)
    {
        printf("No\n");
        return 0;
    }
    int ban[500][500]={};
    int po=0;
    int max=0;
    REP(i,a[n]-1)
    {
        int y=0;
        while(y!=po)
        {
            ban[po][y+1]=ban[y][po];
            y++;
        }
        po++;
        for(int j=1;j<a[n];j++)
        {
            if(ban[i][j]==0)
            {
                ban[i][j]=++max;
            }
        }
    }
    printf("Yes\n%d\n",a[n]);
    REP(i,a[n]-1)
    {
        printf("%d",a[n]-1);
        REP(j,a[n]-1)printf(" %d",ban[i][j+1]);
        printf("\n");
    }
    printf("%d",a[n]-1);
    REP(i,a[n]-1)printf(" %d",ban[i][a[n]-1]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N, M; cin >> N >> M;
  atcoder::dsu d(N);
  rep(i,M){
    int A, B; cin >> A >> B;
    A--; B--;
    d.merge(A, B);
  }
  set<int> st;
  rep(i,N){
    st.insert(d.leader(i));
  }
  cout << max(0,sz(st)-1) << endl;
  return 0;
}


Measured memory_bytes: 7596
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

long long gcd(long long x, long long y) {
  while (y != 0) {
    long long r = x % y;
    x = y;
    y = r;
  }
  return x;
}

map<long long, int> factor(long long n) {
  map<long long, int> mp;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1) mp[n] = 1;
  return mp;
}

int main() {
  int N;
  cin >> N;
  vector<long long> A(N+1);
  REP(i, N+1) cin >> A[i];
  reverse(A.begin(), A.end());
  vector<bool> p(N+21, true);
  for (int i = 2; i <= N+20; i++) {
    if (p[i]) {
      for (int j = i * 2; j <= N+20; j += i) {
        p[j] = false;
      }
    }
  }
  set<long long> ans;
  for (int i = 2; i <= N+20; i++) if (p[i]) {
    bool all = true;
    vector<long long> B(i - 1);
    for (int j = 0; j <= N; j++) {
      B[j % (i - 1)] += A[j];
    }
    if (A[0] % i != 0) all = false;
    for (long long j = 1; j < i && all; j++) {
      long long x = 0;
      for (int k = i - 2; k >= 0; k--) x = (x * j + B[k]) % i;
      all &= x == 0;
    }
    if (all) ans.insert(i);
  }
  long long g = 0;
  REP(i,N+1) g = gcd(g, abs(A[i]));
  for (auto e : factor(g)) {
    ans.insert(e.first);
  }
  for (long long e : ans) cout << e << '\n';
}


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

int main(void){
  int N,v[25],c[25],max,i;
  char str[500],*p;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(str);
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  v[0]=atoi(p);
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
    v[i]=atoi(p);
  }
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  c[0]=atoi(p);
  for(i=1;i<N;i++){
    p=strtok(NULL," \n");
    c[i]=atoi(p);
  }
  for(i=0,max=0;i<N;i++){
    if(v[i]-c[i]>0){
      max+=v[i]-c[i];
    }
  }
  
  printf("%d\n",max);
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b,k,c[100],i,j=0;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&k);
    for(i=100;i>0;i--){
        if(a%i==0&&b%i==0){
            c[j]=i;
            j++;
        }
    }
    printf("%d",c[k-1]);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

int main(void)
{
	int A, B, C;

	std::cin >> A;
	std::cin >> B;
	std::cin >> C;

	int rast = A - B;
	int ans = 0;
	if (rast < C) {
		ans = C - rast;
	}

	std::cout << ans << std::endl;

}

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

int main() {
  int a[9], b[9];
  cin >> a[0] >> b[0];
  REP(i, b[0]) a[i+1] = a[0];
  REP(i, a[0]) b[i+1] = b[0];
  REP(i, max(a[0],b[0])) {
    if (a[i] < b[i]) {
      REP(i, b[0]) cout << a[i];
      cout << endl;
      return 0;
    } else if (a[i] == b[i]) {
      continue;
    } else {
      REP(i, a[0]) cout << b[i];
      cout << endl;
      return 0;
    }
  }
  REP(i, b[0]) cout << a[i];
  cout << endl;
}


Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a, b;
    cin >>a >>b;

    cout << (a+b+1)/2 << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

typedef long long i64;
typedef pair<i64, i64> pii;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  i64 s;
  cin >> s;
  const int v = 1000000000;
  int x = (v - s % v) % v;
  int y = (s + x) / v;

  cout << "0 0 1000000000 1 " << x << ' ' << y << "\n";

  return 0;
}

Measured memory_bytes: 256
N=int(input())
a=[-1]+[int(i) for i in input().split()]
b=[0 for i in range(N+1)]
for i in range(1,N+1)[::-1]:
    tmp=0
    for j in range(2*i,N+1,i):
        tmp+=b[j]
    if tmp%2!=a[i]:
        b[i]=1
ans=[]
for i in range(N+1):
    if b[i]==1:
        ans.append(str(i))
print(len(ans))
print(" ".join(ans))


Measured memory_bytes: 17200
unittest
{
	assert( [ "3", "3 5", "2 7", "9 4" ].parse.expand.solve == 7 );
	assert( [ "7", "3 1", "4 1", "5 9", "2 6", "5 3", "5 8", "9 7" ].parse.expand.solve == 22 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto abs = new long[ 2 ][ n ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
	}
	return tuple( abs );
}

auto solve( long[ 2 ][] abs )
{
	auto ans = 0L;
	foreach_reverse( ab; abs )
	{
		auto r = ( ans + ab[ 0 ] ) % ab[ 1 ];
		if( 0 < r ) ans += ab[ 1 ] - r;
	}
	return ans;
}


Measured memory_bytes: 4860
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

string cnt[105];

signed main(){
  int n; cin>>n;
  char last;
  for(int i=0; i<n; i++){
    cin>>cnt[i];
    for(int j=0; j<i; j++) if(cnt[j]==cnt[i]){cout<<"No"<<en; RE;}
    if(i){
      if(cnt[i][0]!=last){cout<<"No"<<en; RE;}
      last=cnt[i][cnt[i].size()-1];
    }else{
      last=cnt[i][cnt[i].size()-1];
    }
  }

  cout<<"Yes"<<en;
}

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

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    string S, T;
    cin >> S >> T;

    string ans;

    for (ll i = 0; i < (ll)S.size() - (ll)T.size() + 1; ++i) {
        bool match = true;
        for (ll j = 0; j < (ll)T.size(); ++j) {
            if (S[i + j] != '?' && S[i + j] != T[j]) {
                match = false;
                break;
            }
        }
        if (match) {
            string Scopy;
            replace_copy(begin(S), end(S), back_inserter(Scopy), '?', 'a');
            copy(begin(T), end(T), begin(Scopy) + i);
            if (ans.empty() || Scopy < ans) {
                ans = move(Scopy);
            }
        }
    }

    if (ans.empty()) {
        cout << "UNRESTORABLE\n";
    } else {
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
x='Yes'
if n>1:
  h[0]-=1
  for i in range(1,n):
    if h[i-1]<h[i]:
      h[i]-=1
    elif h[i-1]>h[i]:
      x='No'
      break
print(x)

Measured memory_bytes: 14224
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
const int N = 2e5+7,INF = 0x7f7f7f7f;
ll a[N],f[N],s[N];
int main()
{
    int n;scanf("%d",&n);
    for(int i = 1;i <= n;++i)	scanf("%lld",&a[i]);
	s[1] = a[1];
	for(int i = 2;i <= n;++i)
		s[i] = s[i - 2] + a[i];
	f[2] = max(a[1],a[2]);
	for(int i = 3;i <= n;++i)
		if(i & 1)	f[i] = max(f[i - 1],f[i - 2] + a[i]);
		else	f[i] = max(f[i - 2] + a[i],s[i - 1]);
    printf("%lld",f[n]);
    return 0;
}


Measured memory_bytes: 7932
#include <iostream>
using namespace std;
int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long result;
    if (n == 0 || a > b) {
        result = 0;
    } else if (n == 1) {
        if (a != b) {
            result = 0;
        } else {
            result = 1;
        }
    } else {
        result = (n-2) * (b-a) + 1;
    } 
    cout << result << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int A[N+2];
    A[0] = 0;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    A[N+1] = 0;
    int sum = 0;
    for(int i = 1; i <= N+1; i++) {
        sum += abs(A[i] - A[i-1]);
    }
    int ans[N];

    rep(i, N) {
        if( (A[i] <= A[i+1] && A[i+1] <= A[i+2]) || (A[i+2] <= A[i+1] && A[i+1] <= A[i]) ) {
            ans[i] = sum;
        }
        else if( (A[i] <= A[i+2] && A[i+2] <= A[i+1]) || (A[i+1] <= A[i+2] && A[i+2] <= A[i]) ) {
            ans[i] = sum - 2*abs(A[i+1] - A[i+2]);
        }
        else if( (A[i+1] <= A[i] && A[i] <= A[i+2]) || (A[i+2] <= A[i] && A[i] <= A[i+1]) ) {
            ans[i] = sum - 2*abs(A[i] - A[i+1]);
        }
    }

    rep(i, N) {
        cout << ans[i] << "\n";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int n, k;
    cin >> n >> k;
    if(n == k)
        cout << 1;
    else
        cout << (n - k - 1) / (k - 1) + 2;
    // int a[n];
    // rep(i, n) cin >> a[n];
    // int ans;
    // ans = (n - k - 1) / (k - 1) + 1;
    // cout << n - k - 1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const ll inf=1e18;
const int mod=1e9+7;
const int maxn=5e5+10;
ll n,s;
ll f(ll x,ll b){
	return x<b?x:f(x/b,b)+x%b;
}
int main(){
    ios::sync_with_stdio(false);
    //cout<<(1ll<<26)<<endl;
   	cin>>n>>s;
   	if(s==n){
   		cout<<n+1<<endl;
   		return 0;
   	}
   	for(ll i=2;i*i<=n;i++){
   		if(f(n,i)==s){
   			cout<<i<<endl;
   			return 0;
   		}
   	}
   	ll k=n-s;
   	ll ans=inf;
   	for(ll i=1;i*i<=k;i++){
   		if(k%i==0){
   			if(f(n,k/i+1)==s) ans=min(ans,k/i+1);
   			if(f(n,i+1)==s) ans=min(ans,i+1);
   		}
   	}
   	if(ans==inf) ans=-1;
   	cout<<ans<<endl;
   	/*p*b+q==n
   	p+q==s
   	(n-s)/p==(b-1);*/
   /*	q=s-p;
	k/(k/i);*/
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int N;
    scanf("%d", &N);
    int array[N];
    for(int i=0; i<N; i++) {
        scanf("%d", &array[i]);
    }
    int index1 =0;
    int max =0 , sec = 0;
    for(int i=0; i<N; i++) {
        if(max<=array[i]) {
            max = array[i];
            index1 = i;
        }
    }
    
    for(int i=0; i<N; i++) {
        if(sec <= array[i] && i != index1) {
            sec = array[i];
        }
    }



    for(int i=0; i<N; i++) {
        if(max != array[i]) {
            printf("%d\n", max);
        }
        else {
            printf("%d\n", sec);
        }
    }
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (a > b) {
        cout << "a > b";
    }
    else if (a == b) {
        cout << "a == b";
    }
    else {
        cout << "a < b";
    }
    
    cout << endl;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i, n)
    cin >> v.at(i);
  
  ll ans;
  ans = 0;
  
  rep(j, n)
    ans += v.at(j)-1;
    
  cout << ans << endl;
}

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

typedef struct Node_ Node;

struct Node_
{
    int key;
    Node* parent;
    Node* left;
    Node* right;
};

static Node* root;

static void insert(int key)
{
    Node* node = (Node*)malloc(sizeof(Node));
    node->key = key;
    node->parent = NULL;
    node->left = NULL;
    node->right = NULL;
    
    Node* parent = NULL;
    Node* cur = root;
    while (cur != NULL) {
        parent = cur;
        if (node->key < cur->key) {
            cur = cur->left;
        } else {
            cur = cur->right;
        }
    }
    
    node->parent = parent;
    
    if (parent == NULL) {
        root = node;
    } else {
        if (node->key < parent->key) {
            parent->left = node;
        } else {
            parent->right = node;
        }
    }
}

static Node* find(int key)
{
    Node* node = root;
    while (node != NULL && node->key != key) {
        if (key < node->key) {
            node = node->left;
        } else {
            node = node->right;
        }
    }
    return node;
}

static void printInorder(Node* node)
{
    if (node == NULL)
        return;
    printInorder(node->left);
    printf(" %d", node->key);
    printInorder(node->right);
}

static void printPreorder(Node* node)
{
    if (node == NULL)
        return;
    printf(" %d", node->key);
    printPreorder(node->left);
    printPreorder(node->right);
}

static void printTree()
{
    printInorder(root);
    printf("\n");
    printPreorder(root);
    printf("\n");
}

static void freeTree(Node* node)
{
    if (node->left != NULL) {
        freeTree(node->left);
    }
    if (node->right != NULL) {
        freeTree(node->right);
    }
    free(node);
}

int main()
{
    int n;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        char command[10];
        scanf("%s", command);
        
        if (command[0] == 'i') {
            int key;
            scanf("%d", &key);
            insert(key);
        } else if (command[0] == 'f') {
            int key;
            scanf("%d", &key);
            Node* node = find(key);
            printf((node != NULL) ? "yes\n" : "no\n");
        } else if (command[0] == 'p') {
            printTree();
        }
    }
    
    freeTree(root);
    return 0;
}


Measured memory_bytes: 20452
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long a[10000];
  for(int i=0; i<n;i++)
    cin >>a[i];
  long long min=a[0],max=a[0],sum=a[0];
  for(int i=1;i<n;i++){
    if(min >a[i])
      min=a[i];
    if(max <a[i])
      max=a[i];
    sum+=a[i];
  }
  cout<<min<<' '<<max<<' '<<sum<<endl;
  return 0;
}


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

int main(){
    string w;
    int count =1;
    int ans =0;
    int flag =0;
    cin >> w;
    sort(w.begin(),w.end());
    for(int i=0; i<w.size();i++){
        if(w[i] == w[i+1]) count++;
        else {
            ans = count;
            count =1;
            if(ans %2 !=0){
                flag =1;
            }
        }
    }
    if(flag == 1) printf("No");
    else printf("Yes");
    return 0;
}

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

int main() {
  std::string s;
  int a, b;

  for (int i = 0; i < 9; ++i) {
    std::cin >> s >> a >> b;
    std::cout << s << " " << a + b << " " << a * 200 + b * 300 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3044
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define pf(a)           printf("%lld\n", a)
#define sf(a)           scanf("%lld", &a)
#define line(a)         getline(cin,(a))
#define ll              long long int
#define MAX             2134567891
#define MID(l,r)        (l+r)>>1
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define per(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define T_C(t)          printf("Case %lld: ",t)
#define TC(t)           printf("Case %lld:\n",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb(a)           push_back(a)
#define ff              first
#define ss              second
#define MOD             1000000007///10^9
#define p6              1000007 ///10^6->6 zero after 1 **
#define hlw             printf("hlw\n");
#define SN              4*p6
#define NN              111
#define N               p6

ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc,in,mod,loc,diff,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
    double a,b,c;
    cin>>a;
    a/=3.0;
    c=a*a*a;
    printf("%f\n",c);

}
    return 0;
}

/*

*/
/// Check for constraint 0 or 1?
/// long long or double? sqrt or division will work fine??


Measured memory_bytes: 256
//AOJ 0033

#include<iostream>

using namespace std;

int main(){

	int n;

	cin>>n;

	int **data = new int*[n];
	for(int i=0;i<n;i++){
		data[i] = new int[10];
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin>>data[i][j];
		}
	}

	int youki[2]={0,0};
	int state = 0;
	int flag = 0;

	for(int i=0;i<n;i++){
		for(int k=0;k<2;k++){
			youki[k] = 0;
		}
		for(int j=0;j<10;j++){
			state = 0;
			flag = 0;
			for(int k=0;k<2;k++){

				if(youki[k]<=data[i][j]){
					youki[k] = data[i][j];
					state = 1;//ボール入れられた！
					break;
				}
			}
			if(state==0){
				cout<<"NO"<<endl;
				break;
			}
			if(state == 1 && j == 9){
				flag = 1;
			}
		}
		if(flag == 1){
			cout<<"YES"<<endl;

		}
		
	}
	return 0;
}

Measured memory_bytes: 1184
f=lambda:map(int,input().split())
n,d=f()
ll=[list(f()) for _ in range(n)]
a=0
for j in range(n):
  for i in range(j):
    a+=sum((ll[i][k]-ll[j][k])**2 for k in range(d))**.5%1==0
print(a)

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

int main() {
    int N;
	cin >> N;
	vector<int> height(N);
	for (int i = 0; i < N; i++) {
		cin >> height.at(i);
	}

	int CanSee = 1;

	for (int i = 1; i < N; i++) {
		bool check = true;
		for (int j = 0; j < i; j++) {
			if (height.at(i) < height.at(j)) {
				check = false;
				break;
			}
		}
		if (check) {
			CanSee++;
		}
	}
	cout << CanSee << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;
int i, j, k;
long long ans = 0;
int main() {
	int N,K;
	cin >> N >> K;
	rep(i, N) {
		int h;
		cin >> h;
		if (h >= K)ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm.*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//typedef long long ll;
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define debug() cout << "Hi" << endl	// write debug(); in main()
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
/*		0. Go to main function first.
		1. Take all the inputs................................................
		2. Check Once whether the graph given is directed or undirected.......
		3. Tree can also be undirected.
		4. Whenever you do multiplication and division in the same line, beware.
*/
void solve(){
	int k,n;
	cin >> k >> n;
	int a[n];
	int maxi = 0;
	cin >> a[0];
	int t1;
	for(int i=1;i<n;++i){
		cin >> a[i];
		t1 = a[i]-a[i-1];
		//t1 = min(t1,k-t1);
		if(maxi < t1)maxi = t1;
	}
	t1 = k+a[0]-a[n-1];
	//t1 = min(t1,k-t1);
	if(maxi < t1)maxi = t1;
	//int ans = min(maxi,k-maxi);
	//if(maxi > (k/2) ) cout << (k-maxi) << endl;
	//else cout << maxi << endl;
	cout << (k-maxi) << endl;
}
/*	memset() can be used to set all values as 0 or -1 for integer data types.*/

int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(12); std::cout << std::fixed;
	int t;
	// cin >> t;
	t = 1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int N,K;
  cin>>N>>K;
  int l[N];
  FOR(i,0,N) cin>>l[i];
  sort(l,l+N);
  reverse(l,l+N);
  int ans = 0;
  FOR(i,0,K) ans += l[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = int(input())
lst = [s]

def gold(x):
    if x % 2 == 0:
        return int(x/2)
    else:
        return int(3*x + 1)

if s == 4 or s == 2 or s == 1:
    print(4)
else:
    while lst[-1] != 1:
        lst.append(gold(int(lst[-1])))
    print(len(lst) + 1 )

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <functional>
using namespace std;

using ll = long long;
const ll INF = ((1LL << 60) - 1);

int N, W, u, v, w0, a, b, c, d;
vector<ll> w[4];
ll memo[101][101][101][101];

ll solve(ll price = 0, ll sum = 0, int i = 0, int j = 0, int k = 0, int l = 0) {
  if (memo[i][j][k][l] != 0) return memo[i][j][k][l];

  if (sum > W) return -INF;

  ll ret = 0;

  ret = max(ret, price);

  if (i != a) ret = max(ret, solve(price + w[0][i], sum + w0, i + 1, j, k, l));
  if (j != b) ret = max(ret, solve(price + w[1][j], sum + w0 + 1, i, j + 1, k, l));
  if (k != c) ret = max(ret, solve(price + w[2][k], sum + w0 + 2, i, j, k + 1, l));
  if (l != d) ret = max(ret, solve(price + w[3][l], sum + w0 + 3, i, j, k, l + 1));

  return memo[i][j][k][l] = ret;
}

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

  cin >> N >> W;
  for (int i = 0; i < N; ++i) {
    cin >> u >> v;
    if (i == 0) {
      w0 = u;
      w[0].push_back(v);
    }
    else {
      for (int i = 0; i < 4; ++i) {
        if (w0 + i == u) {
          w[i].push_back(v);
          break;
        }
      }
    }
  }

  for (int i = 0; i < 4; ++i) {
    sort(w[i].begin(), w[i].end(), greater<int>());
  }

  a = w[0].size();
  b = w[1].size();
  c = w[2].size();
  d = w[3].size();

  ll ans = solve();

  cout << ans << endl;

  return 0;
}

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

using ll = long long;
const int mod = 1e9 + 7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++)
        cin >> P[i];
    int ans = 1;
    vector<int> mi(N);
    mi[0] = P[0];
    for (int i = 1; i < N; i++) {
        mi[i] = min(mi[i - 1], P[i]);
        if (mi[i] == P[i])
            ans++;
    }
    cout << ans << endl;
}

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

int a[5];
int main() {
	for(int i=0; i<5; ++i) {
		cin >> a[i];
	}

	int min = 10;
	int imin = -1;
	for(int i=0; i<5; ++i) {
		if ((a[i]-1)%10 < min) {
			min = (a[i]-1)%10;
			imin = i;
		}
	}

	int ans = 0;
	for(int i=0; i<5; ++i) {
		if (i == imin) {
			ans += a[i];
		} else {
			ans += ((a[i]-1)-((a[i]-1)%10))+10;
		}
	}
	cout << ans << endl;
  
	return 0;
}


Measured memory_bytes: 256