akhauriyash/Code-Regression huggingface dataset:
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: i64 = itr.next().unwrap().parse().unwrap();
    let w: i64 = itr.next().unwrap().parse().unwrap();

    let mut ans = 1i64 << 30;
    for i in 0..h - 1 {
        let a = w * (i + 1);
        let rem = h - (i + 1);
        // tate
        let mut b = w / 2 * rem;
        let mut c = (w + 1) / 2 * rem;
        ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
        // 残ったものを半分にする。
        // yoko
        b = rem / 2 * w;
        c = (rem + 1) / 2 * w;
        ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
    }
    for i in 0..w - 1 {
        let a = h * (i + 1);
        let rem = w - (i + 1);
        // tate
        let mut b = h / 2 * rem;
        let mut c = (h + 1) / 2 * rem;
        ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
        // 残ったものを半分にする。
        // yoko
        b = rem / 2 * h;
        c = (rem + 1) / 2 * h;
        ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>

static const int N = 100;

int main(){
  int n, i, j;
  int A[N];
  int count=0;
  int tmp;


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

  for(i=0;i<=n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	count++;
      }
    }
  }
  
  
  for ( i = 0; i < n; i++ ){
    if ( i >= 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  
  printf("%d\n",count);


  return 0;
}

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

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

using namespace std;


int main(void){
	int sum=0;
	rep(i,5){
		int in;
		cin >> in;
		if(in<40) in=40;
		sum+=in;
	}
	cout << sum/5 << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define MAX_N 25
#define NIL -1

struct Node {
  int parent;
  int left;
  int right;
};

Node* N;
int* D;
int* H;
int* B;

int max(int x, int y) {
  if(x>y) return x;
  return y;
}

void print(int i) {
  int deg = (N[i].left != NIL) + (N[i].right != NIL);
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, N[i].parent, B[i], deg, D[i], H[i]);

  if(N[i].parent == NIL) {
    printf("root");
  } else if(deg == 0) {
    printf("leaf");
  } else {
    printf("internal node");
  }
}

void setDepth(int i, int depth) {
  D[i] = depth;
  if(N[i].left != NIL) setDepth(N[i].left, depth+1);
  if(N[i].right != NIL) setDepth(N[i].right, depth+1);
}

int setHeight(int i) {
  int lh = 0;
  int rh = 0;
  if(N[i].left != NIL) {
    lh = setHeight(N[i].left)+1;
  }
  if(N[i].right != NIL) {
    rh = setHeight(N[i].right)+1;
  }
  int h = max(lh, rh);
  H[i] = h;
  return h;
}

int main() {
  N = (Node*)malloc(sizeof(Node)*MAX_N);
  D = (int*)malloc(sizeof(int)*MAX_N);
  H = (int*)malloc(sizeof(int)*MAX_N);
  B = (int*)malloc(sizeof(int)*MAX_N);
  int n, id, left, right;
  cin >> n;

  for(int i=0; i<n; i++) {
    N[i].parent = NIL;
    N[i].left = NIL;
    N[i].right = NIL;
  }

  for(int i=0; i<n; i++) {
    cin >> id >> left >> right;

    N[id].left = left;
    N[id].right = right;
    if(left != NIL) {
      N[left].parent = id;
      B[left] = right;
    }
    if(right != NIL) {
      N[right].parent = id;
      B[right] = left;
    }
  }

  int root;
  for(int i=0; i<n; i++) {
    if(N[i].parent == NIL) {
      root = i;
      break;
    }
  }

  setDepth(root, 0);
  setHeight(root);

  B[root] = -1;

  for(int i=0; i<n; i++) {
    print(i);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using lint = long long;

using namespace std;

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

  int n;
  cin >> n;
  vector<int> s(n);
  lint maxsum = -INFL;
  rep(i, n) cin >> s[i];
  int n1 = n - 1;
  rep1(c, n1 - 1) {
    set<int> alr;
    lint sum = 0;
    for (int nc = 0; nc < n1; nc += c) {
      int a = n1 - nc;
      int b = a - c;
      if (a <= b || b < 0) continue;
      if (alr.find(nc) != alr.end()) break;
      alr.insert(nc);
      if (alr.find(n1 - nc) != alr.end()) break;
      alr.insert(n1 - nc);
      sum += s[nc] + s[n1 - nc];
      maxsum = max(maxsum, sum);
    }
  }
  cout << maxsum << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

int main(){
    ll N, M; 
    cin >> N >> M;
    vector<ll> p(M);
    vector<string> S(M);
    for (int i = 0; i < M; i++) cin >> p[i] >> S[i];

    vector<bool> check(N);
    for (int i = 0; i < N; i++) check[i] = false;

    vector<ll> wrn(N);
    ll cnt = 0, wrnout = 0;

    for (int i = 0; i < M; i++){
        if(S[i]=="AC"){
          check[p[i] - 1] = true;
        }
        else if(S[i]=="WA" && !check[p[i]-1]){
          wrn[p[i]-1]++;
        }
    }

    for (int i = 0; i < N; i++){
      if (check[i]) {
          cnt++;
          wrnout += wrn[i];
      }
    }
    cout << cnt << " " << wrnout << endl;
    return 0;
}

Measured memory_bytes: 7912
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()

	ans := min(n%k, k-n%k)
	puts(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 

 
 
const int INF = 10000000;

int main(){
	int m,n;
	string s;
	while(cin>>m>>n && m > 0 && n > 0){
		vi v(m, 0);
		rep(i, m) v[i] = i + 1;
		auto it = v.begin();
		bool  f;
		for(int i = 1; i <= n; i++){
			cin>>s;
			f = true;
			if(i % 15 == 0){
				if(s != "FizzBuzz") f = false;
			}
			else if(i % 3 == 0){
				if(s != "Fizz") f = false;
			}
			else if(i % 5 == 0){
				if(s != "Buzz") f = false;
			}
			else if(i != atoi(s.c_str())) f = false;
			//if(!f) cout<<s<<" "<<i<<endl;
			if(v.size() != 1){
				if(f) it++;
				else it = v.erase(it);
				if(it == v.end()) it = v.begin();
			}
		}
		for(it = v.begin(); it != v.end(); it++){
			if(it != v.begin()) cout<<" ";
			cout<<*it;
		}
		cout<<endl;
	}
	
}

Measured memory_bytes: 3128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class DModSum {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        ll res = (ll) n * (n - 1) / 2;
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    DModSum solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
int m[2000][2000];
main(){
	int N,K;
	for(scanf("%d%d",&N,&K);N--;){
		int x,y;char c;
		scanf("%d%d%*c%c",&x,&y,&c);
		if(c=='W'){x+=K;}
		x%=2*K;
		y%=2*K;
		for(int i=0;i<2;++i){
			int X=(x+K)%(2*K),Y=(y+K)%(2*K);
			++m[y][x];
			--m[y][X];
			--m[Y][x];
			++m[Y][X];
			if(x>=K){
				++m[y][0];
				--m[Y][0];
			}
			if(y>=K){
				++m[0][x];
				--m[0][X];
			}
			if(x>=K&&y>=K){
				++m[0][0];
			}
			x=X;
			y=Y;
		}
	}
	for(int y=0;y<2*K;++y){
		for(int x=1;x<K;++x){
			m[y][x]+=m[y][x-1];
		}
	}
	int z=0;
	for(int x=0;x<K;++x){
		for(int y=0;y<2*K;++y){
			if(y){
				m[y][x]+=m[y-1][x];
			}
			if(m[y][x]>z){
				z=m[y][x];
			}
		}
	}
	printf("%d",z);
}


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

int main() {
	
	int r;cin>>r;
	
	if(r<1200) cout << "ABC" <<endl;
	else if(r<2800) cout << "ARC" <<endl;
	else cout <<"AGC" <<endl;
	
	
}

Measured memory_bytes: 256
n = int(input())
s = input()

l = [n] * 10
r = [-1] * 10

for i in range(n):
    if l[int(s[i])] == n:
        l[int(s[i])] = i
    r[int(s[i])] = i

answer = 0
for a in range(10):
    for c in range(10):
        if r[c] - l[a] <= 1:
            continue
        str = s[l[a]+1:r[c]]
        answer += len(set(str))
print(answer)


Measured memory_bytes: 3188
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

ll gcd(ll a, ll b)
{
  if (a % b == 0)
  {
    return (b);
  }
  else
  {
    return (gcd(b, a % b));
  }
}

ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

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

  cout << lcm(a, b) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
  int main ()
  {
   long long n,k,sum=0;long long arr[200005];
   cin>>n>>k;
   for(int i=0 ;i<n;i++)
   {
       cin>>arr[i];

   }sort(arr,arr+n);
   if(k>=n)
   {
       cout<<0;
   }
    else
    {

n-=k;

   for(int j=0;j<n;j++)
   {
       sum+=arr[j];

   }cout<<sum;
    }
      return 0;
  }


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

template <typename T, typename U>
T power(T x, U y)
{
    T ret;
    ret = 1;
    while (y > 0)
    {
        if ((y & 1) > 0)
        {
            ret *= x;
        }
        x *= x;
        y >>= 1;
    }
    return ret;
}

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

    vector<vector<long long>> dp(10, vector<long long>(10, 0));
    for (long long i = 1; i <= 9; i++)
    {
        for (long long j = 1; j <= 9; j++)
        {
            long long n = 0;
            for (long long k = 1; k < 10; k++)
            {
                long long offset = i * power(10, k) + j;
                if (offset > N)
                {
                    break;
                }
                long long l = 0;
                long long r = 0;
                for (long long m = 0; m < k - 1; m++)
                {
                    r *= 10;
                    r += 9;
                }
                if (offset + 10 * r <= N)
                {
                    n += r + 1;
                    continue;
                }
                while (r - l > 1)
                {
                    long long c = (l + r) / 2;
                    if (offset + 10 * c > N)
                    {
                        r = c;
                    }
                    else
                    {
                        l = c;
                    }
                }
                n += r;
            }
            if (i == j)
            {
                if (i <= N)
                {
                    n++;
                }
            }
            dp[i][j] = n;
        }
    }
    long long ans = 0;
    for (long long i = 1; i < 10; i++)
    {
        for (long long j = 1; j < 10; j++)
        {
            // if (dp[i][j] * dp[j][i])
            // {
            //     cout << i << " " << j << " " << dp[i][j] * dp[j][i] << endl;
            // }
            ans += dp[i][j] * dp[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  string s;
  cin >> n >> s;
  vector<int>r(n+1);
  vector<int>g(n+1);
  vector<int>b(n+1);
  r[0]=g[0]=b[0]=0;
  
  rep(i,n){
    if(s[i]=='R'){
      r[i+1]=r[i]+1;
      g[i+1]=g[i];
      b[i+1]=b[i];
    }
    if(s[i]=='G'){
      r[i+1]=r[i];
      g[i+1]=g[i]+1;
      b[i+1]=b[i];
    }
    if(s[i]=='B'){
      r[i+1]=r[i];
      g[i+1]=g[i];
      b[i+1]=b[i]+1;
    }
  }
  ll ans=0;
  rep(i,n-2){
    for(int k=i+2;k<n;k++){
      if((i+k)%2==0 && s[i]!=s[(i+k)/2] && s[(i+k)/2]!=s[k] && s[k]!=s[i])ans--;
        if(s[i]=='R' && s[k]=='G'){
          ans+=b[k]-b[i+1];
        }
        if(s[i]=='G' && s[k]=='B'){
          ans+=r[k]-r[i+1];
        }
        if(s[i]=='B' && s[k]=='R'){
          ans+=g[k]-g[i+1];
        }
        if(s[i]=='R' && s[k]=='B'){
          ans+=g[k]-g[i];
        }
        if(s[i]=='G' && s[k]=='R'){
          ans+=b[k]-b[i+1];
        }
        if(s[i]=='B' && s[k]=='G'){
          ans+=r[k]-r[i+1];
        }
      
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  int A[N],B,C[N],ans;
  ans=0;
  int i;
  for(i=0;i<N;i++)
    cin >> A[i];
  for(i=0;i<N;i++){
    cin >> B;
    ans+=B;
  }
  for(i=0;i<N;i++)
    cin >> C[i];
  for(i=0;i<N-1;i++){
    if(A[i+1]==A[i]+1){
      ans+=C[A[i]-1];
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  string T; cin >> T;
  int ans = 0;
  if (T[0] != 'P') ans ++;
  rep(i, T.length()-1) {
    if(T[i+1] != 'P'){
      ans ++;
      if(T[i] == 'P'){
        ans ++;
      }
    }
  }

  rep(i,T.length()){
    if(T[i] == '?'){
      T[i] = 'D';
    }
  }
  cout << T << endl;

}

Measured memory_bytes: 3772
s=input()
t=input()
f=0
if len(t)-len(s)==1:
    for i in range(len(s)):
        if s[i]!=t[i]:
            f=1
            break
    if f==0:
        print('Yes')
        #print(t[len(s)])
    else:
        print('No')
else:
    print('No')



Measured memory_bytes: 8980
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N,M;
    for(;;){
        scanf("%d",&N);
        vector<P> mats;
        if(N==0) break;
        int h,r;
        for(int i=0;i<N;i++){
            scanf("%d%d",&h,&r);
            mats.push_back(P(h,-r));
        }
        scanf("%d",&M);
        for(int i=0;i<M;i++){
            scanf("%d%d",&h,&r);
            mats.push_back(P(h,-r));
        }
        sort(ALL(mats));
        vector<int> dp(N+M,INT_MAX);
        for(int i=0;i<N+M;i++){
            int now=-mats[i].second;
            *lower_bound(ALL(dp),now)=now;
        }
        printf("%d\n",distance(dp.begin(),lower_bound(ALL(dp),INT_MAX)));
    }
}

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

int main(){
  bool seg[11][7]={ {0,1,1,1,1,1,1},
                    {0,0,0,0,1,1,0},
		    {1,0,1,1,0,1,1},
		    {1,0,0,1,1,1,1},
		    {1,1,0,0,1,1,0},
		    {1,1,0,1,1,0,1},
		    {1,1,1,1,1,0,1},
		    {0,1,0,0,1,1,1},
		    {1,1,1,1,1,1,1},
		    {1,1,0,1,1,1,1},
		    {0,0,0,0,0,0,0} };
  int n,prv,tmp;

  while(1){
    cin >> n;
    if(n<0)break;

    prv = 10;
    for(int i=0;i<n;i++){
      cin >> tmp;
      for(int j=0;j<7;j++){
	if(seg[prv][j] == seg[tmp][j])cout << 0;
	else cout << 1;
      }
      cout << endl;
      prv = tmp;
    }
  }
}

Measured memory_bytes: 0
N = int(input())
if N < 2:
  print(N)
elif 2<=N<4:
  print(2)
elif 4<=N<8:
  print(4)
elif 8<=N<16:
  print(8)
elif 16<=N<32:
  print(16)
elif 32<=N<64:
  print(32)
elif 64<=N:
  print(64)

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

int main(){
    int N, L[100], sum = 0;

    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> L[i];

    sort(L, L + N);
    for(int j = 0; j < N - 1; j++)
        sum += L[j];
    
    if(L[N - 1] < sum)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[int(input()) for _ in range(n)]
x=sum(s)
if x%10!=0:
    print(x)
else:
    s.sort()
    for i in range(n):
        if s[i]%10!=0:
            x-=s[i]
            break
    if x%10==0:
        print(0)
    else:
        print(x)

Measured memory_bytes: 3060
//
// Created by moono on 2018/10/27.
//

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


int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;


    //
    int max_x = -200, x;
    for (int i = 0; i < N; ++i) {
        cin >> x;
        if(max_x < x) max_x = x;
    }

    int min_y = 101, y;
    for (int i = 0; i < M; ++i) {
        cin >> y;
        if(min_y > y) min_y = y;
    }

//    cout << "max_x " << max_x << ", min_y " << min_y << endl;
    if(max_x < min_y && X < min_y && min_y <= Y){
        cout << "No War" << endl;
    }else{
        cout << "War" << endl;
    }

    //


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

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

int main() {
	int h, w; CI h >> w;
	char s[50][50] = {}; REP(i, h)REP(j, w)CI s[i][j];

	REP(i, h) {
		REP(j, w) {
			if (s[i][j] == '#')continue;
			int ans = 0;
			REP(k, 8) {
				if (i + dy[k]<0 || h <= i + dy[k]) continue;
				if (j + dx[k]<0 || w <= j + dx[k])continue;
				if (s[i + dy[k]][j + dx[k]] == '#')ans++;
			}
			s[i][j] = char(ans + '0');
		}
	}
	REP(i, h)REP(j, w) { CO s[i][j]; if (j == w - 1)cout << endl; }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<string, int> P;


int main(){
	int n;
	vector<pair<P,int>> v;
	cin >> n;
	for(int i=0;i<n;i++){
		string s;
		int a;
		cin >> s >> a;
		v.push_back({make_pair(s, -a),i});
	}
	sort(v.begin(),v.end());

	 for (int i = 0; i < n; i++) {
		printf("%d\n", v[i].second+1);
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  float D;
  int T;
  float S;

  scanf("%f", &D);
  scanf("%d", &T);
  scanf("%f", &S);

float Z;

Z = D/S;

if(Z <= T){
  printf("Yes");
}else if(Z > T){
  printf("No");
}

    return 0;
}


Measured memory_bytes: 1708
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
maxv=a[1]-a[0]
minv=a[0]
for j in range(1,n):
    maxv=max(maxv,a[j]-minv)
    minv=min(minv,a[j])
print(maxv)
    


Measured memory_bytes: 13592
import java.util.*;
	public class Main{
    public static void main(String[] args){
    	
      Scanner sc= new Scanner(System.in);
      
      int N =sc.nextInt();
      int bit = 0;
      
      for(int i=0; i<N; i++){
      	bit |= sc.nextInt();
      }
       System.out.println(Integer.numberOfTrailingZeros(bit));
    }
    }


Measured memory_bytes: 21588
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>
#include <cmath>

using namespace std;

int main( void ) {

    int N, K;
    cin >> N >> K;

    vector<int> snake(N);

    for ( int i = 0; i < N; i++ ) {
        cin >> snake.at(i);
    }

    sort(snake.begin(), snake.end(), greater<int>());

    int res = 0;
    for ( int i = 0; i < K; i++ ) {
        res += snake.at(i);
    }

    cout << res << endl;
    

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define ll long long int
#define mod 1000000007
#define w(t) int t;	cin>>t while(t--)
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
#define loop(i, k, n) for(ll i=k; i<n; i+=1)
#define loop2(i, k, n) for(ll i=k; i>=n; i--)

const ll inf = 1e18;

void take_fileIO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  return;
}

void solve(){
  ll n; cin>>n;
  ll arr[n][3];

  loop(i, 0, n){
    loop(j, 0, 3){
      cin>>arr[i][j];
    }
  }

  ll dp[n][3];
  memset(dp, 0, sizeof(dp));
  //initializing the dp for first row.
  dp[0][0] = arr[0][0], dp[0][1] = arr[0][1], dp[0][2] = arr[0][2];

  loop(i, 1, n){
    loop(j, 0, 3){
      loop(k, 0, 3){
        if(j!=k){
          dp[i][j] = max(dp[i][j], dp[i-1][k] +  arr[i][j]);
        }
      }
    }
  }

  ll final_ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
  cout<<final_ans<<endl;
  return;
}

int main(){

  fastIO;
  // take_fileIO();

  solve();

  return 0;
}

/*
  Here we can also optimize the space by just taking the n=2 for dp array
  because here we only need to consider the previous row's values only.
*/

Measured memory_bytes: 4992
#include<iostream>
#include<string>
using namespace std;
int a[5][4][11];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int b,f,r,v;
		cin>>b>>f>>r>>v;
		a[b][f][r]+=v;
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout<<" "<<a[i+1][j+1][k+1];
			}cout<<endl;
		}
		for(int j=0;j<19;j++){
			cout<<"#";
		}
		cout<<"#"<<endl;
	}
	for(int i=0;i<1;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout<<" "<<a[i+4][j+1][k+1];
			}cout<<endl;
		}
	}
}



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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Rest[] arr = new Rest[n];
		for (int i = 0; i < n; i++) {
			Rest r = new Rest();
			r.s = sc.next();
			r.p = sc.nextInt();
			r.i = i + 1;
			arr[i] = r;
		}
		sc.close();

		Arrays.parallelSort(arr);

		for (int i = 0; i < arr.length; i++) {
			System.out.println(arr[i].i);
		}
	}

	static class Rest implements Comparable<Rest> {
		String s;
		int p, i;

		public int compareTo(Rest o) {
			if (s.equals(o.s)) {
				return o.p - p;
			} else {
				return s.compareTo(o.s);
			}
		}
	}
}


Measured memory_bytes: 23764
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
#define int long long
using namespace std;
const int mod=1e9+7;
int n,m,fa[200005],sum[200005];
int fin(int x)
{
	if(fa[x]==x)return x;
	else return fa[x]=fin(fa[x]);
}
set<pair<int,int> >s;
signed main()
{
	IO;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		sum[i]=1;
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;
		cin>>x>>y;
		int xx=fin(x),yy=fin(y);
		if(xx==yy)continue;
		if(sum[xx]<sum[yy])
		{
			sum[yy]+=sum[xx];
			fa[xx]=yy;
		}
		else
		{
			sum[xx]+=sum[yy];
			fa[yy]=xx;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(fa[i]==i)
		{
			ans=max(ans,sum[i]);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 6740
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll a[200050],cnt[200050];
int main()
{
	ll n,ans=0;
	cin >> n;
	for(ll i=0;i<n;i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}
	for(ll i=1;i<=n;i++)
	{
		ans+=cnt[i]*(cnt[i]-1);
	}
	ans/=2;
	for(ll i=0;i<n;i++)
	{
		cout<<min(ans,(ans-cnt[a[i]]+1))<<"\n";
	}
	return 0;
} 

Measured memory_bytes: 4736
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++){
			h[i] = sc.nextInt();
		}
		sc.close();

		// db[i] = iマス目にたどり着くための最小コスト
		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0; //最初のマスは0コスト
		// 2つ目のマスは、1つ前から移動するパターンのみ
		dp[1] = Math.abs(h[1] - h[0]); // Math.aps()は絶対値を返す
		// 3マス目以降は、1マス前,2マス前,...kマス前までの複数パターンの移動がある
		for(int i=2;i<n;i++){
			int l = Math.min(i, k);
			for(int j=1;j<=l;j++){
				// 1マス前,2マス前,...kマス前までの最小値を求める
				dp[i] = Math.min(dp[i], dp[i-j] + Math.abs(h[i] - h[i-j]));
			}
		}
		// 最後のマスに到達するための必要数を出力する
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 50924
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

ll sum(ll x){
    return x*(x+1)/2;
}

int main(){
    ll n; cin >> n;
    ll ans = 0;
    rep2(i,n+1){
        ans += i*sum(n/i);
    }
    cout << ans << endl;
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


ll n;
//ll a[SZ];
//ll b[SZ];
vector <pii> adj[SZ];
ll dis[SZ];

void dfs(ll u, ll p, ll d) {
    dis[u] = dis[p] + d;

    for(auto e: adj[u]) {
        if(e.F == p) continue;

        dfs(e.F, u, e.S);
    }
}

int main() {
    ll cs = 0, tc = 1, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0, t = 0;
//    ll a, b, d;
    string s, s1, s2;

    cin1(n);
    for1(i, n-1) {
        cin3(x, y, z);
        adj[x].pb({y, z});
        adj[y].pb({x, z});
    }

    dfs(1, 0, 0);

    for1(i, n) cot1(dis[i]%2);

    return 0;
}



Measured memory_bytes: 20364
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll a,b;
cin >>a >> b;
rep(i,a + 1){
    if(2 * i + 4 * (a - i) == b){
        cout << "Yes" << endl;
        return 0;
    }
}
cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

vector <int> edges[200005];
int depth[200005];

int dfs(int cur, int par, int d) {
    depth[cur] = d;

    int mx = d;
    for (int i : edges[cur]) {
        if (i == par) continue;
        mx = max(mx, dfs(i, cur, d + 1));
    }

    return mx;
}

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

    int n;
    cin >> n;

    for (int i = 1; i < n; i++) {
        int l, r;
        cin >> l >> r;
        edges[r].push_back(l);
        edges[l].push_back(r);
    }

    int mx = dfs(1, 0, 1);

    int idx;
    for (int i = 1; i <= n; i++) {
        if (depth[i] == mx) {
            idx = i;
        }
    }

    int d = dfs(idx, 0, 1);

    if ((d + 1) % 3 == 0) {
        cout << "Second\n";
    } else {
        cout << "First\n";
    }

    return 0;
}

Measured memory_bytes: 24448
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double x=Math.PI;
		double dbArea = 0;
		double dblongth = 0;

		dbArea = r*r*x;
		dblongth = 2*r*x;
		System.out.printf("%.6f %.6f%n",dbArea,dblongth);
		//System.out.printf("%d %d %.7f%n",d,r,f);
	}
}

Measured memory_bytes: 28448
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n, a, b;
	cin >> n >> a >> b;
	REP1(i, n){
		tmp = 0;
		string s = to_string(i);
		REP(j, s.size()) tmp += s[j] - '0';
		if(tmp >= a && tmp <= b) ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(snip_i, n) cin >> h.at(snip_i);
  int ans = 0;
  while(1){
    vector<int> nx = h;
    int add = 0;
    rep(i, n){
      if(h.at(i) > 0){
        if(i == 0 || h.at(i-1) == 0){
          add++;
        }
        nx.at(i)--;
      }
    }
    if(add == 0){
      cout << ans << endl;
      return 0;
    }else{
      ans += add;
    }
    h = nx;
  }
  return 0;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
d = dict()
for i in range(n):
    d[i + 1] = 0
for i in range(q):
    d[int(input())] += 1
for i in range(n):
    print("YNeos"[(q - k) >= d[i + 1]::2])

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

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

using namespace std;


int main() {

    ll tmp[9];
    ll sum = 0;
    string ans = "Yes";


    rep(i,9){
        cin >> tmp[i];
        sum += tmp[i];
    }
    if(tmp[0] + tmp[4] + tmp[8] != tmp[2] + tmp[4] + tmp[6]) ans = "No";
    if(tmp[0] + tmp[4] + tmp[8] != tmp[0] + tmp[5] + tmp[7]) ans = "No";
    if(tmp[0] + tmp[4] + tmp[8] != tmp[1] + tmp[3] + tmp[8]) ans = "No";
    if(tmp[0] + tmp[4] + tmp[8] != tmp[1] + tmp[5] + tmp[6]) ans = "No";
    if(tmp[0] + tmp[4] + tmp[8] != tmp[2] + tmp[3] + tmp[7]) ans = "No";


    cout << ans;
    return 0;
}











Measured memory_bytes: 3624
#include <cstdio>
#define ll long long
int n, a, b, h[100005];
bool ok(ll T)
{
	ll sum = 0;
	
	for (int i = 1; i <= n; i++) {
		ll L = 0, R = T;
		ll ret = -1;
		while (L <= R) {
			ll mid = (L + R) / 2;
			if ((ll)h[i] - mid*(ll)a - (T - mid)*(ll)b <= 0) {
				ret = mid, R = mid - 1;
			}
			else L = mid + 1;
		}
		if (ret == -1)return false;
		sum += ret;
	}
	
	/*
	for (int i = 1; i <= n; i++) {
		ll var = (h[i] - (ll)b*T);
		if (var <= 0)continue;
		var = (ll)(var + a - b - 1) / (ll)(a - b);
		sum += var;	
	}
	*/

	return (sum <= T);
}
ll find()
{
	ll L = 1, R = 2 * 1e9 + 1;
	ll ret = -1;
	while (L <= R) {
		ll mid = (L + R) / 2;
		if (ok(mid))ret = mid, R = mid - 1;
		else L = mid + 1;
	}
	return ret;
}
int main() {
	scanf("%d %d %d", &n, &a, &b);
	for (int i = 1; i <= n; i++)scanf("%d", &h[i]);
	ll ans = find();
	printf("%I64d", ans);
}

Measured memory_bytes: 512
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 M = 0;
	SINT32 C = 0;

	cin >> N;
	cin >> M;
	cin >> C;

	if ((N <= C) && (M >= C)) {
		cout << "Yes" << endl;
	} else if ((M <= C) && (N >= C)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

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

n,m = I()
a =[l() for _ in range(n)]

a.sort()
i = 0
while m != 0:
    if a[i][1] >= m :
        ans += m*a[i][0]
        break
    else:
        ans += a[i][0]*a[i][1]
        m -= a[i][1]
        i += 1

print(ans)


Measured memory_bytes: 28456
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll>Q;

struct edge{
    int to;
    ll coin;
    ll time;
};

vector<edge>g[60];

ll dist[60][2510];
P state[60];

int main(void){
    int n,m,s;
    cin>>n>>m>>s;
    for(int i=0;i<m;i++){
        int u,v;
        ll a,b;
        cin>>u>>v>>a>>b;
        u--;
        v--;
        edge e;
        e.to =v;
        e.coin=a;
        e.time=b;
        g[u].push_back(e);
        e.to=u;
        g[v].push_back(e);
    }
    for(int i=0;i<n;i++){
        ll c,d;
        cin>>c>>d;
        state[i]=P(c,d);
    }
    for(int i=0;i<60;i++){
        for(int j=0;j<2510;j++){
            dist[i][j]=(ll)INF;
        }
    }
    queue<P>que;
    if(s>=2500)s=2500;
    que.push(P(0,s));
    dist[0][s]=0;
    while(!que.empty()){
        P p=que.front();
        que.pop();
        ll now = p.first;
        ll Coin = p.second;
        //cout<<now<<" "<<Coin<<endl;
        for(int i=0;i<g[now].size();i++){
            int next = g[now][i].to;
            ll c=g[now][i].time;
            int coi = g[now][i].coin;
            if(Coin>=2500){
                if(dist[next][2500]>dist[now][Coin]+c){
                    dist[next][2500]=dist[now][Coin]+c;
                    que.push(P(next,2500));
                    continue;
                }
            }
            if(Coin>=coi){
                if(dist[next][Coin-coi]>dist[now][Coin]+c){
                    dist[next][Coin-coi]=dist[now][Coin]+c;
                    que.push(P(next,Coin-coi));
                }
            }
            ll co =state[now].first;
            ll tim =state[now].second;
            ll d = dist[now][Coin];
            for(ll t=1;;t++){
                ll nd = d+tim*t;
                ll nc = Coin+co*t;
                if(nc>=2500){
                    if(dist[now][2500]>nd){
                        dist[now][2500]=nd;
                        que.push(P(now,2500));
                    }
                    break;
                }
                if(dist[now][nc]>nd){
                    dist[now][nc]=nd;
                    que.push(P(now,nc));
                }
            }
        }
    }
    for(ll i=1;i<n;i++){
        ll ans = (ll)INF;
        for(ll j=0;j<=2500;j++){
            ans = min(ans,dist[i][j]);
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

        int n;cin>>n;
        int a[n+1];
        a[n]=INT_MAX;
        for(int i=0;i<n;i++)cin>>a[i];
        int l=0,mx=0;
        for(int i=1;i<=n;i++)
        if(a[i]>a[i-1])
        {
            mx=max(mx,i-l-1);
            l=i;
        }
        cout<<mx;

    return 0;
}


Measured memory_bytes: 640
from heapq import heappush, heappop

s, r = map(int, input().split())
edges = [[] for _ in range(s)]
for _ in range(r):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    edges[u].append((v, w))
    edges[v].append((u, w))

a, b, q = map(int, input().split())
a -= 1
b -= 1


def dijkstra(start):
    INF = 10 ** 20
    dist = [INF] * s
    dist[start] = 0
    parents = [[] for _ in range(s)]
    que = []
    heappush(que, (0, start))
    while que:
        score, node = heappop(que)
        for to, w in edges[node]:
            if dist[to] > score + w:
                dist[to] = score + w
                parents[to] = {node}
                heappush(que, (score + w, to))
            elif dist[to] == score + w:
                parents[to].add(node)
    return dist, parents


def on_shortest_path(c, d, mem):
    if c == d:return True
    if d in mem:return False
    mem.add(d)
    if dist_from_a[c] >= dist_from_a[d]:return False
    for parent in parents[d]:
        if on_shortest_path(c, parent, mem):return True
    return False


dist_from_a, parents = dijkstra(a)
dist_from_b, _ = dijkstra(b)
shortest = dist_from_a[b]
for _ in range(q):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if dist_from_a[c] + dist_from_b[c] == shortest and \
       dist_from_a[d] + dist_from_b[d] == shortest and \
       on_shortest_path(c, d, set()):
        print("Yes")
    else:
        print("No")




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

int main() {
  int n, u, k, v;
  cin >> n;

  vector<vector<int>> G(n, vector<int>(n, 0));
  
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--;
      G.at(u).at(v) = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j) cout << ' ';
      cout << G.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 3192