akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	string s; cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '?')s[i] = 'D';
    }
    cout << s << endl;
    system("pause");
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

using i64 = long long;

struct Graph {
  struct edge {
    int to;
    i64 cap;
    i64 rev;
  };

  int n;
  vector<vector<edge>> edges;

  Graph(int N) {
    n = N;
    edges.resize(n, vector<edge>());
  }

  int size() const { return n; }

  vector<edge> &operator[](int v) { return edges[v]; }
};

struct Dinic {
  int N;
  vector<int> level;
  vector<int> itr;
  Graph G;

  Dinic(int n) : G(n) { N = n; }

  void add_edge(int from, int to, i64 cap, i64 rev_cap) {
    G[from].push_back({to, cap, (int)G[to].size()});
    G[to].push_back({from, rev_cap, (int)G[from].size() - 1});
  }

  bool g_level(int s, int t) {
    level.assign(N, -1);
    queue<int> que;
    que.push(s);
    level[s] = 0;
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      for (auto &e : G[v]) {
        if (e.cap > 0 && level[e.to] == -1) {
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
    return level[t] >= 0;
  }

  i64 dfs(int v, int t, i64 f) {
    if (v == t) return f;

    for (int &i = itr[v]; i < G[v].size(); i++) {
      auto &e = G[v][i];
      if (e.cap > 0 && level[e.to] > level[v]) {
        i64 mi_f = dfs(e.to, t, min(f, e.cap));
        if (mi_f > 0) {
          e.cap -= mi_f;
          G[e.to][e.rev].cap += mi_f;
          return mi_f;
        }
      }
    }
    return 0;
  }

  i64 max_flow(int s, int t) {
    i64 result = 0;
    i64 flow;
    while (g_level(s, t)) {
      itr.assign(N, 0);
      while ((flow = dfs(s, t, 1e9)) > 0) result += flow;
    }
    return result;
  }
};

/*

checked
    http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2723921#1
*/

int N;

using P = pair<int,int>;

vector<P> a;
vector<P> b;

int main(){
    cin >> N;
    a.resize(N);
    b.resize(N);
    rep(i,0,N - 1) cin >> a[i].first >> a[i].second;
    rep(i,0,N - 1) cin >> b[i].first >> b[i].second;
    Dinic di(N * 2 + 2);
    int s = 2 * N;
    int t = 2 * N + 1;
    rep(i,0,N - 1) di.add_edge(s,i,1,0);
    rep(i,0,N - 1) di.add_edge(i + N,t,1,0);
    rep(i,0,N - 1){
        rep(j,0,N - 1){
            if(a[i].first < b[j].first && a[i].second < b[j].second) di.add_edge(i,j + N,1,0);
        }
    }

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

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, q;
  cin >> n >> m >> q;
  VI l(m), r(m), p(q), s(q);
  rep(i, m) cin >> l[i] >> r[i];
  rep(i, q) cin >> p[i] >> s[i];
  VVI dp(n + 1, VI(n + 1, 0));
  rep(i, m) {
    dp[l[i]][r[i]]++;
  }
  rep(i, n) rep(j, n) {
    dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + dp[i + 1][j + 1];
  }
  rep(i, q) {
    out(dp[s[i]][s[i]] - dp[p[i]-1][s[i]] - dp[s[i]][p[i]-1] + dp[p[i]-1][p[i]-1]);
  }

  return 0;
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if((y+r <= H)&&(y-r >= 0)&&(x+r <= W)&&(x-r>=0)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(void) {
    int a, b, c, min, mid, max;
    cin >> a >> b >> c;
    min = 100000;
    if(a<min) min = a;
    if(b<min) min = b;
    if(c<min) min = c;
    max = 0;
    if(a>max) max = a;
    if(b>max) max = b;
    if(c>max) max = c;
    mid = min;
    if(min<a&&a<max) mid = a;
    if(min<b&&b<max) mid = b;
    if(min<c&&c<max) mid = c;
    cout << min << " " << mid << " " << max << endl;
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector <int> arr(n);
    for(int i = 0; i < n; i++) cin >> arr[i];
    sort(arr.begin(), arr.end());

    cout << abs(arr[n - 1] - arr[0]) << endl;
        
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc158/tasks/abc158_e
// AtCoder Beginner Contest 158
// E - Divisible Substring

/*
Problem.
長さNの数字文字列Sと素数Pが与えられ、
全ての空でない連続する連続する部分文字列について、
Pで割り切れるものの総数を答えよ。

Point.
はじめにU[i] := S[i:N]を求める. O(N)
これで(U[i] - U[j+1]) / 10^(i+j+1) でS[i:j]が求められる。
また、Pが10と互いに素、つまり2,5以外の時、
S[i:j]%P == 0 => (U[i]-U[j+1])%P == 0
と言い換えらる。
つまり、あらかじめU[i]をmodPで持っておけば、iの後ろでU[i]==U[j]となるjの数を
mapで管理して、S[i:i+1~N]について一括で求められる。
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n, p; cin >> n >> p;
  string s; cin >> s;
  ll ans = 0;

  if(p == 2 || p == 5){
    for(int i = 0; i < n; i++){
      if((s[i]-'0')%p == 0){
        ans += i+1;
      }
    }
    cout << ans << endl;
    return 0;
  }

  map<int, int> mp;
  vector<int> U(n+1, 0);
  mp[0] = 1;
  int ten = 1;
  for(int i = n-1; i >= 0; i--){
    U[i] = (U[i+1] + ((s[i]-'0')*ten)%p) % p;
    mp[U[i]]++;
    ten *= 10; ten %= p;
  }
  for(int i = 0; i < n; i++){
    mp[U[i]]--;
    ans += mp[U[i]];
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 1684
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		if(X<A) {
			System.out.println(0);
		}else {
			System.out.println(10);
		}
	}
}

Measured memory_bytes: 25172
N = int(input())
SP = [None] * N
for i in range(N):
    SP[i] = input().split() + [i + 1]
    SP[i][1] = int(SP[i][1]) * (-1)

SP.sort(key = lambda x : (x[0], x[1]))
for i in range(N):
    print(SP[i][2])

Measured memory_bytes: 9064
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val Array(n, w) = readLine.trim.split(' ').map(_.toInt)
  val price = readLine.trim.split(' ').map(_.toLong)
  val nodes = Array.fill(n){Nil: List[Route]}
  for (_ ← 1 until n){
    val Array(u, v, c) = readLine.trim.split(' ').map(_.toInt)
    nodes(u - 1) ::= Route(v - 1, c)
    nodes(v - 1) ::= Route(u - 1, c)
  }
  val depth = Array.fill(n){Int.MaxValue}; depth(0) = 0
  val stack = mutable.Stack[Int](0)
  val parents = Array.fill(n){0}
  while(stack.nonEmpty){
    val current = stack.pop()
    for (Route(next, _) ← nodes(current) if depth(next) > depth(current)) {
      depth(next) = depth(current) + 1
      parents(next) = current
      stack.push(next)
    }
  }
  val childCount = Array.fill(n){1}
  def count(current: Int): Int = {
    for (Route(next, _) ← nodes(current) if depth(current) < depth(next)) childCount(current) += count(next)
    childCount(current)
  }
  count(0)
  for (i ← nodes.indices) nodes(i) = nodes(i).filter(r ⇒ depth(r.to) > depth(i)).sortBy(r ⇒ childCount(r.to))(Ordering.Int.reverse)
  val array = Array.fill(n){(Array.fill(w + 1){0L}, Array.fill(w + 1){0L}, Array.fill(w + 1){0L})}
  println(search(0, Array.fill(w + 1){0L})._3.max)

  def search(current: Int, state: Array[Long]): (Array[Long], Array[Long], Array[Long]) = {
    val (x, y, z) = array(current)
    nodes(current) match {
      case Route(first, firstCost)::t ⇒
        val (ix, iy, iz) = search(first, state)
        for (i ← (firstCost until ix.length).reverse) {
          x(i) = math.max(state(i), ix(i - firstCost)) + price(current)
          y(i) = iy(i - firstCost) + price(current)
          z(i) = math.max(iz(i), y(i))
        }
        for (i ← 0 until math.min(state.length, firstCost)) {
          x(i) = state(i) + price(current)
          y(i) = price(current)
          z(i) = math.max(iz(i), y(i))
        }
        for (Route (next, cost) ← t) {
          val (ax, _, az) = search(next, x)
          for (i ← z.indices) {
            z(i) = math.max (z(i), az(i))
          }
          for (i ← cost until x.length) {
            x(i) = math.max(x(i), ax(i - cost))
          }
          val (bx, _, _) = search(next, y)
          for (i ← cost until x.length) {
            y(i) = math.max (y(i), bx(i - cost))
          }
        }
        for (i ← z.indices) {
          z(i) = math.max (z(i), y(i))
        }
        (x, y, z)
      case Nil ⇒
        for (i ← x.indices) {
          x(i) = state(i) + price(current)
          y(i) = price(current)
        }
        (x, y, y)
    }
  }
  case class Route(to: Int, cost: Int)
  case class Road(a: Int, b: Int, cost: Long)
  implicit class Scope[T](val value: T) extends AnyVal {
    def let[A](@inline func: T ⇒ A): A = func(value)
    def also(@inline func: T ⇒ Unit): T = {func(value);value}
  }
}


Measured memory_bytes: 283464
import sys

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N, A, B = LI()
s = S()
kokunai = 0
kaigai = 0
for i in range(N):
    if s[i] == "a":
        if kokunai + kaigai < A + B:
            kokunai += 1
            print("Yes")
        else:
            print("No")
    elif s[i] == "b":
        if kokunai + kaigai < A + B and kaigai < B:
            kaigai += 1
            print("Yes")
        else:
            print("No")
    elif s[i] == "c":
        print("No")


Measured memory_bytes: 52952
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define pb push_back
using namespace std;
const int N=2100;
priority_queue<int> Q;
vector<int> E[N],W[N];
int n,a[N],d[N],vis[N];
void dfs(int x)
{
    vis[x]=1;
    for(auto R:E[x]) if(!vis[R]) W[x].pb(R);
    for(auto R:E[x]) if(!vis[R]) dfs(R);
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            if(__gcd(a[i],a[j])>1) E[i].pb(j),E[j].pb(i);
    for(int i=1;i<=n;i++) sort(E[i].begin(),E[i].end());
    for(int i=1;i<=n;i++) if(!vis[i]) dfs(i);
    for(int i=1;i<=n;i++) for(auto R:W[i]) d[R]++;
    for(int i=1;i<=n;i++) if(!d[i]) Q.push(i);
    while(!Q.empty())
    {
        int x=Q.top();Q.pop();
        printf("%d ",a[x]);
        for(auto R:W[x])
            if(--d[R]==0) Q.push(R);
    }
}


Measured memory_bytes: 23168
N = int(input())
Dict = {}

for i in range(1,N+1):
    S,P = input().split(" ")
    if S in Dict:
        Dict[S].append((int(P),i))
    else:
        Dict[S] = [(int(P),i)]
        
for j in sorted(Dict):
    l = sorted(Dict[j],reverse=True)
    for k in range(len(l)):
        print(l[k][1])

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <algorithm>

#define INF 2000000001

using namespace std;

int main(){
  int n; cin >> n;
  int a[n];
  long long sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum=sum+a[i];
  }
  long long x=0,y=sum;
  long long ans=INF;
  for(int i=0;i<n-1;i++){
    x=x+a[i];
    y=y-a[i];
    ans=min(ans,abs(x-y));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
using namespace std;

int main() {
  char str[4];
  scanf("%s", str);
  int cnt = 0;
  for(int i = 0; i < 4; i++) {
    if(str[i] == '2') cnt++;
  }
  printf("%d\n", cnt);
}


Measured memory_bytes: 256
A = []
for _ in range(3):
    A += list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]


for bi in b:
    if bi in A:
        ind = A.index(bi)
        if bi:
            A[ind] = 0

zeros = [0, 0, 0]
if (
    A[::4] == zeros
    or A[2:7:2] == zeros
    or A[0:3] == zeros
    or A[3:6] == zeros
    or A[6:9] == zeros
    or A[0::3] == zeros
    or A[1::3] == zeros
    or A[2::3] == zeros
):
    print("Yes")
else:
    print("No")


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n;

    cin >> n;

    int a[10][10];

    memset(a, 0, sizeof(int) * 10 * 10);

    for(int i = 1; i <= n; i++)
    {
        int x = i;
        while(x >= 10)x /= 10;
        a[i % 10][x]++;
    }

    int resenje = 0;

    for(int i = 1; i < 10; i++)
    {
        for(int j = 1; j < 10; j++)
        {
            resenje += a[i][j] * a[j][i];
        }
    }

    cout << resenje << '\n';

    return 0;
}


Measured memory_bytes: 256
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

const int N = 5e5 + 42;
const int MAGIC = 700;
int l[N], r[N], c[N], a[N], b[N], ids[N];
int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n, q; cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
  }
  for (int i = 1; i <= q; ++i) {
    cin >> l[i] >> r[i];
    ++r[i];
  }
  iota(ids, ids + q, 1);
  sort(ids, ids + q, [&] (int i, int j) {
    int bi = l[i] / MAGIC, bj = l[j] / MAGIC;
    if (bi != bj) return bi < bj;
    return bi & 1 ? r[i] > r[j] : r[i] < r[j]; 
  });
  int L = 1, R = 1, ans = 0;
  for (int ii = 0; ii < q; ++ii) {
    int i = ids[ii];
    while (R < r[i]) {
      ans += !a[c[R]];
      ++a[c[R]];
      ++R;
    }
    while (L > l[i]) {
      --L;
      ans += !a[c[L]];
      ++a[c[L]];
    }
    while (R > r[i]) {
      --R;
      --a[c[R]];
      ans -= !a[c[R]];
    }
    while (L < l[i]) {
      --a[c[L]];
      ans -= !a[c[L]];
      ++L;
    }
    b[i] = ans;
  }
  for (int i = 1; i <= q; ++i) cout << b[i] << '\n';
}


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

using namespace std ;
void Main(){
cin.sync_with_stdio(0);
cin.tie(0);
}

int main(){
Main();

int n ; cin >> n ;
int m ; cin >> m ;
int a[m] ;
long long sum = 0 ;
for(int i=0 ; i<m ; i++){
    cin >> a[i] ;
    sum+=a[i] ;
}
if(n-sum >= 0)
    cout << n-sum ;
else
    cout << "-1" ;


return 0 ;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int inn[1000100],a[1000100],num[1000100],wei[1000100],mp[1000100],f[1000100];
bool vis[1000100];
int work(int l,int n)
{
	f[0]=1;f[1]=1+(l&1)-(l==1);
	for (int i=2;i<=n;i++)
		f[i]=((1+(l&1)-(l==1))*f[i-1]+(long long)l*(i-1)%mo*f[i-2])%mo;
	return f[n];
}	
int main()
{
	//freopen("in.txt","r",stdin);
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);inn[a[i]]++;
		if (inn[a[i]]>2) {printf("0\n");return 0;}
	}
	for (int i=1;i<=n;i++) if (!inn[i])
	{
		int js=0,now=i;
		while (inn[now]!=2) {vis[now]=true;now=a[now];js++;}
		num[now]=js;//cerr<<now<<' '<<js<<endl;
	}
	int ans=1;
	for (int i=1;i<=n;i++) if (!vis[i])
	{
		int len=0,now=i;
		while (!vis[now]) {wei[++len]=now;vis[now]=true;now=a[now];}//cerr<<len<<endl;
		if (i!=now) {printf("0\n");return 0;}
		int lst=1;for (int j=1;j<=len;j++) if (num[wei[j]]) lst=j-len;cerr<<lst<<endl;
		if (lst==1) {mp[len]++;continue;}
		for (int j=1;j<=len;j++) if (num[wei[j]])
		{
			if (j-lst>num[wei[j]]) ans=ans*2%mo;
			if (j-lst<num[wei[j]]) {printf("0\n");return 0;}
			lst=j;
		}
	}
	for (int i=1;i<=n;i++) if (mp[i]) ans=(long long)ans*work(i,mp[i])%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 10624
<?php
$n = fgets(STDIN);
$a = explode(" ",fgets(STDIN));
$count = count($a);
$a[$count-1] = trim($a[$count-1]);
//$a = fgets(STDIN);
rsort($a);
$h = 0;
$x = 0;
$y = 0;
for($i = 0;$i < $count;$i++) {
    if($h == $a[$i]){
    	if($x == 0){
    		$x = $a[$i];
    		$h = 0;
    	}else{
    		$y = $a[$i];
    		break;
    	}
    }else{
    	$h = $a[$i];
    }
}
echo $x*$y;

Measured memory_bytes: 22388
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>

using namespace std;

int num(map<int, int>& factor, int n)
{
    int result = 0;
    for (map<int, int>::iterator itr = factor.begin(); itr != factor.end(); itr++) {
        if (itr->second >= n) { result++;}
    }

    return result;
}

int main()
{
    long long n;
    cin >> n;

    map<int, int> factor;
    for (int j = 2; j <= n; j++) {
        int current = j;
        for (int i = 2; i <= j; i++) {
            while (current % i == 0) {
                factor[i]++;
                current /= i;
            }
        }
    }

    int result = 0;
    result += num(factor, 74);
    result += num(factor, 24) * (num(factor, 2) - 1);
    result += num(factor, 14) * (num(factor, 4) - 1);
    result += (num(factor, 4) * (num(factor, 4) - 1) * (num(factor, 2) - 2)) / 2;

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    AB = [0] * N
    for i in range(N):
        AB[i] = map(int, input().split())

    n_press = 0
    for A, B in reversed(AB):
        _, r, = divmod(A + n_press, B)
        n_press += B - r if r > 0 else 0

    ans = n_press
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 50420
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include <iomanip>
using namespace std;
 
typedef long long ll;


int main(){
	int n;
	cin >> n;
	vector<double> v(n);
	
	for(int i=0;i<n;++i){
		cin >> v[i];
	}
	
	sort(v.begin(),v.end());
	
	double res = v[0];
	for(int i=1;i<n;++i){
		res = (v[i] + res)/2;
//		res +=  v[i]/((n-1-i)*2);
//		cout << v[i]/((n-1-i)*2) <<" " <<(n-1-i) << " " << ((n-1-i)*2) <<endl;
	}
//	res += v[n-1]/2;
	
	cout <<std::setprecision(100)<< res << endl;
	
	
	return 0;
}



Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1):
        k = n - i - j
        if 0<=k<=2000 and 10000*i + 5000*j + 1000*k == y :
            print(i, j, k)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
from sys import stdin
from collections import deque

def print_2d_array(A):
    for i in range(1, len(A)):
        print(*A[i][1:], sep=" ")

def read_and_print_graph(n):
    A = [ [0]*(n+1) for _ in range(n+1) ]
    for _ in range(n):
        line = deque(stdin.readline().strip().split())
        i = line.popleft()
        line.popleft()
        for k in line:
            A[int(i)][int(k)] = 1
    print_2d_array(A)

n = int(input())
read_and_print_graph(n)


Measured memory_bytes: 6772
#include<bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi; 
typedef pair<int,int> pi;
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
 
vector<ll> dp;
 
ll v0 = 100010;
 
int main(){
	
	ll n, h, v,w;
	
	cin >> n >> w; 
	
	dp.assign(v0, 10000000000);
	
	dp[0] = 0;
	
	for(ll i = 0; i < n; i++){
		
		cin >> h >> v;
		
		for(ll i2 =  v0 - v ; i2 >= 0; i2--){
			dp[i2 + v] = min( dp[i2 + v], dp[i2] + h );
		}
		
	}
	
	ll maxi = 0;
	
	for(ll i = 0; i < v0; i++){
				
		if(dp[i] <= w){
			maxi = i;
		}
		
	}
			
	cout << maxi << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int A, B, C;
  get(A, B, C);
  print((A <= C && C <= B) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int loop = 0;
    int time = 0;
    bool pass = false;
    for(;;) {
        time += a;
        //cout << "time: " << time << endl;
        if (time >= c && !pass) {
            cout << 60 * loop + c << endl;
            break;
        } 
        time += b;
        if (time == 60) {
            cout << -1 << endl;
            break;
        }
        if (time > 60) {
            pass = false;
            loop++;
            time %= 60;
        }
        if (time >= c) {
            pass = true;
        }
    }
}

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

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

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,m,n;
        vi v;
        cin>>n>>k;
        rs(v,n+1);
        for(i=1;i<=n;i++)
            cin>>v[i];
        ll dp[100005];
        clr(dp,peak);
        dp[1]=0;
        for(i=2;i<=n;i++)
        {
            ll ans=peak;
            for(j=1;j<=k;j++)
            {
                if(i-j<=0)
                    break;
                ans=min(ans,dp[i-j]+abs(v[i-j]-v[i]));
            }
            dp[i]=ans;
        }
        cout<<dp[n];
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll c[30], s[370][30];
ll score[30], last_day[30];
int t[370];

ll calc(int day, int contest) {
    score[contest] += s[day][contest];
    last_day[contest] = day;

    rep(i, 1, 27) score[i] -= c[i]*(day-last_day[i]);
    
    ll sum = 0;
    rep(i, 1, 27) sum += score[i];
    return sum;
}

int main(void) {
    int d;
    cin >> d;
    rep(i, 1, 27) cin >> c[i];
    rep(i, 1, d+1) rep(j, 1, 27) cin >> s[i][j];

    rep(i, 0, d) cin >> t[i];

    rep(i, 0, d) {
        printf("%lld\n", calc(i+1, t[i]));
    }

    return 0;
}



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

char c[55][55]; int H, W, cnt;

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) cin >> c[i][j];
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') cnt++;
		}
	}
	if (cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

        

Measured memory_bytes: 256
n, m = map(int, input().split())
abList = [list(map(int, input().split())) for _ in range(n)]
abList.sort()
abSum = 0
abNum = m
for ab in abList:
    a, b = ab[0], ab[1]
    if b < abNum:
        abSum += b * a
        abNum -= b
    else:
        abSum += abNum * a
        break
print(abSum)


Measured memory_bytes: 27880
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;

  S[K-1] = tolower(S[K-1]);
  cout << S << endl;
  return 0;
}

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

const int MAXN = 103;
int arr[MAXN], n;

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	int res = 0;
	for(int i = 2; i <= n; i++) {
		if(arr[i] == arr[i - 1]) {
			arr[i] = -1, res++;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    vector<int> f(n,0);
    REP(i,n) {
        REP(j,10) {
            int b;
            cin>>b;
            f[i]|=b<<j;
        }
    }
    vector<vector<int>> p(n,vector<int>(11));
    cin>>p;

    int ans=-INF;
    REP(i,1<<10) {
        if(!__builtin_popcount(i)) continue;
        int tmp=0;
        REP(j,n) {
            int cnt=__builtin_popcount(f[j]&i);
            tmp+=p[j][cnt];
        }
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int a, b, c;
	int cnt = 0;
	cin >> a >> b >> c;
	for(int i = a; i <= b; i++){
		if(c%i==0){
			cnt++;
		}
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 3116
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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


int main(){
	ios::sync_with_stdio(false);

	int n;
	int count;
	int nmax = 1000000;
	vector<bool> flag(nmax+1, true);

	flag[0] = !flag[0];
	flag[1] = !flag[1];

	for (int i = 2; i <= sqrt(nmax) + 1; i++){
		if (flag[i]){
			for (int j = i * 2; j <= nmax; j += i){
				flag[j] = false;
			}
		}
	}
	
	while (cin >> n){
		count = 0;
		for (int i = 0; i <= n; i++){
			if (flag[i])
				count++;
		}

	printf("%d\n", count);
	}

}

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

int main() {
  string s;
  int k;
  cin>>s>>k;
  vector<vector<int>>dp0(s.size(),vector<int>(s.size()+1));//i桁までにj個０以外がある数,nより小
  vector<vector<int>>dp1(s.size(),vector<int>(s.size()+1));//i桁までにj個０以外がある数、不明
  dp0[0][1]=s.at(0)-'0'-1;
  
  dp0[0][0]=1;

  dp1[0][1]=1;
  rep2(i,1,s.size()){
    rep(j,s.size()+1){
      if(j!=0){
        dp0[i][j]=9*(dp0[i-1][j-1])+dp0[i-1][j]+(max(0,s.at(i)-'0'-1))*dp1[i-1][j-1]+(min(1,s.at(i)-'0'))*dp1[i-1][j];
        if(s.at(i)!='0'){
          dp1[i][j]=dp1[i-1][j-1];
        }
        else{
          dp1[i][j]=dp1[i-1][j];
        }
      }
      else{
        dp0[i][j]=dp0[i-1][j];
        if(s.at(i)!='0'){
          dp1[i][j]=dp1[i-1][j];
        }
      }
    }
  }
  
  cout<<dp0[s.size()-1][k]+dp1[s.size()-1][k]<<endl;
  
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = 0; i < k; i++) {
	if (i % 2 == 0) {
	  b += a / 2;
	  a /= 2;
	}
	else {
	  a += b / 2;
	  b /= 2;
	}
  }
  cout << a << " " << b << endl;
  return 0;
}



Measured memory_bytes: 256
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<string>
#include<map>
#include<list>
 
using namespace std;
 
using ll = long long int ;
 
 
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
 
    ll n;
    string s;
 
    cin >> n;
    cin >> s;

    if(n%2==1){
        cout << "No" << endl;
        return 0;
    }

    for(ll i=0; i<n/2; i++){
        ll j = i+n/2;
        if(s[i] != s[j]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
 
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include<algorithm>

using namespace std;

const static int N = 36;
typedef struct{
    int value;
    char suit;
}card;

void print(card A[], int n) {
    for(int i = 0; i < n; i++) {
        if(i) printf(" ");
        printf("%c%d", A[i].suit, A[i].value);
    }

}

void swapCard(card A[], int index1, int index2) {
    card temp = A[index1];
    A[index1] = A[index2];
    A[index2] = temp;
}

void bubbleSort(card A[], int n) {
    for(int i = 0; i < n; i++) {
        for(int j = n-1; j >= i+1; j--) {
            if(A[j].value < A[j-1].value)
                swapCard(A, j, j-1);
        }
    }
}

void selectionSort(card A[], int n) {
    int i, j;
    for(i = 0; i < n; i++) {
        int mini = i;
        for(j = i; j < n; j++) {
            if(A[j].value < A[mini].value)
                mini = j;
        }
        if(A[i].value != A[mini].value)
            swapCard(A, i, mini);
    }
}

bool isStable(card b[], card s[], int n) {
    for(int i = 0; i < n; i++) {
        if(b[i].suit != s[i].suit)
            return false;
    }
    return true;
}

int main()
{
    int n;
    card A[N];
    card b[N];
    card s[N];
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf(" %c%d", &A[i].suit, &A[i].value);
        b[i] = A[i];
        s[i] = A[i];
    }
    bubbleSort(b, n);
    print(b, n);
    printf("\nStable\n");
    selectionSort(s, n);
    print(s, n);
    if(isStable(b, s, n))
        printf("\nStable\n");
    else
        printf("\nNot stable\n");
    return 0;
}

Measured memory_bytes: 2668
s = list(input())

count = 0
for i in range(len(s)):
    if i == 0:
        continue
    if int(s[i]) == int(s[i-1]):
        count += 1
        if int(s[i]) == 0:
            s[i] = '1'
        else:
            s[i] = '0'

print(count)


Measured memory_bytes: 3956
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,m,x = I()
book = [l() for i in range(n)]
money = []

for i in range(2**n):
    ccc = 0
    bag = [0]*(m+1)
    for j in range(n):
        for k in range(m+1):
            if ((i>>j)&1):
                bag[k] += book[j][k]
    for p in range(1,m+1):
        if bag[p] >= x:
            ccc += 1
    if ccc == m:
        money.append(bag[0])

if len(money) == 0:
    print(-1)
else:
    print(min(money))
    


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

#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

bool kaibun(std::string s) {
  for(int i = 0;i < s.size() / 2;i++) {
    if(s[i] != s[s.size() - 1 - i]) return false;
  }
  return true;
}

int main(void) {
  int i, j, k, l;
  std::string S;
  std::cin >> S;
  // std::cout << S.substr(0, (S.size() - 1) / 2) << std::endl;
  // std::cout << S.substr((S.size() + 3) / 2 - 1, S.size() - 1 - ((S.size() + 3) / 2 - 1)) << std::endl;
  if(kaibun(S) && kaibun(S.substr(0, (S.size() - 1) / 2)) && kaibun(S.substr((S.size() + 3) / 2 - 1, S.size() - ((S.size() + 3) / 2 - 1)))) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<int, pair<int, int>> PP;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const int mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int n, m;
int graph[55][55];
bool used[55];

void dfs(int u){
    if(used[u]) return;
    used[u] = true;
    for(int v = 0; v < n; ++v){
        if(v == u || used[v])   continue;
        if(graph[u][v] == 0)    continue;
        dfs(v);
    }
}

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

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

    int res = 0;
    for(int i = 0; i < m; ++i){
        graph[a[i]][b[i]] = 0;
        graph[b[i]][a[i]] = 0;
        fill(used, used + n, false);
        dfs(0);

        bool flag = true;
        for(int v = 0; v < n; ++v){
            if(!used[v]){
                flag = false;
                break;
            }
        }
        if(!flag)   ++res;

        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }
    cout << res << endl;
}

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

int main(){
int A, B, C;
  cin>> A >> B >> C;
  
  if(A==B && B!=C){
    cout << "Yes" << endl;
  }
  
    else if (B==C && B!=A){
      cout << "Yes" << endl;
    }
  
      else if(C==A && C!=B){
  cout << "Yes"<< endl;
      }
 else{
cout << "No" << endl;
 }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
int main()
{
	FAST
	#ifdef ayk_16
	    time_taken_start
		freopen("input.txt","rt",stdin);
		freopen("output.txt","wt",stdout);
	#endif
		ll a,b,c;
		cin>>a>>b>>c;
		if((a+b+c)>=22)
			cout<<"bust";
		else
			cout<<"win";
}

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

int main(){
    int64_t X;
    cin >> X;
    
    int64_t num500, num5, rest;
    
    
    num500 = X / 500;
    rest = X % 500;
    num5 = rest / 5;
    
    cout << num500*1000 + num5 * 5 << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

ll maxdiff(ll A, ll B, ll C) {
	ll res = max(abs(A-B), abs(B-C));
	res = max(res, abs(C-A));

	return res;
}

int main() {
	ll H, W;
	cin >> H >> W;

	ll ans = INF;
	FOR(x, 1, W-1) {
		ll y = H/2;
		ans = min(ans, maxdiff(H*x, (W-x)*y, (W-x)*(H-y)));

		ll x2 = (W-x)/2;
		ans = min(ans, maxdiff(H*x, H*x2, H*(W-x-x2)));
	}

	FOR(y, 1, H-1) {
		ll x = W/2;
		ans = min(ans, maxdiff(W*y, (H-y)*x, (H-y)*(W-x)));

		ll y2 = (H-y)/2;
		ans = min(ans, maxdiff(W*y, W*y2, W*(H-y-y2)));
	}

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

Measured memory_bytes: 256
//template
import java.util.*;
import java.util.stream.*;
import java.io.*;
public class Main{
	static BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	private static final int HUNDRED = 100;
	public static void main(String[] args) throws IOException{
		
		String s=in.readLine();
		long n=Long.parseLong(s);
		long k=0,kk=1;
		for(int i=0;i<n;i++) {
			if((k/kk)%10==9&&f(k+kk)>f(k+10*kk))
				kk*=10;
			k+=kk;
			out.append(k+"\n");
		}
		
		out.flush();
		in.close();
		out.close();
	}
	private static double f(long num) {
		long copy=num;
		long sum=0;
		while(copy>0) {
			sum+=copy%10;
			copy/=10;
		}
		return (double)num/sum;
	}
	private static int modulo(int S, int N) { return ((S) & (N - 1)); } // returns S % N, where N is a power of 2
	private static int isPowerOfTwo(int S) { return (S & (S - 1)) == 0 ? 1 : 0; }
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}
	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}
	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}
	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}
	 
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

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

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<float> a(N);

  REP(i, N){cin >> a[i];}
  sort(a.begin(), a.end());

  float sv = 0;
  REP(i, N){sv += a[i];}
  float val = a[N-M];
  float tmp = val/sv;
  float m = M;
  float conf = 1/(4*m);
  if (tmp >= conf) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def prime_fact_factorial(n):
    global e
    e=[0]*(n+1)
    for i in range(2,n+1):
        cur=i
        for j in range(2,i+1):
            while cur%j==0:
                e[j]+=1
                cur//=j
def num(m):
    return len([x for x in e if x>=m-1])
def main():
    n=int(input())
    prime_fact_factorial(n)
    print(num(75)+num(25)*(num(3)-1)+num(15)*(num(5)-1)
        +num(5)*(num(5)-1)*(num(3)-2)//2)

if __name__=='__main__':
    main()

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

#define MAX 500001

void MaxHeap(int*, int, int);

int main(void){
  int i, n;
  int A[MAX];

  scanf("%d", &n);
  for(i=1; i<n+1; i++) scanf("%d", &A[i]);

  for(i=n/2; i>0; i--) MaxHeap(A, i, n);

  for(i=1; i<n+1; i++) printf(" %d", A[i]);
  printf("\n");

  return 0;
}

void MaxHeap(int *A, int i, int n){
  int left, right, largest, tmp;

  left = i*2;
  right = i*2+1;

  if(left <= n && A[left] > A[i]) largest = left;
  else largest = i;

  if(right <= n && A[right] > A[largest]) largest = right;

  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    MaxHeap(A, largest, n);
  }

  return;
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int k[n];
  int cnt=0;
  rep(i,n){
    int y;
    cin >> y;
    cnt+=y;
    k[i]=y;
  }
  int ans=0;
  rep(i,n){
    ans+=k[i]*(cnt-k[i]);
  }
  cout << ans/2 << endl;
}


Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                    # ll = deepcopy(l)
from heapq import *                    # heappush(hp,x)
from string import *                # alpha = ascii_lowercase
from random import *                # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                # minn = -maxsize
from decimal import Decimal
from operator import *                # d = sorted(d.items(), key=itemgetter(1))
from itertools import *				  # pre = [0] + list(accumulate(l))
from collections import Counter        # d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
9990000000000000
9990000000000000
'''

def solve(l):
	a,b = l
	p = Decimal(a)*Decimal(b)
	return int(p)

l = list(map(str, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)



Measured memory_bytes: 11032