akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int N;
int A[300010];


signed main(){
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    int ans = 0;
    rep(i, 0, 60){
        int c = count_if(RNG(A, 0, N), [i](int a){ return (a>>i)&1; });
        CHADD(ans, MUL(MUL(c, N-c), 1LL<<i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<math.h>
using namespace std;
int n;
int x[30], y[30],h1,h2,d1,d2;
  
double dist(int a, int b){
    return sqrt(a*a+b*b+0.0);
}  
int main(){
    while(1){
		bool ok=true;
        cin >> n;
        if(n == 0) break;
        cin >>h1>>h2>>d1>>d2>>x[0]>>y[0];
		if(dist(h1-x[0],h2-y[0])>= dist(d1-x[0],d2-y[0]))ok=false;
        for(int i=1;i<n;i++){
            cin >> x[i] >> y[i];
			if(dist(h1-x[0],h2-y[0])+dist(x[0]-x[i],y[0]-y[i]) >= dist(d1-x[i],d2-y[i]))ok=false;
        }
  
        if(ok) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3036
#include <cassert>
#include <cstdint>
#include <functional>
#include <tuple>
#include <vector>

template <typename Abelian> class PotentializedUnionFind {

public:
  using value_type = Abelian;
  using reference = value_type &;
  using const_reference = const value_type &;
  using size_type = std::uint_fast32_t;

private:
  std::vector<std::tuple<bool, size_type, value_type>> tree;
  value_type potential(const size_type x) {
    find(x);
    return std::get<2>(tree[x]);
  }

public:
  PotentializedUnionFind(const size_type size)
      : tree(size, std::forward_as_tuple(1, 1, value_type())) {}
  size_type find(const size_type x) {
    assert(x < tree.size());
    if (std::get<0>(tree[x]))
      return x;
    const size_type t = std::get<1>(tree[x]);
    std::get<1>(tree[x]) = find(t);
    std::get<2>(tree[x]) = std::get<2>(tree[t]) + std::get<2>(tree[x]);
    return std::get<1>(tree[x]);
  }
  value_type diff(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    return potential(y)+ (-potential(x));
  }
  bool unite(size_type x, size_type y, value_type d) {
    assert(x < size());
    assert(y < size());
    d = d + diff(y, x);
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (std::get<1>(tree[x]) < std::get<1>(tree[y]))
      std::swap(x, y), d = -d;
    std::get<1>(tree[x]) += std::get<1>(tree[y]);
    tree[y] = std::forward_as_tuple(0, x, d);
    return true;
  }
  bool same(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    return find(x) == find(y);
  }
  size_type size(const size_type x) {
    assert(x < size());
    return std::get<1>(tree[find(x)]);
  }
  size_type size() const noexcept { return tree.size(); }
  bool empty() const noexcept { return tree.empty(); }
};
 
#include<iostream>
int main(void) {
	int n, m;
	std::cin >> n >> m;
	PotentializedUnionFind<int> T(n);
	while (m--) {
		int l, r, d;
		std::cin >> l >> r >> d;
		--l;--r;
		if (!T.unite(l, r, d)) {
			if (T.diff(l, r) != d) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 2688
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	ll n;
		cin>>n;

	vector<ll>vect(n);
	unordered_map<ll,ll>mp;

	ll sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>vect[i];
		sum+=vect[i];
		mp[vect[i]]++;
	}

	ll q;
	 cin>>q;
	 while(q--)
	 {
	 	ll a,b;
	 	 cin>>a>>b;
	 	 sum=sum- mp[a]*a + mp[a]*b;
	 	 cout<<sum<<"\n";
	 	 
	 	 if(mp.find(b)==mp.end())
	 	 {
	 	 	mp[b]=mp[a];
	 	 }
	 	 else
	 	 {
	 	 	mp[b]+=mp[a];
	 	 }

	 	 mp[a]=0;


	 }


	
	return 0;
}

Measured memory_bytes: 7900
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll t = n/(a+b);
  if(n - (a+b)*t >= a){
    cout << a*t + a << endl;
  }else{
    cout << a*t +  n - (a+b)*t << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define maxN 1000001
#define mod 1000000007
typedef long long ll;

bool compared(int a,int b){
	return a < b;
}

int cmp(const void *a,const void *b){
	return(*(int*)b - *(int*)a);
}

int GCD(int a,int b){
	return b?GCD(b,a%b):a;
}

int main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int N , K;
    cin >> N >> K;
    int arr[N];
    for (int i = 0 ;  i < N ; i++)
        cin >> arr[i];
    int dp[N];
    dp[0] = 0;

    for (int i = 1 ; i < N ; i++){
        dp[i] = 2e9;
        for (int j = i - 1 ; j >= max(0 , i - K) ; j--)
            dp[i] = min(dp[i] , dp[j] + abs(arr[i] - arr[j]));
    }
    cout << dp[N - 1] << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

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

    ll N;
    string S;
    cin >> N >> S;

    vector<ll> ws(N+1, 0), bs(N+1, 0);
    REP(i, N){
    	ws[i+1] = ws[i] + (S[i] == '.' ? 1 : 0);
    	bs[i+1] = bs[i] + (S[i] == '#' ? 1 : 0);
    }
    //cout << ws << endl;
    //cout << bs << endl;
    ll res = (1ll << 60);
    REP(i, N+1){
    	ll bn = (bs[i] - bs[0]);
    	ll wn = (ws[N] - ws[i]);
    	//dump(i)
    	//dump(bn)
    	//dump(wn)
    	res = min(res, bn+wn);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4244
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
#define pq priority_queue
using namespace std;
const int ms = 2e5+100;
const int sigma = 30;
int n, m, k, t = 1;

void solve(){
  cin>>n>>m;
  if(n*500>=m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while(t--){
    solve();
  }
}

Measured memory_bytes: 256
H,W = map(int,input().split())
a = [list(map(int,input().split())) for i in range(H)]

ans = []
flag = False
before = []
for i in range(H):
    if i%2==0:
        for j in range(W):
            if (not flag) and a[i][j]%2==1:
                flag = True
                before = [i,j]
            elif flag and a[i][j]%2==1:
                flag = False
                ans.append([before[0]+1,before[1]+1,i+1,j+1])
            elif (not flag) and a[i][j]%2==0:
                pass
            else:
                ans.append([before[0]+1,before[1]+1,i+1,j+1])
                before = [i,j]
    else:
        for j in reversed(range(W)):
            if (not flag) and a[i][j]%2==1:
                flag = True
                before = [i,j]
            elif flag and a[i][j]%2==1:
                flag = False
                ans.append([before[0]+1,before[1]+1,i+1,j+1])
            elif (not flag) and a[i][j]%2==0:
                pass
            else:
                ans.append([before[0]+1,before[1]+1,i+1,j+1])
                before = [i,j]
N = len(ans)
print(N)
for i in range(N):
    print(*ans[i])

Measured memory_bytes: 30324
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 16348
import sys
 
 
H,W = sys.stdin.readline().strip().split()
H = int(H)
W = int(W)
 
h,w = sys.stdin.readline().strip().split()
h = int(h)
w = int(w)

ans = (H-h)*(W-w)
ans = int(ans)
print(ans)

Measured memory_bytes: 3060
open Printf
open Scanf

let id x = x

module Dice =
  struct
    type t = {tp:int; ft:int; lt:int; rt:int; bk:int; bm:int}

    let create x1 x2 x3 x4 x5 x6 =
      {tp = x1; ft = x2; lt = x3; rt = x4; bk = x5; bm = x6}

    let roll d = function
        'S' -> {d with tp = d.bk; ft = d.tp; bm = d.ft; bk = d.bm}
      | 'E' -> {d with tp = d.rt; lt = d.tp; bm = d.lt; rt = d.bm}
      | 'W' -> {d with tp = d.lt; rt = d.tp; bm = d.rt; lt = d.bm}
      | 'N' -> {d with tp = d.ft; bk = d.tp; bm = d.bk; ft = d.bm}
      | _ -> failwith "roll"

    let rollx d dirs =
      let rd = ref d in
      String.iter (fun c -> rd := roll !rd c) dirs;
      !rd

    let top d = d.tp
  end
    
let () =
  let d = scanf "%d %d %d %d %d %d " Dice.create in
  let s = scanf "%s " id in
  let d' = Dice.rollx d s in
  printf "%d\n" (Dice.top d')

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

using namespace std;

int main () {
    int n, q, k;
    vector<int> players, acertou;
    cin >> n >> k >> q;
    players.resize(n, k);
    acertou.resize(n,0);
    for(int i=0; i<q; i++){
        int a;
        cin >> a;
        a--;
        acertou[a]++;
    }

    for(int i=0; i<n; i++){
        if(k-(q-acertou[i])>0){
            //cout << k << " " << q << " " << acertou[i] << endl; 
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }



    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;


int main()
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int s0 = A * X + B * Y;

	int z0 = min(X, Y);
	int z1 = max(X, Y);

	int s1, s2;
	if (X > Y)
	{
		s1 = A * (X - z0) + 2 * C * z0;
	}
	else
	{
		s1 = B * (Y - z0) + 2 * C * z0;
	}

	s2 = 2 * C * z1;

	cout << min({ s0,s1,s2 })<<endl;

	
	
}

Measured memory_bytes: 256
using System;

namespace ABC_081_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine();
            char s1 = word[0];
            char s2 = word[1];
            char s3 = word[2];
            string sa = s1.ToString();
            string sb = s2.ToString();
            string sc = s3.ToString();
            int a = int.Parse(sa);
            int b = int.Parse(sb);
            int c = int.Parse(sc);
            Console.WriteLine(a + b + c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11220
my $s = <STDIN>;

my $sum = 0;

if( $s < 10 ){
  $sum =+ $s;
}else{
  $sum = $sum + 9;
if( $s > 99){  
  if($s < 1000 ){
     $sum =  $sum + ($s - 99);
  }else{
     $sum = $sum + 900;
     if( $s > 9999){
        if( $s < 100000 ){ 
  	     $sum =$sum + ($s - 9999);
  		  }else{
         $sum = $sum + 90000;
       }
     }
  }
}
}

print "$sum\n";

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

using namespace std;

int a[200000];

int main() {
    int n, i;
    long long ans = 1e18, sum1 = 0, sum2 = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) sum2 += a[i];
    
    for (i = 0; i < n - 1; i++) {
        sum1 += a[i];
        sum2 -= a[i];
        
        ans = min(ans, abs(sum1 - sum2));
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,W,weight[110],value[110],dp[110][100100]={0},ans=0;
  cin>>N>>W;
  for (long long i=0;i<N;i++){
    cin >> weight[i] >> value[i];
  }
  for(long long i=0;i<=W;i++){
    dp[0][i]=0;
  }
  dp[0][weight[0]]=value[0];
  for (long long i=0;i<N-1;i++){
    for(long long j=0;j<=W;j++){
      if(j>=weight[i+1]){dp[i+1][j]=max(dp[i][j-weight[i+1]]+value[i+1],dp[i][j]);}
      else{dp[i+1][j]=dp[i][j];}
    }
  }
  for(long long i=0;i<=W;i++){
    ans=max(ans,dp[N-1][i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 86272
N = int(input())
task = [list(map(int, input().split())) for i in range(N)]

stask = sorted(task, key = lambda x: x[1])
time = 0
for i in range(N):
    time += stask[i][0]
    if time > stask[i][1]:
        print('No')
        break
    if i == N-1:
        print('Yes')

Measured memory_bytes: 55196
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
bool G[700][700];
int color[700];
int ctr[2];
void dfs(int x, int c) {
  assert(color[x] == -1);
  color[x] = c;
  ctr[c]++;
  rep(t, N) if (x != t && G[x][t]) {
    if (color[t] != -1) {
      if (color[t] == c) {
        cout << -1 << "\n";
        exit(0);
      }
      continue;
    }
    dfs(t, c^1);
  }
}
int dp[2][701];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a][b] = G[b][a] = true;
  }
  rep(i, N) rep(j, N) if (i != j) G[i][j] ^= 1;
  rep(i, N) color[i] = -1;
  dp[0][0] = true;
  int sum = 0;
  rep(root, N) if (color[root] == -1) {
    ctr[0] = ctr[1] = 0;
    dfs(root, 0);
    int a = ctr[0], b = ctr[1];
    sum += a+b;
    rep(j, N+1) dp[1][j] = false;
    rep(j, N+1) {
      if (j+a <= N) dp[1][j+a] |= dp[0][j];
      if (j+b <= N) dp[1][j+b] |= dp[0][j];
    }
    swap(dp[0], dp[1]);
  }
  assert(sum == N);
  int m = INF;
  rep(a, N+1) if (dp[0][a]) {
    int b = N-a;
    m = min(m, (a*(a-1)+b*(b-1))/2);
  }
  cout << m << "\n";
  return 0;
}


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

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(n);
	rep(i, q) {
		int index;
		cin >> index;
		a[index-1]++;
	}

	vector<int> p(n);
	rep(i, n) {
		int result = k - (q - a[i]);
		if (result <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 4064
from heapq import heappop, heappush

X, Y, Z, K = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

a_list.sort(reverse=True)
b_list.sort(reverse=True)
c_list.sort(reverse=True)

h = []
a = a_list[0]
b = b_list[0]
c = c_list[0]
heappush(h, (-(a + b + c), 0, 0, 0))

key_dict = dict()
key_dict[(0, 0, 0)] = 1

ans_list = []
for i in range(K):
    ans, a, b, c = heappop(h)
    ans_list.append(-ans)
    a1 = (a + 1, b, c)
    b1 = (a, b + 1, c)
    c1 = (a, b, c + 1)
    if a + 1 < X and not a1 in key_dict:
        heappush(h, (-(a_list[a + 1] + b_list[b] + c_list[c]), a + 1, b, c))
        key_dict[(a + 1, b, c)] = 1
    if b + 1 < Y and not b1 in key_dict:
        heappush(h, (-(a_list[a] + b_list[b + 1] + c_list[c]), a, b + 1, c))
        key_dict[(a, b + 1, c)] = 1
    if c + 1 < Z and not c1 in key_dict:
        heappush(h, (-(a_list[a] + b_list[b] + c_list[c + 1]), a, b, c + 1))
        key_dict[(a, b, c + 1)] = 1
for ans in ans_list:
    print(ans)


Measured memory_bytes: 10440
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab

int mod(LL x) {
	if (x == 26)return 26;
	return x % 26;
}

#define N 100009


int main(){
	int n, a[N] = { 0 }, tmp, q, b, c;
	LL sum = 0;
	scanf("%d", &n);
	rep(i, n) { scanf("%d", &tmp); a[tmp]++; sum += tmp; }
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &b, &c);
		sum += (c-b)*a[b];
		printf("%lld\n", sum);
		a[c]+=a[b];
		a[b]=0;
	}
}

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

int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  bool flag = true;
  for(int i=1;i<=s.size();i++){
    if(s[i]==s[i-1]) flag = false;
    if(!flag) break;
  }
  if(!flag){
    cout << "no" << endl;
  }else{
    cout << "yes" << endl;
  }
}

Measured memory_bytes: 3564
// problem: "https://atcoder.jp/contests/abc120/tasks/abc120_c"

#include<iostream>
#include<stack>
#include<string>

using namespace std;

int main()
{
    string s;
    cin>>s;

    stack<char>S;

    int i;
    for(i=0;i!=s.size();i++)
    {
        if(S.empty())
            S.push(s[i]);

        else
        {
            if(S.top() == s[i])
                S.push(s[i]);
            else
                S.pop();
        }
    }

    cout<<s.size()-S.size();

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main (){
  string s; cin >> s;
  int n = s.size();
  int a;
  rep(i,n){
    if(i%2==1){
      if(s.at(i)=='L'||s.at(i)=='U'||s.at(i)=='D'){
        a++;
      }
    }
    else{
      if(s.at(i)=='R'||s.at(i)=='U'||s.at(i)=='D')
        a++;
    }
 }
  if(a==n)  cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) ;for (int i = 0; i <(int)(n); i++)
 
int main(){
int N, Y, x, X, y, z, ans;
  ans=0;
  cin >> N >> Y;
  rep(i,N+1){
    x = N-i;
  rep(j,i+1){
    y = i-j;
    z = j;
    if(10000*x+5000*y+1000*z==Y )
      break;
  }
    if(10000*x+5000*y+1000*z==Y)
      break;
  }
  if(10000*x+5000*y+1000*z==Y)
    cout << x << " " << y << " " << z << endl;
  else
    cout<< "-1 -1 -1"<< endl;
}

Measured memory_bytes: 256
/**
*    created: 10.05.2020 16:38:21
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#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;

vector<int> p(100000,-1);

int dpt(int i) {
    if (p[i] == -1) return 0;
    else return dpt(p[i]) + 1;
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n; cin >> n;

    int id, k, c;
    vector<vector<int>> cld(n);
    rep(i,n) {
        cin >> id >> k;
        rep(j,k) {
            cin >> c;
            cld[id].push_back(c);
        }
    }
    rep(i,n) {
        rep(j,cld[i].size()) {
            p[cld[i][j]] = i;
        }
    }

    //出力
    rep(i,n) {
        int d = dpt(i);
        cout << "node " << i << ": ";
        cout << "parent = " << p[i] << ", ";
        cout << "depth = " << d << ", ";

        if (d == 0) cout << "root" << ", " ;
        else if (cld[i].size() == 0) cout << "leaf" << ", ";
        else cout << "internal node" << ", ";

        if(cld[i].size() == 0) cout << "[]" << endl;
        else {
            cout << "[";
            rep(j,cld[i].size()) {
                if (j == cld[i].size() - 1) cout << cld[i][j] << "]" << endl;
                else cout << cld[i][j] << ", ";
            }
        }
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint q,h,s,d,n; cin>>q>>h>>s>>d>>n;
	lint one=min({4*q,2*h,s});
	lint two=min({2*one,d});
	cout<<n/2*two+n%2*one<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)n; i++)

using namespace std;
typedef pair<int, int> pint;

int main() {
    string s; cin >> s;
    int n = s.length();
    string t = ""; 
    rep(i,n) {
        t.push_back('x');
    }   
    cout << t << endl;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j]<<" ";cout<<endl;}};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll r;cin>>r;
  cout<<r*r*3<<endl;

  return 0;
}

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

int main()
{
    long long n,x;
    
    cin>>n>>x;
    
    long long i;
    long long arr[100000];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int flg=0;
    long long ans=0;
    
    for(i=0;i<n-1;i++)
    {
        if(arr[i]+arr[i+1]>x){flg=1;break;}
    }
    if(!flg)
    {cout<<0;return 0;}
    long long f1,f2;
    if(arr[0]>x)
    {
        ans+=(arr[0]-x);arr[0]=x;
        f1=x-arr[0];
    }
    else f1=x-arr[0];
    for(i=1;i<n;i++)
    {
        if(i%2)
        {
          if(arr[i]>f1){
            ans+= arr[i]-f1;
            arr[i]=f1;
            
          }
          f2= x-arr[i];
        }
        else{
            
            if(arr[i]>f2){
            ans+= arr[i]-f2;
            arr[i]=f2;
          }
          f1=x-arr[i];
        }
        
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define crap ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846264338327950288419716939937510
#define pb(a) push_back(a)
#define pf(a) push_front(a)

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

ll maxn = 200000 + 1;
vector <ll> dp(maxn,-1) ;

ll solve(ll n)
{
	if(dp[n]!=-1)
		return dp[n] ;
	dp[n] = 1 + solve(n%(__builtin_popcount(n))) ;
	return dp[n] ;
}

ll fpower(ll x,ll y,ll mod1)
{
	if(!y)
		return 1 ;
	x = x%mod1 ;
	return (y&1) ? x*fpower(x*x%mod1,y/2,mod1)%mod1 : fpower(x*x%mod1,y/2,mod1)%mod1 ;
}

int main()
{
	crap;
	ll n,i,j,k;
	cin >> n;
	string s;
	cin >> s;
	dp[0] = 0 ;
	for(i=n;i>=1;--i)
		if(dp[i]==-1)
			solve(i) ;
	ll count = 0; 
	vector <ll> temp ;
	j = 0;
	for(i=s.size()-1;i>=0;--i)
	{
		if(s[i]=='0')
		{
			j++ ;
			continue ;
		}
		count++ ;
		temp.pb(j++) ; // indexes for powers of 2
	}
	if(count==0)
	{
		f(i,0,n)
			cout << "1\n" ;
		return 0 ;
	}
	ll x = 0,y = 0 ;
	for(i=0;i<temp.size();++i)
	{
		x = (x + fpower(2,temp[i],count+1))%(count+1) ;
		if(count-1>0)
			y = (y + fpower(2,temp[i],count-1))%(count-1) ; 
	}
	j = 0;
	vector <ll> ans ;
	for(i=s.size()-1;i>=0;--i)
	{
		ll ans1 = 0;
		if(s[i]=='0')
		{
			ans1 = 1 + solve((x+fpower(2,j,count+1))%(count+1)) ;
			ans.pb(ans1) ;
		}
		else
		{
			if(count-1==0)
				ans.pb(0) ;
			else
			{
				ans1 = 1 + solve((y-fpower(2,j,count-1) + count-1)%(count-1)) ;
				ans.pb(ans1) ;
			}
		}
		j++ ;
	}
	for(i=ans.size()-1;i>=0;--i)
		cout << ans[i] endl ;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

Measured memory_bytes: 7860
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  readln;
  auto a = readln.chomp.split.map!(to!int);
  auto s = new int[](100003);
  foreach (e; a) {
    s[e]++;
    s[e+3]--;
    //s[e..e+3] +=1;
    //writeln(s[0..10]);
  }
  
  int cnt, prevCnt;
  foreach (i, e; s) {
    cnt += e;
    prevCnt = max(cnt, prevCnt);
  }

  prevCnt.writeln;
}




Measured memory_bytes: 4540
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
    	int res = -1;
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        for(int i = 0;i<1010;i++) {
            if((int)(i*0.1) == B && (int)(i*0.08)==A){
                res = i;
                break;
            }
        }
        System.out.println(res);
    }
}

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

#define llint long long int

using namespace std;

int main(){
    llint H, W;

    cin >> H >> W;

    if(H == 1 || W == 1){
        cout << 1 << endl;
    }else if(H % 2 == 1 && W % 2 == 1){
        cout << H * W / 2 + 1 << endl;
    }else{
        cout << H * W / 2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#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)

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x) {
    return -par[root(x)];
  }
};

int main() {
  int N,M;
  cin>>N>>M;
  UnionFind uf(M+N);
  REP(i,N){
    int k;cin>>k;
    REP(j,k){
      int l;
      cin>>l;l--;
      uf.merge(i,l+N);
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(i==uf.root(i)){
      ans++;
    }
  }
  cout<<(ans==1?"YES":"NO")<<endl;
}


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

n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
m = max(l)
for i in range(1,n):
    l[i] = gcd(max(l[i],l[i-1]),min(l[i],l[i-1]))
if k%l[-1] == 0 and k <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 14224
import java.util.*;

class Main{
  public static void main(String[] args){
    int numx=0;
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
  for(int i=0; i < str.length(); i++){
    if(str.charAt(i)=='x'){
      numx++;
    }
  }
    System.out.println(numx< 8 ? "YES" : "NO");
  }
}


Measured memory_bytes: 21844
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	X = II()
	ans = 0
	ans += (X // 500)*1000
	X = X % 500
	ans += (X // 5)*5

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 38384
s = input(); t = input()
c = 0 #無限ループを防ぐためのカウンターを設置

while (s != t):
    s = s[-1] + s[:-1]
    c += 1
    if c == len(s):
        print('No')
        break
    
if s == t:
    print('Yes')

Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[101];
  scanf("%s", s);
  int l = strlen(s);
  int i, odd = 1, judge = 1;
  for (i = 0;i < l;i++){
    if (s[i] == 'U' || s[i] == 'D'){
      odd *= -1;
      continue;
    }
    if (odd == 1){
      if (s[i] == 'L'){
        judge = 0;
        break;
      }
    }else{
      if (s[i] == 'R'){
        judge = 0;
        break;
      }
    }
    odd *= -1;
  }
  if (judge == 1) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    private int Sx,Sy,Tx,Ty;
    private void Scan()
    {
        var l=Console.ReadLine().Split(' ');
        Sx=int.Parse(l[0]);
        Sy=int.Parse(l[1]);
        Tx=int.Parse(l[2]);
        Ty=int.Parse(l[3]);
    }
    public void Solve()
    {
        Scan();
        string ans="";
        ans+=new string('R',Tx-Sx);
        ans+=new string('U',Ty-Sy);
        ans+=new string('L',Tx-Sx);
        ans+=new string('D',Ty-Sy);
        ans+='D';
        ans+=new string('R',Tx-Sx+1);
        ans+=new string('U',Ty-Sy+1);
        ans+='L';
        ans+='U';
        ans+=new string('L',Tx-Sx+1);
        ans+=new string('D',Ty-Sy+1);
        ans+='R';
        Console.WriteLine(ans);
        
    }
    
    static void Main()
    {
        new Program().Solve();
    }
}

Measured memory_bytes: 13172
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int y = cin.ReadInt;
            int m = -1;
            int g = -1;
            int s = -1;

            for (int i = 0; i <= n; i++)
                for (int j = 0; j <= (n - i); j++)
                    if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y)
                    {
                        m = i;
                        g = j;
                        s = n - i - j;
                    }

            Console.WriteLine(string.Format("{0} {1} {2}", m,g,s));
        }


    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>

int main(void)
{

        int a, b, i;
        int res = 0;

        scanf("%d%d", &a,&b);

        for(i = 0; i < 2; i++) {
                if(a >= b) {
                        res += a;
                        a--;
                } else {
                        res += b;
                        b--;
                }
        }
        printf("%d", res);
        return 0;
}

Measured memory_bytes: 128
li = [0, 0]
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    li[0] = ("#." * W)[:W]
    li[1] = (".#" * W)[:W]
    for i in range(H):
        print(li[i % 2])
    print("")


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int a=0;
    for(char c:s) a=(a+c-'0')%9;
    if(a==0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define pb push_back
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


void init() {

}



int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
//    ios_base::sync_with_stdio(0);
    init();
    int n; cin >>n;
    bool flg = 0;
    for (int i = 0; i <= n / 4; i++){
        if ((n - i * 4) % 7 == 0) {
            flg = 1;break;
        }
    }
    if (flg) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.Arrays;
class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			int times[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				int c = sc.nextInt(),
					m1 = sc.nextInt(),
					s1 = sc.nextInt(),
					m2 = sc.nextInt(),
					s2 = sc.nextInt(),
					m3 = sc.nextInt(),
					s3 = sc.nextInt(),
					m4 = sc.nextInt(),
					s4 = sc.nextInt();
				int time = (m1 + m2 + m3 + m4) * 60 + s1 + s2 + s3 + s4;
				times[i] = time;
				map.put(time, c);
			}
			Arrays.sort(times);
			System.out.println(map.get(times[0]));
			System.out.println(map.get(times[1]));
			System.out.println(map.get(times[n - 2]));
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;
const int inf = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    bool check = true;
    for (int a : A) {
        if (a % 2 == 1) continue;
        if (a % 3 == 0) continue;
        if (a % 5 == 0) continue;
        check = false;
    }
    cout << (check ? "APPROVED" : "DENIED") << endl;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < ((k)+(n)); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef complex<D> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define X real()
#define Y imag()
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,const _Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
ostream &operator<<(ostream &os, const pair<int,int> &p){return(os<<"("<<p.first<<","<<p.second<<")");}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

int main(){
    int n;
    while(cin >> n && n){
        int k[101], c = 0;
        REP(i,n){
            cin >> k[i];
            REP(j,i){
                if(k[j] > k[i]) c++;
            }
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

typedef unsigned long long ull;

int a[111111];

int main()
{
  int n, k, p1, ans;
  cin>>n>>k;

  REP(i,n) {
    cin>>a[i];
    if (a[i] == 1) p1 = i;
  }

  if (n == k) ans = 1;
  else if (k == 2) ans = n - 1;
  else if (p1 == 0 || p1 == n-1)
    ans = (n-1)%(k-1) == 0 ? (n-1)/(k-1) : (n-1)/(k-1) + 1;
  else if (p1 + 1 < k || n - p1 + 1 < k)
    ans = (n+1)/(k-1) == 0 ? (n+1)/(k-1) : (n+1)/(k-1) + 1;
  else {
    ans = (p1-1)%(k-1) == 0 ? (p1-1)/(k-1) : (p1-1)/(k-1) + 1;
    ans += (n-p1-1)%(k-1)== 0 ? (n-p1-1)/(k-1) : (n-p1-1)/(k-1) + 1;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
import numpy as np

A = np.zeros((3, 3))
for i in range(3):
    A[i] = list(map(int, input().split()))

hit = np.zeros((3, 3))

N = int(input())
b = np.zeros((N, 1))

for i in range(N):
    b[i] = int(input())

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            hit[i][j] += 1

hit_T = hit.T

if hit[0][0] + hit[1][1] + hit[2][2] == 3 or \
    hit[0][2] + hit[1][1] + hit[2][0] == 3:
    print('Yes')
    exit()

for i in range(3):
    if sum(hit[i]) == 3:
        print('Yes')
        exit()
    if sum(hit_T[i]) == 3:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 12504
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vi d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    ll ret = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if (i == j)
                continue;
            ret += d[i] * d[j];
        }
    }
    cout << ret << "\n";
    return 0;
}

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

int main () {
    int x, y;
    cin >> x >> y;

    if (x % y == 0) cout << -1 << endl;
    else {
        for (long long i =0; i < 1000000000000000000; i++) {
            if (x * i % y !=0) {
                cout << x * i << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256