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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using namespace std;


int main()
{

    ll n, m ;
    cin >> n >> m;
    vector<int> v(n+1, 0);

    rep(i, m) {
        int tmp;
        cin >> tmp;
        v[tmp] = 1;
    }

    vector<unsigned long long> ress(n+1);
    ress[0] = 1;
    if (v[1] == 1) {
        ress[1] = 0;
    }
    else {
        ress[1] = 1;
    }

    for (unsigned long long i = 2; i <= n; ++i) {
        if(v[i] == 1) {
            ress[i] = 0;
        }
        else {
            ress[i] = (ress[i-1] + ress[i-2])  % 1000000007 ;
        }
    }
    cout << ress[n]<< endl;


    return 0;
}


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

int N;
int V;
int xs[214514];
int vs[20];
int dp1[1145141];
int dp2[1145141];
int dp3[1145141];
vector<int> segs[20];

int main() {
  scanf("%d%d", &N, &V);
  for (int i=0; i<N; i++) {
    scanf("%d", &xs[i]);
  }

  int v = V;
  int cnt = 0;
  while (v >= 0) {
    vs[cnt++] = v;
    if (v == 0) break;
    v /= 2;
  }

  for (int i=0; i<cnt; i++) {
    int v = vs[i];
    segs[i].emplace_back(0);
    for (int idx=1; idx<N; idx++) {
      if (xs[idx]-xs[idx-1] > v) segs[i].emplace_back(idx);
    }
    segs[i].emplace_back(N);
  }

  int lim = 1 << cnt;
  fill(dp1, dp1+lim, -1);
  dp1[0] = 0;
  for (int st=0; st<lim; st++) {
    for (int i=0; i<cnt; i++) {
      if (st >> i & 1) continue;
      int nst = st | (1 << i);
      int g = *upper_bound(segs[i].begin(), segs[i].end(), dp1[st]);
      dp1[nst] = max(dp1[nst], g);
    }
  }

  fill(dp2, dp2+lim, N);
  dp2[0] = N-1;
  for (int st=0; st<lim; st++) {
    for (int i=0; i<cnt; i++) {
      if (st >> i & 1) continue;
      int nst = st | (1 << i);
      auto itr = upper_bound(segs[i].begin(), segs[i].end(), dp2[st]);
      itr--;
      dp2[nst] = min(dp2[nst], *itr-1);
    }
  }

  /*fill(dp3, dp3+lim, -1);
  dp3[0] = 1;
  for (int st=0; st<lim; st++) {
    for (int i=0; i<cnt; i++) {
      if (st >> i & 1) continue;
      int nst = st | (1 << i);
      int g = *upper_bound(segs[i].begin(), segs[i].end(), dp3[st]);
      dp3[nst] = max(dp3[nst], g);
    }
  }

  fill(dp4, dp4+lim, N);
  dp4[0] = N-2;
  for (int st=0; st<lim; st++) {
    for (int i=0; i<cnt; i++) {
      if (st >> i & 1) continue;
      int nst = st | (1 << i);
      auto itr = upper_bound(segs[i].begin(), segs[i].end(), dp4[st]);
      itr--;
      dp4[nst] = min(dp4[nst], *itr-1);
    }
  }*/

  fill(dp3, dp3+N+10, N+1);
  for (int st=0; st<lim; st++) {
    if (st & 1) continue;
    int cst = (lim-1) & (~st) & ~1;
    assert(dp1[st] >= 0);
    dp3[dp1[st]] = min(dp3[dp1[st]], dp2[cst]);
  }

  for (int i=N; i>=0; i--) {
    dp3[i] = min(dp3[i], dp3[i+1]);
  }

  for (int i=0; i<N; i++) {
    auto itr = upper_bound(segs[0].begin(), segs[0].end(), i);
    int b = *itr;
    itr--;
    int a = *itr-1;
    bool ok = false;
    if (dp3[a+1] < b) puts("Possible");
    else puts("Impossible");
  }
}


Measured memory_bytes: 13812
#include <stdio.h>
int main(void) {
  int cash, coin;
  while(scanf("%d",&cash), cash) {
    coin = 0;
    cash = 1000 - cash;
    if(cash >= 500 ) {
      coin += cash / 500;
      cash %= 500;
    }
    if(cash >= 100 ) {
      coin += cash / 100;
      cash %= 100;
    }
    if(cash >= 50 ) {
      coin += cash / 50;
      cash %= 50;
    }
    if(cash >= 10 ) {
      coin += cash / 10;
      cash %= 10;
    }
    if(cash >= 5 ) {
      coin += cash / 5;
      cash %= 5;
    }
    coin += cash;
    printf("%d\n",coin);
  }
  return 0 ;
}

Measured memory_bytes: 596
s = input().split()

A = int(s[0])
B = int(s[1])
N = int(s[2])

result = 0

n = (N // B) * B - 1
if (n < 0):
  n = 0

a = (A*N)//B - A*(N//B)
b = (A*n)//B - A*(n//B)
"""
for x in range(N+1):
  y = (A*x)//B - A*(x//B)
  if y > result:
    result = y
"""
    
if (a > b):
  result = a
else:
  result = b
print(result)   


Measured memory_bytes: 9200
#include <stdio.h>          // printf(), scanf()
#define MAX_N 25

typedef struct node_tbl
{
	int parent;
	int left;
	int right;
} node;

const int nil = -1;
node t[MAX_N];
int d[MAX_N];
int h[MAX_N];

void
set_depth(int u, int v)
{
	if (u == nil)
		return;

	d[u] = v;
	set_depth(t[u].left, v + 1);
	set_depth(t[u].right, v + 1);
}

int
set_height(int u)
{
	int h1 = 0, h2 = 0;
	if (t[u].left != nil)
		h1 = set_height(t[u].left) + 1;

	if (t[u].right != nil)
		h2 = set_height(t[u].right) + 1;

	return h[u] = (h1 > h2) ? h1 : h2;
}

int
get_sibling(int u)
{
	if (t[u].parent == nil)
		return nil;

	if (t[t[u].parent].left != u && t[t[u].parent].left != nil)
		return t[t[u].parent].left;

	if (t[t[u].parent].right != u && t[t[u].parent].right != nil)
		return t[t[u].parent].right;

	return nil;
}

void
print(int u)
{
	printf("node %d: ", u);
	printf("parent = %d, ", t[u].parent);
	printf("sibling = %d, ", get_sibling(u));
	int deg = 0;
	if (t[u].left != nil)
		deg++;

	if (t[u].right != nil)
		deg++;

	printf("degree = %d, ", deg);
	printf("depth = %d, ", d[u]);
	printf("height = %d, ", h[u]);
	if (t[u].parent == nil)
		printf("root\n");

	else if (t[u].left == nil && t[u].right == nil)
		printf("leaf\n");

	else
		printf("internal node\n");
}

int
main(int argc, char** argv)
{
	int n;
	int root;
	int v;
	int l, r;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		t[i].parent = nil;

	for (i = 0; i < n; ++i)
	{
		scanf("%d %d %d", &v, &l, &r);
		t[v].left = l;
		t[v].right = r;
		if (l != nil)
			t[l].parent = v;

		if (r != nil)
			t[r].parent = v;
	}

	for (i = 0; i < n; ++i)
	{
		if (t[i].parent == nil)
		{
			root = i;
			break;
		}
	}

	set_depth(root, 0);
	set_height(root);

	for (i = 0; i < n; ++i)
		print(i);

	return 0;
}

Measured memory_bytes: 612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef pair<int, int> P;
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;
}
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};
const int INF = 1001001001;

int ans;
vector<int> answers;

void dfs(int n, int x, int sum, int cnt) {
  if (cnt == 3) {
    if (sum == x) {
      ans++;
    }
    return;
  }

  if (n == 0) {
    return;
  }

  dfs(n - 1, x, sum + n, cnt + 1);
  dfs(n - 1, x, sum, cnt);
}

int main() {
  while (1) {
    int n, x;
    cin >> n >> x;

    if (n == 0 && x == 0) break;

    ans = 0;
    dfs(n, x, 0, 0);
    answers.push_back(ans);
  }

  for (auto&& i : answers) {
    cout << i << endl;
  }
}



Measured memory_bytes: 3172
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let rec upper_bound l r p =
  if r - l <= 1
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let code c = Char.code c - Char.code 'a'

exception Exists

let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  Printf.printf "%d\n" @@
  upper_bound 0 (n / 2 + 1) @@ fun l ->
    Fun.flip List.for_all [1000000007; 1000000009] @@ fun modulo ->
      let ( +^ ) x y = (x + y) mod modulo in
      let ( -^ ) x y = x +^ (modulo - y) in
      let ( *^ ) x y = (x * y) mod modulo in
      let hash = Array.fold_left (fun h c -> 26 *^ h +^ code c) 0 in
      let radix = power ( *^ ) 1 26 l in
      let h = ref @@ hash @@ Array.init l @@ String.get s in
      let h' = ref @@ hash @@ Array.init l @@ fun i -> s.[i + l] in
      let set = ref @@ IntSet.singleton !h in
      try
        if IntSet.mem !h' !set then raise Exists;
        for i = 0 to n - 2 * l - 1 do
          h := 26 *^ !h +^ code s.[i + l] -^ radix *^ code s.[i];
          h' := 26 *^ !h' +^ code s.[i + 2 * l] -^ radix *^ code s.[i + l];
          set := IntSet.add !h !set;
          if IntSet.mem !h' !set then raise Exists;
        done; false
      with Exists -> true


Measured memory_bytes: 6912
# C - Bugged
def main():
    n = int(input())
    s = [int(input()) for _ in range(n)]
    s.sort()
  
    if sum(s) % 10 != 0:
        print(sum(s))
    else:
        for i in range(n):
            if s[i] % 10 != 0:
                s.pop(i)
                print(sum(s))
                exit()
        else:
            print(0)


if __name__ ==  "__main__":
    main()

Measured memory_bytes: 9100
#include <cstdio>

int main()
{
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if (a != b and a != c and b != c)
    {
        printf("3");
    }
    
    else if (a == b and a == c)
    {
        printf("1");
    }
    
    else if (a == b or a == c or b == c )
    {
        printf("2");
    }
    
}

Measured memory_bytes: 1616
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K=MI()
    H=LIN(N)
    H.sort()
    ans = inf
    for l in range(N):
        r = l+K-1
        if r>=N:
            break
        ans = min(ans, H[r]-H[l])
    print(ans)
if __name__ == '__main__':
    main()

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

int main()
{
  int N;
  cin>>N;
  
  int h[N];
  int i;
  for(i=0;i<N;i++)
  {
    cin>>h[i];
  }
  
  int dp[N][2];
  dp[0][0]=dp[0][1]=0;
  dp[1][0]=dp[1][1]=abs(h[0]-h[1]);
  
  for(i=2;i<N;i++)
  {
    dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(h[i]-h[i-1]);
    dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(h[i]-h[i-2]);
  }
  cout<<min(dp[N-1][1],dp[N-1][0])<<endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int r;
  cin>>r;
  cout<<r*r<<endl;
}


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

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


Measured memory_bytes: 764
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
			if(b-a==c-b) System.out.println("YES");
			else System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21588
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(void){
    int K,X;
    cin>>K>>X;
    if(500*K>=X)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
let [| N; K; Q |] = stdin.ReadLine().Split() |> Array.map int

let A = Array.zeroCreate<int> N

[ 1..Q ]
|> List.map (fun _ -> stdin.ReadLine() |> int)
|> List.map (fun i -> A.[i - 1] <- A.[i - 1] + 1)
|> ignore

A
|> Array.map (fun x ->
    if K - Q + x > 0 then "Yes"
    else "No")
|> Array.iter stdout.WriteLine


Measured memory_bytes: 29128
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        long A = a/x;
        long B = b/x;
        
        if(a%x == 0){
            System.out.println(B-A+1);
        }else{
            System.out.println(B-A);
        }
	}
}


Measured memory_bytes: 35724
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
string s[100];
int x[100];
string die;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	int tot=0;
	for(int i=1;i<=n;i++){
		cin>>s[i]>>x[i];
		tot+=x[i];
	}
	cin>>die;
	for(int i=1;i<=n;i++){
		tot-=x[i];
		if(s[i]==die)
			break;
	}
	cout<<tot<<endl;
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i 
h = {}
n.times do 
  s = gets 
  h[s.chomp] = 1 
end 
for m in ["S", "H", "C", "D"] do 
  for i in 1..13 do 
    puts "#{m} #{i}" if !h.has_key?(m+" "+i.to_s)
  end 
end 


Measured memory_bytes: 6876
#include "stdio.h"

int main(void){
  int x,y,z,i,flag;
  char a[5] = {'A','B','C','D','F'};
  for(i = 0; i < 1000; i++){

    scanf("%d %d %d", &x, &y, &z);
    if((x == -1) && (y == -1) && (z == -1))break;
    if((x == -1) || (y == -1) || (x + y < 30)){
      flag = 4;
    }else if(x + y >= 80){
      flag = 0;
    }else if(x + y >= 65){
      flag = 1;
    }else if(x + y >= 50){
      flag = 2;
    }else if(x + y >= 30){
      if(z >= 50){
        flag = 2;
      }else{
        flag = 3;
      }
    }
    printf("%c\n", a[flag]);

  }
}



Measured memory_bytes: 2044
#include<stdio.h>
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
	int n, most=0, L[100];
	long int total = 0;

	memset(L, 0x00, 100);

	if (scanf("%d", &n) == EOF) {
		return 0;
	}

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

		total += L[i];

		if (L[i] > most)
		{
			most = L[i];
		}
	}

	total -= most;

	if (most < total)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = 998244353;
const int MAX_N = 4010;
ll dp[MAX_N][MAX_N];

// n choose r
ll C[MAX_N][MAX_N];

int main2() {
  CLR(dp, 0);
  string S; cin >> S;
  int N = S.size();
  vector<int> NR(N+1), NB(N+1);
  REP(i, N) {
    if (S[i] == '0') { NR[i+1] = NR[i] + 2; NB[i+1] = NB[i] + 0; }
    if (S[i] == '1') { NR[i+1] = NR[i] + 1; NB[i+1] = NB[i] + 1; }
    if (S[i] == '2') { NR[i+1] = NR[i] + 0; NB[i+1] = NB[i] + 2; }
  }
  // pv(ALL(NR));
  // pv(ALL(NB));
  dp[0][0] = 1;
  for (int r = 0; r < N; r++) {
    for (int b = 0; b < N; b++) {
      int k = r + b + 1;
      if (NR[k] >= r+1 && NB[k] >= b) { (dp[r+1][b] += dp[r][b]) %= MOD; }
      if (NR[k] >= r && NB[k] >= b+1) { (dp[r][b+1] += dp[r][b]) %= MOD; }
    }
  }

  ll ans = 0;
  for (int r = 0; r <= N; r++) {
    int b = N - r;
    int x = NR[N] - r;
    int y = NB[N] - b;
    ll m = C[x+y][y];
    ans += dp[r][b] * m % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j <= i; j++) {
      C[i][j] = (j == 0) ? 1 : (C[i-1][j-1] + C[i-1][j]);
      if (C[i][j] >= MOD) C[i][j] -= MOD;
    }
  }

  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 249728
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	string s;
	cin >> s;
	//string s(N*2,0);
	//cin >> s;
	/*for (int loop = 0; loop < 1 << (N * 2); loop++) {
		cout << "loop " << loop << endl;
		for (int j = 0; j < N * 2; j++) {
			if ((loop >> j) & 1)s[j] = 'W';
			else s[j] = 'B';
		}
		cout << s << endl;
		vector<long long int>by(N + 1, 1);
		for (int i = 1; i <= N; i++) {
			by[i] = by[i - 1] * i;
			by[i] %= MOD;
		}
		long long int ans = 1;
		long long int num = 0;
		bool flag = false;
		for (int i = 0; i < N * 2; i++) {
			if (!num&&s[i] == 'W') {
				//cout <<"not "<< 0 << endl;
				flag = true;
				//return 0;
				break;
			}
			if (s[i] == 'W') {
				if (num & 1) {
					num++;
				}
				else {
					ans *= num;
					ans %= MOD;
					num--;
				}
			}
			else {
				if (num & 1) {
					ans *= num;
					ans %= MOD;
					num--;
				}
				else {
					num++;
				}
			}
		}
		if (flag)continue;
		ans *= by[N];
		ans %= MOD;
		cout << ans << endl;
		vector<int>p(N * 2);
		for (int i = 0; i < N * 2; i++)p[i] = i;
		int ret = 0;
		do {
			vector<int>num(N * 2);
			for (int i = 0; i < N; i++) {
				for (int j = min(p[i * 2], p[i * 2 + 1]); j <= max(p[i * 2], p[i * 2 + 1]); i++)num[j]++;
			}
			int add = 1;
			for (int i = 0; i < N * 2; i++) {
				if (num[i] % 2 == 1 && s[i] == 'W')add = 0;
				if (num[i] % 2 == 0 && s[i] == 'B')add = 0;
			}
			ret += add;
		} while (next_permutation(p.begin(), p.end()));
		for (int i = 0; i < N; i++)ret /= 2;
		cout << ret << endl;
	}
	*/
	//*
	vector<long long int>by(N + 1, 1);
	for (int i = 1; i <= N; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
	}
	long long int ans = 1;
	long long int num = 0;
	for (int i = 0; i < N * 2; i++) {
		if (!num&&s[i] == 'W') {
			cout << 0 << endl;
			return 0;
		}
		if (s[i] == 'W') {
			if (num & 1) {
				num++;
			}
			else {
				ans *= num;
				ans %= MOD;
				num--;
			}
		}
		else {
			if (num & 1) {
				ans *= num;
				ans %= MOD;
				num--;
			}
			else {
				num++;
			}
		}
	}
	if (num) {
		cout << 0 << endl;
		return 0;
	}
	ans *= by[N];
	ans %= MOD;
	cout << ans << endl;
	//*/
}


Measured memory_bytes: 1428
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }

int32_t main(){
	IOS;
	int s;
	cin >> s;
	int sz = 1000 * 1000 * 1000;
	//sz = 5;
	cout << "0 0 1 " << sz << " ";
	if(s % sz == 0)
		cout << s/sz << " " << 0 << endl;
	else
		cout << (s / sz) + 1 << " " << sz - (s % sz) << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    E=[[] for _ in range(n)]
    idx={}
    for i in range(n-1):
        a,b=map(int,input().split())
        a-=1; b-=1
        E[a].append(b)
        idx[(a,b)]=i
    ans=[None]*(n-1)

    # coloring
    Q=[(0,0)]
    while(Q):
        v,c=Q.pop()
        cnt=1
        for nv in E[v]:
            cnt+=cnt==c # 親との辺の色と被るときは1増やす
            ans[idx[(v,nv)]]=cnt
            Q.append((nv,cnt))
            cnt+=1

    print(max(ans))
    print(*ans,sep='\n')
resolve()

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll a,b,c;
  cin>>a>>b>>c;
  int cnt=0;
  if(a%2==1||b%2==1||c%2==1) {
    cout << 0 << endl;
    return 0;
  }
  if(a==b&&b==c) {
    cout << -1 << endl;
    return 0;
  }
  while(a%2==0&&b%2==0&&c%2==0) {
    ll ta = (b+c)/2;
    ll tb = (a+c)/2;
    ll tc = (a+b)/2;
    a = ta, b=tb,c=tc;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 384
let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let parent i = int_of_float ((float_of_int (i - 1)) /. 2.)

let left i = 2*i + 1

let right i = 2*i + 2

let to_pow_of_2 n =
  let rec doit i =
    if i > n then i
    else doit (i * 2) in
  doit 1

let add (s : int array) n i x =
  let j = n + i - 1 in
  s.(j) <- x + s.(j);
  let rec doit j =
    if j > 0 then begin
      let j = parent j in
      s.(j) <- s.(left j) + s.(right j);
      doit j
    end in
  doit j

let sum s n a b =
  let rec doit a b k l r =
    if r < a || b < l then 0
    else if a <= l && r <= b then s.(k)
    else doit a b (left k) l ((l + r) / 2) + doit a b (right k) ((l + r) / 2 + 1) r in
  doit a b 0 0 (n - 1)

let solve n q =
  let n = to_pow_of_2 n in
  let s = Array.make (2*n) 0 in
  let rec doit i =
    if i < q then begin
      begin match List.map int_of_string (split (read_line ()) ' ') with
      | 0 :: x :: y :: _ -> add s n x y
      | 1 :: x :: y :: _ -> Printf.printf "%d\n" (sum s n x y)
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; q] -> solve n q
  | _ -> ()

Measured memory_bytes: 6472
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ab = a+b;
		long ans;
		
		if(n%ab==0) {
			ans = a*(n/ab);
		}
		else {
			ans = a*(n/ab)+Math.min(n%ab, a);
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 23764
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main implements Runnable {
	public static void main(String[] args) throws FileNotFoundException {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}

	public void run() {
		input();
	}

	void input() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			--a[i];
		}
		solver(n, k, a);
	}

	int ans = 0;

	void solver(int n, int k, int[] a) {
		// i->a[i]
		ArrayList<Integer>[] g = new ArrayList[n];
		for (int i = 0; i < g.length; ++i)
			g[i] = new ArrayList<>();
		for (int i = 1; i < n; ++i) {
			g[a[i]].add(i);
		}
		if (a[0] != 0) {
			++ans;
			a[0] = 0;
		}
		depth = new int[n];
		dfs(0, -1, g, k);
		System.out.println(ans);
	}

	int[] depth;

	void dfs(int cur, int par, ArrayList<Integer>[] g, int K) {
		depth[cur] = 0;
		for (int dst : g[cur]) {
			dfs(dst, cur, g, K);
			depth[cur] = Math.max(depth[dst] + 1, depth[cur]);
		}
		if (depth[cur] == K - 1 && par != 0 && cur != 0) {
			++ans;
			depth[cur] = -1;
		}
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 92452
from heapq import heappush, heappop
n, ma, mb = map(int, raw_input().split())
dp = {(0, 0): 0}
INF = 10**18
for i in xrange(n):
    a, b, c = map(int, raw_input().split())
    for x, y in sorted(dp.keys())[::-1]:
        dp[x+a, y+b] = min(dp.get((x+a, y+b), INF), dp[x, y] + c)
ans = INF
for x, y in dp:
    if x*mb == y*ma > 0:
        ans = min(ans, dp[x, y])
print -1 if ans==INF else ans

Measured memory_bytes: 5844
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n; cin >> n;
    VI a(n); REP(i,n) cin >> a[i];
    VI b = a; SORT(b); REVERSE(b);
    int n1 = b[0] , n2 = b[1];
    REP(i,n) if(a[i]==n1){out(n2);} else out(n1);

    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; if (x >= mod) x -= mod; else if (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void out(T s) { cout << s << "\n"; }
template <class T> inline void out(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e5 + 10;
string s, t; 
void run() {
	int res = 0;
	for (int i = 0; i < 3; ++i)
		res += s[i] == t[i];
	cout << res << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> s >> t) run();
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
K= int(input())

list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(list[K-1])



Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	string in,s{};
	
	cin >> in;
	
	in=in+'_';
	for(int i=0;i<in.size();i++)
	{
		s+=in[i];
		if(in[i]=='B' && in[i+1]=='C')
		{
			s[s.size()-1]='X';
			i++;
		}
	}

	lint sum=0;
	lint ans=0;
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='A')
			ans+=sum;
		else if(s[i]=='X')
			sum++;
		else sum=0;
	}

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



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    constexpr int N_MAX = 2999;
    int N;
    long double p[N_MAX];
    cin >> N;
    REP(i, N) cin >> p[i];

    long double dp[N_MAX + 1][N_MAX + 1];
    dp[0][0] = 1;
    REP(i, N) REP(j, i + 2) {
        if (j - 1 >= 0) {
            dp[i + 1][j] = dp[i][j] * (1 - p[i]) + dp[i][j - 1] * p[i];
        } else {
            dp[i + 1][j] = dp[i][j] * (1 - p[i]);
        }
    }
    long double result = 0;
    FOR(i, N / 2 + 1, N + 1) {
        result += dp[N][i];
    }
    printf("%.16Lf\n", result);
    return 0;
}



Measured memory_bytes: 140672
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

/* 配列の要素を交換する */
void Swap(long long x[], int i, int j)
{
	int temp;

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

void QSort(long long x[], long long y[], int left, int right)
{
	int i, j;
	int pivot;

	i = left;                      /* ソートする配列の一番小さい要素の添字 */
	j = right;                     /* ソートする配列の一番大きい要素の添字 */

	pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

	while (1) {                    /* 無限ループ */

		while (x[i] < pivot)       /* pivot より大きい値が */
			i++;                   /* 出るまで i を増加させる */

		while (pivot < x[j])       /* pivot より小さい値が */
			j--;                   /*  出るまで j を減少させる */
		if (i >= j)                /* i >= j なら */
			break;                 /* 無限ループから抜ける */

		Swap(x, i, j);             /* x[i] と x[j]を交換 */
		Swap(y, i, j);             /* x[i] と x[j]を交換 */
		i++;                       /* 次のデータ */
		j--;
	}

	if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
		QSort(x,y, left, i - 1);     /* 左の配列を Q ソートする */
	if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
		QSort(x,y, j + 1, right);    /* 右の配列を Q ソートする */
}

int main() {
	int N, M;
	cin >> N >> M;
	long long A[200000];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	long long B[200000], C[200000];
	for (int i = 0; i < M; i++) {
		cin >> B[i] >> C[i];
	}
	QSort(C, B, 0, M);
	int cnt = 0;
	int Bcnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] < C[M - cnt]) {
			A[i] = C[M - cnt];
			Bcnt++;
		}
		else break;
		if (Bcnt + 1> B[M - cnt]) {
			Bcnt = 0;
			cnt++;
		}

	}
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;


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

  int cnt = 0;
  for(int i = 0;i < N-1;i++){
    if(s[i] == '#' && s[i+1] == '.')cnt++;
  }

  vector<int> to_period(cnt+1,0);
  vector<int> to_sharp(cnt+1,0);

  string s1 = s;
  int index1 = 1;
  for(int i = 0;i < N-1;i++){
    if(s1[i] == '#' && s1[i+1] == '.'){
      int now_cnt = 0;
      for(int j = i;j >= 0;j--){
	if(s1[j] == '#'){
	  s1[j] = '.';
	  now_cnt++;
	}
	else break;
      }
      to_period[index1] = now_cnt + to_period[index1-1];
      index1++;
    }
  }

  string s2 = s;
  reverse(s2.begin(),s2.end()); 
  int index2 = 1; 
  for(int i = 0;i < N-1;i++){
    if(s2[i] == '.' && s2[i+1] == '#'){
      int now_cnt = 0;	
      for(int j = i;j >= 0;j--){
	if(s2[j] == '.'){
	  s2[j] = '#';
	  now_cnt++;
	}
	else break;
      }
      to_sharp[index2] = now_cnt + to_sharp[index2-1];
      index2++;
    }
  }

  int ans = 200000; 

  for(int i = 0;i <= cnt;i++){
    ans = min(ans,to_period[cnt-i]+to_sharp[i]);
  }

  cout << ans << endl;  
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define sc second
#define INF 3000000000
#define SINF 2*(1e18)
#define inf -10000000
#define pb push_back
#define forr(i,p,n) for(int i=p;i<n;i++)
#define mpk make_pair
#define upb(a,s) upper_bound(a.begin(),a.end(),s)
#define lwb(a,s) lower_bound(a.begin(),a.end(),s)
#define D(x) cout << #x " = " << (x) << endl
#define mem(a,val) memset(a,val,sizeof a)
#define cc continue
#define bb break
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
//priority_queue<ll> pq;
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
bool pal(string s){
  ll j=s.size()-1;
  ll sw=0;
  for(ll i=0;i<s.size()/2;i++){
    if(s[i]!=s[j]){sw=1;break;}j--;}
  if(sw)return false;
  else return true;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
    ll a,b,c,d,n,t,m,k;
    while(cin>>n){
      ll cnt=0;
      forr(i,1,n+1){
	if(i%3!=0 and i%5!=0)cnt+=i;
      }
      cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3648
char s[65536],t[65536];main(n,i,r,w,c){for(;scanf("%d",&n),n;puts(s))for(i=!scanf("%s",s);i++<n;t[w]=0,strcpy(s,t))for(r=w=0;r<strlen(s);t[w++]=s[r],r+=c){for(c=0;s[++c+r]==s[r];);for(sprintf(t+w,"%d\0",c);t[++w];);}}

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

int main(){
    string S;
    cin>>S;
    string a="";
    for(int i=1;i<=5;i++){
        a = a +  "hi";
        if(a==S){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
		int ans=0;
		ans+=Math.max(a,b);
  		if(a<=b){
          b--;
        }else{
          a--;
        }
  		ans+=Math.max(a,b);
  		
    
    	System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b)
{
    int *x, *y;
    
    x = (int *)a;
    y = (int *)b;
    
    return (*x - *y);
}

int binary_search(int *data, int n, int key)
{
    int left, right, center;
    int a, b;
    
    left = 0;
    right = n - 1;
    
    while (left <= right){
        center = (left + right) / 2;
        
        if (data[center] > key){
            right = center - 1;
        }
        else {
            left = center + 1;
        }
    }
    
    a = key - data[right];
    b = data[left] - key;
    
    return (a > b ? b : a);
}


int main(void)
{
    int d;
    int n, m;
    int dist[100001];
    int i, j, k;
    int ans;
    
    while (1){
        scanf("%d", &d);
        
        if (d == 0){
            break;
        }
        
        scanf("%d", &n);
        scanf("%d", &m);
        
        dist[0] = 0;
        
        for (i = 1; i < n; i++){
            scanf("%d", &dist[i]);
        }
        dist[n] = d;
        
        qsort(dist, n + 1, sizeof(int), compare);
        
        ans = 0;
        for (i = 0; i < m; i++){
            scanf("%d", &k);
            ans += binary_search(dist, n + 1, k);
        }
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 1116
N = int(input())

can = True
for i in range(N):
    t, x, y = list(map(int, input().split()))
    
    if not t%2 == (x+y)%2 or (x+y) > t:
        can = False
        break
        
if can:
    s = "Yes"
else:
    s = "No"
print(s)

Measured memory_bytes: 3060
N, M = tuple(map(int, input().split()))
cnt = [0 for _ in range(N+1)]
for _ in range(M):
    fr, to = tuple(map(int, input().split()))
    cnt[fr] += 1
    cnt[to] += 1
for i in range(1, N+1):
    print(cnt[i])



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const int inf=1e9;
const ll MOD=1e9+7;

int par[100005];
int root(int i){
    if(par[i]==i)return i;
    else return par[i]=root(par[i]);
}
int main(){
    int N,M;cin>>N>>M;
    rep(i,N)par[i]=i;
    rep(i,M){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        a=root(a);b=root(b);
        if(a!=b)par[par[b]]=par[a];
    }
    rep(i,N)par[i]=root(i);
    set<int> ans;
    rep(i,N)ans.insert(par[i]);
    cout<<ans.size()<<endl;
    return 0;
}

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


int main(){
    ll x1, x2, x3, x4, x5;

    cin >> x1 >> x2 >> x3 >> x4 >> x5;

    if(x1 == 0){
        cout << 1 << endl;
    }else if(x2 == 0){
        cout << 2 << endl;
    }else if(x3 == 0){
        cout << 3 << endl;
    }else if(x4 == 0){
        cout << 4 << endl;
    }else{
        cout << 5 << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int n;
string s;
int cnt[200005];

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n >> s;
    s = 'a' + s;
    int res = n;
    for (int i = 1; i < s.size(); i++)
        cnt[i] = cnt[i - 1] + (s[i] == 'W');
    for (int i = 0; i < s.size(); i++){
        int tmp = n - i - (cnt[n] - cnt[i]);
        res = min(res, max(cnt[i], tmp));
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 4544
import java.lang.StringBuilder

fun main(arr:Array<String>) {
    val inputCount = readLine()!!.toInt()
    val mojiList = (1..inputCount).map { readLine()!! }.sortedBy { it.length }
    var mp = getCharCount(mojiList[0])
    for(i in (1 until mojiList.size)) {
        mp = getSub(mojiList[i], mp)
    }
    if(mp.count() <= 0) {
        println("")
        return
    }
    val ans = StringBuilder()
    for(c in mp.keys.sorted()) {
        ans.append("".padStart(mp[c]!!, c))
    }
    println(ans.toString())
}

fun getSub(txt:String, map:MutableMap<Char, Int>): MutableMap<Char, Int> {
    val ret = getCharCount(txt)
    val keys = ret.keys.union(map.keys)
    val newMap = mutableMapOf<Char, Int>()
    for(c in keys) {
        val cnt1 = map[c]?:0
        val cnt2 = ret[c]?:0
        val cnt = Math.min(cnt1, cnt2)
        if(cnt > 0) {
            newMap[c] = cnt
        }
    }
    return newMap
}

fun getCharCount(txt:String): MutableMap<Char, Int> {
    val ans = mutableMapOf<Char, Int>()
    for(c in txt) {
        val cnt = ans[c]?:0
        ans[c] = cnt + 1
    }
    return ans
}


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


int main(){

    int n,k,tmp;
    cin >> n >> k;
    vector<int> a(n+10,0);

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

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

    int ans = 0;
    for(int i = 0;i < k;i++){
        ans+=a[i];
    }
    cout << n-ans << endl;
    
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <string>
using namespace std;

int main() {
	int a,b; string str;
	map<int,int> pre_m,post_m;
	map<int,int>::iterator mp;
	while(1)
	{
		getline(cin,str);
		if(str=="") break;
		string tmp="";
		int i=0;
		for( ;i<str.size();i++) if(str[i]==',') break; else tmp+=str[i];
		int TMP=atoi( tmp.c_str() );
		if(pre_m.find(TMP)==pre_m.end()) pre_m.insert(pair<int,int>(TMP,1));
		else pre_m[TMP]++;
	}
	while(scanf("%d,%d",&a,&b)!=EOF)
	{
		if(pre_m.find(a)==pre_m.end()) continue;
		if(post_m.find(a)!=post_m.end()) post_m[a]++;
		else post_m[a]=pre_m[a]+1;
	}
	for(mp=post_m.begin();mp!=post_m.end();mp++)
		cout << mp->first << ' ' << mp->second << '\n' ;
}

Measured memory_bytes: 1240
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#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;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vecotor<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H, W, sh, sw, gh, gw;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}


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



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int N;
	cin>>N; 
	set<int> st;
	REP(i,N){
		int a;
		cin>>a;
		st.insert(a);
	}
	YESNO(st.size()==N)






}







Measured memory_bytes: 12948