akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m , q;
int a[51], b[51], c[51], d[51];
ll ans = 0;
int A[15];
void dfs(int cut = 0, int lst = 1) {
  if(cut == n) {
    ll tmp = 0;
    REP(i, q) if(A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
    ans = max(ans, tmp);
    return;
  }

  FOR(nxt, lst, m + 1) {
    A[cut] = nxt;
    dfs(cut + 1, nxt);
  }
}

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

  cin >> n >> m >> q;
  REP(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }

  dfs();
  cout << ans << endl;
}


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


int main()
{
  
  int n,k;
  cin>>n>>k;
  
  int ans=0;
  
  while(n--)
  {
      int x;
     cin>>x;
    ans+=(x>=k);
  }
  cout<<ans;
  
 return 0; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int c[a];
    for(int i=0;i<a;i++){
        cin>>c[i];
    }
    
    for(int i=0;i<a-1;i++){
        for(int j=i+1;j<a;j++){
            if(c[i]>=c[j]){
                int k=c[i];
                c[i]=c[j];
                c[j]=k;
            }
        }
    }
    int x=0;
   for(int i=0;i<b;i++){
       x+=c[i];
    } 
    cout<<x;
    return 0;
    
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n;
    cin>>n;
    int sum=0;
    rep(i,1,n+1){
        if(i%3!=0&&i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3648
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

A, B, N = map(int, input().split())

if N >= B-1:
    print(A*(B-1)//B)
else:
    print(A*N//B)

Measured memory_bytes: 77584
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int ans = 0;
    rep(i, 4) {char x; cin >> x; if(x == '+') ++ans; else --ans;}
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

const ll MOD = 998244353;

// mod p における掛け算
ll mul_mod(ll a, ll b, ll modp){
    return (a * b) % modp;
}

// mod p における累乗
ll mod_pow(ll x, ll n, ll modp){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % modp;
        x = x * x % modp;
        n >>= 1;
    }
    return res;
}

/*----------------------------------
// 1 : O(n)でテーブル準備 計算はO(1) //
// 使用例 : COMinit(); COM(10, 4); //
----------------------------------*/
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

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

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

int main(void){
    ll n, m, k;
    cin >> n >> m >> k;

    COMinit();

    ll ans = 0;
    for(int i=0; i<=k; i++){
        ll cmb = COM(n-1, i);
        ll Mn = mod_pow(m-1, n-i-1, MOD);
        ll tmp_ans = mul_mod(cmb, Mn, MOD);
        tmp_ans = mul_mod(tmp_ans, m, MOD);
        ans += tmp_ans;
        ans %= MOD;
    }

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

Measured memory_bytes: 15600
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

#define int LL

int n, a, x[101];
int dp[55][55][2550];

signed main() {
	cin >> n >> a;
	REP(i, n)cin >> x[i];
	dp[0][0][0] = 1;
	int ans = 0;
	REP(i, n)REP(j, n)REP(k, 2500) {
		dp[i + 1][j][k] += dp[i][j][k];
		dp[i + 1][j + 1][k + x[i]] = dp[i][j][k];
	}
	for (int j = 1; j <= n; j++) {
		ans += dp[n][j][a*j];
	}
	cout << ans << endl;
}

Measured memory_bytes: 56448
n, p = [int(_) for _ in input().split(' ')]
a = [int(x) % 2 == 0 for x in input().split(' ')]
if all(a):
    if p == 1:
        print(0)
    else:
        print(1 << n)
else:
    print(1 << (n - 1))


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

using namespace std;

ll sumdigit(ll n){
	string s = to_string(n);
	ll ret = 0;
	for (char c : s) ret += c - '0';
	return ret;
}

int main(){
	ll n; cin >> n;
	ll nd = sumdigit(n);
	if (n % nd == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	string s;
	cin >> s;
	vector<int> dp(12);
	if (s.at(0) == 'A' || s.at(0) == 'C' || s.at(0) == 'G' || s.at(0) == 'T') dp[0] = 1;
	else dp[0] = 0;
	int ans = dp[0];
	for (int i = 1; i < s.size(); i++) {
		if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
			dp[i] = dp[i - 1] + 1;
			ans = max(ans, dp[i]);
		}
		else {
			dp[i] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int x, y, z; cin >> x >> y >> z;
    cout << ( x - z ) / ( y + z ) << endl;
}


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

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main() {
  const i64 mod = 1e9 + 7LL;
  int n, m;
  cin >> n >> m;
  vl a(n + 1, 0);
  for (int i = 0; i < m; i++) {
    int t;
    cin >> t;
    a[t] = -1;
  }
  a[0] = 1;
  a[1] = a[1] == -1 ? -1 : 1;
  for (int i = 2; i <= n; i++) {
    if(a[i] == -1)continue;
    if (a[i - 1] != -1) {
      a[i] += a[i - 1];
      a[i] %= mod;
    }
    if (a[i - 2] != -1){
      a[i] += a[i-2];
      a[i] %= mod;
    }
  }
  // for(auto&& x:a)cerr << x << " ";
  // cerr << endl;
  cout << a[n] << endl;;
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.math.*;

 
 public class Main	{
   static class Pair implements Comparable<Pair>{
   int a;
   int b;
   public Pair(int x,int y){a=x;b=y;}
   public Pair(){}
   public int compareTo(Pair p){
	 return p.a - a;
   }



 }
static class TrieNode{
  TrieNode[]child;
  int w;
  boolean term;
  TrieNode(){
    child = new TrieNode[26];  
  }
}
  public static int gcd(int a,int b)
  {
    if(a<b)

      return gcd(b,a);
    if(b==0)
      return a;
    return gcd(b,a%b);
    
  }
  //static long ans = 0;
  static long mod = (long)(1e9+7);///998244353;
   
    public static void main(String[] args) throws Exception {
       new Thread(null, null, "Anshum Gupta", 99999999) {
            public void run() {
                try {
                    solve();
                } catch(Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }

static long pow(long x,long y){
    if(y == 0)return 1;
    if(y==1)return x;
    long a = pow(x,y/2);
    a = (a*a)%mod;
    if(y%2==0){
        return a;
    }
    return (a*x)%mod;
}

static long mxx;
static int mxN = (int)(1e6+5);
static long[]fact,inv_fact;
static long my_inv(long a) {
	return pow(a,mod-2);
}
static long bin(int a,int b) {
	if(b>a)return 0;
    return ((fact[a]*inv_fact[a-b])%mod * inv_fact[b])%mod;
}
static String str;
static int n,k;

 public static void solve() throws Exception {
   // solve the problem here
   MyScanner s = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int tc = 1;//s.nextInt();
        mxx = (long)(1e18+5);
       
        while(tc-->0){
        	double n = s.nextDouble();
        	n /= 3;
        	double ans = n*n*n;
        	out.println(ans);
        }
        
           
        out.flush();
}
 
     
 
 
 
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
 
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
         
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  ll n=sz(s);
  vvll dp(n+1,vll(2,INF));
  dp[0][0]=0;
  reverse(all(s));
  rep(i,n)rep(j,2){
    if(dp[i][j]==INF) continue;
    ll c=s[i]-'0';
    ll no=10-c;
    if(j==0){
      chmin(dp[i+1][0],dp[i][j]+c);
      chmin(dp[i+1][1],dp[i][j]+no);
    }
    else{
      chmin(dp[i+1][0],dp[i][j]+1+c);
      chmin(dp[i+1][1],dp[i][j]+no-1);
    }
  }
  COUT(min(dp[n][0],dp[n][1]+1LL));
}


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

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
int n;
ll c;
const int N=2e5+5;
const int H=1e6+1;
vector<int> h(N);
struct func{
    int h;
    ll c;
};
ll get(func f,int pos)
{
    return (ll)(pos-f.h)*(pos-f.h)+c+f.c;
}
struct LiChao{
    vector<func> f;
    void init(func fe)
    {
        f.resize(4*H);
        fill(all(f),fe);
    }
    void add(func ne,int l=0,int r=H,int i=1)
    {
        int m=(l+r)>>1;
        bool le=get(ne,l)<get(f[i],l);
        bool mid=get(ne,m)<get(f[i],m);
        if(mid)
            swap(f[i],ne);
        if(r-l==1)
            return;
        if(le!=mid)
            add(ne,l,m,2*i);
        else
            add(ne,m,r,2*i+1);
    }
    ll gett(int pos,int l=0,int r=H,int i=1)
    {
        if(r-l==1)
            return get(f[i],pos);
        int m=(l+r)>>1;
        if(pos<m)
            return min(get(f[i],pos),gett(pos,l,m,2*i));
        return min(get(f[i],pos),gett(pos,m,r,2*i+1));
    }
} st;
int main()
{
    scanf("%i %lld",&n,&c);
    for(int i=0;i<n;i++)
        cin >> h[i];
    func en={h[n-1],0};
    st.init(en);
    for(int i=n-2;i>0;i--)
    {
        func tr={h[i],st.gett(h[i])};
        st.add(tr);
    }
    printf("%lld\n",st.gett(h[0]));
    return 0;
}


Measured memory_bytes: 63616
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int n = in();
  int m = in();
  vector<int> heights(n);
  foreach(i,heights)i=in();
  vvector<int> edges(n);
  rep(i,m){
    int a = in()-1;
    int b = in()-1;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  int ans = 0;
  rep(i,n){
    bool flag = true;
    foreach(j,edges[i]){
      if(heights[i]<=heights[j]){
        flag = false;
        break;
      }
    }
    if(flag)++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8804
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;

char S[10];
int main()
{
	scanf("%s", S);
	int ans = 0;
	if (strcmp(S, "SUN") == 0) ans = 7;
	if (strcmp(S, "MON") == 0) ans = 6;
	if (strcmp(S, "TUE") == 0) ans = 5;
	if (strcmp(S, "WED") == 0) ans = 4;
	if (strcmp(S, "THU") == 0) ans = 3;
	if (strcmp(S, "FRI") == 0) ans = 2;
	if (strcmp(S, "SAT") == 0) ans = 1;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<map>
#include<vector>
#include<set>
#include<math.h>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long int 
int main()
{
	ll n;
	cin>>n;
	if(n==0)
    {
      cout<<"0"<<endl;
      return 0;
    }
	vector<ll>v(n);
	for(ll i=0;i<n;i++)
		cin>>v[i];
	ll mx=v[0],stool=0;
	for(ll i=1;i<n;i++)
	{
		if(mx>v[i])
			stool+=(mx-v[i]);
		mx=max(mx,v[i]);
	}
	cout<<stool<<endl;
	return 0;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
using f32 = float;
using f64 = double;
using LL = long long;
using ULL = unsigned long long;
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
signed main()
{ 
  string a;
    cin >>a;
  REP(i,2){
  if(a[i]!=a[i+1]){
  cout << "Yes";
  return 0;
  }
  }
  cout << "No";
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std; 

//しゃくとり方でとく//
int main(void){
 int N,K;

 char S[100050];
 vector<int> A;

 cin>>N>>K;
 cin>>S;

 int cnt=0;
 int now=0;

 for(int i=0; i<strlen(S);i++){
  if(S[i]==('1'-now)){
   cnt++;
  }
  else{
   now=1-now;
   A.push_back(cnt);
   cnt=1;
  }
 }
 A.push_back(cnt);          
 
 if(A.size()%2==0)A.push_back(0);
 
 int sum,left,right,ans,nowleft,nowright;
 sum=0;
 left=0;
 right=0;
 nowleft=0;
 nowright=0;
 ans=0;

 while(nowright<A.size()){
  right=min(left+2*K+1,(int)A.size());

  while(nowleft<left){
   sum-=A[nowleft];
   nowleft++;
  }
  while(nowright<right){
   sum+=A[nowright];
   nowright++;
  }
  left+=2;
  ans=max(sum,ans);
 }

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

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;

ll n, m, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
	cin >> n;
	int L[n];
	int S[n][n];
	REP(i,n){ cin >> L[i]; }
	sort(L,L+n);
	REP(i,n-1) {
      FOR(j,i+1,n) {
        S[i][j] = L[i] + L[j];
      }
    }
	REP(i,n-2) {
      FOR(j,i+1,n-1) {
      	FOR(k,j+1,n) {
          if (L[k] < S[i][j]) {
            ++cnt;
          }
        }
      }
    }
	cout << cnt << endl;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;
using namespace std;

int n;
bool hs(const string& str, const vector<int>& phi){
  //cout << "[" << str[n] <<"]" << endl;
  if(str[n] == '('){
    n++;
    bool l = hs(str, phi);
    bool r;
    switch(str[n]){
      case '*':
        n++;
        r = hs(str, phi);
        assert(str[n] == ')'); n++;
        return l && r;
      case '+':
        n++;
        r = hs(str, phi);
        assert(str[n] == ')'); n++;
        return l || r;
      case '-':
        n++; assert(str[n]=='>'); n++;
        r = hs(str, phi);
        assert(str[n] == ')'); n++;
        return (!l) || r;
    }
    cout << "(" << endl;
    assert(false);
  }else if(str[n] == '-'){
    n++;
    bool p = hs(str, phi);
    return !p;
  }else if(str[n] == 'T'){
    n++; return 1;
  }else if(str[n] == 'F'){
    n++; return 0;
  }else if('a'<=str[n] && str[n]<='k'){
    //cout << str[n]  << endl;
    bool p = phi[str[n] - 'a'];
    n++;
    return p;
  }
  cout << "hs" << endl;
  assert(false);
}
bool parse(const string& str, const vector<int>& phi){
  n = 0;
  bool pl = hs(str, phi);
  assert(str[n] == '=');
  n++;
  bool pr = hs(str, phi);
  return pl == pr;
}
bool tryp(const string& str, const vector<int>& phi){
  if(phi.size() == 11){
    return parse(str, phi);
  }
  vector<int> t(phi), f(phi);
  t.push_back(1);
  f.push_back(0);
  bool pt = tryp(str,t);
  bool pf = tryp(str,f);
  return pt && pf;
}
bool solve(const string& str){
  return tryp(str, vector<int>());
}
signed main(){
  string str;
  while(cin >> str, str != "#"){
    if(solve(str)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
bool cmp(const pair<string,int>& a,const pair<string,int>& b)
{
    if(a.second==b.second)return a.first<b.first;
    else return a.second>b.second;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<string>v;
    map<string,int>mp;
    int k=0;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    vector<pair<string,int> >p;
    for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++){
        p.push_back({it->first,it->second});
    }
    sort(p.begin(),p.end(),cmp);
    v.push_back(p[0].first);
    k=p[0].second;
    for(int i=1;i<p.size();i++){
        if(k==p[i].second)v.push_back(p[i].first);
    }
    for(auto &x: v)cout<<x<<endl;
}


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

int main() {
  int a, b, m; cin >> a >> b >> m;
  vector<int> ap(a), bp(b);
  for(int i = 0; i < a; i++){
    cin >> ap.at(i);
  }
  for(int i = 0; i < b; i++){
    cin >> bp.at(i);
  }
  vector<int> x(m), y(m), c(m);
  for(int i = 0; i < m; i++){
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }
  int out = 10000000;
  for(int i = 0; i < m; i++){
    int price = ap.at(x.at(i)-1) + bp.at(y.at(i)-1) - c.at(i);
    if(price < out) out = price;
  }
  sort(ap.begin(), ap.end());
  sort(bp.begin(), bp.end());
  if(ap.at(0) + bp.at(0) < out) out = ap.at(0) + bp.at(0);
  cout << out;
}

Measured memory_bytes: 2176
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		
		public static void Compute(TextReader reader, TextWriter writer)
		{
			var line = reader.ReadLine();
			var ary = SplitToDoubles(line);
			var x1 = ary[0];
			var y1 = ary[1];
			var x2 = ary[2];
			var y2 = ary[3];
			var xx = x1 - x2;
			var yy = y1 - y2;
			
			writer.WriteLine(Math.Sqrt(xx * xx + yy * yy));
			
		}
	}
}

Measured memory_bytes: 6080
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    solve(new Scanner(System.in))
  }

  def solve(sc: Scanner): Unit = {
    val A = sc.nextInt
    val B = sc.nextInt
    val C = sc.nextInt
    var X = sc.nextInt
    var Y = sc.nextInt

    var p = if (A + B > C * 2) {
      val m = List(X, Y).min
      X -= m
      Y -= m
      C * 2 * m
    } else 0
    p += List(A, C * 2).min * X
    p += List(B, C * 2).min * Y
    println(p)
  }
}


Measured memory_bytes: 27332
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

int diameter(int n,vector<vector<int>>g){ // nodes 1 to n
	vector<int>vis(n+1),dp(n+1);          // g : forest 
	int dia = 0;
	function<void(int)> dfs = [&](int u){
		dp[u]=0;
		vis[u]=1;
		for(auto v:g[u]){
			if(!vis[v]){
				dfs(v);
				dia=max(dia,dp[u]+dp[v]+1);
				dp[u]=max(dp[u],dp[v]+1);
			}
		}
	};
	for(int i=1;i<=n;i++){
		if( !vis[i] ){
			dfs(i);
		}
	}
	return dia;
}
int32_t main(){
	IOS
	int n;cin>>n;
	vector<vector<int>>g(n+1);
	for(int i=1;i<n;i++){
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if( diameter(n,g) % 3 == 1 ) cout << "Second\n";
	else cout << "First\n";
	
	
}
/*
 * long long or int?
 * index out of bound?
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 43216
S = gets.chomp
Qn = gets.to_i
Q = readlines.map(&:split)

fs = ''
bs = S

Q.each do |t,f,c|
  if t == '1'
    fs,bs = bs,fs
  elsif f == '1'
    fs << c
  else
    bs << c
  end
end

puts fs.reverse + bs

Measured memory_bytes: 63328
N = int(input())
B = list(map(int,input().split()))

A = [B[i] for i in range(N-1)]

for i in range(N-2):
    if max(A[i],A[i+1]) > B[i]:
        A[i+1] = B[i]
A.append(B[N-2])

print(sum(A))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABCK = ReadSplitLong();
            var A = ABCK[0];
            var B = ABCK[1];
            var C = ABCK[2];
            var K = ABCK[3];

            if (K % 2 == 0)
                Println(A - B);
            else
                Println(B - A);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



Measured memory_bytes: 11348
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int N;
int S[2048];

struct edge {
  int src, dst;
  edge(int s, int d) : src(s), dst(d) { }
};
typedef vector<edge> edges;
typedef vector<edges> graph;
graph G;

struct result {
  int ps, lo, hi;
  Int dists;
  result(int p, int l, int h, Int d) : ps(p), lo(l), hi(h), dists(d) { }
};

result dfs(int u, int p = -1) {
  result res(0, 0, 0, 0);
  for (const edge& e : G[u]) {
    if (e.dst == p) {
      continue;
    }
    result t = dfs(e.dst, u);
    t.lo += t.ps;
    t.hi += t.ps;
    res.ps += t.ps;
    res.lo = max(res.lo, t.lo) <= min(res.hi, t.hi) ? 0 : (max(res.lo, t.lo) - min(res.hi, t.hi));
    res.hi = res.hi + t.hi;
    res.dists += t.dists + t.ps;
  }
  res.ps += S[u];
  // cerr<<u+1<<": "<<res.ps<<' '<<res.lo<<' '<<res.hi<<' '<<res.dists<<endl;
  return res;
}

int main() {
  int tot = 0;
  N = in();
  char buf[2048];
  scanf("%s", buf);
  for (int i = 0; i < N; ++i) {
    S[i] = buf[i] - '0';
    tot += S[i];
  }

  G.resize(N);
  for (int i = 0; i < N - 1; ++i) {
    int a = in() - 1;
    int b = in() - 1;
    G[a].emplace_back(a, b);
    G[b].emplace_back(b, a);
  }
  if (tot == 1) {
    puts("0");
    return 0;
  }

  Int res = INFLL;
  for (int i = 0; i < N; ++i) {
    result r = dfs(i, -1);
    if (r.lo == 0 && r.dists % 2 == 0) {
      chmin(res, r.dists / 2);
    }
  }

  printf("%lld\n", res == INFLL ? -1 : res);

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  n %= 10;
  string ans;
  if(n== 2 || n == 4 || n == 5 || n== 7 || n == 9)ans = "hon";
  if(n==0 || n == 1 || n == 6 || n == 8) ans = "pon";
  if(n == 3) ans = "bon";
  cout << ans << endl;
}

Measured memory_bytes: 3544
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s


#@lru_cache(maxsize=None)  
def f():
    return 1
#main
N,M=list(map(int,input().split()))
print(N*(N-1)//2+M*(M-1)//2)


Measured memory_bytes: 70252
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll mod=1000000007;

int main(){
  int n; cin>>n;
  vector<int> a(8,0);
  int k=0;
  rep(i,n){
    int A; cin>>A;
    if(A<400) a[0]++;
    else if(A<800) a[1]++;
    else if(A<1200) a[2]++;
    else if(A<1600) a[3]++;
    else if(A<2000) a[4]++;
    else if(A<2400) a[5]++;
    else if(A<2800) a[6]++;
    else if(A<3200) a[7]++;
    else k++;
  }
  // sort(ALL(a));
  int c=0;
  rep(i,8){
    if(a[i]!=0)
    c++;
  }

  if(c==0)
  cout<<1<<" ";
  else
  cout<<c<<" ";

  cout<<c+k<<endl;


  return 0;
}


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

int m=1e9+7;

int main(){
  long long S; cin >> S;
  long long x1, x2=1, x3=0, y1, y2, y3=0;
  x1 = y2 = ceil(sqrt(S));
  if (S-x1*y2>0) {x1++; y2++;}
  //cout << (S-2*x1*y2) << endl;
  //cout << S << endl;
  //cout << x1*y2 << endl;
  x2 = 1;
  y1 = -(S-x1*y2);
  //cout << (S-x1*y2) << endl;
  cout << x1 << " "<< y1 << " " <<x2 << " " <<y2<< " " <<x3 << " " <<y3 << endl;
}

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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  Bint a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;

  bool y = false;

  if (a < b) {
    if (b + w * t <= a + v * t) {
      y = true;
    }
  } else if (a == b) {
    y = true;
  } else {
    if (b - w * t >= a - v * t) {
      y = true;
    }
  }

  if (y) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void add(ll& a, ll b){a = (a+b) % MOD;}

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string correct="CODEFESTIVAL2016";
    string s;cin>>s;
    int ans=0;
    REP(i,16){
        if(s[i]!=correct[i])ans++;
    }
    cout<<ans<<endl;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int n, q;
std::vector<std::set<int> > hen;
std::vector<int64_t> lazy;

void dfs(int i, int par) {
	for (auto j : hen[i]) {
		if (j == par) continue;
		lazy[j] += lazy[i];
		dfs(j, i);
	}
}

int main() {
	n = ri(), q = ri();
	hen.resize(n);
	lazy.resize(n);
	for (int i = 0; i + 1 < n; i++) {
		int a = ri() - 1;
		int b = ri() - 1;
		hen[a].insert(b);
		hen[b].insert(a);
	}
	for (int i = 0; i < q; i++) {
		int p = ri() - 1;
		int x = ri();
		lazy[p] += x;
	}
	dfs(0, -1);
	for (int i = 0; i < n; i++) std::cout << lazy[i] << std::endl;
	
	return 0;
}


Measured memory_bytes: 41472
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    N, K = get_inputs(int)
    ans = min(N % K, K-(N % K))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
typedef long long LL;
const int maxN = 1e5 + 7;
const LL INF = (1LL << 61) + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

inline LL getch() {
	static char s[5]; scanf("%s", s);
	return s[0] == '-' ? -1 : 1;
}

inline LL sgn(int x) {return (x & 1) ? -1 : 1;}

inline void Max(LL &x, LL y) {if (y > x) x = y;}

int n;
LL a[maxN], opr[maxN];
LL f[3][maxN];

int main() {
	
	n = ri();
	opr[1] = 1;
	rep (i, 1, n) a[i] = ri(), opr[i + 1] = getch();

	f[0][0] = 0; f[1][0] = f[2][0] = -INF;
	rep (i, 1, n) {
		rep (j, 0, 2) f[j][i] = -INF;
		rep (j, 0, 2) rep (k, 0, j) {
			Max(f[k][i], f[j][i - 1] + sgn(k) * opr[i] * a[i]);
		}
		if (opr[i] == -1) {
			per (j, 2, 1) {
				Max(f[j][i], f[j-1][i]);
			}
		}
	}

	printf("%lld\n", max(max(f[0][n], f[1][n]), f[2][n]));

	return 0;
}


Measured memory_bytes: 4096