akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
#define MAX 10000
#define NIL -1

struct Node{ int p, l,r; };
struct Node T[MAX];
int n;

void preorder(int u){
    if(u==NIL)return ;
    cout<<" "<<u;
    preorder(T[u].l);
    preorder(T[u].r);
}

void inorder(int u){
    if(u==NIL)return;
    inorder(T[u].l);
    cout<<" "<<u;
    inorder(T[u].r);
}

void postorder(int u){
    if(u==NIL)return;
    postorder(T[u].l);
    postorder(T[u].r);
    cout<<" "<<u;
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    cin>>n;
    for(int i=0;i<n;i++)T[i].p=NIL;
    for(int i=0;i<n;i++){
        int v,l,r;cin>>v>>l>>r;
        T[v].l=l;T[v].r=r;
        if(l!=NIL)T[l].p=v;
        if(r!=NIL)T[r].p=v;
    }
    int root;
    for(int i=0;i<n;i++){
        if(T[i].p==NIL)root=i;
    }
    cout<<"Preorder"<<endl;
    preorder(root);cout<<endl;
    cout<<"Inorder"<<endl;
    inorder(root);cout<<endl;
    cout<<"Postorder"<<endl;
    postorder(root);cout<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------















































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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const
      noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const
      noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const
      noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const
      noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const
      noexcept {
    return x == p.x;
  }
  constexpr bool operator!=(const ModInt &p) const
      noexcept {
    return x != p.x;
  }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while(n) {
      if(n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(
      ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is,
                                       ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

vector<ModInt<>> sum(100010);

ModInt<> inv(ModInt<> x) {
  ModInt<> res = 1;
  long long k = (long long)(1e9 + 7) - 2;
  ModInt<> y = x;
  while(k) {
    if(k & 1) res = (res * y);
    y = y * y;
    k >>= 1;
  }
  return res;
}

int main(void) {
  long long n;
  cin >> n;
  vector<long long> x(n + 1);
  ModInt<> ans = 0;
  ModInt<> kaijo = 1;
  for(int i = 1; i <= n - 1; i++) kaijo = kaijo * i;
  for(int i = 0; i < n; i++) cin >> x[i + 1];
  for(int i = 0; i < n; i++)
    sum[i + 1] = (sum[i] + x[i + 1]);

  for(long long p = 1; p <= n - 1; p++) {
    ModInt<> tmp =
        ModInt<>(n - p).inverse() * (x[n] - x[p]);
    ans = ans + tmp;
  }
  for(long long p = 1; p <= n - 2; p++) {
    ModInt<> tmp = ModInt<>(p * (p + 1)).inverse();
    ModInt<> tmp1 = sum[n - 1] - sum[p];
    ModInt<> tmp2 = sum[n - 1 - p];
    ModInt<> tmp3 = tmp1 - tmp2;
    ModInt<> tmp4 = tmp * tmp3;
    ans = ans + tmp4;
  }
  ans = ans * kaijo;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<math.h>
int a[107];
int b[107];
int main(){
    int n,t=0,j=0,Min=100000000;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    while(t<=n-2){
        int sum1=0,sum2=0;
        for(int i=0;i<=t;i++){
            sum1+=a[i];
        }
        for(int i=t+1;i<n;i++){
            sum2+=a[i];
        }
        b[j]=fabs(sum1-sum2);
        j++;
        t++;
    }
    for(int i=0;i<j;i++){
        if(b[i]<Min){
            Min=b[i];
        }
    }
    printf("%d\n",Min);
    return 0;
}


Measured memory_bytes: 128
s = input()
s += input()
s += input()

if(
    not(s.count("1")==1 or s.count("1")==2) or 
    not(s.count("2")==1 or s.count("2")==2) or
    not(s.count("3")==1 or s.count("3")==2) or
    not(s.count("4")==1 or s.count("4")==2)
    ) :
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 2000000

int sise, X[MAX+1];

void maxHeapify(int i){
  int l, r, largest, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= sise && X[l] > X[i] ) 
    largest = l;
  else 
    largest = i;
  if ( r <= sise && X[r] > X[largest] ) 
    largest = r;
  if ( largest != i ){
    t = X[i];
    X[i] = X[largest]; 
    X[largest] = t;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if ( sise < 1 )
    return;
  maxv = X[1];
  X[1] = X[sise--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i, int key){
  int tmp;
  if ( key < X[i] ) 
    return;

  X[i] = key;
  while ( i > 1 && X[i/2] < X[i] ){
    tmp = X[i];
    X[i] = X[i/2];
    X[i/2] = tmp;
    i = i/2;
  }
}

void insert(int key){
  sise++;
  X[sise] = -1000000001;
  increaseKey(sise, key);
}

main(){
  int key;
  char com[20];
  while(1){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &key);
      insert(key);
    } 
    else if ( strcmp(com, "extract") == 0  ){
      printf("%d\n", extract());
    }
    else
         break;
  }

  return 0;
}


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

int A, B;

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

  if (A == B) {
    cout << "Draw";
  } else if (A == 1) {
    cout << "Alice";
  } else if (B == 1) {
    cout << "Bob";
  } else if (A > B) {
    cout << "Alice";
  } else {
    cout << "Bob";
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1'000'000'007;
constexpr ll mod = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int _;
  cin >> _;
  while(_--){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    if(B > A){
      cout << "No\n";
      continue;
    }
    if(B > D){
      cout << "No\n";
      continue;
    }
    if(C >= B){
      cout << "Yes\n";
      continue;
    }
    if(C < B - gcd(B,D) + A%gcd(B,D)){
      cout << "No\n";
    }else{
      cout << "Yes\n";
    }
  }

  return 0;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	var k int
	fmt.Scan(&k)
	cnt := 0
	r := 0
	f := iniSeq(s)
	l := finSeq(s)
	//奇数奇数でも偶数になるから場合分け
	//finseqのカウント数は毎回変わらない、最初だけ
	if len(s) != f && s[0] == s[len(s)-1] && f%2 != 0 && (f+l)%2 == 0 {
		for i := 1; i < len(s); i++ {
			if s[i] == s[i-1] && cnt%2 == 0 {
				r++
				cnt++
			} else if s[i] == s[i-1] && cnt%2 != 0 {
				cnt++
			} else {
				cnt = 0
			}
		}
		fmt.Println(r*k + k - 1)
		return
	} else if len(s) == f && f%2 != 0 && k%2 == 0 {
		fmt.Println(f / 2)
		fmt.Println(((f/2)+1)*(k/2) + ((f / 2) * k / 2))
	} else if len(s) == f && f%2 != 0 && k%2 != 0 {
		fmt.Println((f/2)*((k/2)+1) + (((f / 2) + 1) * (k / 2)))
	} else {
		for i := 1; i < len(s); i++ {
			if s[i] == s[i-1] && cnt%2 == 0 {
				r++
				cnt++
			} else if s[i] == s[i-1] && cnt%2 != 0 {
				cnt++
			} else {
				cnt = 0
			}
		}
		fmt.Println(r * k)
		return
	}
}

//文字列の最初の文字がどこまで何文字続くかを返す
func iniSeq(s string) int {
	ini := s[0]
	r := 1
	for i := 1; i < len(s); i++ {
		if s[i] == ini {
			r++
		} else {
			return r
		}
	}
	return r
}

//文字列の最後の文字がどこまで何文字続くかを返す
func finSeq(s string) int {
	fin := s[len(s)-1]
	r := 1
	for i := len(s) - 1; i >= 1; i-- {
		if s[i-1] == fin {
			r++
		} else {
			return r
		}
	}
	return r
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
pii c[25];
int v[25];

int dp[40][1<<18];

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",&c[i].first);
    REP(i,n)scanf("%d",&c[i].second);
    const int INF = 252521;
    REP(i,n+n+1)REP(j,1<<n)dp[i][j] = INF;
    dp[n+n][0] = 0;
    REP(msk,1<<n)REP(last,n+n+1){
        int v = 0;
        if(last == n+n){
            v = 0;
        }else if(last%2==0){
            v = c[last/2].first;
        }else{
            v = c[last/2].second;
        }
        int popcnt = __builtin_popcount(msk);
        int cnt = 0;
        FORR(i,0,n){
            if(msk>>i&1){
                cnt += 1; continue;
            }
            int flipnum = cnt + (i - (popcnt - cnt));
            if(flipnum % 2 == 0){
                int w = c[i].first;
                if(w >= v){
                    CHMIN(dp[2*i+0][msk | (1<<i)], dp[last][msk] + (i-(popcnt-cnt)));
                }
            }else{
                int w = c[i].second;
                if(w >= v){
                    CHMIN(dp[2*i+1][msk | (1<<i)], dp[last][msk] + (i-(popcnt-cnt)));
                }
            }
        }
    }
    int ans = INF;
    REP(i,n+n)CHMIN(ans, dp[i][(1<<n)-1]);
    if(ans==INF)ans = -1;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 39168
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
#include <iomanip>
using namespace std;

int main()
{
    const double PI = 3.141592653589793238463;
    double r, cr, ca;

    cin >> r;
    cr = 2 * PI * r;
    ca = PI * r * r;
    printf("%.6f %.6f\n", ca, cr);
    return 0;
}


Measured memory_bytes: 3284
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
            {
                WriteLine("Yes");
            }
            else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
            {
                WriteLine("Yes");
            }
            else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
def pow(x,n)
	if n==0
		return 1
	elsif n.even?
		res=pow(x*x%1000000007,n/2)
	else
		res=pow(x*x%1000000007,n/2)*x
	end
end
m,n=gets.chomp.split(" ").map{|i| i.to_i}

puts pow(m,n)%1000000007

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

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; }
const ll llINF = 1LL << 60;
const int iINF = 1e8;

//---main---------------------------------------------
int main(){
    //main
    string S;
    cin >> S;

    int ans = 0;
    rep(i,3){
        if(S[i]=='R') ans++;
    }
    if(S=="RSR") ans =1;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    ll s;
    cin >> s;
    ll pre = s/100;
    ll post = s%100;
    if(1 <= pre and pre <= 12){
        if(1 <= post and post <= 12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1 <= post and post <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }


}

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

int main(){
  int N,all=0;
  int s[100];
  bool t=false;

  cin>>N;
  REP(i,N){
    cin>>s[i];
    all+=s[i];
  }
  sort(s,s+N);

  REP(i,N){
    if(!(all%10)){
      all-=((s[i]%10)?s[i]:0);
    }else{
      cout<<all;
      t=true;
      break;
    }
  }
  cout<<(t?"":"0")<<endl;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N, M; cin>>N>>M;
    int ans=0;
    vector<int> vec[100000];
    for (int i = 0; i < N; ++i) {
        int A,B; cin>>A>>B;
        vec[A-1].push_back(B);
    }
    priority_queue<int> pq;
    for (int i = 0; i < M; ++i) {
        for(int j : vec[i]){
            pq.push(j);
        }
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5632
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, A, B, h[111111], d;

  std::cin >> N >> A >> B;

  for (int i = 0; i < N; i ++)
    std::cin >> h[i];

  d = A - B;

  long long l = 0, u = INF / B;

  while (u - l > 1) {
    long long m = (l + u) / 2, c = 0;

    for (int i = 0; i < N; i ++) {
      long long x = h[i] - B * m;

      if (x > 0)
        c += (x + d - 1) / d;
    }

    (c <= m ? u : l) = m;
  }

  std::cout << u << std::endl;
    
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int
std::string to_stringx(int val)
{
	char buffer[std::numeric_limits<int>::digits10 + 1
		+ 2]; // '-' + '\0'
	std::sprintf(buffer, "%d", val);
	return buffer;
}

int digitsum(int n) {
	int ret = 0;
	while (n > 0) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

double rate(int n) {
	return n / (double)digitsum(n);
}

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

	vector<int> v;
	rep(i, 15) {
		REP(j, 1, 150) {
			string T = to_stringx(j);
			int tmp = i;
			while (tmp--) T.push_back('9');
			int num = stoll(T);
			auto itr = find(v.begin(), v.end(), num);
			if (itr == v.end()) {
				v.push_back(stoll(T));
			}
		}
	}
	sort(v.begin(), v.end());
	//rep(i, v.size()) cout << v[i] << endl;
	rep(i, v.size()) {
		bool flag = false;
		//cout << v[i] << " " << rate(v[i]) << endl;
		REP(j, i + 1, v.size() - 1) {
			//cout << v[j] << " " << rate(v[j]) << endl;
			if (rate(v[i]) > rate(v[j])) {
				flag = true;
				break;
			}
		}
		if (flag) {
			v.erase(v.begin() + i);
			i--;
		}
	}
	rep(i, K) {
		cout << v[i] << endl;
	}


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, p; scan(n, p);
      LI xs(n); rep(i, n) scan(xs[i]);
      long dp[128][2] = {{}};
      dp[0][0] = 1;
      dp[0][xs[0]%2] += 1;
      for(long i = 1; i < n; ++i) {
         dp[i][0] = dp[i-1][0];
         dp[i][1] = dp[i-1][1];
         if( xs[i] % 2 == 0 ) {
            dp[i][0] += dp[i-1][0];
            dp[i][1] += dp[i-1][1];
         }
         else {
            dp[i][0] += dp[i-1][1];
            dp[i][1] += dp[i-1][0];
         }
      }
      printf("%ld\n", dp[n-1][p]);
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007LL
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int arr[MAX],check[MAX],ans,cnt[MAX];
vector<pii> v;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		cnt[x+5]++;
		cnt[x-1+5]++;
		cnt[x+1+5]++;
		//cout<<cnt[2+5]<<endl;
	}
	//cout<<cnt[7]<<endl;
	for(int i=0;i<=100006;i++)
	{
		ans=max(ans,cnt[i]);
	}
	cout<<ans<<endl;
	return 0;
	sort(v.begin(),v.end());
	int prt=1,ans=1,r=v[0].SS;
	for(int i=1;i<n;i++)
	{
		if(v[i].FF<=r)
		{
			ans++;
		}
		else
		{
			prt=max(prt,ans);
			r=v[i].SS;
			ans=1;
		}
	}
	prt=max(prt,ans);
	cout<<prt<<endl;
}

Measured memory_bytes: 2688
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long ans = 0;
        ans = (x/11)*2;
        long r = x%11;
        if(r != 0){
            if(r <= 6)  ans++;
            else    ans += 2;
        }
        if(x == 0)  ans = 0;
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n);
  rep(i,n) {
    queue<int> q;
    vector<int> d(n, INF);
    auto push = [&](int v, int dist) {
      if(d[v] != INF) return;
      d[v] = dist;
      q.push(v);
    };
    push(i, 0);
    while(!q.empty()) {
      int v = q.front(); q.pop();
      if(v + 1 < n) push(v+1, d[v] + 1);
      if(v - 1 >= 0) push(v-1, d[v] +1);
      if(v == x) push(y, d[v] + 1);
      if(v == y) push(x, d[v] + 1);
    }
    rep(i,n)ans[d[i]]++;
  }
  rep(i,n) ans[i] /= 2;
  for(int i=1; i<n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        ArrayList<Integer> ali = new ArrayList<>();
        for(int i = 0; i < 5; i++) {
            ali.add(scn.nextInt());
        }
        Collections.sort(ali);
        Collections.reverse(ali);
        StringBuilder sb = new StringBuilder();
        for(int elm : ali) {
            sb.append(elm + " ");
        }
        System.out.println(sb.toString().trim());
    }
}

Measured memory_bytes: 26284
from scipy.misc import comb

n, p = map(int, input().split())
a = list(map(int, input().split()))

odd = 0
even = 0
for x in a:
    if x % 2 == 1:
        odd += 1
    else:
        even += 1

s_even = 0
for i in range(even+1):
    s_even += comb(even, i, exact=True)

s_odd = 0
ans = 0
if p == 0:
    for i in range(odd+1)[::2]:
        s_odd += comb(odd, i, exact=True)
        ans = s_even * s_odd
else:
    for i in range(odd)[1::2]:
        s_odd += comb(odd, i, exact=True)
        ans = s_even * s_odd

print(ans)


Measured memory_bytes: 13200
#define PI 3.14159265
 
#include <stdio.h>
#include <math.h>
 
int main() 
{
	double a,b,C,c,x;
	double S,L,h;


	scanf("%lf %lf %lf",&a,&b,&C);

	x=C*PI/180;
	S=a*b*sin(x)/2;
	c=sqrt(a*a+b*b-2*a*b*cos(x));
	L=a+b+c;
	h=b*sin(x);

	printf("%f\n%f\n%f\n",S,L,h);

	return  0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    char c[n];
    for (int i=0;i<n;i++) cin>>c[i];
    int i=0;
    while (i<n and c[i]=='R') i++;
    int j=n-1;
    while (j>=0 and c[j]=='W') j--;
    int ans=0;
    while (i<j){
        c[i]='R';
        c[j]='W';
        ans++;
        i++;
        j--;
        while (i<n and c[i]=='R') i++;
        while (j>=0 and c[j]=='W') j--;
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3836
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<set>
#include<algorithm>
#include<map>
#include<ctime>
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double eps = 1e-8;
const int maxn = 209;
const int inf = 100000009;
const ll mod = 1e9 + 7;

int main()
{
	int op[10];
	mst(op, 0);
	int a, b;
	cin >> a >> b;
	op[a] = 1;
	op[b] = 1;
	for (int i = 1; i <= 3; ++i) 
		if (!op[i]) {
		cout << i;
		break;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Created by Aksenov239 on 12.03.2017.
 */
public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public void solveA() throws IOException {
        int n = nextInt();
        int c = nextInt();
        int k = nextInt();

        int[] t = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = nextInt();
        }

        Arrays.sort(t);

        int ans = 0;
        for (int i = 0; i < n;) {
            int j = i;
            while (j < i + c && j < n && t[j] <= t[i] + k) {
                j++;
            }
            i = j;
            ans++;
        }
        out.println(ans);
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            solveA();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 36852
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

const ll N = 2e5 + 5;
ll height[N],beauty[N],n,sol[N],num=2;

struct node{
    ll left=-1,right=-1,data=0;
    node(){
        left = -1;
        right = -1;
        data = 0;
    }
}seg[4*N];

ll query(int index,int l,int r,int ql,int qr){
    if(index<=0 || l>qr || r<ql)
        return 0;
    else if(ql<=l && qr>=r){
        // cout<<" returning "<<seg[index].data<<" for q-range "<<ql<<" "<<qr<<" from seg-range "<<l<<" "<<r<<" from index "<<index<<endl;
        return seg[index].data;
    }
    ll mid = (l+r)/2;
    return max(query(seg[index].left,l,mid,ql,qr),query(seg[index].right,mid+1,r,ql,qr));
}

void update(int index,int l,int r,int qp,ll qd){
    if(l==r){
        seg[index].data=max(qd,seg[index].data);
        // cout<<"updated "<<qd<<" at index "<<l<<endl;
        return;
    }
    ll mid = (l+r)/2;
    if(qp<=mid){
        if(seg[index].left == -1)
            seg[index].left = num++;
        update(seg[index].left,l,mid,qp,qd);
        seg[index].data = max(seg[index].data,seg[seg[index].left].data);
    }
    else{
        if(seg[index].right == -1)
            seg[index].right = num++;
        update(seg[index].right,mid+1,r,qp,qd);
        seg[index].data = max(seg[index].data,seg[seg[index].right].data);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    // for(int i=0;i<4*N;i++)
    //     seg[i].data = 0;
    cin>>n; /*cout<<n<<" ; \n";*/
    for(int i=1;i<=n;i++)
        cin>>height[i];
    for(int i=1;i<=n;i++)
        cin>>beauty[i];
    for(int i=1;i<=n;i++){
        sol[i]=beauty[i]+query(1,1,n,0,height[i]-1);
        update(1,1,n,height[i],sol[i]);
    }
    cout<<query(1,1,n,1,n)<<"\n";   
    // for(int i=1;i<=n;i++)
    //     cout<<sol[i]<<" \n"[i==n];
    // for()

    return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define bit(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;

// mod4  1,2

// mod4  2 -->2
// mod8  4,6 -->4
// mod16 8 10 12 14 -->8.

//000 0
//001 1
//010 2
//011 3
//100 4
//101 5
//110 6

void calc(lli N, lli &flg)
{
    int i = 1;
    if (N < 0)
    {
        flg = 0;
        return;
    }
    flg = N % 4ll == 1ll || N % 4ll == 2ll;
    lli p = 4ll;
    while (N >= p / 2ll)
    {
        lli val = N % p;
        flg += bit(i) * (val % 2ll == 0 && val >= p / 2ll);
        p *= 2ll;
        i++;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli A, B;
    cin >> A >> B;

    //Bまでに含まれる1の個数を2で割ったもの.
    lli flgA, flgB;
    calc(B, flgB);
    calc(A - 1, flgA);
    cout << (flgA ^ flgB) << "\n";
}


Measured memory_bytes: 256
import collections as col
n = int(input())
li = list(map(int,input().split()))

li1 = []
for i in range(n):
  li1.append(li[i])
  li1.append(li[i]+1)
  li1.append(li[i]-1)
c = col.Counter(li1)
print(max(list(c.values())))

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,p;
    cin >> a >> p;
    p += a * 3;
    ANS(p / 2);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int n,l=-1e9,r=1e9,mida,midb;
ll ana,anb;
ll a[200010];
ll che(int x){
	ll sum=0;
	for(int i=1;i<=n;++i){
		x++;sum+=abs(a[i]-x);
	}
	return sum;
}
int main(){
	l--;r++;
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;++i)  scanf("%lld",&a[i]);
	while(l+1<r){
		mida=l+(r-l+1)/3;midb=r-(r-l+1)/3;
		ana=che(mida);anb=che(midb);
		if(ana>anb)  l=mida;
		else  r=midb;
	}
	printf("%lld\n",min(che(l),che(r)));
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

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

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; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;
  cin>>n;
  int ans = n*n*n;
  cout(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
  
int main() {
 
	int n, a[10000];
	int MIN = 1000000;
	int MAX = -1000000;
	long long SUM = 0;

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> a[i];
		MIN = min(MIN,a[i]);
		MAX = max(MAX,a[i]);
		SUM = SUM + a[i];
	}

	cout << MIN << " " << MAX << " " << SUM << endl;


    return 0;
 
}



/* 配列の宣言について */
 
   /*
 
     　● イメージ ⇒　配列はタンスを想像して下さい。
 
 
 
       i.――i============i　　
　　　|　 　 |　　　　o　　　　
　　　|　 　 |＿＿＿＿＿＿|　　　タンスには１段目、２段目、３段目にそれぞれ別々の衣類が入っているよね。
　　　|　 　 |　　　　o　　　　　また、タンスは衣類をまとめた大きな塊である。
　　　|　 　 |＿＿＿＿＿＿|　　　そう、大きな塊に自分の好きな推しグッズを綺麗に分けて整頓している感じ。
　　　|　 　 |　　　　o　　　　
　　　  |＿＿|＿＿＿＿＿＿|
 
 
      　　　　　　　　　
 
     　● 書き方 ⇒　型　変数名[ 　 ] 
 
   　　　 そう、変数名に大かっこ→[   ]を隣に書くだけ～
      例: int a[7]; 
 
       ※ 注意: 大かっこ内には、“ 数 ” OR “ 変数名 ” 入れる。
 
 
 
　　*/
            
 
 
 /* min関数、max関数 について */
 
   /*
 　　  ● 説明　 ⇒　・ min関数：対象と比較して小さい方を取り出す関数。minimum を簡略化したもの。
 
                 ・ max関数：対象と比較して大きい方を取り出す関数。maximum を簡略化したもの。
                      
                      
 
     　● 書き方 ⇒　変数名 = min( 比較対象① , 比較対象② ) ←　※ 比較対象① と　比較対象② は “ 変数名 ” や “ 数 ”を入れよう！！！
 
      　　　　　 変数名 = max( 比較対象① , 比較対象② ) ←　※                            同　上
 
 
       ● 働き　 ⇒　対象を比較して“大きい方”や“小さい方”を取り出す。
 
 
                                         
              　　　 MIN = min(a,b);  
 
                     ＿                 
                    ｜｜
            　　　 ＿｜｜＿　　　　　 上のコードは下のコードと同じ意味を表しています。
               　  ＼　　／ 　　　　　どちらを使っても大丈夫！！  
                     ＼／
 
                                             
                  if( a < b ){                
                          MIN = a;              
                   } 
                        
                   else{                   
                      MIN = b;              
                   }                        
                                           
                                          
 
　　*/


Measured memory_bytes: 3144
N=int(input())
A=list(map(int,input().split()))
ans=10**15
for t in [1,-1]:
    r=0
    cnt=0
    T=t
    for i in range(N):
        r+=A[i]
        if(T>0 and r<=0):
            cnt+=1-r
            r+=1-r
        if(T<0 and r>=0):
            cnt+=r+1
            r-=r+1
        T*=-1
    ans=min(cnt,ans)
print(ans)

Measured memory_bytes: 14332
#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;
typedef long long ll;

bool queen_range(vector< vector<char> > &b, int r, int c){
	if(b[r][c] != '.') {
		return 0;
	}
	// 縦
	rep(i, 8) {
		if(i == r) continue;
		if(b[i][c] == 'Q'){
			return 0;
		}
	}
	// 横
	rep(i, 8) {
		if(i == c) continue;
		if(b[r][i] == 'Q'){
			return 0;
		}
	}
	
	// 斜め
	int dr[4] = {+1, +1, -1, -1};
	int dc[4] = {+1, -1, -1, +1};
	rep(dir, 4) {
		int next_r = r + dr[dir];
		int next_c = c + dc[dir];
		while(next_r >= 0 && next_r < 8 && next_c >= 0 && next_c < 8) {
			if(b[next_r][next_c] == 'Q'){
				return 0;
			}
			next_r += dr[dir];
			next_c += dc[dir];
		}
	}
	// Queenの移動可能範囲にxを記入
	b[r][c] = 'Q';
	rep(i, 8) {
		if(i == r) continue;
		b[i][c] = 'x';
	}
	// 横
	rep(i, 8) {
		if(i == c) continue;
		b[r][i] = 'x';
	}
	
	// 斜め
	rep(dir, 4) {
		int next_r = r + dr[dir];
		int next_c = c + dc[dir];
		while(next_r >= 0 && next_r < 8 && next_c >= 0 && next_c < 8) {
			b[next_r][next_c] = 'x';
			next_r += dr[dir];
			next_c += dc[dir];
		}
	}
	return 1; // 1は正常終了。0は被りあり
}

int main() {
	int k;
	cin >> k;
	vector< pair<int, int> > q(k);
	rep(i, k) {
		int r, c;
		cin >> r >> c;
		q[i] = make_pair(r, c);
	}
	set<int> sr;
	set<int> sc;
	rep(i, k) {
		sr.insert(q[i].first);
		sc.insert(q[i].second);
	}
	vector< vector<char> > b(8, vector<char>(8, '.'));
	rep(i, k){
		queen_range(b, q[i].first, q[i].second);
	}
	vector<int> per(8);
	rep(i, 8) {
		per[i] = i;
	}
	do{
		vector< vector<char> > now = b;
		bool ok = true;
		rep(i, 8) {
			if(sr.count(i) && sc.count(per[i])) {
				continue;
			}
			if(!queen_range(now, i, per[i])) {
				ok = false;
				break;
			}
		}
		if(ok){
			b = now;
			break;
		}
	}while(next_permutation(all(per)));
	
	rep(i, 8){
		rep(j, 8) {
			printf("%c", (b[i][j] == 'Q') ? 'Q' : '.');
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3168
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, D);
    AIN(ll, c, 26);
    vvi s(D, vi(26));
    REP(i, D)
    {
        REP(j, 26)
        {
            cin >> s[i][j];
        }
    }
    AIN(ll, t, D);

    ll S = 0;
    vi last(26);
    REP(i, D)
    {
        ll k = t[i] - 1;
        last[k] = i + 1;
        S += s[i][k];
        REP(j, 26)
        {
            S -= c[j] * (i + 1 - last[j]);
        }
        OUT(S);
    }
}

Measured memory_bytes: 3688
// 問題の URL を書いておく
// 

#include <algorithm>
#include <bitset>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int n, k;
    cin >> n >> k;
    vector<int> f(n);
    rep(i, n)
    {
        cin >> f[i];
    }
    sort(f.begin(), f.end());
    int amount = 0;
    rep(i, k)
    {
        amount += f[i];
    }
    cout << amount << endl;
    return 0;
}


Measured memory_bytes: 3632
# 貪欲の改良版
d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]

max_score = -10**10
best_T = None
for next_day in range(26):
    # Tの構築
    T = []
    L = [-1 for j in range(26)]
    for i in range(d):
        # 各日のスコア増加を最大にするjを選ぶ
        max_daily_score = -10**10
        best_j = 0
        for j in range(26):
            memo = L[j]
            L[j] = i
            # next_day日後までjがなかったときのdaily_scoreを計算
            daily_score = S[i][j]
            for jj in range(26):
                daily_score -= C[jj] * (i + next_day - L[jj])
            if daily_score > max_daily_score:
                max_daily_score = daily_score
                best_j = j
            L[j] = memo
        L[best_j] = i
        T.append(best_j)
    # スコアの計算
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    score = 0
    for i in range(d):
        score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        score -= C[j] * (dd - X[j])
    if score > max_score:
        max_score = score
        best_T = T
for t in best_T:
    print(t + 1)


Measured memory_bytes: 74828
num = int(input())
num_list = [int(x) for x in input().split()]
cnt = 0
for i in range(num):
    if num_list[i] % 2 == 0:
        if not (num_list[i] % 3 == 0 or num_list[i] % 5 == 0):
            cnt += 1
            
if cnt != 0:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N, L, R;
  int Goukei = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> L >> R;
    Goukei += R - L + 1;
  }
  cout << Goukei << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll po(ll a, ll b)
{
	if (b == 0)return 1;
	ll z = po(a, b / 2);
	z = z*z%mod;
	if (b & 1)z = z*a%mod;
	return z;
}
ll invv(ll a)
{
	return po(a, mod - 2);
}
int d[500];
ll dp[301][301][301];
int main()
{
	invinit();
	int num;
	scanf("%d", &num);
	int mini = 100;
	for (int i = 0; i < num; i++)scanf("%d", &d[i]), mini = min(mini, d[i]);
	if (mini == 2)
	{
		printf("%lld\n", kai[num - 1] * invv(2) % mod);
		return 0;
	}
	dp[0][0][0] = 1;
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			for (int k = 0; k <= num; k++)
			{
				dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k] * invkai[d[i] - 1]) % mod;
				if (d[i] >= 2)dp[i + 1][j + 1][k + d[i] - 2] = (dp[i + 1][j + 1][k + d[i] - 2] + dp[i][j][k] *invkai[d[i] - 2]) % mod;
			}
		}
	}
	ll ans = 0;
	for (int i = 3; i <= num - 1; i++)
	{
		for (int j = 0; j <= num; j++)
		{
			ans += dp[num][i][j] * kai[num - i - 1] % mod*j%mod*kai[i - 1]%mod*invv(2);
			ans %= mod;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 213504
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def main():
  a,b=LS()
  a=int(a)
  b=b.replace('.','')
  b=int(b)
  
  ans=a*b
  return ans//100

# main()
print(main())


Measured memory_bytes: 10792
N, M = map(int, input().split())
data = []
for i in range(N):
    data.append(list(map(int, input().split())))
#print(data)
counter2 = 0
for i in range(1, M + 1):
    counter1 = 0
    for ans in data:
        num = ans[0]
        if i in ans[1 : num + 1]:
            counter1 += 1
        else:
            counter1 = 0
            break
    if counter1 == N:
        counter2 += 1
print(counter2)

Measured memory_bytes: 3064
#include<stdio.h>
int main() {
	int n,k;
	scanf("%d %d",&n,&k);
	int ans=0;
	for(int i=0,x;i<n;++i) {
		scanf("%d",&x);
		ans+=(x<k-x?x:k-x)<<1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    string one = "";
    string zero = "";
    int a=0;
    int b=0;
    for(int i=0;i<n/2;i++){
        one += "10";
        zero += "01";
    }
    if(n%2 == 1){
        one += "1";
        zero += "0";
    }
    for(int i=0;i<n;i++){
        if(s.at(i) != one.at(i)){
            a++;
        }else{
            b++;
        }
    }
    cout << min(a,b) << endl;
}

Measured memory_bytes: 768