akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;


int main(){
    int data[2000]={};
    vi a;
    int m,n;
    cin>>m>>n;
    rep(i,m){
        int tm;
        cin>>tm;
        a.pb(tm);
    }
    
    rep(i,n){
        int tm;
        cin>>tm;
        rep(j,m){
            if(a[j]<=tm){
                data[j]++;
                break;
            }
        }
    }
    
    int v=-1,num=-1;
    rep(i,m){
        if(data[i]>v){
            v=data[i];
            num=i;
        }
    }
    cout<<num+1<<endl;
    
    return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
#include <unordered_map>
#include <numeric>
using namespace std;
#define fol(i,n) for (int i=1;i<=n;i++)

int main(){
    int N;
    long long p=1;
    cin >>N;
    fol(i, N){
        p = (p*i)%1000000007;
    }
    cout << p<<endl;
}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  map<string, int> mp;
  int q; cin >> q;
  for (int i = 0; i < q; ++i) {
    int op; cin >> op;
    if (op == 0) {
      string k; int x; cin >> k >> x;
      mp[k] = x;
    } else {
      string k; cin >> k;
      cout << mp[k] << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 25892
#include "bits/stdc++.h"

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) (a).begin(), (a).end()
#define inf 10000000
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    if (n==5||n==3||n==7){
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
    
return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    if(n <= 111) cout << 111 << endl;
    else if(n <= 222) cout << 222 << endl;
    else if(n <= 222) cout << 222 << endl;
    else if(n <= 333) cout << 333 << endl;
    else if(n <= 444) cout << 444 << endl;
    else if(n <= 555) cout << 555 << endl;
    else if(n <= 666) cout << 666 << endl;
    else if(n <= 777) cout << 777 << endl;
    else if(n <= 888) cout << 888 << endl;
    else cout << 999 << endl;

    return 0;
}


Measured memory_bytes: 3556
/*
  AOJ 1052
  Title:
  @kankichi573
*/
#include <stdio.h>
#include <stdlib.h>

int N,M;
struct bridge_st
{
  int br;
  int tr;
};

struct bridge_st brg[25];

int compare_br(const void *a, const void *b)
{
  if( ((struct bridge_st *)a)->br > ((struct bridge_st *)b)->br)
    return(-1);
  if( ((struct bridge_st *)a)->br < ((struct bridge_st *)b)->br)
    return(1);
  if( ((struct bridge_st *)a)->tr > ((struct bridge_st *)b)->tr)
    return(-1);
  if( ((struct bridge_st *)a)->tr < ((struct bridge_st *)b)->tr)
    return(1);
  if( ((struct bridge_st *)a)->tr == ((struct bridge_st *)b)->tr)
    return(0);
}

int main()
{
  int i,ret,flag,sum;
  
  while(scanf("%d",&N) && N)
    {
      for(i=sum=0;i<N;i++)
	{
	  scanf("%d %d",&brg[i].tr,&brg[i].br);
	  sum += brg[i].tr;
	}

      qsort(brg,N,sizeof(struct bridge_st),compare_br);
      //printf("sum=%d\n",sum);
      
      flag=1;
      //for(i=0;i<N;i++)
      //printf("%d %d\n",brg[i].tr,brg[i].br);
      
      for(i=0;i<N;i++)
	{
	  if(brg[i].br < sum)
	    {
	      flag=0;
	      break;
	    }
	  sum -= brg[i].tr;
	}
      printf("%s\n",flag?"Yes":"No");
    }
  return(0);
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> vec(n);
    rep(i,n){
        int a;
        cin >> a;
        pair<int,int> p = mp(a,i+1);
        vec.at(i)=p;
    }
    sort(all(vec));
    rep(i,n){
        cout << vec.at(i).se<<' ';
    }
}


Measured memory_bytes: 1536
#include <stdio.h>

#define arr_print_d0dn(a, n) for(int i=0;i<(n)-1;++i)put_uint((a)[i]),putchar_unlocked(' ');put_uint((a)[(n)-1]),putchar_unlocked('\n')
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) {
        n = 10 * n + (c & 0xf);
        c = getchar_unlocked();
    }
    return n;
}
void counting_sort(int *dst, const int *src, const int N, const int max) {
    // 'int c[max+1] = {}' cannot initialize
    int c[10001] = {};
    for(int i = 0; i < N; ++i) c[src[i]]++;
    for(int i = 1; i < max; ++i) c[i] += c[i - 1];
    for(int i = N - 1; i >= 0; --i) {
        int x = src[i];
        int y = c[x];
        dst[c[src[i]]-- - 1] = src[i];
    }
}
int main(int argc, char **argv) {
    int n = get_uint();
    int a[n], b[n];
    for(int i = 0; i < n; ++i) a[i] = get_uint();
    counting_sort(b, a, n, 10000);
    arr_print_d0dn(b, n);
    return 0;
}



Measured memory_bytes: 17276
#include <cstdio>
#include <algorithm>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

int ans, tans, a, b, c;

int main()
{
    scanf("%d%d%d", &a, &b, &c); ans = 1e9;
    FOR(i, 0, 50)
    {
        tans = 0;
        if (a > i) tans += a - i;
        if (a < i)
        {
            tans += (i - a) / 2;
            if ((i - a) & 1) tans += 2;
        }
        if (b > i) tans += b - i;
        if (b < i)
        {
            tans += (i - b) / 2;
            if ((i - b) & 1) tans += 2;
        }
        if (c > i) tans += c - i;
        if (c < i)
        {
            tans += (i - c) / 2;
            if ((i - c) & 1) tans += 2;
        }
        ans = min(ans, tans);
    }
    printf("%d\n", ans);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>A1(N);
  vector<int>A2(N);
  
  for(int i=0; i<N; i++)cin >> A1.at(i);
  for(int i=0; i<N; i++)cin >> A2.at(i);
  
  int count =0;
  int ans =0;
  
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(j<i)count += A1.at(j);
      else if (j==i) count += A1.at(j)+A2.at(j);
      else count += A2.at(j);
    }
    ans = max(ans, count);
    count =0;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3632
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

void main() {
	const n = readNum();
	const row = readRows(1)[0];
	size_t leftFlip = 0;
	size_t rightFlip = row.count('E');
	size_t minFlip = rightFlip;
	foreach(c; row) {
	    immutable east = c == 'E';
	    if(east) {
	        --rightFlip;
	    }
	    
	    minFlip = min(minFlip, rightFlip + leftFlip);
	    
	    if(!east) {
	        ++leftFlip;
	    }
	}
	writefln("%d", minFlip);
}


Measured memory_bytes: 2940
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<math.h>
using namespace std;
 int main(){
   int a,b,c; cin >>a>>b>>c;
   cout << max(a,max(b,c))*10+a+b+c-max(a,max(b,c)) <<endl;
 }
   

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

using namespace std;

int main()
{
	int n,m,Q;
	cin >> n >> m >> Q;
	vector<vector<int> > t(n+1);
	for(int i = 0; i < n+1; i++){
		t[i].resize(n+1);
		t[i].assign(t[i].size(),0);
	}
	for(int i = 0; i < m; i++){
		int l,r;
		cin >> l >> r;
		t[l][r]++;
	}

	for(int i = 0; i < n+1; i++){
		for(int j = 1; j < n+1; j++){
			t[i][j] += t[i][j-1];
		}
	}
	for(int i = 1; i < n+1; i++){
		for(int j = 0; j < n+1; j++){
			t[i][j] += t[i-1][j];
		}
	}

	for(int i = 0; i < Q; i++){
		int p,q;
		cin >> p >> q;
		cout << t[q][q] - t[p-1][q] - t[q][p-1] + t[p-1][p-1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
import std.stdio;
import std.conv;
import std.algorithm;
import std.math;


void main() {
	long n;
	scanf("%ld", &n);
	long m = long.max;
	foreach(i; 1..n.to!double.sqrt.ceil.to!size_t+2) {
		if (n % i == 0) {
			m = min(i + n/i-2, m);
		}
	}
	m.write;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int r,g,b;
	int number;
	cin >> r >> g >> b;
	number = 100*r+10*g+b;
	if(number%4==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  int n;
  cin>>n;
  
  vector<int> X(n),Y(n),H(n);
  rep(i,n) cin>>X[i]>>Y[i]>>H[i];

  set<int> s;
  set<pair<int,int>> t;
  rep(i,101){
    rep(j,101){
      rep(k,n){
        if(H[k]==0){
          t.insert({X[k],Y[k]});
          continue;
        }
        s.insert(abs(X[k]-i)+abs(Y[k]-j)+H[k]);
      }
      if(s.size()==1){
        bool b=true;
        for(auto x:t){
          if((*begin(s)-abs(x.first-i)-abs(x.second-j))>0) b=false;
        }
        if(b){
          cout<<i<<" "<<j<<" "<<*begin(s)<<endl;
          return 0;
        }
      }
      s.clear();
      t.clear();
    }
  }

  return 0;
}

Measured memory_bytes: 3612
let nil = -1

type tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }

let make () = { parent = nil; child = nil; bro = nil; depth = nil }

let set_depth t n =
  let rec root i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else root (i + 1) in
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).bro <> nil then doit t.(i).bro d;
    if t.(i).child <> nil then doit t.(i).child (d + 1) in
  doit (root 0) 0

let print_tree t =
  let rec print_children i c =
    if c <> nil then begin
      if c <> t.(i).child then print_string ", ";
      print_int c;
      print_children i t.(c).bro
    end in
  t |> Array.iteri (fun i _ ->
    "node " ^ string_of_int i ^ ": parent = " ^ string_of_int t.(i).parent
       ^ ", depth = " ^ string_of_int t.(i).depth
       ^ (if t.(i).parent = nil then ", root, ["
          else if t.(i).child = nil then ", leaf, ["
          else ", internal node, [")
    |> print_string;
    print_children i t.(i).child;
    Printf.printf "]\n")

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let t = Array.init n (fun _ -> make ()) in
  for _ = 0 to n - 1 do
    let (id, k) = Scanf.scanf "%d %d " (fun id k -> (id, k)) in
    let left_child = ref 0 in
    for i = 0 to k - 1 do
      let c = Scanf.scanf "%d " (fun i -> i) in
      t.(c).parent <- id;
      if i = 0 then t.(id).child <- c
      else t.(!left_child).bro <- c;
      left_child := c;
    done;
  done;
  set_depth t n;
  print_tree t

Measured memory_bytes: 13272
using System; 
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    static void Main(string[] args) {
        
        var NAB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var N = NAB[0];
        var A = NAB[1];
        var B = NAB[2];
        
        Console.WriteLine((B/N)*A);
     }
}
     
     
                   
public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) { } public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) { } public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }


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

int main(){
    for ( int i = 0 ; i < 10000 ; i++ ){
        int n;
        cin >> n ;
        if(n != 0){
            cout << "Case " << i+1 << ":" << " " <<  n << endl;
        }
        else
        {
            break;
        }
    }
}


Measured memory_bytes: 3100
<?php
  fscanf(STDIN,"%d",$n);
  $p = preg_split("/ /",trim(fgets(STDIN)));
  $count = 0;
  for($i=0;$i<$n;$i++){
    if(($i+1)!=$p[$i]){
      $count++;
    }
  }
  if($count==0 or $count==2){
    echo("YES");
  }else{
    echo("NO");
  }

Measured memory_bytes: 3700
'''
ABC 075
https://www.youtube.com/watch?v=VJntQuR2zNI

'''
def inpl(): return input().split()
def arr(r, c): return [[False for x in range(c)] for y in range(r)]

def dfs(x):
    if vis[x]:
        return
    else:
        vis[x] = True
        for i in range(n):
            if graph[x][i]:
                dfs(i)

if __name__ == '__main__':
    n, m = map(int, inpl())
    M = [list(map(int, inpl())) for _ in range(m)]

    ans = 0
    for e in range(m):#e:取り除く辺    
        graph = arr(n, n)#arr(i, j): i, j間に辺があればTrue
        for i in range(m):
            if i == e:
                continue
            a, b = M[i]
            #inputは1インデックス
            #graphは0インデックスなので、1減
            graph[a - 1][b - 1] = True
            graph[b - 1][a - 1] = True

        vis = [False for _ in range(n)]#訪れていたらTrue
        dfs(0)#0から辿れる範囲をvis = Trueにする
        
        connected = True
        for i in range(n):
            if not vis[i]:
                connected = False
                break
        if not connected:
            ans += 1
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define repeat(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int n, a, b;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    }else{
        cin >> a >> b;
    cout << a + b << endl;}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

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

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

int main(){
    int n; cin>>n;
    vector<P> team(n);

    for(int i=0; i<n; i++){
        team[i].sc=i;
    }
    
    for(int i=0; i<n*(n-1)/2; i++){
        int a, b, c, d; cin>>a>>b>>c>>d;
        a--, b--;
        if(c>d){
            team[a].fs+=3;
        }
        else if(c<d){
            team[b].fs+=3;
        }
        else{
            team[a].fs++;
            team[b].fs++;
        }
    }

    sort(team.begin(), team.end(), greater<P>());

    vector<int> ans(n+10);
    for(int i=0; i<n; i++){
        if(i==0){
            ans[team[i].sc]=i+1;
        }
        else{
            if(team[i-1].fs==team[i].fs){
                ans[team[i].sc]=ans[team[i-1].sc];
            }
            else ans[team[i].sc]=i+1;
        }
    }

    for(int i=0; i<n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 3072
n,p = map(int,input().split())
a = list(map(int,input().split()))

odd = 0
even = 0
for i in a:
    if i%2 == 0:
        even += 1
    else:
        odd += 1
if odd == 0:
    if p == 1:
        print(0)
    else:
        print(2 ** n)
else:
    print(2 ** (n - 1))


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> pi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 1e5+5;
int A[maxn];
int N;

int main()
{
    LL ans = 0;
    cin >> N;
    _for(i,0,N){
        cin >> A[i];
    }
    ans = (A[0] - 1);
    int minsub = 2;
    _for(i,1,N){
        int num = A[i];
        if(minsub > num) continue;
        if(minsub == num) minsub++;
        else{
            if(num % minsub){
                ans += num/minsub;
            }
            else{
                ans += 1 + (num-minsub-1)/minsub;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include <cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#pragma comment(linker, "/STACK:8809999999")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<ld, ld> pld;
typedef pair<pll, ll> ppll;
typedef pair<pll, pll> ppp;
typedef vector <vector <pair <ll, ll>>> gosh; // cost, end of edge
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const ll settled = 400007;

vl a;
gosh ed;
ll co = 0;
void DnC(ll d, ll le = 0, ll ri = a.size())
{
	co++;
	if (le >= ri-1)
		return;
	DnC(d, le, (ri + le) / 2);
	DnC(d, (ri + le) / 2, ri);
	ll lem = 0, rim = (ri + le) / 2;
	
	forn(i, le, (ri + le) / 2)
	{
		ll cost1, cost2;
		cost1 = a[lem] - d*lem;
		cost2 = a[i] - d*i;
		if (cost2 < cost1)
			lem = i;
	}

	forn(i, (ri + le) / 2, ri)
	{
		ll cost1, cost2;
		cost1 = a[rim] + d*rim;
		cost2 = a[i] + d*i;
		if (cost2 < cost1)
			rim = i;
	}
	
	forn(i, le, (ri + le) / 2)
	{
		ll cle, cri;
		cle = a[i] - d*i;
		cri = a[rim] + d*rim;
		ll cost = cle + cri;
		ed[i].push_back(make_pair(cost, rim));
		if(i != lem)
			ed[rim].push_back(make_pair(cost, i));
	}

	forn(i, (ri + le) / 2, ri)
	{
		ll cle, cri;
		cle = a[lem] - d*lem;
		cri = a[i] + d*i;
		ll cost = cle + cri;
		ed[i].push_back(make_pair(cost, lem));
		if (i != rim)
			ed[lem].push_back(make_pair(cost, i));
	}
}


ll MSTcost()
{
	priority_queue<pll, vector<pll>, greater<pll> > pile;
	vl used(ed.size(), 0);
	ll cost = 0;
	pile.push(make_pair(0, 0));
	while (pile.size())
	{
		pair<ll, ll> cur;
		cur = pile.top();
		pile.pop();
		if (used[cur.second])
			continue;
		used[cur.second] = 1;
		cost += cur.first;
		for (pair<ll, ll> edge : ed[cur.second])
		{
			if (used[edge.second])
				continue;
			pile.push(edge);
		}
	}
	cost;
	return cost;
}

int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	//freopen("sufpref.in", "r", stdin);
	//freopen("sufpref.out", "w", stdout);
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
	ll n, d;
	cin >> n >> d;
	a.resize(n, 0); ed.resize(n);
	forn(i, 0, ed.size())
		ed[i].reserve(20);
	forn(i, 0, n)
		cin >> a[i];
	DnC(d);
	ll val = MSTcost();
	cout << val;

	return 0;
}

Measured memory_bytes: 237312
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    n,m,k = LI()

    for i in range(n+1):
        t = m*i
        for j in range(m+1):
            if t + (n-i)*j - (i)*j == k:
                return 'Yes'
    return 'No'


print(main())




Measured memory_bytes: 7720
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<string> s(n);
    rep(i, n) {
        cin >> s[i];
    }
    vector<int> mi(n, 0), fi(n, 0);
    vector<P> fo, bc;
    rep(i, n) {
        int sz = (int)s[i].size();
        int now = 0;
        rep(j, sz) {
            if(s[i][j] == '(') ++ now;
            else -- now;

            chmin(mi[i], now);
        }
        fi[i] = now;
        if(fi[i] >= 0) {
            fo.pb({mi[i], fi[i]});
        } else {
            bc.pb({mi[i], fi[i]});
        }
    }
    sort(all(fo));
    reverse(all(fo));
    sort(all(bc), [&](P x, P y){ return x.sc - x.fr > y.sc - y.fr;});
    int cur = 0;
    rep(i, (int)fo.size()) {
        if(cur + fo[i].fr < 0) {
            cout << "No" << endl;
            return;
        }
        cur += fo[i].sc;
    }
    rep(i, (int)bc.size()) {
        if(cur + bc[i].fr < 0) {
            cout << "No" << endl;
            return;
        }
        cur += bc[i].sc;
    }
    //cerr << cur << endl;
    if(cur != 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 65868
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<Integer>();
    for (int i = 0; i < 3; i++) {
      list.add(sc.nextInt());
    }
    sc.close();
    Collections.sort(list);
    System.out.println(list.get(0) + list.get(1));
  }
}


Measured memory_bytes: 23636
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n ,a, b;
   cin >> n >> a >> b;
   cout << min(a*n,b) << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> s(m);
    vector<int> a(n);
    rep(i,m){
        cin>>s[i].first>>s[i].second;
        if(s[i].first==1) a[s[i].second-1]++;
        if(s[i].second==n) a[s[i].first-1]++;
    }
    rep(i,n){
        if(a[i]==2){
            cout<<"POSSIBLE";
            return 0;
        }
    }
    cout<<"IMPOSSIBLE";
}

Measured memory_bytes: 5576
a = list(input())
b = list(input())
c = 0
if len(a) > len(b):
    c = 1
elif len(a) < len(b):
    c = 2
else:
    for i in range(len(a)):
        if int(a[i]) > int(b[i]):
            c = 1
            break
        elif int(a[i]) < int(b[i]):
            c = 2
            break
if c == 0:
    print("EQUAL")
elif c == 1:
    print("GREATER")
else:
    print("LESS")

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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAX = 1e5 + 10 ;

long long n , a , b ;
int arr[MAX] ;
string s ;

long long powlog(long long base , long long power)
{
	if(power == 0)
		return 1ll ;
	long long x = powlog(base , power / 2ll) ;
	x = (x * x) % mod ;
	if(power & 1)
		x = (x * base) % mod ;
	return x ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>a>>b ;
	long long ans = powlog(2ll , n) ;
	long long cur = 1ll , now ;
	long long cur2 = 1ll ;
	for(long long i = 1 ; i <= b ; ++i)
	{
		cur2 = (cur2 * i) % mod ;
		now = (n-i+1ll) ;
		cur = (cur * now) % mod ;
		if(i == a || i == b)
		{
			now = (cur * powlog(cur2 , mod-2ll)) % mod ;
			ans = (ans - now + mod) % mod ;
		}
	}
	return cout<<(ans - 1ll + mod) % mod<<"\n" , 0 ;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  # 重複組合せ
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

    def factInvN(self, n):
        if n < 0:
            return 0
        return self.factInv[n]

N = int(input())
MOD = 10**9 + 7
comb = Combination(N + 100)

edges = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    fr, to = map(int, input().split())
    edges[fr].append(to)
    edges[to].append(fr)

order = []
parent = [0] * (N + 1)
st = [1]
while st:
    now = st.pop()
    order.append(now)
    for to in edges[now]:
        if to == parent[now]:
            continue
        st.append(to)
        parent[to] = now

size = [1] * (N + 1)
for v in order[::-1]:
    size[parent[v]] += size[v]

dpLeaf = [1] * (N + 1)
for v in order[:: -1]:
    pr = parent[v]
    dpLeaf[v] = dpLeaf[v] * comb.fact[size[v] - 1] % MOD
    dpLeaf[pr] = dpLeaf[pr] * dpLeaf[v] * comb.factInv[size[v]] % MOD

ans = [0] * (N + 1)
ans[1] = dpLeaf[1]
for v in order[1:]:
    pr = parent[v]
    ans[v] = ans[pr] * comb.inv[N - size[v]] * size[v] % MOD

print(*(ans[1:]), sep='\n')

Measured memory_bytes: 86616
N = int(input())
a_list = list(map(int, input().split())) 
a_list.sort(reverse=True)
Alice, Bob = 0, 0
for i in range(N):
  if i %2 == 0:
    Alice += a_list[i]
  else:
    Bob += a_list[i]
print(Alice - Bob)

Measured memory_bytes: 3060
#abc086c
import sys

def yn(s,x,y):
 r=abs(x)+abs(y)
 if s>=r and (s-r)%2==0:
  return True
 else:
  return False

n=int(raw_input())
s0,x0,y0=map(int,raw_input().split())
if yn(s0,x0,y0)==False:
 print 'No'
 sys.exit()
for i in xrange(n-1):
 s,x,y=map(int,raw_input().split())
 if yn(s-s0,x-x0,y-y0)==False:
  print 'No'
  sys.exit()
 s0,x0,y0=s,x,y
print 'Yes'


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int d[n];
    rep(i, 0, n) cin >> d[i];
    int ans = 0;
    rep(i, 0, n - 1) {
        rep(j, i + 1, n) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  string all_S = "";
  
  for (int k = 0-1; k < W+1; k++) {
    all_S += '.';
  }
  for (int i = 0; i < H; i++) {
    string S;
    cin >> S;
    all_S += '.' + S + '.';
  }
  for (int k = 0-1; k < W+1; k++) {
    all_S += '.';
  }

  //cout << all_S << endl;

  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++) {
      //int x = 0;
      if (all_S.at((W+2)*i+j) == '#') {
        //result_all_S += '#';
        cout << '#';
        continue;
      }
      else if (all_S.at((W+2)*i+j) == '.') {
        int x = 0;
        if (all_S.at((W+2)*(i-1)+(j-1)) == '#') x++;
        if (all_S.at((W+2)*(i-1)+j    ) == '#') x++;
        if (all_S.at((W+2)*(i-1)+(j+1)) == '#') x++;
        if (all_S.at((W+2)*i    +(j-1)) == '#') x++;
        if (all_S.at((W+2)*i    +(j+1)) == '#') x++;
        if (all_S.at((W+2)*(i+1)+(j-1)) == '#') x++;
        if (all_S.at((W+2)*(i+1)+j    ) == '#') x++;
        if (all_S.at((W+2)*(i+1)+(j+1)) == '#') x++;
        cout << x;
      }
    }
    cout << endl;
  }
}

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

int main() {
	/*
	int a, b;
	std::cin >> a >> b;

	if (a - b * 2 > 0) {
		std::cout << a - b * 2;
	}
	else {
		std::cout << 0;
	}
	*/

	/*
	int N;
	std::cin >> N;
	std::vector<int> takoyaki;
	for (int i = 0; i < N; ++i) {
		int hoge;
		std::cin >> hoge;
		takoyaki.push_back(hoge);
	}

	int sum = 0;
	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			sum += takoyaki[i] * takoyaki[j];
		}
	}
	std::cout << sum;
	*/

	int N;
	std::cin >> N;

	std::string S;
	std::cin >> S;

	int count = 1;
	for (int i = 0; i < N - 1; ++i) {
		if (S[i] != S[i + 1]){
			count += 1;
		}
	}
	std::cout << count;
	return 0;
}

Measured memory_bytes: 512
module Main

open System

let nm =
    Console.ReadLine().Split(' ')
        |> Array.map int

let ss =
    [ for _ in 1..nm.[0] ->
        [for c in Console.ReadLine() -> c]
    ]

let bs =
    [ for _ in 1..nm.[1] ->
        [for c in Console.ReadLine() -> c]
    ]

let rec prefix xxs yys =
    (xxs, yys) |> function
        | (x :: xs, y :: ys) when x = y -> prefix xs ys
        | ([], _) -> true
        | _ -> false

let rec zip xxs yys =
    (xxs, yys) |> function
        | (x :: xs), (y :: ys) -> (x, y) :: zip xs ys
        | _ -> []

let solve c xs =
    let rec reccolf n ys =
        if n = 0 then
            false
        elif List.forall (fun (b, x) -> prefix b x) <| zip bs ys then
            true
        else
            reccolf (n - 1) <| List.map List.tail ys

    let rec recf n ys =
        if n = 0 then
            false
        elif reccolf c ys then
            true
        else
            recf (n - 1) <| List.tail ys

    recf c xs

Console.WriteLine(
    if solve (nm.[0] - nm.[1] + 1) ss then
        "Yes"
    else
        "No"
)


Measured memory_bytes: 14432
from math import sqrt

def divs(n):
  d=[]
  for x in range(1,int(sqrt(n))+1):
    if n%x==0:
      d.extend([x,n//x])
  d=list(set(d))
  d.sort()
  return d

def f(b,n):
  if n<b:
    return n
  else:
    return f(b,n//b)+(n%b)

n=int(input())
s=int(input())

if n<s:
  print(-1)
  exit()
elif n==s:
  print(n+1)
  exit()
else:
  ds=divs(n-s)
  for x in ds:
    if s==f(x+1,n):
      print(x+1)
      exit()
print(-1)

Measured memory_bytes: 9200
N = int(input())
*A, = map(int, input().split())
cnt = [0]*(10**5+1)
s = 0
for i in range(N):
    cnt[A[i]] += 1
    s += A[i]

Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    d = (C-B)*cnt[B]
    s += d
    cnt[C] += cnt[B]
    cnt[B] = 0
    print(s)


Measured memory_bytes: 83552
H, W = [int(x) for x in input().split()]
a = [x for x in [input() for _ in range(H)] if '#' in x]
w = 0
while w < len(a[0]):
  for h in range(len(a)):
    if a[h][w]=='#':
      w += 1
      break
  else:
    for h in range(len(a)):
      a[h] = a[h][:w] + a[h][w+1:]

for h in range(len(a)):
  print(a[h])

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>


using namespace std;

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        for (int j = 0; j <= i; j++) {
            tmp += a[j];
        }
        for (int k = i; k < N; k++) {
            tmp += b[k];
        }
        ans = max(ans, tmp);
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 100010
char ss[maxn];
int main()
{
	int n;
	cin>>n;
	cin>>ss;
	int siz=sizeof(ss);
	char pre;
	pre=ss[0];
	int cnt=0;
	for(int i=1;i<siz;i++)
	{
		if(pre!=ss[i])
		{
			cnt++;
			pre=ss[i];
		 } 
	}
	cout<<cnt;
	return 0;
 } 

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define MOD 1000000007

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

	int ans = 0;
	if(A >= B){
		ans += A;
		A--;
	}
	else{
		ans += B;
		B--;
	}
	if(A >= B){
		ans += A;
		A--;
	}
	else{
		ans += B;
		B--;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    int i,n;
    long long int sum=1;
    
    scanf( "%d",&n );
    
    for( i = 1; i <= n; i++ ){
        sum = sum * i;
        sum = sum % (1000000000+7);
    }
    
    printf( "%lld\n",sum );

    return 0;
}

Measured memory_bytes: 128
import itertools
import copy

k = int(input())
li = [list(map(int, input().split())) for _ in range(k)]

bord = [['.']*8 for _ in range(8)]

exclude_num = []
x_list = [i for i in range(8)]
y_list = [i for i in range(8)]

def queen_move(some_list):
    for x,y in some_list:
        
        for i in range(8):
            bord[x][i] = '.'
            bord[i][y] = '.'
        
        cnt = 1    
        while True:
            if x-cnt >= 0 and y-cnt >= 0:
                bord[x-cnt][y-cnt] = '.'
            else:
                break
            cnt += 1
            
        cnt = 1    
        while True:
            if x-cnt >= 0 and y+cnt <= 7:
                bord[x-cnt][y+cnt] = '.'
            else:
                break
            cnt += 1
    
        cnt = 1    
        while True:
            if x+cnt <= 7 and y+cnt <= 7:
                bord[x+cnt][y+cnt] = '.'
            else:
                break
            cnt += 1
    
        cnt = 1    
        while True:
            if x+cnt <= 7 and y-cnt >= 0:
                bord[x+cnt][y-cnt] = '.'
            else:
                break
            cnt += 1

def check_queen(k):
    check = 0
    for i in range(8):
        for j in range(8):
            if bord[i][j] == 'Q':
                check += 1
    if check == k:
        return True
    else:
        return False

queen_move(li)
        
for x,y in li:
    bord[x][y] = 'Q'
    x_list.remove(x)
    y_list.remove(y)
    
bord_original = copy.deepcopy(bord)

for numbers in itertools.permutations(y_list, 8-k):
    cnt = 0
    bord = copy.deepcopy(bord_original)
    for number in numbers:
        tmp_li = [[x_list[cnt], number]]
        queen_move(tmp_li)
        bord[tmp_li[0][0]][tmp_li[0][1]] = 'Q'
        cnt += 1
        if check_queen(k+cnt) == False:
            break
    else:
        for ans in bord:
            print(''.join(ans))
        break



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

int pcheck(int cur){
  int i;
  for(i=2; i*i<=cur; i++){
    if(cur%i==0) return 0;
  }
  return 1;
}

int main(){
  int n,i,j,cur; 
  cin >> n;
  i=0; j=0;
  while(i<n){
    j++; cur=10*j+1;
    if(pcheck(cur)){
      cout << cur << ' '; i++;
    }
  }
}

Measured memory_bytes: 256
N, M = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
A_sum = sum(A)

A.sort(reverse=True)
cnt = 0
for a in A:
    #print(a)
    if a >= A_sum/(4*M):
        cnt += 1
    else:
        ans = "No"

    if cnt == M:
        ans = "Yes"
        break

print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

func ceilDivInt(end int, div int) int {
	if end%div > 0 {
		return end/div + 1
	}
	return end / div
}

func battle(h int, attack int, arrB []int) int {
	var cnt = 0
	for i := range arrB {
		if arrB[i] < attack {
			break
		}
		h -= arrB[i]
		cnt++
		if h <= 0 {
			break
		}
	}
	if h <= 0 {
		return cnt
	}
	return cnt + ceilDivInt(h, attack)
}

func main() {
	const nCity = 5
	var n, h int
	fmt.Scan(&n, &h)
	var arrA, arrB []int
	for i := 0; i < n; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		arrA = append(arrA, a)
		arrB = append(arrB, b)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(arrA)))
	sort.Sort(sort.Reverse(sort.IntSlice(arrB)))

	var attack = arrA[0]

	fmt.Println(battle(h, attack, arrB))
}


Measured memory_bytes: 7552
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main()
{
	int num;
	scanf("%d", &num);
	string s;
	cin >> s;
	ll r = 1, t = 0;
	bool now = false;
	for (int i = 0; i < s.size(); i++)
	{
		if (now)s[i] = 'B' + 'W' - s[i];
		if (s[i] == 'W')r = r*t%mod, t--, now = !now;
		else t++, now = !now;
	}
	if (t != 0)r = 0;
	for (int i = 1; i <= num; i++)r = r*i%mod;
	printf("%lld\n", r);
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b;
  int c=0;
  cin>>a>>b;
  for(int i=0;i<3;i++){
    if(a[i]==b[i]){
      c++;
    }
  }
  cout<<c<<"\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef pair <int, int> pii;
pii a[100010];
vector <int> g[100010];
int k,col[100010];
void dfs(int x)
{
    col[x]=k;
    for (int i=0;i<g[x].size();i++)
        if (!col[g[x][i]]) dfs(g[x][i]);
}
int b[100010];
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i].first);
        a[i].second=i;
    }
    for (i=0;i<m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for (i=0;i<n;i++)
        if (!col[i])
        {
            k++;
            dfs(i);
        }
    sort(a,a+n);
    int c=k;
    if (2*(k-1)>n)
    {
        printf("Impossible\n");
        return 0;
    }
    long long ans=0;
    int l=1;
    for (i=0;l<=2*k-2;i++)
    {
        int x=col[a[i].second];
        if (b[x]==0)
            c--;
        else
            if (2*k-1-l==c) continue;
        b[x]++;
        ans+=a[i].first;
        l++;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>
#include<string.h>
int cnt;
char data[10000][75];
void legister(const char *s,const char *t){
    char tmp[75]={0};
    strcat(tmp,s);
    strcat(tmp,t);
    for(int i=0;i<cnt;i++){
        if(!strcmp(data[i],tmp)) return;
    }
    strcpy(data[cnt],tmp);
    cnt++;
}
int main(void){
    int m; scanf("%d",&m);
    getchar();
    for(int i=0;i<m;i++){
        cnt=0;
        char train[75]={0};
        fgets(train,74,stdin);
        //printf("%s",train);
        int len=strlen(train)-1;
        for(int j=1;j<len;j++){
            char s[74]={0},t[74]={0},rs[74]={0},rt[74]={0};
            for(int k=0;k<j;k++) s[k]=train[k];
            for(int k=0;k<j;k++) rs[k]=train[j-1-k];
            for(int k=0;k<len-j;k++) t[k]=train[j+k];
            for(int k=0;k<len-j;k++) rt[k]=train[len-1-k];
            legister(s,t); legister(s,rt); legister(rs,t); legister(rs,rt);
            legister(rt,rs); legister(t,rs); legister(rt,s); legister(t,s);
        }
        printf("%d\n",cnt);
    }
}



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

int main(){
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++){
  	cin >> vec.at(i);
  }
  
  int max = 0;
  for (int i = 0; i < vec.size(); i++){
    if (max < vec.at(i)){
      max = vec.at(i);
    }
  }
  int sum = accumulate(vec.begin(), vec.end(), 0) - max;
  
  if (sum > max){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
    ll a, b; cin>>a>>b;
    loop(1000000){
        if(i*8/100 == a && i*10/100 == b){
            cout<<i<<"\n";
            return 0;
        }
    }
    cout<<-1<<"\n";
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;

fn main() {
    input! {
        l: usize,
        a: [i64; l],
    }

    let mut tbl = vec![vec![0; 5]; l + 1];

    for i in 0..l {
        tbl[i + 1][0] = tbl[i][0] + a[i];
        tbl[i + 1][1] = min(tbl[i][0], tbl[i][1]) + if a[i] == 0 { 2 } else { a[i] % 2 };
        tbl[i + 1][2] = min(tbl[i][0], min(tbl[i][1], tbl[i][2])) + 1 - a[i] % 2;
        tbl[i + 1][3] = min(tbl[i][0], min(tbl[i][1], min(tbl[i][2], tbl[i][3])))
            + if a[i] == 0 { 2 } else { a[i] % 2 };
        tbl[i + 1][4] = min(
            tbl[i][0],
            min(tbl[i][1], min(tbl[i][2], min(tbl[i][4], tbl[i][3]))),
        ) + a[i];
    }

    let ans = tbl[l].iter().min().unwrap();

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


Measured memory_bytes: 20732