akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int BinarySerch(int left, int right, int t, vector<int> S)
{
	while (left < right)
	{
		//中央の要素を調べる
		int mid = (left + right) / 2;

		//目的のキーと中央のキーが一致すれば終了
		if (t == S.at(mid))
		{
			return 1;
		}
		//小さければ前半を、大きければ後半を範囲にして繰り返し
		else if (t < S.at(mid))
		{
			right = mid;
		}
		else
		{
			left = mid + 1;
		}
	}
	return 0;
}
int main()
{
	int n, q;
	cin >> n;
	vector<int> S(n);

	for (int i = 0; i < n; i++)
	{
		cin >> S.at(i);
	}
	cin >> q;

	int cnt = 0;

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

		cnt += BinarySerch(left, right, t, S);
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3520
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[][] arr = new int[M][2];
        for (int i = 0; i < M; i++) {
            arr[i][0] = scanner.nextInt();
            arr[i][1] = scanner.nextInt();
        }
        Arrays.sort(arr, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1] - o2[1];
            }
        });
        int latest = 0;
        int cnt = 0;
        for (int i = 0; i < M; i++) {
            if (arr[i][0] >= latest) {
                latest = arr[i][1];
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 91552
#include <cstdio>
#include <cstdlib>

struct Node {
    int key;
    Node *parent, *left, *right;
};
Node *nil, *root;

void Insert(int key)
{
    Node *x = root;
    Node *y = nil;
    Node *z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->left = nil;
    z->right = nil;
    while (x != nil) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;

    if (y == nil) {
        root = z;
    } else if (z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

bool Find(int key)
{
    if (root == nil) {
        return false;
    }
    Node *x = root;
    while (x != nil) {
        if (x->key == key) {
            return true;
        }
        if (x->key < key) {
            x = x->right;
        } else {
            x = x->left;
        }
    }
    return false;
}

void PrintPreorder(Node *node)
{
    if (node != nil) {
        fprintf(stdout, " %d", node->key);
        PrintPreorder(node->left);
        PrintPreorder(node->right);
    }
}

void PrintInorder(Node *node)
{
    if (node != nil) {
        PrintInorder(node->left);
        fprintf(stdout, " %d", node->key);
        PrintInorder(node->right);
    }
}

int main(int argc, char *argv[])
{
    int n, key;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        char inst[32];
        scanf("%s", inst);

        if (inst[0] == 'i') {
            scanf("%d", &key);
            Insert(key);
        } else if (inst[0] == 'p') {
            PrintInorder(root);
            fprintf(stdout, "\n");
            PrintPreorder(root);
            fprintf(stdout, "\n");
        } else if (inst[0] == 'f') {
            scanf("%d", &key);
            if (Find(key)) {
                fprintf(stdout, "yes\n");
            } else {
                fprintf(stdout, "no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 21320
x,y = map(int,input().split())
if x*y >= 0:
    if x == 0:
        if y < 0:
            print(1-y)
        else:
            print(y)
    elif y == 0:
        if x > 0:
            print(1+x)
        else:
            print(-x)
    elif x > y:
        print(2+x-y)
    else:
        print(y-x)
else:
    if x >= -y:
        print(1+x+y)
    else:
        print(1-x-y)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,area1,area2;
	cin>>a>>b>>c>>d;
	area1=a*b;
	area2=c*d;
	if(area1>area2){
	cout<<area1;
	}
	else if(area2>area1){
		cout<<area2;
	}
	else{
		cout<<area1;
	}
	}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++)
		{
			int x = sc.nextInt(),
				y = sc.nextInt(),
				w = sc.nextInt(),
				h = sc.nextInt();
			int m = sc.nextInt();
			int count = 0;
			for (int j = 0; j < m; j++)
			{
				int catX = sc.nextInt(),
					catY = sc.nextInt();
				if (catX < x || catY < y || x + w < catX || y + h < catY)
					continue;
				count++;
			}
			System.out.println(count);
		}
	}
}

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

void ConfirmBomb(vector<string> vec, int column, int row, int maxcolumn, int maxrow, int &bombCount)
{
  //範囲を確認してからボムかどうかを確認する
  if((column < 0) || (column == maxcolumn))
  {
    return;
  }
  if((row < 0) || (row == maxrow))
  {
    return;
  }
  if(vec[column].at(row) == '#')
  {
    bombCount++;
  }
}
  
string CountBomb(vector<string> vec, int column, int row, int maxcolumn, int maxrow)
{
  //#の場合は＃を返す
  if(vec[column].at(row) == '#')
  {
    return "#";
  }
  
  int BombCount = 0;
  //上の行を確認
  for(int i = -1; i < 2; i ++)
  {
    for(int j = -1; j < 2; j ++)
    {
      ConfirmBomb(vec, column + i, row + j, maxcolumn, maxrow, BombCount);
    }
  }
  return to_string(BombCount);
}
 
int main() {
  int h, w;
  vector<string> inVec, outVec;
  
  cin >> h >> w;
  for(int i = 0; i < h; i++)
  {
    string temp;
    cin >> temp;
    inVec.push_back(temp);
    outVec.push_back(temp);
  }
  
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      outVec[i].at(j) = CountBomb(inVec, i, j, h, w).at(0);
    }
  }
  
  for(int i = 0; i < h; i++)
  {
    cout << outVec[i] << endl;
  }
}

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

int main() {
  int a,b,k;cin>>a>>b>>k;
  if(b-a+1>2*k){
    for(int i=a;i<a+k;i++)cout<<i<<endl;
    for(int i=b-k+1;i<=b;i++)cout<<i<<endl;
  }
  else {
    for(int i=a;i<=b;i++)cout<<i<<endl;
  }
}

Measured memory_bytes: 3644
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def permutation(n, x, mod=10**9+7):
    # nPx 順列　ex) permutaion(5, 2) = 20
    tmp = 1
    for i in range(n, n-x, -1):
        tmp = (tmp * i) % mod
    return tmp

N, K = lr()
edges = [[] for _ in range(N+1)]
MOD = 10 ** 9 + 7

for _ in range(N-1):
    a, b = lr()
    edges[a].append(b)
    edges[b].append(a)

parent = [0] * (N+1)
stack = [1] # 1の頂点から
while stack:
    node = stack.pop()
    for x in edges[node]:
        if x == parent[node]:
            continue
        parent[x] = node
        stack.append(x)

answer = K
stack = [1]
while stack:
    node = stack.pop()
    if parent[node] == 0:
        answer *= permutation(K-1, len(edges[node]))
    else:
        answer *= permutation(K-2, len(edges[node])-1)
    for next in edges[node]:
        if next == parent[node]:
            continue
        elif len(edges[next]) >= 2:
            stack.append(next)
    answer %= MOD

print(answer)
# 48

Measured memory_bytes: 65456
#include <iostream>
using namespace std;
int main() {
  signed int x, y;
  unsigned int W, H, r, hantei;
  cin >> W >> H >> x >> y >> r;
  signed int top = y + r;
  signed int right = x + r;
  signed int bottom = y - r;
  signed int left = x - r;

  if(top > H || right > W || bottom < 0 || left < 0){
    cout << "No\n";
  } else{
    cout << "Yes\n";
  }
}

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


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

int main(void){
    int n;
    cin>>n;
    vector<int>h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    int ans = 0;
    for(int i=0;i<n;){
        int j=i;
        while(true){
            if(i==n-1)break;
            if(h[i]>=h[i+1])i++;
            else {
                break;
            }
        }
        ans = max(ans,i-j);
        i++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;

fn to_str(sgn: i64) -> String {
    return (if sgn == 1 { "+" } else { "-" }).to_string();
}

fn main() {
    input! {
        ABCD: String,
    }

    let A: i64 = ABCD[0..1].parse().unwrap();
    let B: i64 = ABCD[1..2].parse().unwrap();
    let C: i64 = ABCD[2..3].parse().unwrap();
    let D: i64 = ABCD[3..4].parse().unwrap();

    let pm: Vec<i64> = vec![1, -1];

    for &sgn1 in pm.iter() {
        for &sgn2 in pm.iter() {
            for &sgn3 in pm.iter() {
                let ans = A + sgn1 * B + sgn2 * C + sgn3 * D;

                if ans == 7 {
                    println!(
                        "{}{}{}{}{}{}{}=7",
                        A,
                        to_str(sgn1),
                        B,
                        to_str(sgn2),
                        C,
                        to_str(sgn3),
                        D
                    );
                    return;
                }
            }
        }
    }

}


Measured memory_bytes: 2132
a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans=0
for i in range(0,a+1):
  for j in range(0,b+1):
    for k in range(0,c+1):
      if 500*i+100*j+50*k==d:
        ans+=1
print(ans)


Measured memory_bytes: 9188
require "matrix"
n, m, l = gets.split.map(&:to_i)
ary1, ary2 = [], []
n.times{ary1<<gets.split.map(&:to_i)}
m.times{ary2<<gets.split.map(&:to_i)}
ma = Matrix[*ary1]
mb = Matrix.rows(ary2)
(ma * mb).row_vectors.each{|z| puts z.to_a.join("\s")}

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

vector<int> prime(int x) {
    vector<int> out(x);
    out.at(0) = 2;
    int j = 1;
    for (int k = 3; k <= x; k++) {
        bool f = true;
        for (int i = 2; i*i <= k; i++) {
            if (k%i==0) {
                f = false;
                break;
            }
        }
        if (f) {
            out.at(j) = k;
            j ++;
        }
    }
    return out;
}
int main() {
  int n;
  int count = 0;
  cin >> n;
  vector<int> p(n);
  p = prime(55555);
  for(int x:p){
    if (x>0) {
      if (count == n)
        break;
      if (x%5==1) {
        count ++;
        if (count<n) {
          cout << x << ' ';
        }
        else {
          cout << x << endl;
        }
      }
      
    }
	}
  return 0;
}

Measured memory_bytes: 512
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]
 
# 2次元のbit全探索
# 各探索ごとに、塗られていない黒いマスの個数を数え、K個なら ans+=1
ans = 0
for h in range(2**H):
  for w in range(2**W):
    black = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1 == 0) and ((w >> j) & 1 == 0) and C[i][j] == '#': black += 1
    
    if black == K:
      ans += 1

print(ans)

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            var reg = new Regex("[a-z]");

            string result = "A";
            if (reg.IsMatch(s))
            {
                result = "a";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 26772
from decimal import Decimal, ROUND_HALF_UP
n = int(input())
x = list(map(int,input().split()))
a = sum(x)/n
a = int(Decimal(str(a)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
s=0
for i in range(n):
    s += (x[i]-a)*(x[i]-a)
print(s)

Measured memory_bytes: 5076
N, M = map(int, input().split())
st = []
ch = []

for i in range(N):
    st.append(list(map(int, input().split())))

for i in range(M):
    ch.append(list(map(int, input().split())))

for i in range(N):
    x = float('inf')
    c = 0
    
    for j in range(M):
        if abs(st[i][0]-ch[j][0])+abs(st[i][1]-ch[j][1]) < x:
            x = abs(st[i][0]-ch[j][0])+abs(st[i][1]-ch[j][1])
            c = j+1
    
    print(c)

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

template<int mod>
struct modulo {
	int w;
	operator int&() { return w; }
	
	modulo() {}
	modulo(int w, bool f = 0) { if (!f) this->w = w; else *this = fix(w); }
	modulo inline fix(int w) const { w %= mod; if (w < 0) w += mod; return w; }
	
	inline modulo& operator += (const modulo &b) { if ((w += b.w) >= mod) w -= mod; return *this; }
	inline modulo& operator -= (const modulo &b) { if ((w -= b.w) < 0) w += mod; return *this; }
	inline modulo& operator *= (const modulo &b) { w = (num) w * b.w % mod; return *this; }
	inline modulo& operator /= (const modulo &b) { w = (num) w * b.inv() % mod; return *this; }
	inline modulo  operator +  (const modulo &b) { modulo r = *this; r += b; return r; }
	inline modulo  operator -  (const modulo &b) { modulo r = *this; r -= b; return r; }
	inline modulo  operator *  (const modulo &b) { modulo r = *this; r *= b; return r; }
	inline modulo  operator /  (const modulo &b) { modulo r = *this; r /= b; return r; }
	
	modulo inline inv() const {
		int a = w, m = mod, u = 0, v = 1, t;
		for (; a != 0; t = m / a, m -= t * a, swap(a, m), u -= t * v, swap(u, v));
		return fix(u);
	}
	
	modulo inline pow(int p) const {
		if (!w)  return 0;
		modulo a = *this, r = 1;
		for (; p > 0; a *= a, p >>= 1) if (p & 1) r *= a;
		return r;
	}
};
const int mod = int(1e9 + 7);
typedef modulo<mod> rem;

const int nsz = int(5e3);
int n, k, a[nsz + 5];
rem dp[nsz + 5], ans;
vector<int> r;

struct union_find {
	int pr[nsz + 5], siz[nsz + 5];
	
	union_find() {
		cont (u, nsz) pr[u] = u, siz[u] = 1;
	}
	
	int inline operator [] (int id) { return qry(id); }
	
	int qry(int u) { return pr[u] == u ? u : pr[u] = qry(pr[u]); }
	
	bool inline link(int u, int v) {
		int pu = qry(u), pv = qry(v);
		if (pu == pv) return 0;
		pr[pv] = pu;
		siz[pu] += siz[pv];
		return 1;
	}
};
union_find uf;

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
		if (a[i] != -1) uf.link(a[i], i);
		if (a[i] == -1) r.push_back(i);
	}
	k = int(r.size());
	
	cont (u, n) {
		if (uf[u] != u || a[u] == -1) continue;
		ans += rem(n - 1).pow(k);
	}
	
	dp[0] = 1;
	loop (i, k) {
		int sz = uf.siz[r[i]];
		for (int j = i; j >= 0; --j) {
			dp[j + 1] += dp[j] * (j ? rem(j) : rem(1)) * rem(sz);
		}
	}
	
	cont (j, k) {
		ans += dp[j] * rem(n - 1).pow(k - j);
	}
	cont (u, n) {
		if (uf[u] != u || a[u] != -1) continue;
		ans -= rem(n - 1).pow(k - 1);
	}
	
	ans = rem(n) * rem(n - 1).pow(k) - ans;
	printf("%d\n", ans);
}

Measured memory_bytes: 3872
main = do
    s <- getLine
    putStrLn $ if analyze (reverse s) then "YES" else "NO"
   
analyze "" = True
analyze ('m':'a':'e':'r':'d':k) = analyze k
analyze ('r':'e':'m':'a':'e':'r':'d':k) = analyze k
analyze ('e':'s':'a':'r':'e':k) = analyze k
analyze ('r':'e':'s':'a':'r':'e':k) = analyze k
analyze _ = False

Measured memory_bytes: 7548
//Solution By SlavicG
#include <bits/stdc++.h>
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	int n;
	cin >> n;
	int x = n % 10;
	if(x==2 || x== 4 || x==5 || x== 7 || x == 9){
		cout << "hon";
	}
	if(x==0||x==1||x==6||x==8){
		cout << "pon";
	}
	if(x==3)
		cout << "bon";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;

int nn;
const int nxx = 1e5+5;
int acc[nxx][3];
int dpp[3][nxx];
int go(int aa, int ii)
{
	if(ii==nn) return 0;
	if(dpp[aa][ii] != -1) return dpp[aa][ii];
	int& ans = dpp[aa][ii];
	if(aa==0)
	{
		ans=max(ans, go(1, ii+1)+acc[ii][0]);
		ans=max(ans, go(2, ii+1)+acc[ii][0]);
	}
	if(aa==1)
	{
		ans=max(ans, go(0, ii+1)+acc[ii][1]);
		ans=max(ans, go(2, ii+1)+acc[ii][1]);
	}
	if(aa==2)
	{
		ans=max(ans, go(0, ii+1)+acc[ii][2]);
		ans=max(ans, go(1, ii+1)+acc[ii][2]);
	}

	return ans;

}
int main()
{
    cin>>nn;
    for(int ii=0; ii<nn; ii++) cin>>acc[ii][0]>>acc[ii][1]>>acc[ii][2];
    memset(dpp, -1, sizeof dpp);
    cout<<max(go(0,0), max(go(1,0),go(2,0)))<<"\n";
    return 0;
}

Measured memory_bytes: 7296
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}
int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	int A, B, C;
	A = a.size();
	B = b.size();
	C = c.size();
	int i = 1, j = 0, k = 0;
	int n;
	if (a[0] == 'a') {
		i++;
		n = 0;
	}
	else if (a[0] == 'b') {
		j++;
		n = 1;
	}
	else {
		k++;
		n = 2;
	}
	while (i <= A && j <= B && k <= C) {
		switch (n) {
		case 0:
			if (a[i] == 'a') {
				i++;
				n = 0;
			}
			else if (a[i] == 'b') {
				j++;
				n = 1;
			}
			else {
				k++;
				n = 2;
			}
			break;
		case 1:
			if (b[j] == 'a') {
				i++;
				n = 0;
			}
			else if (b[j] == 'b') {
				j++;
				n = 1;
			}
			else {
				k++;
				n = 2;
			}
			break;
		case 2:
			if (c[k] == 'a') {
				i++;
				n = 0;
			}
			else if (c[k] == 'b') {
				j++;
				n = 1;
			}
			else {
				k++;
				n = 2;
			}
			break;
		}
	}
	if (i == A + 1)
		cout << 'A' << endl;
	else if (j == B + 1)
		cout << 'B' << endl;
	else
		cout << 'C' << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>

int main() {
  intmax_t N, X;
  scanf("%jd %jd", &N, &X);

  std::vector<intmax_t> pb(N+1);
  pb[0] = 1;
  for (intmax_t i = 1; i <= N; ++i)
    pb[i] = 2*pb[i-1] + 3;

  std::vector<intmax_t> p(N+1);
  p[0] = 1;
  for (intmax_t i = 1; i <= N; ++i)
    p[i] = 2*p[i-1] + 1;

  intmax_t res = 0;
  for (intmax_t i = N; i >= 0; --i) {
    if (i == 0) {
      if (X >= 1) ++res;
    } else if (X <= pb[i-1]+1) {
      --X;
    } else {
      res += p[i-1]+1;
      X -= pb[i-1]+2;
    }
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    writeln(S[2] == S[3] && S[4] == S[5] ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cerr<<' ';cerr<<elem;}cerr<<endl;}

inline void YESNO(bool ans){cout<<(ans?"YES":"NO")<<endl;}
inline void YesNo(bool ans){cout<<(ans?"Yes":"No")<<endl;}
inline void yesno(bool ans){cout<<(ans?"yes":"no")<<endl;}

int main(){
	int x;
	cin>>x;
	
	bool ans=false;
	if(x>=30) ans=true;
	
	YesNo(ans);
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
class Main{
  static int n;
  static int[][] map;
  static int[] dx = {1, 1, -1, -1};
  static int[] dy = {1, -1, 1, -1};
  static void dfs(int y, int x,int c, boolean first, List<Long> xy){
    if(first)map[y][x] = c%2+1;
    else map[y][x] = map[y][x]*2 + c%2+1;
    
    for(Long l: xy){
      int yy = (int)(l/1000000);
      int xx = (int)(l%1000000);
      for(int i=0;i<4;++i){
        int yyy= y + yy*dy[i];
        int xxx= x + xx*dx[i];
        if(yyy<0 || yyy>=2*n || xxx<0 || xxx>=2*n)continue;
        if(first){
          if(map[yyy][xxx]>0)continue;
          dfs(yyy, xxx, (c+1)%2, first, xy);
        }else{
          if(map[yyy][xxx]>2)continue;
          dfs(yyy, xxx, (c+1)%2, first, xy);
      	}
    	}
  	}
  }
  
  
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    n = sc.nextInt();
    int d1 = sc.nextInt(), d2=sc.nextInt();
    map = new int[2*n][2*n];
    Map<Integer, Integer> sqrToseed = new HashMap<>();
    for(int i=0;i*i<=200000;++i)sqrToseed.put(i*i, i);
    List<Long> d1xy = new ArrayList<>();
    List<Long> d2xy = new ArrayList<>();
    for(Map.Entry<Integer, Integer> entry: sqrToseed.entrySet()){
      if(sqrToseed.containsKey(d1 - entry.getKey())){
        d1xy.add((long)entry.getValue()*1000000 + sqrToseed.get(d1-entry.getKey()));
      }
      if(sqrToseed.containsKey(d2 - entry.getKey())){
        d2xy.add((long)entry.getValue()*1000000 + sqrToseed.get(d2-entry.getKey()));
      }
    }
    for(int i=0;i<2*n;++i)for(int j=0;j<2*n;++j)if(map[i][j]==0)dfs(i, j, 0, true, d1xy);
    for(int i=0;i<2*n;++i)for(int j=0;j<2*n;++j)if(map[i][j]<3)dfs(i, j, 0, false, d2xy);
    for(int k=3;k<=6;++k){
      int cnt = 0;
      for(int i=0;i<2*n;++i)for(int j=0;j<2*n;++j)if(map[i][j]==k)++cnt;
      if(cnt >=n*n){
        cnt=0;
        PrintWriter out = new PrintWriter(System.out);
        for(int i=0;i<2*n;++i)for(int j=0;j<2*n;++j)if(map[i][j]==k){
          out.println(i+" "+j);
          ++cnt;
          if(cnt==n*n){
            out.flush();
            return;
          }
        }
      }
    }
  }
}

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

const int N = 2010;

struct edge {
    int to, next;
} e[N * 2];

int head[N], ecnt;

inline void adde(int from, int to) {
    e[++ecnt] = (edge){to, head[from]}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to]}, head[to] = ecnt;
}

// sum: 子树内棋子个数 dp: 子树内最少操作步数
int sum[N], dp[N];

int val[N];

void dfs(int u, int f) {
    sum[u] = val[u], dp[u] = 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) {
            dfs(e[i].to, u);
            sum[u] += sum[e[i].to], dp[u] += dp[e[i].to] + sum[e[i].to];
        }
}

// 子树的最小剩余深度
int dfs2(int u, int f) {
    int mx = 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) 
            if (dp[e[i].to] >= dp[mx]) 
                mx = e[i].to;
    if (!mx) return 0;
    int tmp = dfs2(mx, u) + sum[mx];
    if (dp[u] - dp[mx] - sum[mx] >= tmp) return dp[u] & 1;
    return tmp - (dp[u] - dp[mx] - sum[mx]);
}

char s[N];

int main() {
    int n; scanf("%d%s", &n, s + 1);
    for (int i = 1; i <= n; i++) val[i] = s[i] == '1';
    for (int i = 1, a, b; i < n; i++) scanf("%d%d", &a, &b), adde(a, b);
    int res = 1e9;
    for (int i = 1; i <= n; i++) {
        dfs(i, 0);
        if (!dfs2(i, 0)) res = min(res, dp[i] / 2);
    }
    if (res < 1e8) printf("%d\n", res);
    else puts("-1");
    return 0;
}//

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin>>s;
	int cnt[2] = {0};
	int n = s.size();
	for(int i = 0; i < n; i++){
		if(s[i]=='0')cnt[0]++;
		else cnt[1]++;
	}
	cout << min(cnt[0],cnt[1])*2<<endl;

	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	int A, B, C;
	int[] vals = new int[3];
	int result = 0;

	private Main() {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		A = Integer.parseInt(tokens[0]);
		B = Integer.parseInt(tokens[1]);
		C = Integer.parseInt(tokens[2]);
		vals[0] = A;
		vals[1] = B;
		vals[2] = C;
		Arrays.sort(vals);
		in.close();
	}

	private void calc() {
		// littleとmedに1ずつn回足して，med == largeにする
		int addOne = vals[2] - vals[1];
		vals[0] += addOne;
		vals[1] += addOne;
		result += addOne;
		// large - little % 2 == 0なら，(large-little)/2回2をlittleに足して完了
		// そうでない場合は，(lare+1-little)/2回2をlittleに足し，最後にlargeとmiddleに1を足す
		if ((vals[2] - vals[0]) % 2 == 0) {
			result += (vals[2] - vals[0]) / 2;
		} else {
			result += (vals[2] + 1 - vals[0]) / 2 + 1;
		}

	}

	private void show() {
		System.out.println(result);
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		ins.show();
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}

int a[100000];
int g[100000];
int m[100000];
int f[100000] = { 0 };
int min[100000];
int c[100000];

int dfs(int i) {
	if (g[i] != i) {
		return g[i] = dfs(g[i]);
	}
	else {
		return i;
	}
}

void Swap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		Swap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	if (M == N - 1) {
		PRINTD(0);
		return 0;
	}
	if (N < 2 * (N - M - 1)) {
		PRINTS("Impossible");
		return 0;
	}
	REP(i, N) g[i] = i;
	REP(i, N) m[i] = 1000000001;
	REP(i, N) c[i] = 1;
	REP(i, N) {
		scanf("%d", &a[i]);
		min[i] = a[i];
	}
	//REP(i, N) a[i] = i;
	REP(i, M) {
		int x,y;
		scanf("%d %d", &x, &y);
		//x = i; y = i + N / 2;
		f[x] = f[y] = 1;
		int g1 = dfs(x);
		int g2 = dfs(y);
		if (a[g1] <= a[g2]) {
			g[g2] = g1;
			m[g2] = 0;
			c[g1] += c[g2];
			c[g2] = 0;
			if (a[g2] < m[g1])m[g1] = a[g2];
		}
		else {
			g[g1] = g2;
			m[g1] = 0;
			c[g2] += c[g1];
			c[g1] = 0;
			if (a[g1] < m[g2])m[g2] = a[g1];
		}
	}
	/*
	int cnt = 0;
	REP(i, N) {
		if (f[i]==0)cnt++;
		if (c[i] > 2)cnt -= c[i] - 2;
	}
	if (cnt > 2) {
		PRINTS("Impossible");
		return 0;
	}
	*/
	ll sum = 0;
	int flag = 0;
	REP(i, N) {
		if (g[i] == i) {
			flag++;
			sum += a[i];
			min[i] = 1000000001;
		}
	}
	QSort(min, 0, N - 1, 1);
	//ShowData(min, 0, N - 1);
	/*
	REP(i, N) {
		printf("%d ", g[i]);
	}
	PRINTS("");
	REP(i, N) {
		printf("%d ", m[i]);
	}
	PRINTS("");
	*/
	/*
	if (flag==1) {
		PRINTD(0);
	}
	else {
	*/
		REP(i, N - M - 2) {
			sum += min[i];
		}
		printf("%lld\n", sum);
	//}
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
std::vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
#define size_t ll
const int mod = 1000000007;
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
int n,m;
int main(){
  cin >> n >> m;
  cout << (n == m ? "Yes":"No") << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.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");}

ll N;
vector <ll> P;
int cnt[100];

int Solve(){
  ll now = N;
  for (ll i = 2; i * i <= N; i++){
    int ans = 0;
    while (now % i == 0){
      now /= i; ans++;
    }
    P.push_back(ans);
  }
  if (now > 1) P.push_back(1);

  return 0;
}

int main(){
  cin >> N;
  for (int i = 1; i < 100; i++){
    cnt[i] = cnt[i-1] + i;
  }
  Solve();
  int ans = 0;
  for (int i = 0; i < P.size(); i++){
    for (int j = 1; j < 100; j++){
      if (P[i] < cnt[j]){
        ans += j - 1; break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11668
#include <iostream>

using namespace std;

int main(){

int H,W;

 while(true){

 cin >> H >> W;

 if (H==W && H==0) break;

 for (int i = 0 ; i< W;i++) cout << "#";
 cout << endl;
 
 for (int i = 0; i < (H-2);i++){
    cout << "#";
    for (int j =0 ; j < (W-2);j++){
        cout << ".";
    }
    cout << "#\n";
}

for (int i = 0 ; i< W;i++) cout << "#";
cout << endl << endl;
 }
}


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

int main() {
  string s,t;
  cin >> s >> t;
  int ns = s.size();
  int nt = t.size();
  if (nt != ns+1) {
    cout << "No" << endl;
    return 0;
  }
  for(int i = 0; i < ns; ++i) {
    if(s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 2e5+5;

string txt;
int dp[N];
int cnt[2020];

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> txt;

  int mult = 1;
  for(int i = txt.size(); i >= 1; i--) {
    dp[i] = (dp[i+1] + (mult*(txt[i-1] - '0')) % 2019 ) % 2019;
    //db(i _ dp[i]);
    mult = ( mult*10 ) % 2019;
  }

  int ans = 0;
  for(int i = 1; i <= txt.size(); i++) {
    if(!dp[i]) ans++;
    ans += cnt[dp[i]];
    cnt[dp[i]]++;
  }
  
  cout << ans << "\n";
}


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

long long n;
int k;
vector<int> q;

void solve(long long n){
	if (n==1) return;
	solve(n/2);
	q.push_back(++k);
	if (n%2) q.insert(q.begin(),++k);
}

int main(){
	scanf("%lld",&n);
	solve(n+1);
	printf("%d\n",2*(int)q.size());
	for (int i=1;i<=(int)q.size();i++)
		printf("%d ",i);
	for (int i=0;i<(int)q.size();i++)
		printf("%d ",q[i]);
	printf("\n");return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0;i < n;++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
inline int newline() { putchar('\n'); return 0; }

int main() {
    ll n, k;
    cin >> n >> k;

    ll result = 0;

    erep3(i, k, n + 1) {
        ll min = i * (0 + i - 1) / 2;
        ll max = i * (n - i + 1 + n) / 2;

        result += max - min + 1;
    }

    print(result % 1000000007);
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=200005;
char ch[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	For(i,1,n)if(ch[i]=='?')ch[i]='D';
	cout<<(ch+1)<<endl;
}


Measured memory_bytes: 3924
import math
X, Y = map(int, input().split())

MOD = 10 ** 9 + 7

xx = 2 * Y - X
if (xx >= 0 and xx % 3 == 0 and Y - 2 * xx // 3 >= 0):
    a = xx // 3
    b = Y - 2 * a

    f = 1
    factorials = [1]
    for m in range(1, a + b + 1):
        f *= m
        f %= MOD
        factorials.append(f)

    inv = pow(f, MOD - 2, MOD)
    invs = [1] * (a + b + 1)
    invs[a + b] = inv
    for m in range(a + b, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv


    print (factorials[-1] * invs[a] * invs[b] % MOD)

    # print (math.factorial(a + b) // math.factorial(a) // math.factorial(b) %  MOD)


else:
    print (0)


Measured memory_bytes: 55852
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int count = 0;
  while(n)
  {
    int k = n%10;
    if(k==7)
    {
      count++;
      break;
    }
    n=n/10;
  }
  if(count != 0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3596
import collections
import sys

N,K = map(int,input().split())
A = list(map(int,input().split()))
c = collections.Counter(A)
cnt = 0
if len(c)<= K:
    print(0)
    sys.exit()

for i in c.most_common(K):
    cnt += i[1]

print(N-cnt)


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

int main(){
  int L,R,d;
  cin >>L>>R>>d;
  
  int ans=0;
  for(int i=L;i<=R;i++){
    if(i%d==0){
      ans++;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3584
#include <stdio.h>
#define M 1000000007

int main()
{		
	int n, i, k;
	int d, x;
	long long s = 1;
		
	scanf("%d%d", &n, &k);
	for(d = n + 1, x = n, i = 1; i <= n; i++){
		if(i >= k) s += d;
		d += (x -= 2);
		if(d >= M) d -= M;
		if(d < 0) d += M;
	}
	printf("%lld\n", s %= M);
			
	return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
ll int MOD=998244353;
#define INF 2*1e9
#define N 310000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    int a[600],ans[N]={};
    vector<pii> p;
    rep2(i,1,n){
        cin>>a[i];
        if(ans[a[i]]){
            cout<<"No"; return 0;
        }
        ans[a[i]]=i;
        p.pb({a[i],i});
    }
    sort(p.begin(),p.end());
    int res[600]={};
    rep2(i,1,n){
        res[i]=i-1;
    }
    int pos=0;
    rep2(i,1,n*n){
        if(ans[i]&&res[ans[i]]){
            cout<<"No";return 0;
        }
        else if(ans[i]) continue;
        if(pos>n-1) continue;
        else{
            if(res[p[pos].second]){
                res[p[pos].second]--;
                ans[i]=p[pos].second;
            }
            else{
                pos++;
                if(!res[p[pos].second]){
                    pos++;
                }
                res[p[pos].second]--;
                ans[i]=p[pos].second;
            }
        }
    }
    rep2(i,1,n){
        res[i]=n-i;
    }
    rep2(i,1,n){
        ans[a[i]]=-i;
    }
    queue<int> q;
    rep2(i,1,n*n){
        if(ans[i]<0){
            q.push(-ans[i]);ans[i]*=-1;continue;
        }
        if(!ans[i]&&q.empty()){
            cout<<"No";return 0;
        }
        if(!ans[i]){
            if(res[q.front()]){
                ans[i]=q.front();res[q.front()]--;
            }
            else{
                q.pop();
                if(q.empty()){
                    cout<<"No";return 0;
                }
                if(!res[q.front()]){
                    q.pop();
                    if(q.empty()){
                        cout<<"No";return 0;
                    }
                }
                ans[i]=q.front();res[q.front()]--;
            }
        }
    }
    cout<<"Yes"<<endl;
    rep2(i,1,n*n){
        cout<<ans[i]<<" ";
    }
}


Measured memory_bytes: 2432
//g++  5.4.0

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    int ar[n+1][3],mem[n+1][3];
for(int i = 0;i<n;i++){
    for(int j = 0;j<3;j++){
        cin>>ar[i][j];
mem[i][j] = 0;
}
}
mem[0][0] = ar[0][0];mem[0][1] = ar[0][1];mem[0][2] = ar[0][2];
   for(int i = 1;i < n;i++){
    for(int j = 0;j<3;j++){
        for(int k= 0;k<3;k++){
            if(j!=k){
                mem[i][j] = max(mem[i][j],ar[i][j]+mem[i-1][k]);
            }
        }  
           
     }
    }
    int ans = mem[n-1][0];

    for(int i = 1;i<3;i++){
    ans = max(ans,mem[n-1][i]);
//cout<<ans<<"*ans"<<endl;
}
cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
char s[105];
int len;

int main(){
	scanf("%s",s+1);
	len=strlen(s+1);
	if(len&1) puts("No");
	else{
		for(int i=1;i<=len;i+=2){
			if(s[i]!='h'||s[i+1]!='i'){puts("No");return 0;}
		}
		puts("Yes");
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;


int main(void)
{
	int N, A, B;
	cin >> N >> A >> B;

	string s;
	cin >> s;

	int passed = 0;
	int kaigai = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'a') {
			if (passed < A + B) {
				cout << "Yes" << endl;
				passed++;
			}
			else cout << "No" << endl;
		}
		else if (s[i] == 'b') {
			if (passed < A + B && kaigai < B) {
				cout << "Yes" << endl;
				passed++;
				kaigai++;
			}
			else cout << "No" << endl;
		}
		else
			cout << "No" << endl;
	}
	return 0;
}

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

int main()
{
  int H, W;
  string s[100];
  int ans[100][100];
  fill((int*)ans, (int*)ans + 10000, -1);
  cin >> H >> W;
  for(int y = 0; y < H; y++)
    cin >> s[y];

  for(int y = 0; y < H; y++)
  {
    for(int x = 0; x < W; x++)
    {
      if(s[y][x] != 'c')
        continue;
      for(int t = 0; x + t < W && (t == 0 || s[y][x + t] != 'c'); t++)
        ans[y][x + t] = t;
    }
  }
  for(int y = 0; y < H; y++)
  {
    for(int x = 0; x < W; x++)
      cout << ans[y][x] << (x == W - 1 ? "": " ");
    cout << endl;
  }
}

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

int main() {
    
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    if(s=="Cloudy")cout << "Rainy" << endl;
    if(s=="Rainy")cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int n; cin >> n;
    int d1, d2;
    int c = 0;
    bool f = false;
    rep(i, n) {
        cin >> d1 >> d2;
        if (d1 == d2) ++c;
        else c = 0;
        if (c == 3) f = true;
    }
    cout << (f?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 3636
A_B = list(map(int, input().split()))
A = A_B[0]
B = A_B[1]

count = 1
while count * 0.08 // 1 != A or count * 0.1 // 1 != B:
    count += 1
    if count * 0.1 - 10 > B:
        print(-1)
        exit()
print(count)


Measured memory_bytes: 2940
import numpy as np
a_1 = list(map(int,input().split()))
a_2 = list(map(int,input().split()))
a_3 = list(map(int,input().split()))
a = []
a.append(a_1)
a.append(a_2)
a.append(a_3)
bingo = [[False] * 3 for _ in range(3)]
n = int(input())
for _ in range(n):
    tmp = int(input())
    for x,row in enumerate(a):
        try:
            pos = [x,row.index(tmp)]
            bingo[pos[0]][pos[1]] = True
            break
        except ValueError:
            pass
bingo = np.array(bingo)
if (sum(bingo[0]) == 3) | (sum(bingo[1])==3) | (sum(bingo[2])==3) | (3 in np.sum(bingo,axis=0)):
    print('Yes')
elif ((bingo[0][0]==True) & (bingo[1][1]==True) & (bingo[2][2]==True)) | ((bingo[0][2]==True) & (bingo[1][1]==True) & (bingo[2][0]==True)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 21664
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		String str = (new Scanner(System.in)).next();
		String ans = str.matches("^A[a-z]+C[a-z]+$") ? "AC" : "WA";
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <utility>
#include <climits>
#include <algorithm>

using namespace std;

int main() {
    while(true) {
        int N, M, H, K;
        cin >> N >> M >> H >> K;
        if(!N && !M && !H && !K) break;
        
        vector<int> scores;
        vector<int> goals;
        vector<pair<int, int> > swaps;

        for(int i = 0; i < N; ++i) {
            int s;
            cin >> s;
            scores.push_back(s);
            goals.push_back(i);
        }

        vector<pair<int, int> > bars;
        for(int i = 0; i < M; ++i) {
            int a, b;
            cin >> a >> b;
            --a;
            bars.push_back(make_pair(b, a));
        }
        sort(bars.begin(), bars.end());
        for(int i = 0; i < M; ++i) {
            int a = bars[i].second;
            swaps.push_back(make_pair(goals[a], goals[a+1]));
            //cout << "swap " << goals[a] << ' ' << goals[a+1] << endl;
            swap(goals[a], goals[a+1]);
        }

        vector<int> to_goal(N);
        for(int i = 0; i < N; ++i) {
            to_goal[goals[i]] = i;
        }

        int ans = INT_MAX;
        int sum = 0;
        for(int i = 0; i < K; ++i) {
            sum += scores[to_goal[i]];
        }
        ans = sum;
        for(int i = 0; i < M; ++i) {
            int a = swaps[i].first;
            int b = swaps[i].second;
            if(a < K && b < K) continue;
            if(a >= K && b >= K) continue;

            int minus = (a<K) ? scores[to_goal[a]] : scores[to_goal[b]];
            int plus = (a<K) ? scores[to_goal[b]] : scores[to_goal[a]];
            int tmp = sum-minus+plus;
            ans = min(ans, tmp);
        }
        cout << ans << endl;
    }
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m; assert(b>=0); for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int r, n, a, b, c, h[44];

signed main() {
	while (1) {
		cin >> r >> n;
		if (r==0) break;
		zero(h);
		rep(i,n) {
			cin >> a >> b >> c;
			reps(j,a,b) chmax(h[j+20],c);
		}
		double res = 1e100;
		reps(i,-r,r) {
			int x = min(abs(i),abs(i+1)), y = h[i+20];
			chmin(res, y+r-sqrt(r*r-x*x));
		}
		printf("%.8lf\n",res);
	}
}


Measured memory_bytes: 3136