akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  vector<ll> ret(N+1, 0);

  for(ll x=1; x*x<=N; x++){
    for(ll y=1; y*y<=N; y++){
      for(ll z=1; z*z<=N; z++){
        ll res = x*x + y*y + z*z + x*y + y*z + z*x;

        if(res <= N) ret[res]++;
      }
    }
  }

  REP(i,1,N+1){
    cout << ret[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3676
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

sys.setrecursionlimit(210000)


class Node(object):

  def __init__(self, idx, color):
    self.idx = idx
    self.color = color
    self.edges = []
    self.traced = False

  def trace(self, counts, excludes):
    self.traced = True
    num = 1

    for edge in self.edges:
      if edge.traced:
        continue

      excludes[self.color].append(0)
      n = edge.trace(counts, excludes)
      p = n - excludes[self.color].pop()
      counts[self.color] += p * (p - 1) // 2 + p
      num += n

    excludes[self.color][-1] += num

    return num


def main():
  N = int(input())
  nodes = [Node(i, v - 1) for i, v in enumerate(map(int, input().split()))]
  counts = [0] * N
  excludes = [[0] for _ in range(N)]

  for _ in range(N - 1):
    a, b = map(int, input().split())
    nodes[a - 1].edges.append(nodes[b - 1])
    nodes[b - 1].edges.append(nodes[a - 1])

  num = nodes[0].trace(counts, excludes)
  pair = num * (num - 1) // 2 + num

  for i in range(len(counts)):
    p = num - excludes[i][0]
    counts[i] += p * (p - 1) // 2 + p

  for c in counts:
    print(pair - c)


if __name__ == '__main__':
  main()


Measured memory_bytes: 367876
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
char a[114], b[114];
signed main() {
	string s, t;
	cin >> s >> t;
	rep(i, s.size())a[i] = s[i];
	rep(i, t.size())b[i] = t[i];
	sort(a, a + s.size());
	sort(b, b + t.size());
	reverse(b, b + t.size());
	string news = s, newt = t;
	rep(i, s.size())news[i] = a[i];
	rep(i, t.size())newt[i] = b[i];
	if (news < newt)puts("Yes");
	else puts("No");
	getchar(); getchar(); return 0;
}

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

int main(void) {
  int K;
  cin >> K;
  int sum = 0;
  for(int i = 1; i <= K; i++) {
    for(int j = 1; j <= K; j++) {
      for(int k = 1; k <= K; k++) {
        int a = i,b = j;
	if(a > b) {
          int tmp = a;
          a = b;
          b = tmp;
        }
        int r = a % b;
        while(r != 0) {
          a = b;
          b = r;
          r = a % b;
        }
        a = k;
        if(a > b) {
          int tmp = a;
          a = b;
          b = tmp;
        }
        r = a % b;
        while(r != 0) {
          a = b;
          b = r;
          r = a % b;
        }
        sum += b;
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
void fun(int ,int );
void fun(int n,int y)
{
    int i,j;
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=n-i;j++)
        {
            if(10000*i+5000*j+1000*(n-i-j)==y)
            {
                printf("%d %d %d\n",i,j,n-i-j);
                return;
            }
        }
    }
    printf("-1 -1 -1\n");
    return;
}
int main()
{
    int n,y;
    scanf("%d%d",&n,&y);
    fun(n,y);
    return 0;
}

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

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

void solve() {
  int k, x;
  cin >> k >> x;

  for (int i = x - k + 1; i < x + k - 1; i++) {
    cout << i << ' ';
  }
  cout << x + k - 1 << endl;
}

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

  solve();
  return 0;
}


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

int main() {
    ll a, b, x;
    cin >> a >> b >> x;

    // if (a % x == 0 && b % x == 0) {
    //     cout << (b - a) / x + 1 << endl;
    // } else if (a % x == 0 || b % x == 0) {
    //     cout << (b - a) / x + 1 << endl;
    // } else {
    //     cout << (b - a) / x << endl;
    // }

    ll output = b / x;
    if (a != 0) {
        output -= (a - 1) / x;
    } else {
        output++;
    }
    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>

int main()
{
int n,m,i,g=0;
float sum=0;
  
scanf("%d%d",&n,&m);
int a[n];
for(i=0;i<n;i++){
	scanf("%d",&a[i]);
	sum+=a[i];
}
 
for(i=0;i<n;i++){
	if((float)a[i]>=sum/4/m){g++;}
	if(g>=m){break;}
}
if(g>=m){printf("Yes\n");}
else{printf("No\n");}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int N_MAX = 3000;

ll MOD;
ll fact[N_MAX+1], rfact[N_MAX+1];

ll perm(ll n, ll r){
    return (fact[n] * rfact[r]) % MOD;
}

ll comb(ll n, ll r){
    return (perm(n, r) * rfact[n-r]) % MOD;
}

void init(ll n){
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(int i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    ll p, a;
    cin >> p;
    MOD = p;
    vector<ll> b(p, 0);
    init(p);
    for(int i=0;i<p;++i) {
        cin >> a;
        if(a == 0) continue;
        b[0] += 1;
        ll i_power = 1;
        for(int j=p-1;j>=0;--j) {
            if((p-j) % 2) {
                b[j] += p - (comb(p-1, p-1-j) * i_power) % p;
            } else {
                b[j] += (comb(p-1, p-1-j) * i_power) % p;
            }
            b[j] %= p;
            i_power *= i;
            i_power %= p;
        }
    }

    for(int j=0;j<p-1;++j) {
        cout << b[j] << " ";
    }
    cout << b[p-1] << endl;
}


Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>N) {
		VI c(N);
		REP(i, N-1) {
			cin>>K;
			K--;
			c[K]++;
		}
		REP(i, N) cout<<c[i]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 4496
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define pb push_back
#define mp make_pair

#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

vector<vector<LL>> adj1,adj2;
vector<bool> visited1(100009,false),visited2(100009,false);

vector<LL> left_dp,right_dp;


LL dfs1(LL s)
{
    if(!visited1[s])
    {
        visited1[s]=true;
        LL cnt=0;
        for(auto x:adj1[s])
        {
            cnt=max(1+dfs1(x),cnt);
        }
        left_dp[s]=cnt;
    }
    return left_dp[s];
}

LL dfs2(LL s)
{
    if(!visited2[s])
    {
        visited2[s]=true;
        LL cnt=0;
        for(auto x:adj2[s])
        {
            cnt=max(1+dfs2(x),cnt);
        }
        right_dp[s]=cnt;
    }
    return right_dp[s];
}
int main()
{    
    fastinput;
    LL n,i,j,k,t,temp,m;
    cin>>n>>m;
    adj1.resize(n+1);
    adj2.resize(n+1);
    for(i=1;i<=m;i++)
    {
        cin>>j>>k;
        adj1[j].pb(k);
        adj2[k].pb(j);
    }

    left_dp.resize(n+1,0);
    right_dp.resize(n+1,0);

    for(i=1;i<=n;i++)
    {
        if(!visited1[i])
        {
            dfs1(i);
        }
    }

    for(i=1;i<=n;i++)
    {
        if(!visited2[i])
        {
            dfs2(i);
        }
    }

    LL maxima=0;
    for(i=1;i<=n;i++)
    {
        maxima=max(maxima,left_dp[i]+right_dp[i]);
    }
    cout<<maxima<<endl;
    return 0;
}

Measured memory_bytes: 17280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cfloat>
using namespace std;

double v_min(int* v, int* t, int size, double i);
double f(double v, double l, double r, double x);
int main(){
  int n; cin >> n;
  int t[n+1], v[n+1];
  t[0]=0; v[0]=0;
  for(int i=1; i<=n; i++) {
    cin >> t[i];
    t[i] += t[i-1];
  }
  for(int i=1; i<=n; i++) cin >> v[i];


  double ans=0;
  for(double i=0; i<t[n]; i+=0.5){
    ans += 0.25*(v_min(v, t, n, (double)i)+v_min(v, t, n, (double)i+0.5));
  }

  printf("%lf\n", ans);

  return 0;
}

double v_min(int*v, int* t, int size, double x){
  double ans=DBL_MAX;
  for(int i=1; i<=size; i++){
    ans = min(f((double)v[i], (double)t[i-1], (double)t[i], x), ans);
  }
  ans = min(f(0.0, 0.0, 0.0, x), ans);
  ans = min(f(0.0, (double)t[size], (double)t[size], x), ans);

  return ans;
}

double f(double v, double l, double r, double x){
  double ans;
  if(0<=x && x<=l) ans=v+(l-x);
  else if(l<=x && x<=r) ans=v;
  else ans=v+(x-r);
  return ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i, n) for (signed long long i = 0; i < (n); i++)
#define mod 1000000007
#define inf 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<ll, p> tp;
typedef pair<string, string> ps;

ll imos[123456];
int main() {
  ll n, q;
  cin >> n >> q;
  ll imos[123456];
  string s;
  cin >> s;

  rep(i, s.size() - 1) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      imos[i + 1]++;
    }
  }

  rep(i, s.size() - 1) { imos[i + 1] += imos[i]; }

  rep(i, q) {
    ll a, b;
    cin >> a >> b;
    cout << -imos[a - 1] + imos[b - 1] << endl;
  }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MOD 1e9+7

int main(){
  string str;
  cin >> str;
  ll n = str.size();
  ll result = 0;
  ll buf = 0;
  ll i;
  for(i = 0; i <= n; i++){
  switch(str[i]){
    case 'A':buf++;
      break;
    case 'T':buf++;
      break;
    case 'C':buf++;
      break;
    case 'G':buf++;
      break;
    default:
      if(buf > result)
        result = buf;
      buf = 0;
  }
  }
  cout << result << endl;

  return 0;
}

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

typedef long long ll;
const int INF = 1e8;
// const ll INF = 1LL << 60;
typedef pair<int, int> P;

struct edge { int to, cap, rev; };
vector<edge> G[20000];
int level[20000];
int iter[20000];

// G[e.to][e.rev] で逆辺の構造体にアクセスできる
void add_edge(int from, int to, int cap) {
    // int D = H * W;
    // if (from == to) {
    //     to += D;
    // } else {
    //     from += D;
    // }
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

void bfs(int s) {
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int i = 0; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}
int dfs(int v, int t, int f) {
    if (v == t) return f;
    for (int &i = iter[v]; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]) { 
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s, int t) {
    int flow = 0;
    for (;;) {
        bfs(s);
        if (level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while ((f = dfs(s, t, INF)) > 0) {
            flow += f;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    vector<P> red, blue; 
    red.resize(N);
    blue.resize(N);

    // red: 0 ~ N - 1;
    // blue: N ~ N + N  - 1
    int s = N + N - 1 + 1, t = s + 1;

    // red
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        red[i] = P(a, b);
        add_edge(s, i, 1);
    }

    // blue
    rep(i, N) {
        ll c, d;
        cin >> c >> d;
        blue[i] = P(c, d);
        add_edge(i + N, t, 1);
    }

    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    rep(i, N) {
        rep(j, N) {
            // can
            // cout << red[i].first << " " << red[i].second << endl;
            // cout << blue[j].first << " " << blue[j].second << endl;
            // cout << endl;
            if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
                // cout << i << " " << j << endl;
                add_edge(i, N + j, 1);
            }
        }
    }

    cout << max_flow(s, t) << endl;
}

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

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n%3==0)
            printf("%d\n",n/3);
        else if(n%3!=0&&n>3)
            printf("%d\n",n/3);
        else
            printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

class Eratosthenes {
  vector<bool> isPrime;

public:
  Eratosthenes(int max) : isPrime(max + 1, true) {
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i * i <= max; ++i) {
      if(isPrime[i]) {
        for(int j = 2; i * j <= max; ++j) {
          isPrime[i * j] = false;
        }
      }
    }
  }

  inline bool IsPrime(int idx) { return isPrime[idx]; }
};

using range = pair<int, int>;

int main() {
  int Q;
  cin >> Q;
  vector<range> ranges(Q);
  for(int i = 0; i < Q; ++i) {
    cin >> ranges[i].first >> ranges[i].second;
  }
  Eratosthenes etns(100000);
  vector<int> pcs(100000 + 1, 0);
  for(int i = 1; i <= 100000; ++i) {
    auto isPrimeN = etns.IsPrime(i);
    auto isPrimeNH = etns.IsPrime((i + 1) / 2);
    pcs[i] = pcs[i - 1] + ((isPrimeN && isPrimeNH) ? 1 : 0);
  }
  for(auto r : ranges) {
    cout << pcs[r.second] - pcs[r.first - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int sz[4] = {5,7, 5,7};

bool CHK( string s, string t ) {
    int ind = t.size() - 1, ind2 = s.size() - 1;
    bool ok = 1;
    while( ind >= 0 ) {
        if( t[ind] != s[ind2] ) ok = 0;
        --ind;
        --ind2;
    }
    return ok;
}

int main()
{
    int ok = 1, Ans = 1;
    string s;
    cin >> s;
    while( s.size() && ok ) {
        ok = 0;

        /// size 5
        if( s.size() < 5 ) {
            Ans = 0;
            break;
        }
        if( s[ s.size()-3 ] == 'e' ) { /// drEam
            if( !CHK( s, "dream" ) ) {
                Ans = 0;
                break;
            }
            else {
                ok = 1;
                s.resize( s.size()-5 );
                continue;
            }
        }
        if( s[ s.size()-3 ] == 'a' ) { /// erAse
            if( !CHK( s, "erase" ) ) {
                Ans = 0;
                break;
            }
            else {
                ok = 1;
                s.resize( s.size()-5 );
                continue;
            }
        }

        /// size 6
        if( s.size() < 6 ) {
            Ans = 0;
            break;
        }
        if( s[ s.size()-3 ] == 's' ) { /// eraSer
            if( !CHK( s, "eraser" ) ) {
                Ans = 0;
                break;
            }
            else {
                ok = 1;
                s.resize( s.size()-6 );
                continue;
            }
        }

        /// size 7
        if( s.size() < 7 ) {
            Ans = 0;
            break;
        }
        if( s[ s.size()-3 ] == 'm' ) { /// dreaMer
            if( !CHK( s, "dreamer" ) ) {
                Ans = 0;
                break;
            }
            else {
                ok = 1;
                s.resize( s.size()-7 );
                continue;
            }
        }
    }
    if( Ans && !s.size() ) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}



Measured memory_bytes: 512
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let a: i64 = input();
    let b: i64 = input();
    let h: Vec<i64> = (0..n).map(|_| input()).collect();

    let hmax = h.iter().max().unwrap();
    let c = a - b;

    let mut l = 0;
    let mut r = (hmax + b - 1) / b;
    while r - l > 1 {
        let m = (l + r) / 2;
        let d: i64 = h
            .iter()
            .filter_map(|h| {
                if h - b * m > 0 {
                    let h = h - b * m;
                    Some((h + c - 1) / c)
                } else {
                    None
                }
            })
            .sum();
        if m >= d {
            r = m;
        } else {
            l = m;
        }
    }

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


Measured memory_bytes: 4352
// Java program For handling Input/Output 
import java.io.*; 
import java.util.*;
import java.math.*;
//import java.awt.*;

public class Main 
{ 
    FastReader sc;
    //actual logic
    void solve() throws IOException{
        int h = sc.ni();
        int n = sc.ni();
        int a[] = new int[n];
        long sum = 0;
        for(int i = 0;i < n;i++)
        {
            a[i] = sc.ni();
            sum += a[i];
        }

        System.out.println(sum >= h ? "Yes":"No");
    }   

    //constructor
    Main()
    {
        try{  
            sc = new FastReader();
        }catch(Exception e){
            System.out.println(e);
        }
    }


    //main metohd
    public static void main(String[] args) throws IOException
    { 
       new Main().solve();
   }
    //Utility methods

   static class FastReader{
    BufferedReader br;
    StringTokenizer st;
    FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
        try{
            st = new StringTokenizer(br.readLine());
        }catch(Exception e){
            System.out.println(e);
        }
    }

    FastReader(String s){
        try{
            br = new BufferedReader(new FileReader(s));
            st = new StringTokenizer(br.readLine());
        }catch(Exception e){
            System.out.println(e);
        }
    }

    String ns(){
        if(!st.hasMoreTokens())
        {
            try{
                st = new StringTokenizer(br.readLine());
            }catch(Exception e){
                System.out.println(e);
            }    
        }
        return st.nextToken();

    }

    int ni(){
        return Integer.parseInt(ns());
    }

    long nl(){
        return Long.parseLong(ns());
    }

    double nd(){
        return Double.parseDouble(ns());
    }
}
}


Measured memory_bytes: 33432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Rummy
 */
public class Main {


	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int T = parseInt(br.readLine());

		for (int i = 0; i < T; i++) {

			StringTokenizer st1 = new StringTokenizer(br.readLine());
			StringTokenizer st2 = new StringTokenizer(br.readLine());

			int[] R = new int[10];
			int[] G = new int[10];
			int[] B = new int[10];

			for (int j = 0; j < 9; j++) {
				int n = parseInt(st1.nextToken());
				switch (st2.nextToken().charAt(0)) {
					case 'R':
						R[n]++;
						break;
					case 'G':
						G[n]++;
						break;
					case 'B':
						B[n]++;
						break;
				}
			}

			//
			int count = solve(R, 1, 0) + solve(G, 1, 0) + solve(B, 1, 0);
			System.out.println(count >= 3 ? 1 : 0);
		}
	}

	public static int solve(int[] cards, int s, int c) {

		if (s == 10) return c;

		int c1 = 0, c2 = 0, c3 = 0;

		if (cards[s] >= 3) {
			int[] _cards = Arrays.copyOf(cards, cards.length);
			_cards[s] -= 3;
			c1 = solve(_cards, s + 1, c + 1);
		}

		if (s <= 7 && cards[s] >= 1 && cards[s + 1] >= 1 && cards[s + 2] >= 1) {
			int[] _cards = Arrays.copyOf(cards, cards.length);
			_cards[s]--;
			_cards[s + 1]--;
			_cards[s + 2]--;
			if (_cards[s] >= 1) {
				c2 = solve(_cards, s, c + 1);
			} else {
				c2 = solve(_cards, s + 1, c + 1);
			}
		}

		c3 = solve(cards, s + 1, c);

		return Math.max(c1, Math.max(c2, c3));
	}
}

Measured memory_bytes: 24844
# https://atcoder.jp/contests/abc077/tasks/arc084_a
# bisectで行けるけどめぐる式の練習

# Bを固定すると、A,Cを二分探索すれば条件を満たす個数が計算できる

from bisect import bisect_left, bisect_right
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
A = read_ints()
B = read_ints()
C = read_ints()

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    ans += bisect_left(A, b) * (N - bisect_right(C, b))
    # Cに関しては真に大きい個数を知りたいことに注意
print(ans)


Measured memory_bytes: 22720
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    lli n;
    cin>>n;
    lli count=0;
    lli cnt=0;
    while(n>0) {
        // lli x=pow(2,cnt);
        count+=pow(2,cnt);
        n/=2;
        ++cnt;
    }
    cout<<count<<endl;

    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

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

/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")   */


//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 3e5 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 2e12;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

pair <int, int> aa[N];

int ans[N], d[N], n;
vi g[N];

void bfs (int v) {
    for (int i = 1; i <= n; i++) d[i] = INF;
    d[v] = 0;
    queue <int> q;
    q.push(v);
    while (!q.empty()) {
        v = q.front();
        q.pop();
        for (auto to : g[v]) {
            if (d[to] > d[v] + 1) {
                d[to] = d[v] + 1;
                q.push(to);
            }
        }
    }
}

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, y;
    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) g[i].pb(i + 1), g[i + 1].pb(i);
    g[x].pb(y), g[y].pb(x);
    for (int i = 1; i <= n; i++) {
        bfs(i);
        for (int j = i + 1; j <= n; j++) ans[d[j]]++;
    }
    for (int i = 1; i <= n - 1; i++) cout << ans[i] << "\n";
}


Measured memory_bytes: 10624
flag=1
listForA = []
while flag:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        flag=0
    else:
        index=0
        while index < h:
            if index%2==0:
                if w%2==0:
                    pattern = w//2
                    listForA.append("#."*pattern)
                else:
                    pattern = w//2
                    listForA.append("#."*pattern+"#")
            else:
                if w % 2 == 0:
                    pattern = w//2
                    listForA.append(".#"*pattern)
                else:
                    pattern = w//2
                    listForA.append(".#"*pattern+".")
            index+=1
        listForA.append("")

for a in listForA:
    print(a)


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main(){

  int a,n,ans=-100,ans2=1001;
  cin>>n;
 for(int i=1;i<=n;i++)
 {
 	 cin>>a;
 	 ans=max(ans,a);
 	 ans2=min(ans2,a);
 }
 cout<<ans-ans2;

	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

void fall(vvll& mp) {
  auto fallitr = [&](ll x) {
    ll h = mp.size();
    for (ll ii = h - 1; ii >= 1; ii--) {
      for (ll jj = 0; jj < ii; jj++) {
        if (mp[jj + 1][x] == -1 && mp[jj][x] != -1)
          swap(mp[jj+1][x], mp[jj][x]);
      }
    }
    return;
  };
  rep(j, 5) { fallitr(j); }  // j
}

int main() {
  while (true) {
    ll h;
    cin >> h;
    if (h == 0) break;

    vvll mp(h, vll(5));
    rep(i, h) rep(j, 5) cin >> mp[i][j];

    ll ans = 0;
    bool cont;
    do {
      cont = false;
      rep(i, h) {
        rep(j, 3) {
          if (mp[i][j] == -1) continue;
          bool era = mp[i][j] == mp[i][j + 1] && mp[i][j + 1] == mp[i][j + 2];
          if (era) {
            cont = true;
            ll mv = 3;
            ll mc = mp[i][j];
            mp[i][j] = mp[i][j + 1] = mp[i][j + 2] = -1;
            if (j + 3 < 5 && mc == mp[i][j + 3]) {
              mp[i][j + 3] = -1;
              mv++;
              if (j + 4 < 5 && mc == mp[i][j + 4]) {
                mp[i][j + 4] = -1;
                mv++;
              }
            }
            ans += mv * mc;
          }
        }  // j
      }    // i

      // cout << "before fall" << endl;
      // rep(i, h) {
      //   rep(j, 5) printf("%3lld ", mp[i][j]);
      //   cout << endl;
      // }
      if (cont) fall(mp);

      // cout << "after fall" << cont << endl;
      // rep(i, h) {
      //   rep(j, 5) printf("%3lld ", mp[i][j]);
      //   cout << endl;
      // }

    } while (cont);
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3068
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e5;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
    // const int mod = 2600000069;
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

const int MAXN = 1e5 + 10;

int cnt[MAXN];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        sum -= cnt[b] * b;
        sum += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << "\n";
    }
}
/*

*/

Measured memory_bytes: 4900
#!/usr/bin/env python
# coding: utf-8

# In[8]:


N,x = map(int, input().split())
a = list(map(int, input().split()))


# In[9]:


ans = 0
if a[0] > x:
    ans += a[0]-x
    a[0] = x
for i in range(N-1):
    if a[i]+a[i+1] > x:
        cnt = a[i]+a[i+1]-x
        ans += cnt
        a[i+1] -= cnt
print(ans)


# In[ ]:






Measured memory_bytes: 19764
N = gets.to_i
L = gets.chomp.split(" ").map(&:to_i).sort.reverse
count = 0

(N - 2).times do |i|
    j = i + 1
    k = N - 1
    while j < k do 
        if L[i] < L[j] + L[k]
            count += k - j
            j += 1
        else
            k -= 1
        end
    end
end

puts count

Measured memory_bytes: 1912
import itertools

n = list(map(str, raw_input().split()))
n.append('+')
nc = list(itertools.permutations(n))
ncc = []
vn = []
for _ in nc:
    if _[0] != '+' and _[3] != '+':
        ncc.append(_)
for __ in ncc:
    v = eval(('').join(__))
    vn.append(v)
print(max(vn))

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

using namespace std;

int w, h, x, y, r;

bool a;

string answer;

int main(){

	cin >> w >> h >> x >> y >> r;

	if (y + r > h || y - r < 0 || x - r < 0 || x + r > w){

		a = false;

	}
	else{

		a = true;
	}


	if (a == false){
		
		answer = "No";
	}
	else{

		answer = "Yes";
	}

	cout << answer << endl;

	return 0;
}






Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
int n;
long double a,x;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		x+=(long double)(1.00000)/a;
	}
	cout<<(long double)(1.00000)/x<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Map <Integer,Integer> mapP = new HashMap<Integer,Integer> ();
 
		Scanner sc = new Scanner(System.in);
			// 整数の入力
			int n,p,p1,p0,p2,result;
			int index;
			
			n = sc.nextInt();
			for(index=0;index<n;index++) {
				p = sc.nextInt();
				mapP.put(index, p);
			}
			sc.close();
			result=0;
			for(index=1;index<n-1;index++) {
				p0 = mapP.get(index-1);
				p1 = mapP.get(index);
				p2 = mapP.get(index+1);
				if((p0-p1)*(p2-p1)<0 ) {
					result=result+1;
				}
			}

			System.out.println(result);
			
 
			// 出力
 
	}
}

Measured memory_bytes: 21844
def a(n):
    cnt = 0
    for i in range(1, n + 1):
        if (n % i == 0):
            cnt = cnt + 1
    
    return cnt

ans = 0
n = int(input())
if(n >= 105):
    for i in range(105, n + 1, 2):
       divcnt = a(i)

       if (divcnt == 8):
           ans = ans + 1
    

print(0 if(n < 105) else ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	bool ans=true;
	cin >>n;
	Vi h(n);
	vector<bool>de(n,false);
	rep(i,n){
		cin>>h[i];
	}
	for(int i=n-1;i>0;i--){
	//	clog<<h[i-1]<<" "<<h[i]<<endl;
		if(h[i-1]  > h[i]){
			de[i-1]=true;
			h[i-1]--;
		}
		if(h[i-1] > h[i]){
			ans=false;
		}
	}
	//rep(i,n){
	//	clog<<h[i]<<" ";
//	}
	cout<<solve(ans)<<endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
def main():
    import time

    N = int(input())
    A = [int(x) for x in input().split()]

    num_lst = [0] * (N + 1)
    for a in A:
        num_lst[a] += 1

    ans = 0
    for num in num_lst:
        # ans += comb(num, 2, exact=True)
        ans += num * (num - 1) // 2

    start = time.time()
    for a in A:
        print(ans - (num_lst[a] - 1))
    end = time.time() - start
    # print(f'{end:6f}', 's')


if __name__ == '__main__':
    main()


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

int main(){
    int a, b, k; cin >> a >> b >> k;
    int cnt = 0, ans = 0;
    for (int i = 100; i >= 1; i--){
        if (a % i == 0 && b % i == 0){
            cnt++;
            ans = i;
        }
        if (cnt == k) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
/*
			███╗   ███╗ █████╗ ███████╗███╗   ███╗ ██████╗ ██╗   ██╗██████╗ ███████╗ █████╗ ███╗   ███╗██████╗ ██╗   ██╗
			████╗ ████║██╔══██╗╚════██║████╗ ████║██╔═══██╗██║   ██║██╔══██╗╚════██║██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝
			██╔████╔██║███████║    ██╔╝██╔████╔██║██║   ██║██║   ██║██║  ██║    ██╔╝███████║██╔████╔██║██║  ██║ ╚████╔╝
			██║╚██╔╝██║██╔══██║   ██╔╝ ██║╚██╔╝██║██║   ██║██║   ██║██║  ██║   ██╔╝ ██╔══██║██║╚██╔╝██║██║  ██║  ╚██╔╝
			██║ ╚═╝ ██║██║  ██║   ██║  ██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██████╔╝██╗██║  ██║  ██║██║ ╚═╝ ██║██████╔╝   ██║
			╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝  ╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝╚═╝  ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝    ╚═╝

			“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define pb push_back
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define un_map unordered_map
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define scll(x) scanf("%I64d", &x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define pr(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const ll mod = 1000000007;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const int N = 1e5 + 1;
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
int n, k;
int dp[N];
//int mem[N];
vector<int>v;
/*int solve(int i) {
	int& ret = mem[i];
	if (~ret)return ret;
	ret = Mx;
	for (int j = 1; j <= k && i + j < n; j++)
		ret = min(ret, solve(i + j) + abs(v[i] - v[i + j]));

	ret = ret == Mx ? 0 : ret;
	return ret;
}*/
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	//clr(mem, -1);
	cin >> n >> k;
	v = vector<int>(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	//cout << solve(0) << endl;


	for (int i = 0; i < n; i++) {
		int& ret = dp[i];
		ret = Mx;
		for (int j = 1; j <= k && i - j >= 0; j++)
			ret = min(ret, dp[i - j] + abs(v[i] - v[i - j]));

		ret = ret == Mx ? 0 : ret;
	}

	cout << dp[n - 1] << endl;
	return Accepted;
}

Measured memory_bytes: 4004
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
#include <math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7;

using namespace std;

lol n,x,a[25];
lol power;
void flutes(int i,lol sum){
    if(i==n){
	power=min(abs(x,sum),power);
	return;
    }
    if(sum>=x){
	power=min(abs(x,sum),power);
	return;
    }
    
    for(int j=i+1;j<=n;j++){
	flutes(j,sum+a[j]);
	power=min(abs(x,sum),power);
    }
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a[5],sum=0;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a +3,greater<int>());
    sum+=a[0]-a[1];
    a[2]+=a[0]-a[1];
    a[1]=a[0];

    sum+=(a[0]-a[2])/2;
    a[2]+=(a[0]-a[2])/2*2;
    if(a[0]-a[2]==0){
	cout<<sum<<'\n';
    }
    else{
	cout<<sum+2<<'\n';
    }
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) puts("error");
	else cout << a + b << endl;
	return 0;
}


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

int main(void){

  int N,A,B,i,j,train,min=0;
  scanf("%d",&N);
  scanf("%d",&A);
  scanf("%d",&B);

  train = A*N;

  if(train < B){
    min = train;
  }

  else{
    min = B;
  }

  printf("%d",min);

  return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int H, N; cin >> H >> N;
    vector<Pi_i> AB(N);
    VLL dp(10001, INF);
    dp[0] = 0;
    int maxa = 0;
    REP(i, N){
        cin >> AB[i].first >> AB[i].second;
        chmax(maxa, AB[i].first);
        dp[AB[i].first] = AB[i].second;
    }
    SORT(AB);
    RREP(i, maxa-1) chmin(dp[i], dp[i+1]);
    REPS(i, H){
        REP(j, N){
            if(i < AB[j].first) chmin(dp[i], AB[j].second);
            else chmin(dp[i], dp[i - AB[j].first] + AB[j].second);
        }
    }
    cout << dp[H] << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int count = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            
            if (a == b) {
                count++;
            } else {
                count = 0;
            }
            
            ans = Math.max(count, ans);
        }
        
        if (ans >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 36056