akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  ll n, m, x; cin >> n >> m >> x;
  vector<ll> c(n);
  vector<vector<ll>> sk(n, vector<ll>(m));
  for (ll i = 0; i < n; i++) {
    cin >> c[i];
    for (ll j = 0; j < m; j++) cin >> sk[i][j];
  }
  ll ans = __LONG_LONG_MAX__;
  for (ll i = 1; i < (1<<n); i++) {
    ll ind = 0;
    ll tmp = i;
    vector<ll> t(m, 0);
    ll cost = 0;
    while (tmp) {
      if (tmp & 1) {
        for (ll j = 0; j < m; j++) t[j] += sk[ind][j];
        cost += c[ind];
      }
      tmp >>= 1;
      ind++;
    }
    sort(t.begin(), t.end());
    if (t[0] >= x) {
      ans = min(ans, cost);
    }
  }
  if (ans == __LONG_LONG_MAX__) cout << -1;
  else cout << ans;
  return 0;
}

Measured memory_bytes: 3648
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := make(map[int]int, n)
	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		m[a]++
	}

	b := []int{}
	for k, v := range m {
		if v >= 2 {
			b = append(b, k)
		}
	}
	sort.Ints(b)

	if len(b) >= 2 {
		x := b[len(b)-1]
		if m[x] >= 4 {
			fmt.Println(x * x)
		} else {
			fmt.Println(b[len(b)-1] * b[len(b)-2])
		}
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 5760
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll X, Y, Z;
  std::cin >> X >> Y >> Z;

  ll ans = (X - Z) / (Y + Z);
  print(ans);

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s=new Scanner(System.in);
		int N=s.nextInt();
		double A[]=new double[N];
		double B=0;;
		int i=0;
		int count=1;
		
		for(i=0;i<N;i++){
			A[i]=s.nextInt();
		}
		
		Arrays.sort(A);	
		
			B=A[0];
			for(i=0;i<N-1;i++){
				
			if(A[i+1]/B<=2){
				count++;
				B+=A[i+1];
			}else{
				count=1;
				B+=A[i+1];
			}
			
			}
		
			System.out.print(count);
		}
}

Measured memory_bytes: 59660
N, D = list(map(int, input().split()))
X = []
for k in range(N):
  X.append(list(map(int, input().split())))

Z = []
for j in range(N):
  for i in range(j):
    Y = []
    for n in range(D):
      Y.append((X[i][n] - X[j][n])**2)
    Z.append(Y)

a = 0    
for l in range(N*(N-1)//2):    
  if (sum(Z[l]))**0.5 == int((sum(Z[l]))**0.5):
    a = a+1

print(a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    while (n--)
        cout << "ACL";
    cout << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 309 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
double ev[maxn][maxn][maxn];
double p[maxn][maxn][maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(11);
    int n;
    cin>>n;
    vector<int> et(4,0);
    rep(i,0,n){
        int a;
        cin>>a;
        et[a]++;
    }
    p[et[1]][et[2]][et[3]]=1;
    per(k,n+1,0){
        per(j,n+1,0){
            per(i,n+1,0){
                if(i==0 && j==0 && k==0){
                    continue;
                }
                if(i+j+k>n){
                    continue;   
                }
                double pwaste=((double)(n-(i+j+k))/(n))*p[i][j][k];
                double evwaste=0;
                if(p[i][j][k]>0)evwaste=pwaste/(1-(pwaste/p[i][j][k]))+p[i][j][k];
                ev[i][j][k]+=evwaste;
                // cout<<i<<" "<<j<<" "<<k<<" "<<ev[i][j][k]<<endl;
                if(i>0){
                    double pgo=((double)i/(i+j+k));
                    p[i-1][j][k]+=p[i][j][k]*pgo;
                    ev[i-1][j][k]+=ev[i][j][k]*pgo;
                }
                if(j>0){
                    double pgo=((double)j/(i+j+k));
                    p[i+1][j-1][k]+=p[i][j][k]*pgo;
                    ev[i+1][j-1][k]+=ev[i][j][k]*pgo;
                }
                if(k>0){
                    double pgo=((double)k/(i+j+k));
                    p[i][j+1][k-1]+=p[i][j][k]*pgo;
                    ev[i][j+1][k-1]+=ev[i][j][k]*pgo;
                }
            }
        }
    }
    cout<<ev[0][0][0]<<'\n';
    return 0;   
}

Measured memory_bytes: 450816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 998244353;
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

const int MAX_DIGIT=50;
ll dp[100][2];

int main(){
   int N;
   ll K;
   cin>>N>>K;
   vector<ll>A(N);
   rep(i,N)cin>>A[i];

   memset(dp,-1,sizeof(dp));
   dp[0][0]=0;
   for(int d=0;d<MAX_DIGIT;++d){
      ll mask=1ll<<(MAX_DIGIT-d-1);

      int num=0;
      rep(i,N)if(A[i] & mask)++num;

      ll cost0=mask*num;
      ll cost1=mask*(N-num);

      if(dp[d][1]!=-1){
         chmax(dp[d+1][1],dp[d][1]+max(cost0,cost1));//smaller->smaller
      }
      if(dp[d][0]!=-1){
         if(K &mask){
            chmax(dp[d+1][1],dp[d][0]+cost0);//same->smaller
            chmax(dp[d+1][0],dp[d][0]+cost1);//same->same
         }
         else{
            chmax(dp[d+1][0],dp[d][0]+cost0);//same->same(両方0)
         }
      }
   }
cout<<max(dp[MAX_DIGIT][0],dp[MAX_DIGIT][1])<<endl;
}

Measured memory_bytes: 4020
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> x, std::vector<ll> y) {
  vector<int> route(N);
  rep(i, N) { route.at(i) = i; }
  int cnt = 0;
  double sum = 0.0;

  do {
    int xj = x.at(route.at(0));
    int yj = y.at(route.at(0));
    FOR(i, 1, N) {
      sum +=
          sqrt(pow(x.at(route.at(i)) - xj, 2) + pow(y.at(route.at(i)) - yj, 2));
      int xj = x.at(route.at(i));
      int yj = y.at(route.at(i));
    };

    cnt++;
  } while (next_permutation(all(route)));

  cout << std::fixed << std::setprecision(15) << sum / double(cnt) << endl;
}

int main() {
  ll N;
  scanf("%lld", &N);
  std::vector<ll> x(N);
  std::vector<ll> y(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
    scanf("%lld", &y[i]);
  }
  solve(N, std::move(x), std::move(y));
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<iterator>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
    int a;
    cin>>a;
    cout<<a*a*a+a*a+a;
    return 0;
}

Measured memory_bytes: 3588
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    sm, r1 = 0, 0
    for n in range(N):
        sm += A[n]
        if n % 2 == 0 and sm < 1:
            r1 += abs(sm) + 1
            sm = 1
        elif n % 2 != 0 and sm > -1:
            r1 += abs(sm) + 1
            sm = -1

    sm, r2 = 0, 0
    for n in range(N):
        sm += A[n]
        if n % 2 == 0 and sm > -1:
            r2 += abs(sm) + 1
            sm = -1
        elif n % 2 != 0 and sm < 1:
            r2 += abs(sm) + 1
            sm = 1

    print(min(r1, r2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19732
#include <bits/stdc++.h>
using namespace std;
int ceilk(int n, int d) {
	if (n % d == 0) {
		return n/d;
	}
	return n/d + 1;
}
int main() {
	int n;cin >> n;
	int c[n+1],s[n+1],f[n+1],r[n+1];
	for (int i=1; i<n; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i=1; i<=n; i++) {
		int t = 0;
		for (int j=i; j<n; j++) {
			t = max(s[j],t);
			t = ceilk(t, f[j])*f[j];
			t = t + c[j];
		}
		r[i] = t;
	}

	for (int i=1; i<=n; i++) {
		cout << r[i] << endl;
	}
	return 0;
}

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

int main() {
	std::size_t q, h, s, d, n;
	std::cin >> q >> h >> s >> d >> n;
	//std::cout << q << h << s << d << n;
	//std::cin >> n;

	std::size_t total{};

	s = std::min(std::min(q*4, h*2), s);
	if (n % 2 == 1) {
		total += s;
	}

	total += (n / 2)*std::min(s * 2, d);
	std::cout << total << "\n";
	//std::cin >> n;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include <string.h>
#include <ctype.h>

int main(){
int x,a,b,c,d;
char n[3];
a=0;
b=0;
c=0;
d=0;

while(scanf("%d,%s",&x,n)!=EOF){
if(n[0]=='A'&&n[1]=='B')d++;
else if(n[0]=='A')a++;
else if(n[0]=='B')b++;
else if(n[0]=='O')c++;
}
printf("%d\n%d\n%d\n%d\n",a,b,d,c);

return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define mn 100005
#define inf 4444444444444444444
#define mod 1000000009
#define FLN "test" 
#define pii pair <int, int>
#define XX first
#define YY second

int n;

bool checkPow2(int k)
{
    // cerr<<k<<"\n";
    for (int i=0; i<=20; i++) if (k==(1<<i)) return 1;
    return 0;
}

signed main()
{
#ifdef lowie
    freopen(FLN".inp", "r", stdin);
    freopen(FLN".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    if (n==1) cout<<"No";
    else if (n%2==0)
    {
        if (checkPow2(n)) cout<<"No";
        else
        {
            vector <pii> V={{2, 1}, {1, 3}, {3, n+2}, {n+2, n+1}, {n+1, n+3}};
            int temp=0;
            while ((1<<(temp+1))<n) 
            {
                temp++;
                // cerr<<temp<<"\n";
            }

            int t2=(1<<temp);
            V.push_back({1, t2});
            V.push_back({3, t2+1});
            V.push_back({t2+1, t2+2});
            V.push_back({3, n+t2+2});
            V.push_back({n+t2, n+t2+2});
            V.push_back({n+t2+1, n+t2+2});

            for (int i=4; i<t2; i+=2)
            {
                V.push_back({i, i+1});
                V.push_back({i+1, 1});
                V.push_back({1, i+n});
                V.push_back({i+n, i+n+1});
            }

            for (int i=t2+3; i<n; i+=2)
            {
                V.push_back({i, i+1});
                V.push_back({i+1, i^(i+1)});
                V.push_back({i^(i+1), i+n});
                V.push_back({i+n, i+n+1});
            }

            cout<<"Yes\n";
            for (pii P: V) cout<<P.XX<<" "<<P.YY<<"\n";
        }
        
    }
    else
    {
        vector <pii> V={{1, 2}, {2, 3}, {3, n+1}, {n+1, n+2}, {n+2, n+3}};
        for (int i=4; i<n; i+=2) 
        {
            V.push_back({i, i+1});
            V.push_back({i+1, 1});
            V.push_back({1, n+i});
            V.push_back({n+i, n+i+1});
        }
        cout<<"Yes\n";

        for (pii P: V) cout<<P.XX<<" "<<P.YY<<"\n";
        

    }
    
}

// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Code by low_
// Contact me via mail: dung.totuan01@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie_review/

Measured memory_bytes: 7408
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;
#define MOD 1000000007LL

int main(){
  string S;
  cin >> S;
  int a = 0, b = 0, c = 0;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == 'a') a++;
    else if(S.at(i) == 'b') b++;
    else c++;
  }
  int x = max(a, max(b, c));
  int y = min(a, min(b, c));
  cout << ((x-y)<=1? "YES": "NO") << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    ll x;
	cin>>x;
	x-=x%5;
	ll gohyaku=x/500;
	ll go=(x-gohyaku*500)/5;
	cout<<gohyaku*1000+go*5<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  bool ok = true;
  rep(i, n) {
    if(a[i] % 2 == 0) {
      if(a[i] % 3 != 0 && a[i] % 5 != 0) ok = false;
    }
  }
  cout << (ok ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	char x[4];
	int count=0;
	for (int i=0;i<4;i++) {
		x[i]=getchar();
	}
	for (int i=0;i<4;i++) {
		if (x[i]=='+') {
			count++;
		}
		else {
			count--;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

N, M = map(int, readline().split())
PS = [line.split() for line in readlines()]
AC = [False] * (N + 1)
WA = [0] * (N + 1)

penal = 0
for p, s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA[p] += 1
    else:
        AC[p] = True
        penal += WA[p]

ac = sum(AC)
print(ac, penal)

Measured memory_bytes: 68000
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
const int P =(1<<12)+10;
int dp[P];

int main(){
int n,m,pricex,b,k,mask=0,l;
long long int i;
cin>>n>>m;
int price[m];
int mascara[m];
for(k=0;k<m;k++){
cin>>pricex>>b;
price[k]=pricex;
mask=0;
while(b>0){
  b--;
cin>>i;
i--;
mask|=(1<<i);
}  //mask é inteiro corrrespondente a baús que chave abre
mascara[k]=mask;
}//price[k] é preço e mascaras[k] é a mask correspondente da chave k
// we begin DP
dp[0]=0;
for(i=1;i<P;i++){
dp[i]=1e9;
}
for(k=0;k<m;k++){ //percorro as chaves
   mask = mascara[k];
      int w = price[k];
for(i=0;i<P;i++){
if(dp[i]>1e8){continue;}
dp[(i|mask)]=min(dp[(i|mask)],dp[i]+w);

    }
  }


if(dp[(1<<n)-1]>1e8){cout << "-1"<<endl;
}else{
  cout << dp[(1<<n)-1]<<endl;
}














}


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

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int sum = min(X, Y) * C * 2;
    if(X > Y) {
        sum += (X - Y) * A;
    } else {
        sum += (Y - X) * B;
    }
    cout << min( { sum, A * X + B * Y, max(X, Y) * C * 2 } ) << endl;
    return (0);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
struct unionfind{
  int par[100010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[100010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
int main(){
  long long int i,n,m,a[100010],b[100010];
  long long int ans[100010];
  scanf("%lld %lld\n",&n,&m);
  unionfind tree(n);
  for(i=0;i<m;i++){
    scanf("%lld %lld\n",&a[i],&b[i]);
  }
  ans[m-1]=(n-1)*n/2;
  for(i=m-1;i>0;i--){
    if(tree.same(a[i],b[i])==0){
      ans[i-1]=ans[i]-(tree.size(a[i])*tree.size(b[i]));
      tree.unite(a[i],b[i]);
    }
    else{
      ans[i-1]=ans[i];
    }
  }
  for(i=0;i<m;i++){
    printf("%lld\n",ans[i]);
  }
  return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>

using namespace std;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int n,m;
int a[50],b[50];

bool graph[50][50];
bool visited[50];

void dfs(int v){
	visited[v] = true;
	for(int v2=0;v2<n;++v2){
		if(graph[v][v2]==false) continue;
		if(visited[v2] == true) continue;
		dfs(v2);
	}
}

int main(void){
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> a[i] >> b[i];
		a[i] -=1;
		b[i] -=1;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}

	int ans = 0;
	
	for(int i=0;i<m;i++){
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

		for(int j=0;j<n;j++){
			visited[j] = false;
		}

		dfs(0);

		bool bridge = false;
		for(int j=0;j<n;j++){
			if(visited[j] == false){
				bridge = true;
			}
		}
		if(bridge){
			ans += 1;
		}

		graph[a[i]][b[i]] = graph [b[i]][a[i]] = true;

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

Measured memory_bytes: 256
def main():
    n,m,c = map(int,input().split())
    B = list(map(int, input().split()))
    count = 0

    for i in range(n):
        sum_temp = 0
        A = list(map(int,input().split()))
        for j in range(m):
            sum_temp += A[j]*B[j]
        if sum_temp+c > 0:
            count += 1
        sum_temp = 0
    print(count)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, C; scanf("%d %d", &N, &C);
  vector<int> S(N + 5), T(N + 5), CH(N + 5);
  vector<vector<int>> table(C + 5, vector<int>(1e5 * 2 + 5, 0));
  for (int i = 1; i <= N; ++i) {
    scanf("%d %d %d", &S[i], &T[i], &CH[i]);
    S[i] *= 2;
    T[i] *= 2;
    ++table[CH[i]][S[i] - 1];
    --table[CH[i]][T[i]];
  }
  for (int ch = 1; ch <= C; ++ch) {
    for (int i = 1; i <= 1e5 * 2; ++i) {
      table[ch][i] += table[ch][i - 1];
    }
  }
  int ans = 0;
  for (int t = 1; t <= 1e5 * 2; ++t) {
    int cnt = 0;
    for (int ch = 1; ch <= C; ++ch) {
      cnt += (table[ch][t] > 0);
    }
    ans = max(ans, cnt);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 29696
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    string S;
    cin >> S;
    if (S=="ABC") cout << "ARC" << endl;
    if (S=="ARC") cout << "ABC" << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc166/abc166_a && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc166/abc166_a && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc166/abc166_a && sh shellscripts/submit_cpp.sh
*/


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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const int INF = 1e9;

ll mod=1000000007;

int main() {
	int n;
	cin >> n;
	cout << (n-1)/2 << endl;
	return 0;
}

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

#define ll long long int
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//const int MOD = 1e9 + 7;
//typedef unsigned long long u64;
//const double pi = 3.141592653589793238460;

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int a, b;
		cin >> a >> b;
		cout << a*b << endl;
	}
	return 0;
}


Measured memory_bytes: 3692
h,w=map(int,input().split())
l=[input() for i in range(h)]

ans='Yes'
for i in range(1,h-1):
    for j in range(1,w-1):
        if l[i][j]=='#':
            if l[i-1][j]==l[i+1][j]==l[i][j-1]==l[i][j+1]=='.':
                ans='No'
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#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 REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> P(M), Y(M);
  vector<vector<int> > pre(N + 1);
  rep(i, M){
    cin >> P[i] >> Y[i];
    pre[P[i]].pb(Y[i]);
  }
  rep(i, N + 1)sort(all(pre[i]));

  // rep(i , N + 1){for(auto x : pre[i])cout << x << " ";cout << endl;}
  
  for(int i = 0; i < M; i++){
    int x = lower_bound(pre[P[i]].begin(), pre[P[i]].end(), Y[i]) - pre[P[i]].begin() + 1;
    //cout << P[i] << " " << Y[i] << " " << x << endl;
    printf("%06d%06d\n", P[i], x);
  }
  return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    l=m;
    for(i=1;i<n;i++)
    {
        l*=(m-1);
    }
    cout<<l<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int num, game, n, m, p1, p2, i, j;
  int team[100];
  int k,count=0,teamrank[100];

  for(i=0; i<100; i++){
    team[i]=0;
  }

  scanf("%d", &num);
  game = num*(num-1)/2;
  
  for(i=0; i<game; i++){
    scanf("%d%d%d%d", &n, &m, &p1, &p2);
    if(p1==p2){
      team[n-1]++;
      team[m-1]++;
    }else if(p1>p2){
      team[n-1]+=3;
    }else{
      team[m-1]+=3;
    }
  }

  // for(i=0;i<num;i++)printf("%d\n",team[i]);
  
  k=1;
  
  for(j=3*(num-1);j>=0;j--){
    for(i=0;i<num;i++){
      if(team[i]==j){
	teamrank[i]=k;
	count++;
      }
    }
    k+=count;
    count=0;
  }

    for(i=0;i<num;i++)printf("%d\n",teamrank[i]);

  
  
  
  return 0;
}

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

int main(void) {
	
	int x, y;
	float a, b;
	cin >> x >> y;

	a =(4*x-y) / 2;
	b = (y - 2 * x) / 2;
	

	
	if (((a + b) == x)&&(a>=0&&b>=0) ){
		cout << "Yes";
	}
	else {
		cout << "No";
	}


	return 0;
}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int cmpAsc(const void* a, const void* b){
    lld x = *(long long int*)a, y = *(long long int*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

lld func(lld a){
    return a<0 ? -1 * a : a;
}

int main(){
    int n;
    scanf("%d", &n);
    lld a[n], b[n];
    rep(i, 0, n){
        scanf("%lld", &a[i]);
        b[i] = a[i] - i - 1;
    }
    qsort(b, n, sizeof(lld), cmpAsc);
    lld sum = 0, buf;
    if(n%2){
        buf = b[n/2];
    }else{
        buf = (b[n/2] + b[n/2-1])/2;
    }
    rep(i, 0, n){
        sum += func(b[i] - buf);
    }
    printf("%lld", sum);

    return 0;
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD 1000000007
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define get(...) int __VA_ARGS__; bulk(__VA_ARGS__);
int main(){
	get(w,a,b);
	if(a>b)swap(a,b);
	cout<<max(min(b-a-w,b+w-a),0)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}


#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;


template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};
int n;
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]&&e.to==n) return vector< T >();
  }
  return dist;
}

main(){
    int a,b;cin>>a>>b;
    cout<<max({a+b,a-b,a*b});
}



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

const int maxn=2e4+10;
const int maxnd=maxn<<2;
const int maxm=maxn<<7;

int n,totnd,x[maxn],y[maxn],pos[maxn];
int tote,FIR[maxnd],TO[maxm],NEXT[maxm];
int color,col[maxnd],times,dfn[maxnd],low[maxnd],st[maxnd];
bool vis[maxnd];

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

struct Data{
	int x,id;
	Data() {}
	Data(int x,int id):x(x),id(id) {}
	bool operator < (const Data &d) const {return x<d.x;}
}D[maxn];

namespace SegTree{
	int id[maxnd];
#define lc (nd<<1)
#define rc (nd<<1|1)
#define mid ((s+t)>>1)

	void build(int nd,int s,int t)
	{
		if (s==t)
		{
			id[nd]=D[s].id^1;
			return;
		}
		id[nd]=++totnd;
		build(lc,s,mid);
		build(rc,mid+1,t);
	}

	void addedge0(int nd,int s,int t)
	{
		if (s==t) return;
		addedge(id[nd],id[lc]);
		addedge(id[nd],id[rc]);
		addedge0(lc,s,mid);
		addedge0(rc,mid+1,t);
	}

	void addedge1(int nd,int s,int t,int l,int r,int u)
	{
		if (l<=D[s].x&&D[t].x<=r)
		{
			bool flag=0;
			flag|=s<=pos[u]&&pos[u]<=t;
//			flag|=s<=pos[u^1]&&pos[u^1]<=t;
			if (!flag) addedge(u,id[nd]);
			else if (s!=t)
			{
				addedge1(lc,s,mid,l,r,u);
				addedge1(rc,mid+1,t,l,r,u);
			}
			return;
		}
		if (s==t) return;
		if (l<=D[mid].x) addedge1(lc,s,mid,l,r,u);
		if (r>=D[mid+1].x) addedge1(rc,mid+1,t,l,r,u);
	}
#undef lc
#undef rc
#undef mid
};

void init()
{
	int i;
	for (i=1;i<=n;i++)
	{
		D[i*2-1]=Data(x[i],i<<1);
		D[i*2]=Data(y[i],i<<1|1);
	}
	totnd=n<<1|1;
	sort(D+1,D+n+n+1);
	for (i=1;i<=n+n;i++)
		pos[D[i].id]=i;
	SegTree::build(1,1,n+n);
}

void tarjan(int u)
{
	vis[u]=1;
	st[++st[0]]=u;
	low[u]=dfn[u]=++times;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (!dfn[v])
		{
			tarjan(v);
			low[u]=min(low[u],low[v]);
		}
		else if (vis[v]) low[u]=min(low[u],dfn[v]);
	}
	if (low[u]==dfn[u])
	{
		color++;
		while (st[st[0]]!=u)
		{
			vis[st[st[0]]]=0;
			col[st[st[0]]]=color;
			st[0]--;
		}
		vis[u]=0;
		col[u]=color;
		st[0]--;
	}
}

bool solve(int lim)
{
	int i;
	tote=0;
	memset(FIR,0,sizeof(FIR));
	SegTree::addedge0(1,1,n+n);
	for (i=1;i<=n+n;i++)
		SegTree::addedge1(1,1,n+n,D[i].x-lim+1,D[i].x+lim-1,D[i].id);
	memset(vis,0,sizeof(vis));
	memset(col,0,sizeof(col));
	memset(dfn,0,sizeof(dfn));
	memset(low,0,sizeof(low));
	times=0; color=0; st[0]=0;
	for (i=2;i<=totnd;i++)
		if (!dfn[i]) tarjan(i);
	for (i=1;i<=n;i++)
		if (col[i<<1]==col[i<<1|1]) return 0;
	return 1;
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		if (x[i]>y[i]) swap(x[i],y[i]);
	}
	init();
	int L=1,R=1000000000/(n-1),mid;
	while (L<=R)
	{
		mid=(L+R)>>1;
		if (solve(mid))
			L=mid+1;
		else
			R=mid-1;
	}
	printf("%d\n",R);
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> divisor(ll N) {
    vector<ll> res;
    for (int i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N / i != i) res.push_back(N / i);
        }
    }
    return res;
}

void Main() {
    ll N;
    cin >> N;
    ll cnt = 0;
    for (int i = 1; i <= N; ++i) {
        if (i % 2) {
            if (divisor(i).size() == 8) {
                cnt++;
            }
        }
    }
    cout << cnt << '\n';
}

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


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

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

set<int> factorize(int n) {
  set<int> factor;
  int i = 1;
  while (i * i <= n) {
    if (n % i == 0) {
      factor.insert(i);
      factor.insert(n / i);
    }
    i++;
  }
  return factor;
}

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

  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (auto &x: A) cin >> x;

  int total = 0;
  for (int i = 0; i < N; i++) total += A[i];

  set<int> factor = factorize(total);

  int maximum = 0;
  for (int f: factor) {
    vector<int> r = A;
    for (auto &x: r) x %= f;
    sort(r.begin(), r.end());
    int remaining = K;
    int diff = 0;
    int left = 0, right = N-1;
    while (left < right) {
      if (diff <= 0) {
        diff += r[left];
        remaining -= max(0, diff);
        left++;
      }
      else if (diff > 0) {
        diff -= f - r[right];
        remaining -= max(0, -diff);
        right--;
      }
    }
    if (remaining >= 0) maximum = f;
  }

  cout << maximum << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
   int H,W,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(x+r>W||y+r>H){
    cout<<"No"<<endl;
    }
    else if(x-r<0||y-r<0){
    cout<<"No"<<endl;
    }
    else{
    cout<<"Yes"<<endl;
    }
return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#define ll long long
#define rep(i, n) for(i=0; i<n; i++)
#define rep1(i, n) for(i=1; i<=n; i++)
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, k, q;
	cin >> n >> k >> q;
	map<ll, ll> player;
	int i;
	/*ll players[n];
	rep(i, n){
		players[i] = k;
	}*/
	rep1(i, q){
		int x;
		cin >> x;
		player[x]++;
	}
	ll tmp;
	rep1(i, n){
		tmp = k - q + player[i];
		//cout << tmp << " ";
		if(tmp>0) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 9912
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1100000;
int n;
int f[N], ans;
int main()
{
    cin >> n;
    f[0] = 1; f[1] = 2; f[2] = 3;
    for (int i = 3; i <= n; ++ i)
        f[i] = (0ll + MOD + f[i - 1] + f[i - 1] - (f[i - 2] - f[i - 3])) % MOD;
    // for (int i = 1; i <= n; ++ i) cerr << f[i] << endl;
    for (int i = 0; i < n - 1; ++ i)
        ans = (ans + 1ll * (f[i] + (i? MOD - f[i - 1]: 0)) * (1ll * (i + 2 - (i == n - 2)) * n % MOD + 1ll * (n - 1 - (i + 2 - (i == n - 2))) * (n - 1) % MOD)) % MOD;
    ans = (ans + 1ll * (f[n - 1] + MOD - f[n - 2]) * n) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,string> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll n;
  ll k;
  cin>>n>>k;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  
  ll fu,zero,sei;
  fu=lower_bound(a,a+n,0)-a;
  zero=upper_bound(a,a+n,0)-lower_bound(a,a+n,0);
  sei=n-fu-zero;
  //cout << sei << ' ' << zero << ' ' << fu << endl;
  
  ll f,z,s;
  f=fu*sei;
  z=(fu+sei)*zero+zero*(zero-1)/2;
  s=sei*(sei-1)/2+fu*(fu-1)/2;
  //cout << f << ' ' << z << ' ' << s << endl;
  
  if(k<=f){
    ll l=1;
    ll r=1e18;
    while(l<r){
      ll x=(l+r)/2;
      ll p=0;
      ll q=0;
      rep(i,0,fu){
        while(q<sei && (-a[i])*a[fu+zero+q]<=x) q++;
        p+=q;
      }
      if(p<f-k+1) l=x+1;
      else r=x;
    }
    cout<<-r<<endl;
  }
  else if(k<=f+z){
    cout<<0<<endl;
  }
  
  else{
    ll l=1;
    ll r=1e18;
    while(l<r){
      ll x=(l+r)/2;
      ll p=0;
      ll q=0;
      rep(i,0,sei){
        while(q<sei-1-i && a[n-1-i]*a[fu+zero+q]<=x) q++;
        p+=min(q,sei-1-i);
      }
      q=0;
      rep(i,0,fu){
        while(q<fu-1-i && a[i]*a[fu-1-q]<=x) q++;
        p+=min(q,fu-1-i);
      }
      if(p<k-f-z) l=x+1;
      else r=x;
    }
    cout<<r<<endl;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N=1234;
int head[N];
struct EdgeNode{
	int to,next;
}Edges[N];
int col;
void add(int u,int v){
	Edges[++col].to=v;
	Edges[col].next=head[u];
	head[u]=col;
}
int bj[N];
int ans;
void dfs(int k,int n,int c){
	if(c==n){
		ans++;
		return;
	}
	for(int i=head[k];i;i=Edges[i].next){
		if(!bj[Edges[i].to]){
			bj[Edges[i].to]=1;
			dfs(Edges[i].to,n,c+1);
			bj[Edges[i].to]=0;
		}
	}
}
int main(int argc, char const *argv[]){
	int n,m;
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	memset(bj,0,sizeof(bj));
	ans=0;
	bj[1]=1;
	dfs(1,n,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
//package EducationalDPContest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            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; 
        } 
    } 

	public static void main(String[] args) {
		FastReader sc=new FastReader();
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
		}
		int dp[]=new int[n+1];
		Arrays.fill(dp, -1);
		int res=solve(a,n-1,dp);
		
		System.out.println(res);
	}
	
	
	//Recursion code with memoization;
	
	public static int solve(int a[], int i,int dp[])
	{
		if(i<=0)
		{
			//no items are left;
			return 0;
		}
		if(dp[i]!=-1)
		{
			return dp[i];
		}
		//taking next element
		int option1=Math.abs(a[i]-a[i-1])+solve(a,i-1,dp);
		int option2=Integer.MAX_VALUE;
		if(i>1)
		{
			//you can take two steps;
			option2=Math.abs(a[i]-a[i-2])+solve(a,i-2,dp);
		}
		return dp[i]=Math.min(option1,option2);
		
	}

}


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

using namespace std;

const int maxn = 59;

int arr[maxn];

int main() {
#if DEBUG
    freopen("in.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cout.precision(10);
    cout << fixed;
    int n; cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
    sort(arr, arr + n);
    double ans = (arr[0] + arr[1]) / 2.0;
    for (int i = 2; i < n; ++i)
        ans = (ans + arr[i]) / 2.0;
    cout << ans << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n; ll c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    rep(i, n) cin >> x[i] >> v[i];

    ll ans = -5e18;
    rep(_, 2) {
        vector<ll> sum(n+1);
        rep(i, n) sum[i+1] += sum[i] + v[i];
        vector<ll> a(n+1);
        rep(i, n) a[i+1] = sum[i+1] - 2 * x[i];
        rep(i, n) chmax(a[i+1], a[i]);

        chmax(ans, a[n]);
        ll now = 0;
        rrep(j, n) {
            now += v[j];
            chmax(ans, now - (c - x[j]) + a[j]);
        }
        
        rep(i, n) x[i] = c - x[i];
        reverse(all(x));
        reverse(all(v));
    }

    cout << ans << endl;
}


Measured memory_bytes: 6340