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

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

Measured memory_bytes: 3636
using System;
using System.Linq;

class K
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var a = read();
		var k = h[1];

		var dp = new bool[k + 1];
		for (int i = 1; i <= k; i++)
			dp[i] = a.Any(x => x <= i && !dp[i - x]);
		Console.WriteLine(dp[k] ? "First" : "Second");
	}
}


Measured memory_bytes: 17504
import java.io.*;
import java.util.*;

public class Main {

    static List<Integer> al[];
    private  static void solver(InputReader sc, PrintWriter out) throws Exception {
        String s = sc.next();
        StringBuilder sb2 = new StringBuilder(s);
        String ans = sb2.reverse().toString();
        int n = s.length();
        int a  = n /2;
        int b = (n/2)+1;
        String x =s.substring(0, a);
        String y = s.substring(b,n);
        x = x.trim(); y = y.trim();
        if(a != n-b)
            throw new Exception();
        StringBuilder sb = new StringBuilder(x);
        StringBuilder sb1 = new StringBuilder(y);
        String z = sb.reverse().toString(); String z1  = sb1.reverse().toString();
        if(ans.equals(s) && x.equals(z) && y.equals(z1))
            out.println("Yes");
        else
            out.println("No");

    }

    public static void main(String[] args) throws Exception{
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }

        public long[] readLongArr(int n){
            long arr[] = new long[n];
            for(int i=0; i<n; i++){
                arr[i] = nextLong();
            }
            return arr;
        }
        public int[] readIntArr(int n){
            int arr[] = new int[n];
            for(int i=0; i<n; i++){
                arr[i] = nextInt();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 22612
from math import ceil
n, a, b, c, d, e = (int(input()) for i in range(6))
move01 = int(ceil(n/a))
move12 = 1 + int(ceil(n/min(a,b)))
move23 = max(2 + int(ceil(n/c)), 1 + move12)
move34 = max(3 + int(ceil(n/d)), 1 + move23)
move45 = max(4 + int(ceil(n/e)), 1 + move34)
print(move45)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    queue<ll> Q;
    int K;
    cin >> K;
        for(int i = 1; i <= 9; i++){
        Q.push(i);
        }
        ll x;
        for(int i = 0; i < K; i++){
            x = Q.front();
            //cout << x << " ";
            Q.pop();
            if (x % 10 != 0) Q.push(10 * x + (x % 10) - 1);
            //cout << Q.front() << " ";
            Q.push(10 * x + (x % 10));
            //cout << Q.front() << " ";
            if (x % 10 != 9) Q.push(10 * x + (x % 10) + 1);
            //cout << Q.front() << " ";
            }
        cout << x;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  /*
  int n;
  cin >> n;
  map<string, int> list;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    string s;
    int t;
    cin >> s >> t;
    list[s] = t;
    sum += t;
  }
  string x;
  cin >> x;
  cout << sum - list[x] << endl;
  */

  int n;
  cin >> n;
  vector<pair<string, int>> list(n);
  for (int i = 0; i < n; i++) {
    cin >> list[i].first >> list[i].second;
  }
  string x;
  cin >> x;
  ll ans = 0;
  bool flag = 0;
  for (int i = 0; i < n; i++) {
    if (flag == true) ans += list[i].second;
    if (list[i].first == x) flag = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

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

N = int(input())
B = [0 for _ in range(N)]
for i in range(N):
    B[i] = int(input())


def bingo_judge(A, B):
    # 縦列のビンゴを判定
    for i in range(3):
        flag = True
        for a in [A[0][i], A[1][i], A[2][i]]:
            if not (a in B):
                flag = False
        if flag:
            print("Yes")
            sys.exit()
    # 横列のビンゴを判定
    for i in range(3):
        flag = True
        for a in A[i]:
            if not (a in B):
                flag = False
        if(flag):
            print("Yes")
            sys.exit()
    # 斜めのビンゴを判定
    flag = True
    for a in [A[0][0], A[1][1], A[2][2]]:
        if not (a in B):
            flag = False
    if flag:
        print("Yes")
        sys.exit()
    flag = True
    for a in [A[0][2], A[1][1], A[2][0]]:
        if not (a in B):
            flag = False
    if flag:
        print("Yes")
        sys.exit()
    print("No")


bingo_judge(A, B)


Measured memory_bytes: 9224
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long a, b, c, d, e, f = 0;
	cin >> a >> b >> c;
	if (b % 2 == 1 && c % 2 == 0) {
		cout << "Borys" << endl;
	}
	else if (b % 2 == 0 && c % 2 == 1) {
		cout << "Borys" << endl;
	}
	else {
		cout << "Alice" << endl;
	}
	cin >> e;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, x, mini = INT_MAX, maxi = -1;

    cin >> n;

    while (n--) {

        cin >> x;

        mini = min(mini, x);
        maxi = max(maxi, x);
    }

    cout << maxi-mini;

    return 0;
}


Measured memory_bytes: 256
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const ll N = 1e5 + 15, MOD =  998244353;

void solve() {
    int x;
    cin >> x;
    for (int i = 1; i <= 10000000; i++) {
        if (i * x % 360 == 0) {
            cout << i << "\n";
            return;
        }
    }
}



int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    } 
}                                   

Measured memory_bytes: 3644
#include <iostream>
#include <math.h>
using namespace std;
int main(void)
{
	int N;
	int i, j, k;
	int P[10000];
	int num = 0;

	cin >> N;
	
	for (i = 3;i <= 55555;i += 2)
	{
		k = 0;
		for (j = 3;j <= sqrt(i);j += 2)
		{
			if ((i%j == 0))
			{
				k = 1;
				break;
			}
		}

		if (k == 0&&(i%5==1))
			P[num++] = i;

		if (num >= N) {
			break;
		}
	}
	cout << P[0];
	for (int i = 1; i < N; i++)
	{
		cout << " " << P[i];
	}
	cout << endl;

	return 0;
}

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

using System.Collections;

class Program
{
    static void Main()
    {
        int[] abt = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int A = abt[0];
        int B = abt[1];
        int T = abt[2];

        Console.WriteLine((T / A) * B);
    }
    
}


Measured memory_bytes: 11348
#include <stdio.h>
char s[] = "\x00\x00\x00\x00" "\x00\x00\x00\x00" "\x00\x00\x00\x00";
int main(void) {
    int *i = (int *)s;
    scanf("%d%d%d", i + 0, i + 1, i + 2);
    printf("%d\n", (i[0] += i[1]) * (i[2] >> 1));
    return 0;
}


Measured memory_bytes: 128
// zアルゴリズムを試してみる
// https://snuke.hatenablog.com/entry/2014/12/03/214243

#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

// まずtに対してZ配列を作成
vector<int> getZArr(const string& str) {
  int str_size = str.size();

  vector<int> a(str_size);
  a[0] = str_size; // 使ってないのでなんでもいい
  int i = 1, j = 0;
  while (i + j < str_size) {
    while (i + j < str_size && str[i+j] == str[j]) {
      j++;
    }
    a[i] = j;

    if (j == 0) {
      i++;
      continue;
    }

    int k = 1;
    while (k < j && a[k] + k < j) {
      a[i+k] = a[k];
      k++;
    }

    i += k;
    // k < jでbreakした場合は、k==jで全部チェック済みなので、次回はまた最初(j=0)から。
    // a[k] + k < j でbreakした場合は、a[k] + k >= j, a[k] >= j - kなので、次は最低でもj-k-1までは一致している。よって次はj-kからチェックする
    j -= k;
  }

  return a;
}

vector<bool> check_eq(string s, string t) {
  int s_size = s.size();
  int t_size = t.size();
  vector<bool> result(s_size - t_size + 1);

  vector<int> zarr = getZArr(t + "$" + s); // 先に検索文字列を入れて、長さが一致するかを調べる
  int zarr_size = zarr.size();
  // 照合
  for (int i = 0; i < zarr_size; i++) {
    int j = i - (t_size + 1);
    if (j < 0) {
      continue; // t+"$"はスキップ
    }
    if (j >= result.size()) {
      break;
    }
    result[j] = zarr[i] == t_size;
  }
  
  return result;
}

int main() {
  string s,t,s_origin;
  cin >> s >> t;
  s_origin = s;
  int s_origin_size = s_origin.size();
  int t_size = t.size();
  
  while(s.size() < t_size + s_origin_size - 1) {
    s += s_origin;
  }
  s = s.substr(0, t_size + s_origin_size - 1);
  
  vector<bool> eqs = check_eq(s,t);
  
  int max_length = 0;
  vector<int> length(s_origin_size, -1);

  for (int i = 0; i < s_origin_size; i++) {
    if (length[i] != -1) {
      continue;
    }

    if (!eqs[i]) {
      length[i] = 0;
      continue;
    }

    int current = i;
    int diff = 0;
    queue<int> q;
    while(eqs[current]) {
      if (!q.empty() && i == current) {
        // 無限に一致する
        max_length = -1;
        goto finish;
      }

      if (length[current] != -1) {
        diff = length[current]; // すでに到達済みの場合、計算済みの長さを加えて終了する
        break;
      }
      length[current] = 0; // 一旦到達マーク設定
      q.push(current);
      current = (current + t_size) % s_origin_size;
    }

    max_length = max(max_length, diff + (int)q.size());

    while(!q.empty()) {
      int len = q.size();
      int current = q.front();
      q.pop();
      length[current] = len + diff; // 正確な長さで上書き
    }
  }

finish:
  cout << max_length << endl;
  
  return 0;
}


Measured memory_bytes: 10232
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=100001;

int main(){
  int n;
  cin>>n;
  set<int> s;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    if(s.find(tmp)==s.end()){
      s.insert(tmp);
    }
    else{
      s.erase(s.find(tmp));
    }
  }
  cout<<s.size()<<endl;
  return 0;
}


Measured memory_bytes: 4864
n=int(input())
t,a=map(int,input().split())
l=list(map(int,input().split()))
d=sorted(l+[(t-a)*500/3])
b=d.index((t-a)*500/3)
bn=(t-a)*500/3
if b==0:
  print(l.index(d[1])+1)
elif b==n:
  print(l.index(d[n-1])+1)
else:
  x,y=d[b-1],d[b+1]
  k=min([bn-x,y-bn])
  print(l.index(x)+1) if k==bn-x else print(l.index(y)+1)

Measured memory_bytes: 3064
package main

import "fmt"

func sumArray(a []int) int {
	var s int
	for i := 0 ; i < len(a) ; i++ {
		s += a[i]
	}
	return s
}

func main(){
	var n,k,max int
	fmt.Scan(&n,&k)
	p := make([]int, n)
	sort := make([]int, k)
	for i := 0 ; i < k ; i++ {
		fmt.Scan(&p[i])
	}
	m := sumArray(p[0:k])
	max_i := k-1
	for i := k ; i < n ; i++{
		fmt.Scan(&p[i])
		m += (p[i]-p[i-k])
		if m > max {
			max = m
			max_i = i
		}
	}
	sort = p[max_i-k+1:max_i+1]
//fmt.Println(sort)
	var sum float64
	for i := 0 ; i < k ; i++ {
		sum += float64((float64(sort[i])+1.0)/2.0)
//fmt.Println(sum)
	}
	fmt.Println(sum)
}


Measured memory_bytes: 6272
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int A = sc.nextInt();
  int B = sc.nextInt();
  int C = sc.nextInt();
  int X = sc.nextInt();
  int count = 0;
  for(int i = 0;i <= A;i++){
    for(int j = 0;j <= B;j++){
      for(int k = 0;k <= C;k++){
if(500*i + 100*j +50*k == X)count += 1;
      }
    }
  }
System.out.println(count);
}
}
  


Measured memory_bytes: 22868
n=int(input())
a=list(map(int,input().split()))
sa=sorted(a)
count=1
k=[0]*(n+2)
for i in range(n-1):
  if sa[i+1]==sa[i]:
    count+=1
  else:
    k[sa[i]]=count
    count=1
k[sa[-1]]=count
ans=0
for i in range(len(k)):
  ans+=k[i]*(k[i]-1)/2 
for i in a:
  print(int(ans-(k[i]*(k[i]-1)/2)+((k[i]-1)*(k[i]-2)/2)))

Measured memory_bytes: 26140
#if 1
#include <iostream>
#include <string>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    long long n;
    std::cin >> n;
    if (n % 2 == 1 || n == 0) {
        std::cout << 0 << '\n';
    } else {
        long long res = 0;
        long long div = 10;
        while (div <= n) {
            res += n / div;
            div *= 5;
        }
        std::cout << res << '\n';
    }
    return 0;
}
#endif

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, d; cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) {
    rep(j, d) {
      cin >> x[i][j];
    }
  }

  set<int> st;
  rep(i, 10000) {
    st.insert(i*i);
  }

  int ans = 0;
  for(int i=0; i<n; i++) {
    for(int j=i+1; j<n; j++) {
      int now = 0;
      rep(k, d) {
        int p = x[i][k]-x[j][k];
        now += p*p;
      }
      debug(i, j, now);
      if (st.find(now) != st.end()) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 768
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int ans = 0;
    int nh = 0;
    
    if(n%2==0){
      nh = n/2;
    } else {
      nh = (n+1)/2;
    }
    
    for(int i=1; i<nh; i++){
      if(n-i!=i){
        ans++;
      }
    }

    System.out.println(ans);
    
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll INF = ll(1e18)+1;
const ll MOD = ll(1e9)+7;


ll mod_factorial(ll n){

    if (n < 1){
        return 1;
    }

    ll r = n;
    for (int i = 0; i < n-1; i++) {
        r = r*(i+1) % MOD;
    }
    
    return r;
}

ll mod_pow(ll n, ll m){

    ll r = 1;

    while (m > 0){
        if (m & 1){
            r = r*n % MOD;
        }
        n = n * n % MOD;
        m = m>>1;
    }

    return r;
}


ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    int i=0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
        i++;
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

ll mod_comb(ll n, ll k){

    if ((n+k) < 1) {
        return 1;
    }
    ll a = 1;
    ll b = 1;

    for (int i = 0; i < k; i++) {
        a = a * (n-i) % MOD;
        b = b * (i+1) % MOD;
    }

    return (a * modinv(b, MOD)) % MOD;
}


int main() {
    ll n, a, b;

    cin >> n >> a >> b;

    ll ans = 0;

    if (n > 2) {
        ans = mod_pow(2, n);
        ans = ans - mod_comb(n, a) + MOD;
        ans = ans - mod_comb(n, b) + MOD;
        ans = ans -1 + MOD;
    }

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

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()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  string s;
  cin >> s;
  REP(i, s.size()){
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }

  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3592
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
import string

def decimal_to_26(N):
    number_list = []
    while True:
        number_list.append(N%26)
        N = N//26
        if N == 0:
            if number_list[-1] == 0:
                number_list.pop(-1)
            break
    number_list = number_list[::-1]
    N_26_str = "".join(
        [string.ascii_lowercase[i] for i in number_list]
    )
    return N_26_str

def main():
    N = int(input())
    N -= 1

    counter = 1
    while N >= pow(26, counter):
        N -= pow(26, counter)
        counter += 1
    
    N_26_str = decimal_to_26(N)
    answer = "a"*(counter-len(N_26_str))+N_26_str
    print(answer)

if __name__ == "__main__":
    #print(decimal_to_26(26))
    main()



Measured memory_bytes: 9976
def GCD(a, b):
	while b!=0:
		tmp=b
		b=a%b
		a=tmp
	return a
while True:
	try:
		a, b = map(int, input().split())
	except EOFError:
		break
	a, b = (a, b) if a>=b else (b, a)
	gcd=GCD(a,b)
	print(gcd, a*b//gcd)


Measured memory_bytes: 5592
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( $ t : ty ;; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ;; ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let n = get!(usize);

    if (0..100).any(|x| n >= 4 * x && (n - 4 * x) % 7 == 0) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 8572
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

int N;
i64 h[100100];
i64 dp[100100];

signed main()
{
  cin >> N;

  for (int i = 1; i <= N; ++i) {
    cin >> h[i];
  }

  for (int i = 2; i <= N; ++i) {
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);

    if (i-2 >= 1)
      chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }

  cout << dp[N] << endl;

  return 0;
}



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

using namespace std;

typedef long long int64;

vector< pair< int, int > > g[100000];
int64 dist[100000];

int dfs(int idx, int par = -1)
{
  for(auto &to : g[idx]) {
    if(to.first == par) continue;
    dist[to.first] = dist[idx] + to.second;
    dfs(to.first, idx);
  }
}

int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  int Q, K;
  cin >> Q >> K;
  dfs(--K);
  for(int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    cout << dist[x] + dist[y] << endl;
  }
}


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

int main() {
    char c;
    cin >> c;
    cout << c;
    for (int i = 0; i < 4; i++) cin >> c;
    cout << c;
    for (int i = 0; i < 4; i++) cin >> c;
    cout << c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b; cin >> a >> b;
  if(a >= b){
    REP(i, a){
      cout << b;
    }
    cout << endl;
  }else{
    REP(i, b){
      cout << a;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = sorted(list(set(map(int, input().split()))))

while len(a) > 1:
    for i in range(1, len(a)):
        a[i] %= a[0]
    a = sorted(set(a))

    if a[0] == 0:
        a = a[1::]

print(*a)


Measured memory_bytes: 20012
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
import random
sys.setrecursionlimit(4100000)


D = int(input())
C = list(map(int,input().split()))

S = []
for i in range(D):
    tmp = list(map(int,input().split()))
    S.append(tmp)


class Schejule:

    def __init__(self, sche):
        self.base = sche
        self.last = [0] * 26
        self.y = 0

    def get_score(self):
        self.y = 0
        for d in range(D):
            self.y += S[d][self.base[d]]

        for d in range(D):
            self.last[self.base[d]] = d + 1

            for j in range(26):
                self.y -= C[j] * (d+1 - self.last[j])

    def change_one(self, day, to):

        org = self.base[day]

        # 差分
        div = 0

        # その日の満足度の変化
        div += S[day][to] - S[day][org]

        # 損失
        org_loss = 0
        cha_loss = 0

        org_last = 0
        cha_last = 0
        for d in range(D):
            if self.base[d] == org:
                org_last = d + 1
            elif self.base[d] == to:
                cha_last = d + 1

            org_loss +=  C[org] * (d+1 - org_last)
            cha_loss +=  C[to ] * (d+1 - cha_last)

        def_loss = cha_loss + org_loss


        org_loss = 0
        cha_loss = 0

        org_last = 0
        cha_last = 0
        for d in range(D):
            if d != day:
                if self.base[d] == org:
                    org_last = d + 1
                elif self.base[d] == to:
                    cha_last = d + 1
            else:
                cha_last = d+1

            org_loss +=  C[org] * (d+1 - org_last)
            cha_loss +=  C[to ] * (d+1 - cha_last)

        aft_loss = cha_loss + org_loss


        # 全体の差分
        div -= aft_loss - def_loss

        # ε-greedy
        if div > 0 or random.randint(0, 9) >= 7:
            next_plan = self.base
            next_plan[day] = to

            sche_next = Schejule(next_plan)
            sche_next.y = self.y + div

            return sche_next
        else:
            return self



T = [0] * D

for i in range(D):
    max_day = 0
    for j in range(26):
        if S[i][max_day] < S[i][j]:
            max_day = j
    T[i] = max_day


sche_base = Schejule(T)
sche_base.get_score()


best_score = sche_base.y
best_set = T

#print(sche_base.y)

#print(*sche_base.base)

for i in range(1000):
    d = random.randint(0, D - 1)
    t = random.randint(0, 26 - 1)

    sche_base  = sche_base.change_one(d, t)

    if best_score < sche_base.y:
        best_score = sche_base.y
        best_set = sche_base.base
    #print(*sche_base.base)

    #print(sche_base.y)

for i in range(D):
    print(best_set[i] + 1)


#print(best_score)









Measured memory_bytes: 79576
#p進数展開と同じ(-2)で割ったあまりを追加していく

N = int(input())
ans = ""
while(N != 0):
    if N%2 !=0:
        N -=1
        ans ="1"+ans
    else:
        ans ="0"+ans
    N = N //(-2)
print(ans if ans!="" else 0)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int w = sc.nextInt();
      	int h = sc.nextInt();
      	int x = sc.nextInt();
      	int y = sc.nextInt();
      
      	double area = (double)w*h/2.0;
      	int d = 0;
      	if(w==2*x && h==2*y)
          d = 1;
      	System.out.print(area);
      	System.out.print(" " + d);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
typedef long long ll;
int main(){
    int k;
    cin>>k;
    vector<int>A={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
};
cout<<A[k-1]<<endl;

    return 0;
}

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

int main(){
	int m, f, r;
	for(int i=0; i>=0; i++){
		cin >> m >> f >> r;
		if(m==-1&&f==-1&&r==-1) break;
		if(m==-1 || f==-1) cout << "F" << endl;
		else if(m+f>=80) cout << "A" << endl;
		else if(m+f>=65) cout << "B" << endl;
		else if(m+f>=50) cout << "C" << endl;
		else if(m+f>=30  && r>=50) cout << "C" << endl;
		else if(m+f>=30) cout << "D" << endl;
		else cout << "F" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)




int main() {
    int N,M;cin >> N >> M;
    vector<LL> H(N);rep(i,N)cin >> H[i];
    vector<LL> A(M);
    vector<LL> B(M);
    rep(i,M){
        int a,b;cin >> a >> b;
        a--;b--;
        A[i] = a;
        B[i] = b;
    }
    vector<bool> ok(N,true);

    rep(i,M){
        if(H[A[i]] <= H[B[i]])ok[A[i]] = false;
        if(H[B[i]] <= H[A[i]])ok[B[i]] = false;
    }

    int ans = 0;
    rep(i,N){
        if(ok[i])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#define llu long long unsigned int
#define f(x,y) for(int x=0;x<y;x++)

int main() {
    int n;
    scanf("%d",&n);
    if(n/100==n%10)
        printf("Yes\n");
    else printf("No\n");
    return 0;}


Measured memory_bytes: 128
import java.util.Scanner;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
 

		if (a == 0) {
			System.out.println(1);
		} else if (b == 0) {
			System.out.println(2);
		} else if (c == 0) {
			System.out.println(3);
		} else if (d == 0) {
			System.out.println(4);
		} else if (e == 0) {
			System.out.println(5);
		}
	}
}

Measured memory_bytes: 35836
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<vector>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//purplesun
const int N=2e5+10;
int n,a[N],b[N];
//
int main()
{
	n=getint();
	rep(i,2*n-1)b[i]=getint();
	int lb=1,rb=2*n;
	while(rb-lb>1)
	{
		int mid=(lb+rb)>>1;
		rep(i,2*n-1)a[i]=(b[i]>=mid);
		int p=n-1,x=a[p],ans=0;
		bool flag=false;
		while(p>0)
		{
			p--;
			if(a[p]==x||a[n*2-p-2]==x)
			{
				ans=x;
				flag=true;
				break;
			}
			x^=1;
		}
		if(!flag)ans=a[0]&1;
		if(ans)lb=mid;
		else rb=mid;
	}
	printf("%d\n",lb);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vector<ll> a(n),sum(n+1,0);
	rep(i,n){
		cin>>a[i];
	}
	sort(begin(a),end(a));
	rep(i,n) sum[i+1]=sum[i]+a[i];
	auto solve=[&](ll x){
		ll ret=0;
		rep(i,n){
			ret+=end(a)-lower_bound(begin(a),end(a),x-a[i]);
		}
		return ret>=m;
	};
	ll ok=0,ng=inf,mid;
	while(ng-ok>1){
		mid=(ok+ng)/2;
		if(solve(mid)) ok=mid;
		else ng=mid;
	}
	ll ans=0,cnt=0;
	for(int i=n-1;i>=0;i--){
		ll ind=upper_bound(begin(a),end(a),ok-a[i])-begin(a);
		cnt+=n-ind;
		ans+=a[i]*(n-ind)+sum[n]-sum[ind];
	}
	ans+=ok*(m-cnt);
	cout<<ans<<endl;
}

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

#define MOD 1000000007

typedef struct node{int value;struct node* right;struct node* left;}node;

void swap(int* a,int* b){int c=*a;*a=*b;*b=c;}
int gcd(int a, int b){if(a<b){swap(&a,&b);}while(a%b!=0){int c=a%b;a=b;b=c;}return b;}
int* mid(int* a, int* b, int* c){if(*b<*a&&*a<*c){return a;}if(*a<*b&&*b<*c){return b;}return c;}
void sort(int is_ascending,int* a,int n){if(n<=1){return;}srand((unsigned int)time(NULL));int l=0,r=n-1;int* p=mid(a,a+n-1,a+(rand()%n));while(l<=r){if(is_ascending){while(*(a+l)<*p){l++;}while(*p<*(a+r)){r--;}}else{while(*(a+l)>*p){l++;}while(*p>*(a+r)){r--;}}if(r<=l){break;}swap(a+l,a+r);l++;r--;}sort(is_ascending,a,l);sort(is_ascending,a+r+1,n-r-1);}
int permutations(int n, int r){int a=n;for(int i=1;i<=r;i++){a*=n-i;}return a;}
unsigned long long int modinv(unsigned long long int a){
    long long int b = MOD, u = 1, v = 0;
    while(b > 0){
        long long int t = a/b;
        a -= t*b;
        u -= t*v;
        long long buf = a;
        a = b;
        b = buf;
        buf = u;
        u = v;
        v = buf;
    }
    if(u<0){
        u += MOD;
    }
    u = u%MOD;
    return u;
}

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

void init(){
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<510000; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

unsigned long long int combination(unsigned long long int n,unsigned long long int r){
    if(r==0||r==n){
        return 1;
    }
    if(r==1){
        return n;
    }
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}
//int isPrime(int n){if(n==1){return 0;}if(n==2||n==3){return 1;}if(n%2==0||n%3==0){return 0;}for(int i=5;i*i<=n;i+=2){if(i%3==0){continue;}if(n%i==0){return 0;}}return 1;}

int main(){
    unsigned long long int h, w, a, b;
    scanf("%llu%llu%llu%llu", &h, &w, &a, &b);
    unsigned long long int ans = 0;
    init();
    while(b < w){
        ans += (((combination(b+h-a-1, b)%MOD) * (combination(a-1+w-b-1, a-1)%MOD))%MOD);
        ans = ans%MOD;
        b++;
    }
    printf("%llu", ans);

    return 0;
}

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

using namespace std;

#define up(x,y) (((x)+(y)-1)/(y))
#define LL long long

LL n,m,x,y,ll,rr;

int main(){
	scanf("%lld",&n);
	while (n--){
		scanf("%lld%lld%lld%lld",&x,&y,&ll,&rr);
		LL len=up(max(x,y),(min(x,y)+1));
		LL l=0,r=x+y,tmp=-1;
		while (l<=r){
			LL mid=(l+r)>>1;
			LL xx=x-(mid-mid/(len+1)),yy=y-mid/(len+1);
			if (yy<=1LL*xx*len) tmp=mid,l=mid+1;
			else r=mid-1;
		}
		tmp++;
		for (LL i=ll;i<=min(tmp,rr);i++) putchar(i%(len+1)?'A':'B');
		for (LL i=max(tmp+1,ll);i<=rr;i++) putchar((x+y-i+1)%(len+1)?'B':'A');
		puts("");
	}
	
	return 0;
}
			

Measured memory_bytes: 384
# print('input >>')
K, N = map(int,(input().split()))
As = list(map(int,(input().split())))

As = [A - As[0] for A in As]
As_diffs = [As[i+1] - As[i] for i in range(len(As)-1)]
As_diffs += [K - As[-1]]
As_fiff_max = max(As_diffs)

# print('-----output-----')
print(K - As_fiff_max)

Measured memory_bytes: 26420
import sys
from bisect import bisect_left

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

N = ir()
A = lr()
A.sort()
# -の合計数は最大N-1、最小N//2
minus = bisect_left(A, 0)
# minusは負の数の個数
m = min(minus, N-1)
if m == 0: m += 1
# mは最終的にマイナスにする数
answer = -sum(A[:m]) + sum(A[m:])
print(answer)
cur = A[0]
for i in range(m, N-1):
    print(cur, A[i])
    cur -= A[i]

A[0] = cur
cur = A[N-1]
for i in range(m):
    print(cur, A[i])
    cur -= A[i]

# 53


Measured memory_bytes: 14324
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int cnt;
int main(void){
  int a,b;
  while(cin>>a>>b,a+b){
    cnt = 0 ;
    if(a<b){
      int tmp = a;
      a = b;
      b = tmp;
    }
    int tmp;
    while(b!=0){
      cnt ++;
      //cout << a <<" " << b << endl;
      tmp = a % b;
      a = b;
      b = tmp;
    }
    cout<< a <<" "<< cnt << endl;
  }
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-


def main():
    s = input()
    n = len(s)

    # KeyInsight
    # 2文字が全て同じ，もしくは，3文字のうち2文字以上が同じ文字なら
    # 条件を満たす
    for i in range(n - 1):
        if s[i] == s[i + 1]:
            print(i + 1, i + 2)
            exit()

    for j in range(n - 2):
        if len(set(list(s[j:j + 3]))) <= 2:
            print(j + 1, j + 3)
            exit()

    print(-1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long K = sc.nextLong();
		if (s.length()==1) {
			System.out.println(K/2);
			return ;
		}
		long count =0;
		boolean b = true;
		for (int i=1;i<s.length();i++) {
			if (s.charAt(i-1)!=s.charAt(i)) {
				b =false;
				break;
			}
		}
		if (b==true) {
			System.out.println(s.length()*K/2);
			return ;
		}
		 b = true;
		for (int i=1;i<s.length();i++) {
			if (s.charAt(i-1)==s.charAt(i)) {
				count ++;
				if (i==s.length()-1) {
					b = false;
				}
				i++;
			}
		}
		for (int i=1;i<s.length();i++) {
			if (s.charAt(i-1)!=s.charAt(i)) {
				if (i%2==0) {
					b =false;
				}
				break;
			}
		}
		if (b==true&&s.charAt(s.length()-1)==s.charAt(0)) {
			System.out.println(count *K+K-1);
		} else {
			System.out.println(count *K);
		}
	}
}

Measured memory_bytes: 35744
#include<stdio.h>
#include<string.h>
int main(){
  int ss,i,j,flag=0;
  char s;
  while(scanf("%c",&s)){
  if(s=='\n')break;
  if(s>96 && s<123)s-=32;
  printf("%c",s);
  }
  printf("\n");
  return(0);
}

Measured memory_bytes: 524
import sys
readline = sys.stdin.readline

# 制約が小さいので、「見えてほしい建物」を全探索できる

N,K = map(int,readline().split())
A = list(map(int,readline().split()))

ans = 10 ** 13
for i in range(2 ** N):
  case = bin(i)[2:].zfill(N)
  if case.count("1") < K:
    continue
  # 前から順に見ていって、それまでで一番大きい建物の高さを記録
  # 選ばれた建物が、それまでで一番大きい建物の高さ + 1の高さになるように金額を計算
  # その最小値を求める
  cost = 0
  high = 0
  for j in range(N):
    # j番目の建物は選ぶ対象か？
    if (i >> j) & 1:
      if high >= A[j]:
        high += 1
        cost += (high - A[j])
    high = max(A[j], high)
  if ans > cost:
    ans = cost
print(ans)

Measured memory_bytes: 9148
using System;
using System.Collections.Generic;
using System.Linq;

namespace agc035_a
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var a = CIn.ReadIntArray(n);

      Console.WriteLine(a.Aggregate((x, y) => x ^ y) == 0 ? "Yes" : "No");
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 21984
from collections import Counter

n = int(input())
d = Counter(list(map(int, input().split())))
m = int(input())
t = Counter(list(map(int, input().split())))

ans = 'YES'
for key, value in t.items():
    if value > d[key]:
        ans = 'NO'
        break
    else:
        pass
print(ans)

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

typedef long long int ll;

int main() {

  int n;
  cin >> n;

  vector<ll> arr;
  for(int i=0; i<n; i++) {
    ll t;
    cin >> t;
    arr.push_back(t);
  }

  ll cnt =0;
  ll j=0;
  ll max_so_far = -1;
  for(int i=1; i<arr.size(); i++) {
    max_so_far = max(max_so_far, arr[i-1]);
    if(arr[i] < max_so_far) {
      cnt += (max_so_far - arr[i]);
    }
  }

  cout << cnt << endl;

}


Measured memory_bytes: 5364
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
	string S; long long K;
	cin >> S >> K;
	for (int i = 0; i < min((long long)S.size(), K); i++) {
		if (S[i] >= '2') { cout << S[i] << endl; return 0; }
	}
	cout << '1' << endl;
	return 0;
}

Measured memory_bytes: 256
//abc101_a.cpp
//Sat Jun 23 20:52:55 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
using ll=long long;



int main(){
	string s;
	cin >> s;
	int ans = 0;
	for (int i=0;i<s.size();i++){
		if (s[i] == '+'){
			ans++;
		}else {
			ans--;
		}
	}

	cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n,a[200005],b[200005] = {0};
    cin >> n;
    vector<int> v;
    for(int i = 1 ; i <= n ; i ++){
        cin >> a[i];
    }
    for(int i = n ; i > 0 ; i --){
        int cnt = 0;
        for(int j = i ; j <= n ; j += i){
            cnt += b[j];
        }
        if(cnt % 2 != a[i]){
            v.push_back(i);
            b[i] ++;
        }
    }
    cout << v.size() << endl;
    for(int i = 0 ; i < v.size() ; i ++){
        cout << v[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	int n;
	cin >> n;
	int a[n + 1];
	int x = 0;
	rep(i, 0, n)
	{
		cin >> a[i];
		x ^= a[i];
	}
	rep(i, 0, n)
	{
		int ans = x ^ a[i];
		cout << ans << " ";
	}
	return 0;
}

Measured memory_bytes: 5192
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    long double a,b,h,m;
    cin >> a >> b >> h >> m;

    long double ab = (0.5 * ((h*60)+m)) - (6.0 * m);
//    debug(ab);
    if (ab < 0) ab = -ab;
    ab = min(ab, 360-ab);
    long double co = cos(ab * M_PI / 180.0);
    cout << sqrt(a*a + b*b - 2*a*b*co) << endl;

}


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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;



const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
 
     




int main() {
    ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';
    cout.precision(16);
    

    int n;
    cin >> n;
    vector<pii> as(n);
    ii (n) {
        cin >> as[i].uu;
        as[i].vv = i;
    }
    sort(all(as));

    set<int> taken_indices;
    taken_indices.insert(-1);
    taken_indices.insert(n);

    LL rr = 0;
    ii (len(as)) {
        LL here = as[i].uu;
        int index = as[i].vv;
        ite(taken_indices) it = taken_indices.lower_bound(index);
        ite(taken_indices) previous = it;
        --previous;
        here *= LL(*it - index) * LL(index - *previous);
        rr += here;
        taken_indices.insert(index);
    }

    cout << rr << '\n';

    

    return 0;
}



Measured memory_bytes: 11136