akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    ll N,A,B,C;
    cin >> N >> A>> B >> C;
    vector<ll> num(N);
    rep(i,N)cin >> num[i];
    vector<ll> dore(N);
    ll ans = INF;
    for(ll i = 0;i < pow(4,N);i++){
        ll n = i;
        rep(j,N){
            dore[j] = n % 4;
            n /= 4;
        }
        ll a = 0,b = 0,c = 0,cnt = 0;
        ll p1 = -1,p2 = -1,p3 = -1;
        rep(j,N){
            if(dore[j] == 1){
                a += num[j];
                p1++;
            }
            else if(dore[j] == 2){
                b += num[j];
                p2++;
            }
            else if(dore[j] == 3){
                c += num[j];
                p3++;
            }
        }
        if(p1 < 0)p1 = 0;if(p2 < 0)p2 = 0;if(p3 < 0)p3 = 0;
        if(c == 0 || b == 0 || a == 0)continue;
        cnt += abs(a - A) + abs(b - B) + abs(c - C);
        cnt += (p1 + p2 + p3) * 10;
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    int x1, x2, x3, x4;
    cin >> N;
    x1 = N % 10;
    N /= 10;
    x2 = N % 10;
    N /= 10;
    x3 = N % 10;
    N /= 10;
    x4 = N % 10;
    if(((x1 == x2) && (x2 == x3)) || ((x2 == x3) && (x3 == x4))){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3600
// https://atcoder.jp/contests/abc096/tasks/abc096_b

#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 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int a, b, c, k;

  cin >> a >> b >> c >> k;

  ll m = a + b + c + max({a, b, c}) * (pow(2, k) - 1);

  cout << m << '\n';

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    String[] splitS = S.split("");
    String T = scan.next();
    String[] splitT = T.split("");
    int n = S.length();
    int count = 0;
    for (int i = 0;i < n;i++) {
      if (splitS[i].equals(splitT[i])) {
      }
      else{
        count += 1;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 66376
#include <stdio.h>

int main(){
    int w, h, x, y, r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    if((x > 0 && y > 0) && (x + r <= w) && (y + r <= h )){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2104
package main

import (
	"fmt"
	"io"
	"os"
)

func Solve(stdin io.Reader, stdout io.Writer) {
	var left, right int
	_, _ = fmt.Fscanf(stdin, "%d %d\n", &left, &right)

	modLeft := left % 2019
	modRight := right % 2019

	// 間に2019個より多い数があれば n % 2019 == 0 を満たすnが必ず存在
	// modLeft >= modRight の場合も left <= n <= right, n % 2019 == 0 を満たすnが必ず存在
	// modLeft < modRight の場合は間に n % 2019 == 0 を満たすnが存在しないので，↓が最小になるはず
	if right-left+1 > 2019 || modLeft >= modRight {
		_, _ = fmt.Fprint(stdout, "0\n")
	} else {
		answer := 2019
		for i := modLeft; i < modRight; i++ {
			for j := i + 1; j <= modRight; j++ {
				tmp := (i * j) % 2019
				if tmp < answer {
					answer = tmp
				}
			}
		}
		_, _ = fmt.Fprintf(stdout, "%d\n", answer)
	}

	return
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
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> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int h1,h2,m1,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;

  int s = h1*60+m1;
  int t = h2*60+m2;
  int d = t-s;
  int ans = d-k;
  cout<<(ans)<<endl;

}

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

int N; // 荷物の個数
int weight[110];
int value[110];
int W; // 最大容量

int dp[110][10010];

int main() {


	cin >> N >> W;

	// 荷物データ
	for (int i = 0; i < N; i++) {
		cin >> value[i] >> weight[i];
	}

	// 初期化
	for (int w = 0; w <= W; w++) dp[0][w] = 0;

	// DP
	for (int i = 0; i < N; i++) {

		// 重さのパターンだけ繰り返そう
		for (int w = 0; w <= W; w++) {
			// 予定の重さ以内なら選ぶ
			//                                     この荷物を入れなかった時の最大値から引っ張ってくる
			if (w >= weight[i]) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);

			// 予定重量を超過するなら選ばない
			else dp[i + 1][w] = dp[i][w];
		}
	}

	cout << dp[N][W] << endl;

	return 0;

}


Measured memory_bytes: 7048
A, B = map(int, input().split())
flg = False
# A, B = 2, 2
for i in range(B * 10, (B+1)*10 ):
    # print(i * 0.08)
    # print(i)
    if int(i * 0.08) >= A and int(i * 0.08) < (A+1):
        print(i)
        flg = True
        break

if flg == False:
    print(-1)

Measured memory_bytes: 3060
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common

#N = int(input())
#X,N= map(int,input().split())
#P = list(map(int,input().split()))
S= str(input())
if S.isupper()==True:
    print('A')
else:
    print('a')


Measured memory_bytes: 9012
# Python Program to find the count of 
# numbers in a range where the number 
# does not contain more than K non 
# zero digits 

# This function returns the count of 
# required numbers from 0 to num 
def countInRangeUtil(pos, cnt, tight, num): 

	# Last position 
	if pos == len(num): 

		# If count of non zero digits 
		# is less than or equal to K 
		if cnt == K: 
			return 1
		return 0

	# If this result is already computed 
	# simply return it 
	if dp[pos][cnt][tight] != -1: 
		return dp[pos][cnt][tight] 

	ans = 0

	# Maximum limit upto which we can place 
	# digit. If tight is 1, means number has 
	# already become smaller so we can place 
	# any digit, otherwise num[pos] 
	limit = 9 if tight else num[pos] 

	for dig in range(limit + 1): 
		currCnt = cnt 

		# If the current digit is nonzero 
		# increment currCnt 
		if dig != 0: 
			currCnt += 1

		currTight = tight 

		# At this position, number becomes 
		# smaller 
		if dig < num[pos]: 
			currTight = 1

		# Next recursive call 
		ans += countInRangeUtil(pos + 1, currCnt, currTight, num) 

	dp[pos][cnt][tight] = ans 
	return dp[pos][cnt][tight] 

# This function converts a number into its 
# digit vector and uses above function to compute 
# the answer 
def countInRange(x): 
	global dp, K, M 
	num = [] 
	while x: 
		num.append(x % 10) 
		x //= 10
	num.reverse() 
	dp = [[[-1, -1] for i in range(M)] for j in range(M)] 
	return countInRangeUtil(0, 0, 0, num) 

# Driver Code 

# states - position, count, tight 
dp = [] 
M = 101

# K is the number of non zero digits 
K = 0

L = 1
R = int(input())
K = int(input())
print(countInRange(R) - countInRange(L - 1)) 





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


int main() {
  int N, M;
  int s;
  s = 0;
  cin >> N;
  M = N;
  while(N>0)
  {
    int a = N%10;
    s+=a;
    N /= 10;
  }
  if(M%s==0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
      string a,b;
      cin>>a>>b;
      if(a.size()==b.size()){
        if(a>b) cout<<"GREATER"<<endl;
        else if(a==b) cout<<"EQUAL"<<endl;
        else cout<<"LESS"<<endl;
      }
      else{
        if(a.size()>b.size()) cout<<"GREATER"<<endl;
        else cout<<"LESS"<<endl;
      }
    return 0;
}

Measured memory_bytes: 256
program abc39
 implicit none
 character(len=3)::S
 integer::a(3)
 integer::ia,ans
 read(*,*)S
 do ia=1,3
  if(S(ia:ia)=="R")then
   a(ia)=1
  else
   a(ia)=0
  end if
 end do
 if(a(1)==1.and.a(2)==0.and.a(3)==1)then
  ans=1
 else
  ans=sum(a)
 end if
 print'(i0)',ans
end program abc39

Measured memory_bytes: 2908
#include <stdio.h>

int main(){
  int n,k,keta=0,flag,a=1,b;
  scanf("%d %d",&n,&k);
  
  int d[k+1];
  for(int i=1;i<=k;i++){
    scanf("%d",&d[i]);
  }
  
  for(int i=1;i>0;i++){
    a*=10;
    keta+=1;
    if(a>=n){
      if(a>n){
        a/=10;
        break;
      }
      if(a==n){
        keta+=1;
        break;
      }
    }
  }
  
  for(int i=n;i>0;i++){
    int I=i;
    flag=0;
    if(a*10==i){
      keta+=1;
      a*=10;
    }
    
    b=a;
    for(int j=keta;j>=1;j--){
      for(int l=1;l<=k;l++){
        if((I-(I%b))/b==d[l]){
          flag=1;
          break;
        }
      }
      I%=b;
      b/=10;
      if(flag==1){
        break;
      }
    }
    
    if(flag==0){
      printf("%d",i);
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll A,B;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> A >> B;
    if (A > B) swap(A,B);
    if (A > 1) cout << (A-2)*(B-2);
    else {
        if (B == 1) {
            cout << 1;
        } else cout << B-2;
    }
}

// read the question correctly (is y a vowel?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define sp << " " <<
#define mod 1000000007
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
bool sortfirst(pii &a,pii &b){
    return a.first<b.first;
}
int main(){
    int n;
    std::cin>>n;
    int i;
    ll a[n],sum=0;
    for(i=0;i<n;i++){
        std::cin>>a[i];
        sum+=a[i];
    }
    ll sl=0,sr=0,res;
    for(i=0;i<n;i++){
        sl+=a[i];
        if(2*sl==sum){
            std::cout<<0;
            return 0;
        }
        else if(sl>sum/2){
            break;
        }
    }
    sl-=a[i];
    
    int j; 
    for(j=i+1;j<n;j++){
        sr+=a[j];
    }
  
    if(sl>sr){
        res=a[i]-sl+sr;
    }
    else{
        res=a[i]+sl-sr;
    }
    std::cout<<res;
    

    
    return 0;
}

Measured memory_bytes: 1792
import math



red,green,x,y,z = map(int,input().split())
red_data = list(map(int,input().split()))
green_data = list(map(int,input().split()))
blank_data = list(map(int,input().split()))


red_data.sort(reverse=True)
green_data.sort(reverse=True)
blank_data.sort(reverse=True)


# check if colourless apples are better
red_index = red-1
green_index = green-1


for blank in blank_data:
    red_gap = -1
    if red_index >= 0:
        red_gap = blank - red_data[red_index]
    
    green_gap = -1
    if green_index >=0:
        green_gap = blank - green_data[green_index]
    
    if max(red_gap,green_gap) <= 0:
        break
    
    if red_gap >= green_gap:
        red_data[red_index] = blank
        red_index -= 1
    
    if green_gap > red_gap:
        green_data[green_index] = blank
        green_index -= 1






total = sum(red_data[0:red]) + sum(green_data[0:green])

print(total)



                      
                      



Measured memory_bytes: 105444
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)
int n, m, x, C[MAX_N], A[14][MAX_N];
bool use[MAX_N];

ll rec(int current) {
  if (current == n) {
    for (int i = 0; i < m; i++){
      ll sum = 0;
      for (int j = 0; j < n; j++){
        if (use[j]) {
          sum += A[j][i];
        }
      }

      if (sum < x) {
        return INF;
      }
    }

    ll result = 0;
    for (int i = 0; i < n; i++){
      if (use[i]) {
        result += C[i];
      }
    }

    return result;
  }

  use[current] = true;
  ll tmp = rec(current + 1);
  use[current] = false;

  return min(tmp, rec(current + 1));
}


void exec(){
  cin >> n >> m >> x;
  for (int i = 0; i < n; i++){
    scanf("%d", &C[i]);

    for (int j = 0; j < m; j++){
      scanf("%d", &A[i][j]);
    }
  }

  ll result = rec(0);

  cout << (result == INF ? -1 : result) << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

int main(){
  solve();
  return 0;
}


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


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, d;
  cin >> n >> d;
  int cnt = 0;
  rep(i,n) {
    ll x, y;
    cin >> x >> y;
    if (x*x + y*y <= 1ll*d*d) ++cnt;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, max;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);

            b = int.Parse(word[1]);
            max = a + b;
            if (max < a - b) max = a - b;
            if (max < a * b) max = a * b;
            Console.WriteLine(max);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
<?php
  function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
 
//最小公倍数
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}
  
 fscanf(STDIN,"%d%d%d%d",$a,$b,$c,$d);
 $b2 = intdiv($b,$c)+intdiv($b,$d)-intdiv($b,lcm($c,$d));
 $a2 = intdiv(($a-1),$c)+intdiv(($a-1),$d)-intdiv(($a-1),lcm($c,$d));

$b = $b-$b2;
$a = $a-1-$a2;
echo $b-$a;
 

Measured memory_bytes: 4604
#include<stdio.h>
int main()
{
	int a,b;
	int c,d;
	double e;
	scanf("%d %d",&a,&b);
	
	c=a/b;
	d=a%b;
	e=(double)a/b;
	
	printf("%d %d %.5lf\n",c,d,e);
}


Measured memory_bytes: 1928
#include <stdio.h>
#include <stdlib.h>
#define MIN(a,b) (a<b?a:b)
int cmp(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main()
{
    int n, k, i, h[100000];
    int min=1000000000;
    scanf("%d %d",&n, &k);
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    qsort(h,n,sizeof(int),cmp);
    for(i=0;i<=n-k;i++) {
        min = MIN(min, h[i+k-1]-h[i]);
    
    }
    printf("%d",min);
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
int mul[214514];
int divi[214514];
#define inf 1000000007
int bit[114514],n;
struct edge{int u,v,cost;};
edge es[214514];
int zero=0;
int dp[55][55][3000];
string alph("abcdefghijklmnopqrstuvwxyz");
signed main(){
    int n;cin>>n;
    int a,b;cin>>a>>b;
    if((a-b)%2)cout<<"Borys"<<endl;
    else cout<<"Alice"<<endl;
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int x;
	cin>>x;
	string ans[2]={"Yes", "No"};
	cout<<ans[x<30]<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
ll N,M,Q;
vector <ll> gomi;

void kasu(ll t,ll M,ll K,ll L){
  if(t == N){
    gomi.push_back(K);
    return ;
  }
  for(ll i = L;i<M;i++){
    kasu(t+1,M,K*10+i,i);
  }
}
 
ll ten[11] = {1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000};



int main(){
  cin>>N>>M>>Q;
  for(ll i = 0;i<M;i++){
    kasu(1,M,i,i);
  }
  ll a[Q][4];
  for(ll i = 0;i<Q;i++){
    cin>>a[i][0]>>a[i][1]>>a[i][2]>>a[i][3];
  }
  ll ansans = 0;
  ll ans = 0;
  ll kkk = gomi.size();
  for(ll i = 0;i<kkk;i++){
    ans = 0;
    for(ll k = 0;k<Q;k++){
      ll pp = (gomi[i]/ten[N-a[k][0]])%10+1;
      ll qq = (gomi[i]/ten[N-a[k][1]])%10+1;
      if((qq-pp) == a[k][2]){
        ans+=a[k][3];
      }
    }
    ansans = max(ans,ansans);
  }
  cout << ansans << endl;
  return 0;
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  sort(rng(A));
  ll ans = 0;
  // p0 >= p1 <= p2 => p3 <= p4
  // p0 - p1 + p2 - p1 + p2 - p3 + p4 - p3
  // p0 - 2 p1 + 2 p2 - 2p3 + p4
  if(N % 2 == 1) {
    rep(i,(N-1)/2) {
      ans -= 2 * A[i];
    }
    ans += A[(N-1)/2];
    ans += A[(N-1)/2+1];
    srep(i,(N-1)/2+2,N) {
      ans += 2 * A[i];
    }
  }
  // p0 >= p1 <= p2 >= p3 <= p4 >= p5
  // p0 - p1 + p2 - p1 + p2 - p3 + p4 - p3 + p4 - p5
  // p0 - 2 p1 + 2 p2 - 2p3 + 2 p4 - p5
  else {
    rep(i,(N-2)/2) {
      ans -= 2 * A[i];
    }
    ans -= A[(N-1)/2];
    ans += A[(N-1)/2+1];
    srep(i,(N-1)/2+2,N) {
      ans += 2 * A[i];
    }

  }

  ll ans2 = 0;
  // p0 <= p1 >= p2 <= p3 >= p4 
  // p1 - p0 + p1 - p2 + p3 - p2 + p3 - p4 
  // -p0 + 2 p1 - 2 p2 + 2 p3 - p4
  if(N % 2 == 1) {
    rep(i,(N-2)/2) {
      ans2 -= 2 * A[i];
    }
    ans2 -= A[(N-2)/2];
    ans2 -= A[(N-2)/2+1];
    srep(i,(N-2)/2+2,N) {
      ans2 += 2 * A[i];
    }
  }
  // p0 <= p1 >= p2 <= p3 >= p4 <= p5
  // p1 - p0 + p1 - p2 + p3 - p2 + p3 - p4 + p5 - p4
  // -p0 + 2 p1 - 2 p2 + 2 p3 - 2 p4 + p5
  else {
    rep(i,(N-2)/2) {
      ans2 -= 2 * A[i];
    }
    ans2 -= A[(N-2)/2];
    ans2 += A[(N-2)/2+1];
    srep(i,(N-2)/2+2,N) {
      ans2 += 2 * A[i];
    }
  }
  cout << max(ans,ans2) << endl;
  return 0;
}

Measured memory_bytes: 640
W, H, x, y, r = map(int, input().split())
if x <= 0 or y <= 0 or x >= W  or y >= H:
    print("No")
else:
    if 0 <= x-r <= W and 0 <= x+r <= W and 0 <= y-r <= H and 0 <= y+r <= H:
        print("Yes")
    else:
        print("No")


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

using namespace std;

int main() {
	long long n, k;
	cin >> n >> k;
	vector<long long>a(100001,0);
	int c, d;

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

	}

	c = 0;

	while (k - a[c] > 0) {
			k -= a[c];
			c++;
	}
	cout << c << endl;

	return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll cnt[100001]; rep(i, 100001) cnt[i] = 0;
    int A[N]; rep(i, N) cin >> A[i];
    ll acc = 0; rep(i, N){cnt[A[i]]++; acc += A[i];}
    int Q; cin >> Q;
    rep(i, Q){
        int b, c; cin >> b >> c;
        //増分はcnt[b]*(c-b)
        acc += cnt[b]*(c-b);
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << acc << endl;
    }
    return 0;
}

Measured memory_bytes: 4820
package main

import (
	"fmt"
	"strconv"
	"sort"
)

var pattern []string

func f(s string, p string) {
	if len(s) == 0 {
		pattern = append(pattern, p)
		return
	}
	for i := 0; i < len(s); i++ {
		f(s[:i] + s[i+1:], p + string(s[i]))
	}
}

func main() {
	var n int
	fmt.Scanf("%d", &n)

	p, q := "", ""
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		p += strconv.Itoa(x)
	}
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		q += strconv.Itoa(x)
	}

	s := ""
	for i := 1; i <= n; i++ {
		s += strconv.Itoa(i)
	}

	f(s, "")
	sort.Strings(pattern)

	pi, qi := 0, 0
	for i, pat := range pattern {
		if pat == p {
			pi = i
		}
		if pat == q {
			qi = i
		}
	}

	if pi < qi {
		fmt.Println(qi - pi)
	} else {
		fmt.Println(pi - qi)
	}
}


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

int main(){
  int D,T;
  double S;
  cin>>D>>T>>S;
  double t;
 t=D/S;
  if(t<=T)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int N,K;
int main(){
    cin>>N>>K;
    int A[2][N+1];
    for(int i=0;i<N;i++)cin>>A[0][i];
    for(int i=0;i<=N;i++)A[1][i]=0LL;
    for(int k=0;k<min(K,100);k++){
        for(int i=0;i<N;i++){
            A[(k+1)%2][max(0,i-A[k%2][i])]++;
            A[(k+1)%2][min(N,i+A[k%2][i]+1)]--;
        }
        for(int i=1;i<=N;i++)A[(k+1)%2][i]+=A[(k+1)%2][i-1],A[k%2][i-1]=0;
    }
    for(int i=0;i<N;i++)cout<<A[(K<100)?K%2:0][i]<<" \n"[i+1==N];
    return 0;
}

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

const double eps = 1e-8;
const double inf = 1e10;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

struct P {
  double x, y, z;
  P() : x(0), y(0), z(0) {}
  P(double x, double y, double z) : x(x), y(y), z(z) {}
};

P operator + (const P &a, const P &b) {
  return P(a.x+b.x, a.y+b.y, a.z+b.z);
}
P operator - (const P &a, const P &b) {
  return P(a.x-b.x, a.y-b.y, a.z-b.z);
}
P operator * (const P &p, const double &a) {
  return P(p.x*a, p.y*a, p.z*a);
}
P operator / (const P &p, const double &a) {
  return P(p.x/a, p.y/a, p.z/a);
}

double dot(P a, P b) {
  return a.x*b.x + a.y*b.y + a.z*b.z;
}

double norm(P a) {
  return dot(a,a);
}

double abs(P a) {
  return sqrt(norm(a));
}

P project(P s1, P s2, P p) {
  P base = s2 - s1;
  double t = dot(p - s1, base)/norm(base);
  return s1 + base*t;
}

P reflect(P s1, P s2, P p) {
  return p + (project(s1, s2, p) - p)*2.0;
}

double getDistanceLP(P s1, P s2, P p) {
  return abs(project(s1, s2, p) - p);
}

P getQ(P s1, P s2, P p, double r) {
  P m = project(s1, s2, p);
  P base = s2 - s1;
  double x = r*r - norm(m-p);
  if(equals(x, 0.0)) x = 0.0;
  else if(x < 0) return P(inf,inf,inf);
  return m - base * sqrt(x) / abs(base);
}

int main() {
  int N;
  P v;
  vector<P> p;
  vector<double> r;
  while(cin >> N && N) {
    p.resize(N);
    r.resize(N);
    cin >> v.x >> v.y >> v.z;
    for(int i = 0; i < N; ++i) {
      cin >> p[i].x >> p[i].y >> p[i].z >> r[i];
    }
    
    P s, t;
    t = v;
    while(1) {
      double mini = inf;
      int k = -1;
      for(int i = 0; i < N; ++i) {
        P q = getQ(s, t, p[i], r[i]);
        if(q.x == inf) continue;
        if(dot(t-s, q-s) < eps) continue;
        double dist = abs(q - s);
        if(mini > dist) {
          mini = dist;
          k = i;
        }
      }
      if(k == -1) break;
      P q = getQ(s, t, p[k], r[k]);
      t = reflect(p[k], q, s);
      s = q;
    }
    printf("%.4f %.4f %.4f\n", s.x, s.y, s.z);
  }
  return 0;
}

Measured memory_bytes: 1280
from bisect import bisect_right, bisect_left

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

ans = 4*10**8 + 1
x_0 = bisect_right(x, 0)
x_1 = bisect_left(x, 0) - 1

for i in range(N-K+1):
    if i + K -1 >= x_1 and i <= x_0:
        if x[i + K - 1] <= 0:
            ans = min(ans, -x[i])
        elif x[i] >= 0:
            ans = min(ans, x[i + K - 1])
        else:
            ans = min(ans, min(-x[i]*2 + x[i+K-1], -x[i] + x[i+K-1]*2))
print(ans)

Measured memory_bytes: 14564
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[15],k,mx=0,cnt=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]>mx)
		{
			mx=a[i];
		}
	}
	for(int i=0;i<n;i++)
	{
		if(a[i+1]==mx)
		{
			k=i+1;
			break;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(i==k)
		{
			cnt+=a[i]/2;
		}else cnt+=a[i];
	}
	printf("%d",cnt);
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

# まとめて数える方
taba = n // (a + b)
taba_blue = taba * a

# ちょっと余った方
rest = n - taba * (a + b)
if rest <= a:
  haji_blue = rest
else:
  haji_blue = a

print(taba_blue + haji_blue)

Measured memory_bytes: 3064
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret

def geteach(n):
    ret = defaultdict(int)
    for i in range(2, n+1):
        while True:
            if n % i == 0:
                ret[i] += 1
                n //= i
            else:
                break

        if n == 1:
            break

    return ret


def getyaku(n):
    ret = defaultdict(int)

    for i in range(2, n+1):
        fac = geteach(i)
        for k, v in fac.items():
            ret[k] += v

    return ret

def solve():

    n = getN()
    yaku = (getyaku(n))
    # print(yaku)
    nanashi = 0
    yon = 0
    ni = 0
    nishi = 0
    ichisi = 0
    for v in yaku.values():
        if v >= 74:
            nanashi += 1
        if v >= 24:
            nishi += 1
        if v >= 14:
            ichisi += 1
        if v >= 4:
            yon += 1
        if v >= 2:
            ni += 1

    if yon < 2 or yon + ni < 3:
        print(0)
        return
    pat1 = nanashi
    pat2 = nishi * (ni - 1)
    pat3 = ichisi * (yon - 1)
    pat4 = yon * (yon-1) * (ni - 2) // 2

    print(max(pat1, 0) + max(pat2, 0) + max(pat3, 0) + max(pat4, 0))

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 67404
import java.util.Scanner;
 
enum Type{
    SAME,
    A_BIG,
    B_BIG
};
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        int N = scanner.nextInt();
        String TARO,HANAKO;
        int score_TARO = 0,score_HANAKO = 0;
 
        for(int loop = 0; loop < N; loop++){
 
            TARO = scanner.next();
            HANAKO = scanner.next();
 
            switch(compString(TARO,HANAKO)){
            case SAME:
                score_TARO += 1;
                score_HANAKO += 1;
                break;
            case A_BIG:
                score_TARO += 3;
                break;
            case B_BIG:
                score_HANAKO += 3;
                break;
            }
        }
 
        System.out.printf("%d %d\n", score_TARO,score_HANAKO);
    }
 
    //A基準で比較する関数
    public static Type compString(String A,String B){
        int a_index = 0,b_index = 0;
 
        while(a_index < A.length() && b_index < B.length() && A.charAt(a_index) == B.charAt(b_index)){
            a_index++;
            b_index++;
        }
 
        if(a_index < A.length() && b_index < B.length()){
            if(A.charAt(a_index) > B.charAt(b_index)){
                return Type.A_BIG;
            }else{
                return Type.B_BIG;
            }
 
        }else if(a_index < A.length() && b_index == B.length()){
            return Type.A_BIG;
        }else if(a_index == A.length() && b_index < B.length()){
            return Type.B_BIG;
        }else{
            return Type.SAME;
        }
    }
}


Measured memory_bytes: 30996
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


const int MAX = 510000;
const int mod = 998244353;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//mod mでの a の逆元を求める
ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod; 
    if (u < 0) u += mod;
    return u;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    ll n,m,k;
    cin>>n>>m>>k;
    COMinit();
    ll ans = 0;
    for(ll i=0;i<=k;i++){
        ll ret = COM(n-1,i);
        ret *= m;
        ret %= mod;
        ret *= modpow(m-1,n-i-1);
        ret %= mod;
        ans += ret;
        ans %= mod;
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 15616
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

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

ll n, a, b, c;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	cin >> a >> b >> c >> n;
	if(n % 2 == 0)
		cout << a - b << endl;
	else
		cout << b - a << endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve()
{
    int N, M; cin >> N >> M;
    
    vector<int> A; A.reserve(M);
    REP0(i, M) { int a; cin >> a; A.push_back(a); }
    SORT(A);
    
    vector<int> dist2next; dist2next.reserve(M);
    REP0(i, M-1) dist2next.push_back( abs(A[i+1] - A[i]) ); 
    
    SORT(dist2next);
    
    int ans = 0;
    REP0(i, M-N) ans += dist2next[i];

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e6+10;
int n,r,c,m,size,q[N];
pair<int,int> p[N];
int ID(int x,int y){
	if (!x) return y;
	if (y==c) return c+x;
	if (x==r) return c+r+c-y;
	if (!y) return c+r+c+r-x;
	return -1;
}
int Max[N];
#define lc x<<1
#define rc x<<1|1
void change(int x,int l,int r,int p,int v){
	if (l==r) return void(Max[x]=max(Max[x],v));
	int mid=(l+r)>>1;
	if (p>mid) change(rc,mid+1,r,p,v);
		else change(lc,l,mid,p,v);
	Max[x]=max(Max[lc],Max[rc]);
}
int query(int x,int l,int r,int L,int R){
	if (l>=L&&r<=R) return Max[x];
	int mid=(l+r)>>1,ans=0;
	if (L<=mid) ans=max(ans,query(lc,l,mid,L,R));
	if (R>mid) ans=max(ans,query(rc,mid+1,r,L,R));
	return ans;
}
int main()
{
	scanf("%d%d%d",&r,&c,&n);
	for (int i=1;i<=n;i++){
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		int a=ID(x1,y1),b=ID(x2,y2);
		if (a==-1||b==-1) continue;
		if (a>b) swap(a,b);
		p[++m]=make_pair(a,b);
		q[++size]=a;
		q[++size]=b;
	}
	sort(q+1,q+size+1);
	for (int i=1;i<=m;i++){
		p[i].first=lower_bound(q+1,q+size+1,p[i].first)-q;
		p[i].second=lower_bound(q+1,q+size+1,p[i].second)-q;
		change(1,1,size,p[i].first,p[i].second);
	}
	for (int i=1;i<=m;i++)
		if (query(1,1,size,p[i].first,p[i].second)>p[i].second)
			return puts("NO"),0;
	puts("YES");
	return 0;
}

Measured memory_bytes: 10368
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int H, W;
  while (cin >> H >> W){
    if (H == 0 && W == 0) return 0;

    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++) cout << '#';
      cout << endl;
    }
    cout << endl;
  }   

  return 0;
}



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

int main() {
    int N;
    cin>>N;
    bool ans=false;
    for(int i=0;i<26;i++){
        for(int j=0;j<15;j++){
            if(i*4+j*7==N){
                ans=true;
        }
    }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


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

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> X(M);
    for(int i = 0;i < M;i++){
        cin >> X[i];
    }
    if(N >= M){
        cout << 0 << endl;
    }else{
        sort(X.begin(),X.end());
        int S = 0;
        vector<int> Y(M-1);
        for(int i = 0;i < M-1;i++){
            Y[i] = X[i+1] - X[i];
            S += Y[i];
        }
        sort(Y.begin(),Y.end(),greater<int>());
        for(int i = 0;i < N-1;i++){
            S -= Y[i];
        }
        cout << S << endl;
    }
}

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

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

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

    int count=0;
    int aim=1;
    
    for(int i=0; i<n; i++){
        if(a[i]!=aim){
            count++;
        }else{
            aim++;
        }
    }

    if(aim==1){
        count=-1;
    }

    cout<<count<<endl;
}

Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|i| i.parse().ok().unwrap())
        .collect()
}


fn main() {
    let input = read_vec::<usize>();
    let x = input[0];
    let y = input[1];
    let _a = input[2];
    let _b = input[3];
    let _c = input[4];
    let mut p = read_vec::<usize>();
    let mut q = read_vec::<usize>();
    let mut r = read_vec::<usize>();

    p.sort();
    let mut p: Vec<usize> = p.iter().skip(p.len()-x).map(|e| *e).collect();
    q.sort();
    let mut q: Vec<usize> = q.iter().skip(q.len()-y).map(|e| *e).collect();
    r.sort();

    p.append(&mut q);
    p.append(&mut r);
    p.sort();

    let ans: usize = p.iter().rev().take(x+y).sum();

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

Measured memory_bytes: 13864
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int f(int n){
    int s=0;
    while(n>0){
        s+=(n%10);
        n/=10;
    }
    return s;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    repi(i,n){
        if(f(i)>=a&&f(i)<=b)ans+=i;
    }
    cout<<ans<<enl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

int main(void){
  int n ;
  while(cin>>n,n){
    double min_num,min_bmi;
    double h,w;
    int num;
    cin>>min_num>>h>>w;
    h/=100;
    min_bmi = fabs(w / (h * h) - 22);
    for(int i = 0 ; i < n - 1 ; i ++){
      cin>>num>>h>>w;
      h/=100;
    double bmi = fabs(w / (h*h) - 22);
      //cout<<num<<" "<<h<<" "<<w<<" "<<bmi<<endl;
      if(min_bmi > bmi){
        min_num = num;
        min_bmi = bmi;
      }
      //cout<<min_num<<" "<<min_bmi<<":"<<num<<" "<<bmi<<endl;
    }
    cout<<min_num<<endl;
  }
  
}

Measured memory_bytes: 1280
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int            long long int
#define F              first
#define S              second
#define pb             push_back
#define si             set <int>
#define vi             vector <int>
#define pii            pair <int, int>
#define vpi            vector <pii>
#define vpp            vector <pair<int, pii>>
#define mii            map <int, int>
#define mpi            map <pii, int>
#define spi            set <pii>
#define endl           "\n"
#define sz(x)          ((int) x.size())
#define all(p)         p.begin(), p.end()
#define double         long double
#define que_max        priority_queue <int>
#define que_min        priority_queue <int, vi, greater<int>>
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)       for(auto x : a) cout << x << " "; cout << endl
#define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 205;
int g[N][N], n, m, k;

void solve()
{
     for (int i = 1; i < N; i++)
          for (int j = 1; j < N; j++)
               g[i][j] = __gcd(i, j);


     cin >> n;
     int s = 0;
     for (int a = 1; a <= n; a++)
          for (int b = 1; b <= n; b++)
               for (int c = 1; c <= n; c++)
                    s += g[g[a][b]][c];

     cout << s;
}

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

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 4128