akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define endl '\n'
#define Int long long
#define Double long double
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define CLR(a, b) memset(a, b, sizeof a)
#define debug(x) cerr << #x << " " << x << endl;
#define MOD 1000000007
#define MAXN 2002

using namespace std;

int n, k;
int mark[MAXN];
int depth[2][MAXN];
vector<int> net[MAXN];

void dfs(int v, int d, int t) {
    mark[v] = 1;
    depth[t][d]++;

    for(int i = 0; i < SZ(net[v]); ++i) {
        if(!mark[net[v][i]])
            dfs(net[v][i], d + 1, t);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n >> k;
    for(int i = 0; i < n-1; ++i) {
        int u, v; cin >> u >> v;
        u--, v--;
        net[u].push_back(v);
        net[v].push_back(u);
    }
    int ans = INT_MAX;
    if(k%2 == 0) {
        for(int i = 0; i < n; ++i) {
            CLR(mark, 0);
            CLR(depth, 0);

            dfs(i, 0, 0);

            int res = 0;
            for(int i = k/2 + 1; i < n; ++i)
                res += depth[0][i];
            ans = min(res, ans);
        }
    } else {
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < SZ(net[i]); ++j) {
                CLR(mark, 0);
                CLR(depth, 0);

                mark[net[i][j]] = 1;
                dfs(i, 0, 0);

                dfs(net[i][j], 0, 1);

                int res = 0;
                for(int l = k/2 + 1; l < n; ++l) {
                    res += (depth[0][l] + depth[1][l]);
                }

                ans = min(ans, res);
            }
        }
        
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
/*
  AOJ 2510
  Titl:ewin Book Report
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int N,w[1000];
char s[1000000];

int undermax(int a[],int n,int aim)
{
  int i,j;

  memset(s,0,sizeof(s));
  s[0]=1;
  for(i=0;i<n;i++)
    for(j=aim-a[i];j>=0;j--)
      if(s[j])
	{
	  s[j+a[i]]=1;
	}
  for(i=aim;i>=0;i--)
    if(s[i])
      return(i);
}

main()
{ int i,ret,r1,w1,rmax,rsum,wsum,gap,over,lb;
  
  while(scanf("%d",&N) && N)
    {
      rmax=rsum=wsum=0;
      memset(w,0,sizeof(w));
      for(i=0;i<N;i++)
	{
	  scanf("%d %d",&r1,&w1);
	  if(rmax<r1)
	    {
	      lb=i;        //longest read time book
	      rmax=r1;
	    }
	  rsum+=r1;
	  wsum+=w1;
	  w[i]=w1;
	}
      if(rsum > 2*rmax)
	ret=rsum+wsum;
      else
	{
	  gap=rmax-(rsum-rmax);
	  w[lb]=0;         //exclude lonest read time book
	  over=undermax(w,N,gap);
	  ret=2*rmax+wsum-over;
	}
      printf("%d\n",ret);
    }
  return(0);
}

Measured memory_bytes: 1588
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
  static void Main() {
    string[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int p = int.Parse(str[1]);
    int t = a * 3 + p;
    int ans = t / 2;
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vp vector< pair<int,int> >
const int N=100005;
vi h(N);
int dp[N][2];
int n;
int cost(int stone,int jump)
{
    if(dp[stone][jump]!=-1)
    {
        return dp[stone][jump];
    }
    if(stone>n)
    {
        return 10009;
    }
    if(stone==n)
    {
       return 0;

    }
    dp[stone][jump]=min(cost(stone+1,1)+abs(h[stone+1]-h[stone]),cost(stone+2,2)+ abs(h[stone+2]-h[stone]));
    return dp[stone][jump];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    rep(i,1,n)
    {
        cin>>h[i];
    }
    memset(dp,-1,sizeof(dp));

    cout<<cost(1,0)<<"\n";

    return 0;
}






Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,m,k,c[1010],ans=1e9;
char a[15][1010];
int ok(int s){
	for(int i=0,j;i<n;){
		int tot=0;
		for(j=i;j<n;j++){
			tot+=c[j];
			if(s>>j&1)break;
		}
		if(tot>k)return 0;
		i=j+1;
	}
	return 1;
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			scanf(" %c",a[i]+j);
	for(int i=0;i<(1<<n-1);i++){
		int tot=0;
		for(int j=0;j<n-1;j++)if(i>>j&1)tot++;
		for(int j=0,k;j<m;){
			for(int t=0;t<n;t++)c[t]=a[t][j]-'0';
			for(k=j;k<m&&ok(i);k++){
//				if(!i)printf("%d %d %d\n",c[0],c[1],c[2]);
				for(int t=0;t<n;t++)c[t]+=a[t][k+1]-'0';
			}
			if(j==k)goto fail;
			if(k<m)tot++;
			j=k;
		}
		ans=min(ans,tot);fail:;
	}
	printf("%d\n",ans);
	return 0;
}

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

int arr[2000][2000];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  if (k == 0) {
    cout << "Yes" << endl;
    return 0;
  }

  for (int i = 0; i < n+1; i++) {
    for (int j = 0; j < m+1; j++) {
      arr[i][j] = n*j + m*i - 2*i*j;
    }
  }

  for (int i = 0; i < n+1; i++) {
    for (int j = 0; j < m+1; j++) {
      if (arr[i][j] == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 8576
<?php
list($n,$l)=explode(" ",trim(fgets(STDIN)));
$a=$l;
$sum=($l+$l+$n-1)*$n/2;
$i=2;
while($i<=$n){
  if(abs($a)>abs($l+$i-1)){
    $a=$l+$i-1;
  }
  ++$i;
}
echo $sum-$a;

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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long ll;
typedef pair<int, int> pi;

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int x, y, z, k;
    cin>>x>>y>>z>>k;

    ll A[x], B[y], C[z];
    vector<ll> v, ans;

    for (int i=0;i<x;++i) cin>>A[i];
    for (int i=0;i<y;++i) cin>>B[i];
    for (int i=0;i<z;++i) cin>>C[i];

    sort(A, A+x, greater<ll>());
    sort(B, B+y, greater<ll>());
    sort(C, C+z, greater<ll>());

    for (int i=0;i<x;++i){
        for (int j=0;j<y;++j){
            v.emplace_back(A[i]+B[j]);
        }
    }
    sort(v.begin(), v.end(), greater<ll>());

    for (int i=0;i<min(k, x*y);++i){
        for (int j=0;j<z;++j){
            ans.push_back(v[i]+C[j]);
        }
    }

    sort(ans.begin(), ans.end(), greater<ll>());
    for (int i=0;i<min(k, (int)ans.size());++i){
        cout<<ans[i]<<endl;
    }

    return 0;
}

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

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

    int a, b;
    cin>>a>>b;

    if (a > 0)              cout<<"Positive"<<endl;
    else if (b >= 0)        cout<<"Zero"<<endl;
    else if (a%2 == b%2)    cout<<"Negative"<<endl;
    else                    cout<<"Positive"<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cstdio>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const ll mod = 1000000007;
const double eps = 1e-10;
const int MAX = 200000;

int N;
vector<int> xv, yv;
ld dist (int i, int j) {
  return sqrt(pow((ld)(xv.at(i) - xv.at(j)), 2) + pow((ld)(yv.at(i) - yv.at(j)), 2));
}

ld fun (vector<int> v, int before) {
  if (v.size() == N) return 0;
  ld sum = 0;
  rep(i, N) {
    auto result = std::find(v.begin(), v.end(), i);
    if (result != v.end()) return 0;
    v.push_back(i);
    sum += dist(before, i) + fun(v, i);
    // cout << i << "**" << before << "-" << i << " = " << dist(before, i) << endl;
  }
  return sum;
}

int main() {
	cin >> N;
  int x, y;
  vector<int> v;
  rep(i,N) {
    cin >> x >> y;
    xv.push_back(x);
    yv.push_back(y);
  }
  ld sum = 0;
  rep(i,N) {
    sum += fun(v, i);
  }
	cout << setprecision(10) << (ld)(sum / N) << endl;
  return 0;
}

Measured memory_bytes: 256
S = gets.chomp

L = S.length
min =10**9

for i in 0..S.length-3 do
  a = 0
  for j in 0..2 do
    a += S[i+j].to_i * 10 ** (2-j)
  end

  tmp = (a - 753).abs
  min = tmp if min > tmp

end

puts min


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

int main() {
    int n;
    cin >> n;
    pair<int, int> w[n + 1];
    long long result[n + 1] = {};
    for (int i = 1; cin >> w[i].first; i++) {
        w[i].second = i;
    }
    sort(w + 1, w + n + 1);
    for (int i = n, j = n; i >= 1; i--) {
        j = min(j, w[i].second);
        result[j] += 1ll * (w[i].first - w[i - 1].first) * (n - i + 1);
    }
    for (int i = 1; i <= n; i++) {
        cout << result[i] << '\n';
    }
    return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

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

int main() {
    cin >> n;
    vl a(n + 10);
    vl b;
    NREP() {
        cin >> a[i];
        b.push_back(a[i] - (i + 1));
    }
    sort(ALL(b));
    ll med;
    n % 2 == 0 ? med = (b[(n / 2) - 1] + b[n / 2]) / 2 : med = b[n / 2];

    NREP() {
        sum += abs(a[i] - (med + i + 1));
    }

    MSG(sum)
}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount
const int INF = (int) 1e9;

int main() {
    int D, G;
    cin >> D >> G;
    vector<int> P(D), C(D);
    for (int i = 0; i < D; ++i) {
        cin >> P[i] >> C[i];
    }

    int ans = INF;
    for (int complete_set = 0; complete_set < (1 << D); ++complete_set) {
        int score = 0, solved = 0;
        for (int i = 0; i < D; ++i) {
            if (complete_set >> i & 1) {
                score += P[i] * 100 * (i + 1) + C[i];
                solved += P[i];
            }
        }
        for (int i = D; i >= 0; --i) {// 残りはスコアが大きい方から考えていく。
            if (i == D) {
                if (score >= G) {
                    ans = min(ans, solved);
                    break;
                }
            } else if (!(complete_set >> i & 1)) {
                int pb_score = 100 * (i + 1);
                if (score + (P[i] - 1) * pb_score >= G) {
                    solved += (G - score + pb_score - 1) / pb_score;
                    ans = min(ans, solved);
                    break;
                }
                score += (P[i] - 1) * pb_score;
                solved += P[i] - 1;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k, t; cin >> k >> t;
  vector<int> A(t); rep(i, t) cin >> A[i];
  ll ans = 0;
  rep(i, t) chmax(ans, max(0, 2*A[i]-k-1));
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int N2 = Integer.parseInt(sc.next());
    int N3 = Integer.parseInt(sc.next());
    for(; N2 <= N3; N2++) {
    	if(N2 % N == 0) {
    		System.out.println("OK");
    		break;
    	}

    	if(N2 == N3) {
			System.out.println("NG");
    	}
    }

  }
}

Measured memory_bytes: 26948
S = input()

if len(S) == 1:
    print(0)
else:

    # 6の場合。index0-2と、3-5だから、/2-1
    # 5の場合。index0-1と、3-4だから、/2-1

    cen = int(len(S) / 2) - 1

    left = list(S[:cen + 1])

    if len(S) % 2 == 1:
        right = S[cen+2:]
    else:
        right = S[cen+1:]

    right = list(reversed(right))

    cnt = 0
    for l, r in zip(left, right):
        if l != r:
            cnt+=1

    print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long 
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define inf 1e9+1
#define all(a) a.begin(),a.end()
vector <int> arr(101);
int k;
int n;
ll dp[101][100001] = {0};

ll solve()
{
  for(int j = 0 ; j <= k ; j++)
  {
    dp[1][j] = (j > arr[1]) ? 0 : 1;
  }

  for(int i = 2; i <= n ; i++)
  {
    dp[i][0] = dp[i-1][0];
    foo(j,1,k+1)
    {
      dp[i][j] = (M+dp[i][j-1]+dp[i-1][j] - ((j-1-arr[i] >= 0 ) ? dp[i-1][j-1-arr[i]] : 0))%M ;
    }
  }
  return dp[n][k];
}

int main()
{  

  cin >> n >> k;
  foo(i,1,n+1)
  cin >> arr[i];

  cout << solve() << endl;
    
  
}



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

int main() {
	int n;

	cin >> n;

	vector<int> a(n);
	vector<int> b;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];


		if (a[i] % 2 == 0)
		{
			b.push_back(a[i]);
		}
	}

	for (auto c : b)
	{
		if (!(c % 3 == 0 || c % 5 == 0))
		{
			cout << "DENIED";
			return 0;
		}
	}

	cout << "APPROVED";
	return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    int d, t, s;
    cin >> d >> t >>s;

    cout << (d <= s * t ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <queue>

using ll = long long;
using namespace std;
using P = pair<int, int>;
static const int INF = 10000000;
int dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
int dis[52][52];
bool ma[52][52] = {};

int main() {
    int h, w, c = 0;
    cin >> h >> w;
    queue<P> Q;
    fill_n(&dis[0][0], 52*52, INF);
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j) {
            ma[i+1][j+1] = s[j] != '#';
            if(s[j] != '#') c++;
        }
    }
    Q.push(make_pair(1, 1));
    dis[1][1] = 1;
    while(!Q.empty()){
        int y = Q.front().first, x = Q.front().second; Q.pop();
        for (int j = 0; j < 4; ++j) {
            int ny = y + dy[j], nx = x + dx[j];
            if(dis[ny][nx] == INF && ma[ny][nx]){
                dis[ny][nx] = dis[y][x] + 1;
                Q.push(make_pair(ny, nx));
            }
        }
    }
    
    cout << (dis[h][w] == INF ? -1 : c-dis[h][w]) << "\n";
    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int M,D;
    cin >> M >> D;
    int ans=0;
    REP(i,1,M+1){
        REP(j,1,D+1){
            if((j%10)>=2&& (j/10)>=2 && i==((j%10)*(j/10))){
                ans++;
            }
        }
    }
    P(ans);
}

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

typedef long long ll;

using namespace std;

ll S(ll n) {
    ll r = 0;
    for (ll t = n; t > 0; t /= 10) {
        r += t % 10;
    }
    return r;
}

double Snuke(ll n) {
    return 1.0 * n / S(n);
}

ll pow_int(int a, int n) {
    ll r = 1;
    for (int i = 0; i < n; ++i) {
        r *= a;
    }
    return r;
}

ll f(ll n) {
    ll x = n;
    for (int d = 0; d <= log10(n) + 1; ++d) {
        ll y = n - (n % pow_int(10, d)) + (pow_int(10, d) - 1);
        if (Snuke(x) > Snuke(y)) {
            x = y;
        }
    }
    return x;
}

int main(void) {
    int K;
    cin >> K;

    ll N = 0;
    for (int i = 0; i < K; ++i) {
        N = f(N + 1);
        cout << N << endl;
    }

    return 0;
}

Measured memory_bytes: 3844
n = int(input())
alst = [int(input()) for _ in range(n)]
cnt = 0
bef = 0
for num in alst:
    cnt += (num + bef) // 2
    if (num + bef) % 2 == 1 and num > 0:
        bef = 1
    else:
        bef = 0
print(cnt)

Measured memory_bytes: 13104
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		int N = GetInt();
		var h = new int[N];
		for(int i = 0; i < N; i++)
			h[i] = GetInt();

		int[] dp = new int[N];  // dp[0] = 0
		dp[1] = Math.Abs(h[1] - h[0]);
		for(int i = 2; i < N; i++)
			dp[i] = Math.Min(
				dp[i-1] + Math.Abs(h[i] - h[i-1]), dp[i-2] + Math.Abs(h[i] - h[i-2]));
		
		Console.WriteLine(dp[N-1]);		
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 20064
from itertools import permutations


def mapt(fn, *args):
    return tuple(map(fn, *args))
  

def main():
    n = int(input())
    data = permutations(range(1, n+1), n)
    p = mapt(int, input().split(" "))
    q = mapt(int, input().split(" "))

    list1 = []
    for index, i in enumerate(data):
        if p == i or i == q:
            list1.append(index)
    print(abs(list1[0] - list1[-1]))
main()

Measured memory_bytes: 9060
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
using namespace std;
int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	char buffer[33];

	cin >> a;
	cin >> b;
	if (a<9&&b<9)
	{
		cout << "Yay!" << endl;

	}
	else
	{
		cout << ":(" << endl;

	}





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

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


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

    ll a;
    ll ans = 0;
    REP(i, N){
        cin >> a;
        if(i % 2 == 1 && a % 2 == 1){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
/*
 *  AUTHOR : MANAV PATEl
*/
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, W;
	cin >> N >> W;
	int w[N], v[N];
	for(int i = 0; i < N; i++)
	{
		cin >> w[i] >> v[i];
	}
	vector <long long int> dp(W + 1);
	for(int i = 0; i < N; i++)
	{
		for(int j = W - w[i]; j >= 0; j--)
		{
			dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
		}
//		for(int j = 0; j <= W; j++) cout << dp[j] << "   ";
//		cout << "\n";
	}
	for(int i = 0; i <= W; i++) dp[0] = max(dp[i],dp[0]);
	cout << dp[0] << "\n";
} 


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

typedef double dbl;

int main() {
	dbl v, t, y;
	while (cin >> v) {
		t = v / 9.8;
		y = 4.9 * t * t;
		int N = 1;
		while (5 * N - 5 < y) {
			N++;
			if (5 * N - 5 >= y) {
				cout << N << endl;
				break;
			}
		}
	}
}


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

int main()
{
  int N;
  int a[110];
  int res=0;
  cin >> N;

  rep(i,N) {
    int aa;
    cin >> aa;
    a[i] = -aa;
  }

  sort(a, a+N);

  int maximum = -a[0];

  int sum=0;
  for(int i=1;i<N;i++){
    sum-=a[i];
  }
  if(maximum<sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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

    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> member(N, K - Q);
    for (int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        member[a - 1]++;
    }
    for (int i = 0; i < N; i++) {
        if (member[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	char c;
	cin >> c;
	if(c >= 'A' && c <= 'Z') cout << 'A' << endl;
	else cout << 'a' << endl;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    int fl=0;
    for (int i = 0; i <n ; ++i) {
        cin>>a[i];
        if(a[i]%2==0){
            if((a[i]%3)!=0&&(a[i]%5)!=0){fl=1;}
        }
    }
    if(!fl)cout<<"APPROVED";
    else cout<<"DENIED";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define per(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(c<a+b) {cout<<"No"<<endl;return 0;}
    ll ans1=4*a*b;
    ll ans2=c-a-b;
     ans2=ans2*ans2;
    if(ans1<ans2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		 int n = sc.nextInt();
		 Map<Integer,Integer> map = new HashMap<>();
		 int[] a = new int[n];
		 for(int i = 0; i < n; i++) {
			 int x = sc.nextInt();
			 a[i] = x;
			 if(map.containsKey(x)) {
				 map.put(x, map.get(x)+1);
			 }else {
				 map.put(x, 1);
			 }
		 }
		 Map<Integer, Long> map2 = new HashMap<>();
		 Map<Integer, Long> map3 = new HashMap<>();
		 long all = 0l;
		 for(Map.Entry<Integer, Integer> entry : map.entrySet()) {
			 int y = entry.getValue();
			 map2.put(entry.getKey(), (long)y*(y-1)/2);
			 map3.put(entry.getKey(), (long)(y-1)*(y-2)/2);
			 all += (long)y*(y-1)/2;
		 }
		 
		 for(int i = 0; i < n; i++) {
			 System.out.println(all - map2.get(a[i])+map3.get(a[i]));
		 }
		 
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 82504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100010];

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

    ll n;cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
    }

    ll m=1;
    for(int i=0;i<n;i++)
    {
        if(a[i]<=1000000000000000000/m)m*=a[i];
        else
        {
            cout<<-1<<endl;return 0;
        }
    }

    cout<<m<<endl;
    return 0;

}


Measured memory_bytes: 4344
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N;

  std::cin >> N;

  for (int i = 0; i <= 100 / 4; i ++)
    for (int j = 0; j <= 100 / 7; j ++)
      if (i * 4 + j * 7 == N) {
        std::cout << "Yes" << std::endl;

        return 0;
      }
  
  std::cout << "No" << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

public static void main(String [] args){

        long N,K;
        long count =0;
        Scanner input = new Scanner(System.in);

        N = input.nextLong();
        K = input.nextLong();

        if (K ==0) {
                count =N*N;
        }else{
                for (long b=K+1; b<=N; b++ ) {
                        count += N/b * (b-K);
                        if (N%b > K-1) {
                                count += N%b-(K-1);
                        }
                }
        }


        System.out.println(count);
}
}


Measured memory_bytes: 23764
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las
solve :: [Int] -> [Int]
solve as = 
    fst <$> (sortOn snd $ zip [1..] as)
    
main = do
    n <- readInt
    as <- readInts
    putStrLn $ unwords (show <$> solve as)

Measured memory_bytes: 34428
s = input()
LN = 753#ご主人様が好きな数字
ans= 754

for i in range(len(s)-2):
    tmp = int(s[i:i+3])#左端から３桁ずつみる
    if abs(LN - tmp) < ans :
        ans = abs(LN - tmp)
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) {
	    cin >> arr[i];
	}
	int res = 0;
	int total = 0;
	for (int i = 0; i < n; i++) total += arr[i];
	int i = 0;
	while (res < total/2) {
	    res += arr[i++];
	}
	res = min(abs(total - 2*res), abs(total - 2*res + 2*arr[i - 1]));
	cout << res;
}

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

int main(){
  int n,x,t;
  cin>>n>>x>>t;
  cout<<(n+x-1)/x*t<<endl;
}

Measured memory_bytes: 3628
n, l = map(int, input().split())
i = 0
s = list()
while i<n:
    s.append(str(input()))
    i+=1

i=0
while i<n:
    w = "z"*l
    j = 0
    while j < n:
        if s[j] <w:
            x = j
            w = s[j]
        j+=1
    if i == 0:
        ans = w
    else:
        ans += w
    s[x] = "z"*l
    i += 1
print(ans)


Measured memory_bytes: 3064
k = gets.to_i

runrun = []

q = [*1..9].map(&:to_s)
cnt = 0
while cnt < 100010 && !q.empty?
  n = q.shift
  m = n[-1].to_i
  q << "#{n}#{m - 1}" if m - 1 >= 0
  q << "#{n}#{m}"
  q << "#{n}#{m + 1}" if m + 1 <= 9
  runrun << n
  cnt += 1
end
runrun.map(&:to_i).sort!
p runrun[k - 1].to_i


Measured memory_bytes: 21744
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

int sum(int a, int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int sub(int a, int b) {
    return a - b < 0 ? a - b + MOD : a - b;
}
int mul(int a, int b) {
    return (1LL*a*b)%MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int ans = 0;
    int pre = 0;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans = sum(ans, mul(pre, x));
        pre = sum(pre, x);
    }


    cout << ans << "\n";

    return 0;
}


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

int main(void){
    string S;
    cin>>S;
    int m=stoi(S.substr(5,2));
    if (m>=5) cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A,B;
  cin >> A >> B;
  cout << A * B;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int x; cin >> x;
    vector<int> check(x+1);
    check[1] = 1;
    for(int b = 2; b <= x; b++){
        int tmp = b*b;
        while(tmp <= x){
            check[tmp] = 1;
            tmp *= b;
        }
    }
    for(int i = x; i >= 1; --i){
        if(check[i]) {
            cout << i << endl;
            return 0;
        }
    }
}

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

int main() {
    int x_1, x_2, y_1, y_2, a, b;
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    a = x_2 - x_1;
    b = y_2 - y_1;
    cout << x_2 - b << " " << y_2 + a << " " << x_1 - b << " " << y_1 + a << " " << endl;

    return 0;
}


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

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

	int minX = N/1.08;
	int maxX = (N+1)/1.08;

	int price;
	bool find = false;

	for (int x=minX; x<=maxX; x++) {
		price = x*1.08;
		if (price == N) {
			cout << x << endl;
			find = true;
			break;
		}
	}
	if (!find) cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string x,y,z;
    cin>>x>>y>>z;
    if(*(x.end()-1)==*(y.begin())&&*(y.end()-1)==*z.begin())
    {
        cout <<"YES"<<endl;
    }
    else
    {
        cout <<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

vector<int> divisor(int n)
{
	vector<int> v;
	for (int i = 1; i * i <= n; i++) 
	{
		if (n % i == 0) 
		{
			v.push_back(i);
			if (i * i != n) 
				v.push_back(n / i);
		}
	}
	sort(begin(v), end(v));
	return v;
}

int A, B;
vector<int>v;
vector<int> v2;

signed main()
{
	cin >> A >> B;
	if (A < B) swap(A, B);
	v = divisor(A);

	for (int n : v)
	{
		if (B % n == 0) 
			v2.push_back(n);
	}

	int ans = 0;
	for (int i = 0; i < v2.size(); i++)
	{
		vector<int> v3 = divisor(v2[i]);
		if (v3.size() <= 2) ans++;
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 512
n, m = map(int, input().split())
a, b = [], []
for row in range(n):
    a.append(list(map(int, input().split())))
for row in range(m):
    b.append(int(input()))

for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)



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

int main()
{
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; ++i) cin >> A[i];

    
    bool dir;
    if(N >= 2) dir = A[0] < A[1];
    bool flg = false; //増加か減少かが決まったらtrueにする。
    if(A[0] != A[1]) flg = true;
    int cnt = 1;
    for(int i = 2; i < N; ++i) {
        bool tmp = A[i-1] < A[i];
        if(flg) {
            if(A[i-1] == A[i]) continue;
            if(dir != tmp) { ++cnt; flg = false; }
        }
        else {
            if(A[i-1] != A[i]) { dir = tmp; flg = true; }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef struct {double x, y;} POINT;
int main()
{
	POINT a, b, c, d;
	double m1, m2;
	while (cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y)
	{
		if (!(a.x - b.x == 0 && c.x - d.x == 0))
		{
			if ((a.x - b.x == 0 && c.y - d.y == 0) || (a.y - b.y == 0 && c.x - d.x == 0))
			{
				cout << "YES" << endl;
				continue;
			}
			else if (((a.y - b.y) / (a.x - b.x)) * ((c.y - d.y) / (c.x - d.x)) == -1.0)
			{
				cout << "YES" << endl;
				continue;
			}
		}
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;
typedef long long ll;

ll H[300];

int main() {
    int h;
    cin >> h;
    for (int i = 1; i <=h; i++) {
        cin >> H[i];
    }

    for (int i = 1; i <=h; i++) {
        cout << "node " << i << ": "
            << "key = " << H[i] << ", ";
        if (i/2 > 0)
            cout << "parent key = " << H[i / 2] << ", ";
        if (i * 2 <= h)
            cout << "left key = " << H[i * 2] << ", ";
        if (i * 2 + 1<= h)
            cout << "right key = " << H[i * 2 + 1] << ", ";
        cout << '\n';
    }
}




Measured memory_bytes: 3084
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define CIN(s) int (s);cin>>(s);
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; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;
struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};
//BipartiteMatching(n)　頂点n個
//add_edge(s,t)
//bipartite_matching()最大マッチング数
long long GCD(long long a,long long b){
    if(b==0)return a;
    return GCD(b,a%b);
}
long long LCM(long long a,long long b){
    return a*b/GCD(a,b);
}
int main(){
  int a,b;
   while(1){
        cin>>a>>b;
        if(a==0&&b==0)break;
        BipartiteMatching match(a+b+1);
        V vec(a);
        V vec1(b);
        rep(i,a)cin>>vec[i];
        rep(i,b)cin>>vec1[i];
        rep(i,a){
            rep(j,b){
                if(GCD(vec[i],vec1[j])!=1){
                    match.add_edge(i,a+j);
                    //cout<<vec[i]<<" "<<vec1[j]<<endl;
                }
            }
        }
        cout<<match.bipartite_matching()<<endl;
   }
}


Measured memory_bytes: 4468
#include <stdio.h>

int main(void) {
  int N, M, C;
  scanf("%d%d%d", &N, &M, &C);
  int B[20];
  for(int i = 0; i < M; i++) {
    scanf("%d", &B[i]);
  }

  int Num = 0;
  for(int i = 0; i < N; i++) {
    int Ans = C;
    for(int j = 0; j < M; j++) {
      int A;
      scanf("%d", &A);
      Ans += A * B[j];
    }
    if(Ans > 0) {
      Num++;
    }
  }
  
  printf("%d\n", Num);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int k, x;

int main() {

	cin >> k >> x;

	if (k * 500 >= x)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int sx, sy, tx, ty;

int main()
{
    cin >> sx >> sy >> tx >> ty;
    string ans = "", X[] = {"L", "R"}, Y[] = {"D", "U"};
    for (int i = 0; i < 2; i++)
    {
        bool x = sx < tx, y = sy < ty;
        if (i == 1)
            x = !x, y = !y;
        for (int j = 0; j < abs(sx - tx); j++)
        {
            ans = ans + X[x];
        }
        for (int j = 0; j < abs(sy - ty); j++)
        {
            ans = ans + Y[y];
        }
    }
    for (int i = 0; i < 2; i++)
    {
        bool x = sx < tx, y = sy < ty;
        if (i == 1)
            x = !x, y = !y;
        for (int j = 0; j < abs(sy - ty) + 1; j++)
        {
            if (j == 0)
                ans = ans + X[!x];
            ans = ans + Y[y];
        }
        for (int j = 0; j < abs(sx - tx) + 1; j++)
        {
            ans = ans + X[x];
            if (j == abs(sx - tx))
                ans = ans + Y[!y];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){


	int A, B, C; cin >> A >> B >> C;
	if(A==B and B==C) cout << "Yes" << endl;
	else cout << "No" << endl;
  



	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
int num[100000];
int main() {
	int n, t; cin >> n >> t;
	vector<int> v;
	rep(i, n) {
		int x; cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	rep(i, n) {
		int r = upper_bound(v.begin(), v.end(), v[i] + t) - v.begin();
		num[i] = r - i;
	}
	ll out = 1;
	rep(i, n) {
		out = (out * (ll)num[i]) % MOD;
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		int a,b,sa=0,sb=0;
		rep(i,0,n){
			cin>>a>>b;
			if(a>b) sa+=a+b;
			else if(a<b) sb+=a+b;
			else{
				sa+=a; sb+=b;
			}
		}
		o(sa<<" "<<sb);
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define modu int(1e9+7)
#define mp make_pair
using namespace std;

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

    int n,f=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x%2==0&&x%3!=0&&x%5!=0){ f=1;}
    }
    if(f) cout<<"DENIED";
    else
    cout<<"APPROVED";
    return 0;
}


Measured memory_bytes: 256