akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;} return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;} return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N; int K; cin >> N >> K;
    int n=N.size();
    ll dp[n+1][K+1][2];
    rep(i,n+1) rep(j,K+1) rep(k,2) dp[i][j][k]=0;
    dp[0][0][1]=1;
    rep(i,n) rep(j,K+1) rep(k,2){
        if (k){
            int x=N[i]-'0';
            if (x!=0){
                dp[i+1][j][0]+=dp[i][j][k];
                if (j<K) dp[i+1][j+1][0]+=dp[i][j][k]*(x-1);
                if (j<K) dp[i+1][j+1][1]+=dp[i][j][k];
            }
            else dp[i+1][j][1]+=dp[i][j][k];
        } else {
            dp[i+1][j][0]+=dp[i][j][k];
            if (j<K) dp[i+1][j+1][0]+=dp[i][j][k]*9;
        }
    }
    cout << dp[n][K][0]+dp[n][K][1] << endl;
}

Measured memory_bytes: 256
c=eval('[0]*50,'*50)
r=0
for a in[*open(0)][1:]:
 a=round(float(a)*10**9);x=y=0
 while a%2<1:a//=2;x+=1
 while a%5<1:a//=5;y+=1
 r+=sum(sum(d[max(0,18-y):])for d in c[max(0,18-x):]);c[x][y]+=1
print(r)

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

using namespace std;

int main()
{
    int a[5];
    for(int i=0; i<5 ; i++) cin>>a[i];

    int k;
    cin>>k;

    sort(a, a+5);

    cout<<(a[4]-a[0] > k ? ":(" : "Yay!");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
	char so[10001];
	int i,j,n;
	memset(so,0,sizeof(so));
	
	so[0]=so[1]=1;
	for(i=2;i<=100;i++){
		for(j=2*i;j<=10000;j+=i){
			so[j]=1;
		}
	}
	
	while(~scanf("%d",&n)){
		j=0;
		for(i=1;i<=n;i++){
			if(so[i]==0 && so[n+1-i]==0)++j;
		}
		printf("%d\n",j);
	}
	
	
	return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

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



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N;
	vector<int>place(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> place[i];
	}
	cin >> M;
	cin >> K;
	vector<vector<int>>nx(N + 1, vector <int>(20, MOD));
	int box = N;
	for (int i= N - 1; i >= 1; i--) {
		while (place[box] - place[i] > M) {
			box--;
		}
		nx[i][0] = box;
	}
	int two[20] = {};
	two[0] = 1;
	for (int i = 1; i < 20; i++) {
		two[i] = two[i - 1] * 2;
	}
	for (int j = 1; j < 20; j++) {
		for (int i = 1; i <= N; i++) {
			if (nx[i][j - 1] == MOD)break;
			nx[i][j] = nx[nx[i][j - 1]][j - 1];
		}
	}
	for (int i = 0; i < K; i++) {
		cin >> L >> R;
		if (L > R) swap(L, R);
		int ans = 0;
		for (int j = 19; j >= 0; j--) {
			if (nx[L][j] <= R) {
				L = nx[L][j];
				ans += two[j];
			}
		}
		if (L < R) {
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
vector<int>dp(100007,-1);
int fn(int index,vector<int>&vect){
    if(index==0)
        return INT_MAX;
    if(dp[index]!=-1)
        return dp[index];
    int x=abs(vect[index-1]-vect[index-2])+fn(index-1,vect);
    int y=abs(vect[index-1]-vect[index-3])+fn(index-2,vect);
    dp[index]=min(x,y);
    return dp[index];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    dp[1]={0};
    int n;
    cin>>n;
    vector<int>vect(n);
    for(int i=0;i<n;i++)
        cin>>vect[i];
    dp[2]=abs(vect[1]-vect[0]);
    if(n>2){
    cout<<min(abs(vect[n-1]-vect[n-2])+fn(n-1,vect),abs(vect[n-1]-vect[n-3])+fn(n-2,vect));
    }
    else{
        cout<<abs(vect[n-1]-vect[n-2]);
    }
    return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n; cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int tmp_min = p[0];
    int ans = 1;
    if(n>1){
        for(int i=1; i<n; i++){
            if(p[i] <= tmp_min){
                ans += 1;
            }
            tmp_min = min(tmp_min, p[i]);
        }
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  int P;
  P = N % 500;
 
  if (P <= A) {
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N;i++)
    {
        cin >> X.at(i);
    }
    int healthsum, min;
    min = INT_MAX;
    //iは座標
    for (int i = 0; i <= 100;i++){
        int sum=0;
        for (int j = 0; j < N;j++)
        {//jは人番号
            sum += pow((X.at(j) - i), 2);
        }
        if(sum<min)
        {
            min = sum;
        }
    }
    cout << min << endl;

}




Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m:usize = read();
    let mut v:Vec<Vec<usize>> = vec![Vec::new();  200_001];
    for _ in 0..m {
        let a:usize = read();
        let b:usize = read();
        v[a].push(b);
    }
    for i in v[1].iter() {
        if v[*i].contains(&n) {
            println!("POSSIBLE");
            return;
        }
    }
    println!("IMPOSSIBLE");
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int n,w;
ll dp[101][100010];
int flag[101][100010];
ll W[101],V[101];

ll ddpp(int x,int y){
    if (flag[x][y]){
        return dp[x][y];
    }
    else{
        flag[x][y]=1;
        if (x==0 || y==0){
            dp[x][y]=0;
            return 0;
        }
        if (y>=W[x]){
            dp[x][y]=max(ddpp(x-1,y-W[x])+V[x],ddpp(x-1,y));
        }
        else{
            dp[x][y]=ddpp(x-1,y);
        }
        return dp[x][y];
    }

}

int main() {
    cin>>n>>w;
    rep(i,n){
        cin>>W[i+1];
        cin>>V[i+1];
    }
    memset(dp,0,sizeof(dp));
    ddpp(n,w);
    cout<<dp[n][w]<<endl;
    return 0;
}

Measured memory_bytes: 118656
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

bool prime[1001];

void pr(){
    int i,j;
    prime[1]=false;
    for (i = 2; i*i<=1000; i++) {
        if (prime[i] == true)
            for (j=2 ; i*j <= 1000; j++)
                prime[i*j] = false;
    }
}

int main(){
    int N;
    cin >> N;
    memset(prime,true,sizeof(prime));
    pr();
    LL ans=1;
    for(int i=2;i<=1000;i++){
        int count=0;
        int u=1;
        if(prime[i]==true){
            for(int j=1;u<=N;j++){
                u*=i;
                count+=N/u;
            }
            ans*=count+1;
            ans%=mod;
        }
    }
    cout << ans%mod << endl;
    return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

int n;
int d;

int main(){
    cin >> d >> n;
    for(int i = 1; i <= 10000000; i++){
        int cnt = 0 , x = i;
        while(x % 100 == 0){
                cnt++;
                x /= 100;
        }
        //cout << i << " " << cnt << endl;
        if(cnt == d){
            //cout << i << " ";
            n--;
            if(n == 0){
                cout << i;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#! python3
# stack.py - ポーランド記法で記述された計算式を解くプログラム

# 必要な変数を定義する
stack = [None] # 空の配列、0番目は埋まっている
# top = 0  # 配列の中の、一番うしろの値、初期状態では0
MAX = 201  # 配列が持つことができる最大値

# 配列が空かどうかを判定する（真偽値を返す）
def isEmpty(top):
    return top == 0

# 配列がいっぱいになっているかどうかを判定する（真偽値を返す）
def isFull(top):
    return top >= MAX - 1

# 配列の一番うしろに値を追加する
def push(x, stack):
    if isFull(len(stack)):
        raise Exception  # オーバーフロー
    stack.append(x)
    return stack

# 配列の一番うしろから値を削除する
def pop(stack):
    if isEmpty(len(stack)):
        raise Exception  # アンダーフロー
    stack = stack.pop()
    return stack

# 入力を扱う
original_input_list = input().split(' ')
input_list = []
for items in original_input_list:
    if items.isdecimal():
        input_list.append(int(items))
    else :
        input_list.append(items)

# print(input_list)        

for items in input_list:
    if type(items) == int:
        push(items, stack)
    elif items == "+":
        first_digit = pop(stack)
        second_digit = pop(stack)
        calculated_digit = second_digit + first_digit
        push(calculated_digit, stack)
    elif items == "-":
        first_digit = pop(stack)
        second_digit = pop(stack)
        calculated_digit = second_digit - first_digit
        push(calculated_digit, stack)
    elif items == "*":
        first_digit = pop(stack)
        second_digit = pop(stack)
        calculated_digit = second_digit * first_digit
        push(calculated_digit, stack)
    elif items == "/":
        first_digit = pop(stack)
        second_digit = pop(stack)
        calculated_digit = second_digit / first_digit
        push(calculated_digit, stack)

# print(stack)
# print(first_digit)
# print(second_digit)
print(stack[-1])




Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >>N;
  int s = 0;
  vector<bool> rate(8,false);
  for(int i = 0; i < N; i++){
    int a; cin >> a;
    if(a >= 3200)
      s++;
    else if(a >=2800)
      rate.at(7) = true;
    else if(a >=2400)
      rate.at(6) = true;
    else if(a >=2000)
      rate.at(5) = true;
    else if(a >=1600)
      rate.at(4) = true;
    else if(a >=1200)
      rate.at(3) = true;
    else if(a >=800)
      rate.at(2) = true;
    else if(a >=400)
      rate.at(1) = true;
    else 
      rate.at(0) = true;
  }
  int min_num = 0;
  for(int i = 0; i < 8; i++){
    if(rate.at(i)) min_num++;
  }
  cout << max(1,min_num) << " " <<max(1,min_num + s) << endl;
}
 


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

// graph flow {{{
template<class T>
struct GF {
    struct EF {
        int to;
        T cap;
        int rev;
    };

    int n;
    vector<vector<EF>> e;

    GF() {}
    GF(int n) {
        this->n = n;
        e.resize(n);
    }

    void add(int from, int to, T cap) {
        e[from].push_back({to, cap, int(e[to].size())});
        e[to].push_back({from, 0, int(e[from].size()-1)});
    }
};


// 最大流 (Ford-Fulkerson) {{{
// O(FE)
// verified AOJ GRL_6_A
template<class T>
struct MF {
    GF<T> g;
    vector<bool> visited;

    MF() {}
    MF(const GF<T> &g) {
        this->g = g;
        visited.resize(g.n, false);
    };

    T dfs(int v, int t, T f) {
        if(v == t) return f;
        visited[v] = true;
        for(auto &e : g.e[v]){
            if(!visited[e.to] && e.cap > 0){
                T d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    g.e[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    T query(int from, int to) {
        T flow = 0;
        while(true){
            fill(visited.begin(), visited.end(), false);
            T f = dfs(from, to, INF);
            if(f == 0) break;
            flow += f;
        }
        return flow;
    }
};//}}}
//}}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int n, A, B;
    cin >> n >> A >> B;
    vector<int> a(n), b(n);
    inc(i, 0, n){
        cin >> a[i] >> b[i];
    }

    vector<bool> used(n, false);
    int ans1 = 0;

    inc(i, 0, n){
        int d = abs(a[i]-b[i]);
        if(d <= A || (B <= d && d <= 2*A)){
            //gf.add(i, n+i, 1);
            used[i] = true;
            ans1++;
        }
    }


    GF<int> gf(2*n+2);
    inc(i, 0, n){
        inc(j, 0, n){
            if(used[i] || used[j]) continue;
            if(i == j) continue;
            int d = abs((a[i]+a[j])-(b[i]+b[j]));
            if(d <= A || (B <= d && d <= 2*A)){
                gf.add(i, n+j, 1);
            }
        }
    }
    inc(i, 0, n){
        gf.add(2*n, i, 1);
        gf.add(n+i, 2*n+1, 1);
    }
    MF<int> mf(gf);
    int ans2 = mf.query(2*n, 2*n+1)/2;

    cout << ans1+ans2 << endl;
    return 0;
}



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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

//漸化式を利用してコンビネーションを表を作る.O(nk)
vector<vector<i64>> comb;
void init_mod_comb(int n, int k, i64 mod) {
    comb.resize(n + 1);
    for (int i = 0; i <= n; ++i) {
        comb[i].resize(k+1);
        comb[i][0] = 1;
        if (i <= k) comb[i][i] = 1;
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= min(i - 1, k); ++j) {
            comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % mod;
        }
    }
}

void solve() {
    const i64 mod = 1'000'000'007;

    init_mod_comb(3010,3010,mod);

    i64 N,K;
    cin >> N >> K;

    rep(i,1,K+1){
        i64 tmp=comb[N-K+1][i];
        i64 r=K-i;
        tmp*=comb[r+i-1][i-1];
        tmp%=mod;

        cout << tmp << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 71168
class Dice:
    """Dice class"""
    def __init__(self):                  # ?????????????????????
        self.eyeIndex = 1        #center
        self.eyeIndex_E = 3      #east
        self.eyeIndex_W = 4      #west
        self.eyeIndex_N = 5      #north
        self.eyeIndex_S = 2      #south
        self.eye = 0
        self.eye_S = 0
        self.eye_E = 0
        self.eyes = []

    def convEyesIndexToEyes(self):
        self.eye = self.eyes[self.eyeIndex]
        self.eye_S = self.eyes[self.eyeIndex_S]
        self.eye_E = self.eyes[self.eyeIndex_E]
 

    def shakeDice(self, in_command):
        pre_eyeIndex = self.eyeIndex
        if in_command == "E":
            self.eyeIndex = self.eyeIndex_W 
            self.eyeIndex_E = pre_eyeIndex 
            self.eyeIndex_W = 7 - self.eyeIndex_E
            
        elif in_command == "W":
            self.eyeIndex = self.eyeIndex_E 
            self.eyeIndex_W = pre_eyeIndex
            self.eyeIndex_E = 7 - self.eyeIndex_W
            
        elif in_command == "N":
            self.eyeIndex = self.eyeIndex_S 
            self.eyeIndex_N = pre_eyeIndex 
            self.eyeIndex_S = 7 - self.eyeIndex_N

        elif in_command == "S":
            self.eyeIndex = self.eyeIndex_N         
            self.eyeIndex_S = pre_eyeIndex 
            self.eyeIndex_N = 7 - self.eyeIndex_S 
        
        self.convEyesIndexToEyes()


    def rotateDice(self):
        #rotate clockwise
        pre_E = self.eyeIndex_E
        pre_S = self.eyeIndex_S
        pre_W = self.eyeIndex_W
        pre_N = self.eyeIndex_N
        
        self.eyeIndex_E = pre_N
        self.eyeIndex_S = pre_E
        self.eyeIndex_W = pre_S
        self.eyeIndex_N = pre_W

        self.convEyesIndexToEyes()
        
    def getEye(self):
        return self.eye
        
    def getEye_S(self):
        return self.eye_S
    
    def getEye_E(self):
        return self.eye_E

    def setEyes(self, eyes):             # setEyes()???????????? ???????????????
        eyes = "0 " + eyes
        self.eyes = list(map(int, eyes.split(" ")))
        self.convEyesIndexToEyes()
        
dice_1 = Dice()
dice_1.setEyes(input().rstrip())
command_time = int(input().rstrip())

for i in range(command_time):
    in_eye, in_eye_S = map(int, input().rstrip().split(" "))
    
    shake_direction = "E"
    def_eye = dice_1.getEye()
    
    while True:
        dice_1.shakeDice(shake_direction)

        if dice_1.getEye() == in_eye:
            break
        if dice_1.getEye() == def_eye:
            shake_direction = "N"

    while True:
        if dice_1.getEye_S() == in_eye_S:
            break
        dice_1.rotateDice()


    print(dice_1.getEye_E())

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

using ll = long long;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

    ll ans = 0;
    for (int i = 0; i < n-2; i++) {
        for (int j = i+1; j < n-1; j++) {
            if (a[i] == a[j]) continue;
            for (int k = j+1; k < n; k++) {
                if (a[k] == a[i] or a[k] == a[j]) continue;
                if (a[i] + a[j] > a[k]) ans++;
            }
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3776
#![allow(unused_imports, unused_macros, dead_code)]
use std::f64::*;
use std::cmp::*;
use std::collections::*;

macro_rules! dump{
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const INF: i64 = 0x3f3f3f3f3f3f3f3f;
const MOD: i64 = 1000000007;
const NOTHING: usize = std::usize::MAX;
const DX: [usize; 4] = [1, 0, std::usize::MAX, 0];
const DY: [usize; 4] = [0, 1, 0, std::usize::MAX];

fn main() {
    let n: usize = readln();
    let xs: Vec<usize> = readln();
    let ys: Vec<usize> = readln();
    let mut res = 0;
    for k in 0..n {
        let mut sum = 0;
        for i in 0..k {
            sum += xs[i];
        }
        sum += xs[k];
        for i in k..n {
            sum += ys[i];
        }
        res = max(res, sum);
    }
    println!("{}", res);
}

trait Read {
    fn read(s: &str) -> Self;
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
   int a, b, c, key;
   scanf("%d %d %d", &a, &b, &c);
   if ( a > b ) {
        key = a;
        a = b;
        b = key;
   }
   if( b > c ) {
        key = b;
        b = c;
        c = key;
        if ( a > b ) {
            key = a;
            a = b;
            b = key;
        }
   }
   printf("%d %d %d\n", a, b, c);
   return 0;
}

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

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

	map<long long, int> count;

	int N, M, B;
	long long C;
	scanf("%d %d", &N, &M);

	long long A;
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A);
		count[A]++;
	}

	for (int i = 0; i < M; i++) {
		scanf("%d %lld", &B, &C);
		count[C] += B;
	}

	auto it = count.rbegin();
	int num = N;
	long long result = 0;
	while (it != count.rend()) {
		if (num > it->second) {
			// printf("num = %d it->first = %lld, it->second = %d \n", num,
			//    it->first, it->second);
			result += it->first * it->second;
			num -= it->second;
		} else {
			// printf("num = %d it->first = %lld, it->second = %d \n", num,
			//    it->first, it->second);
			result += it->first * num;
			break;
		}
		it++;
	}

	printf("%lld", result);

	return 0;
}

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

int main() {
    string s; cin >> s;
    for (int i = 0; i < s.length(); ++i)
    	for (int j = i+1; j < s.length(); ++j) {
    		if (s[i] == 'C' && s[j] == 'F') {
    			cout << "Yes\n"; return 0;
    		}
    	}
    cout << "No\n";
}

Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
import bisect

con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def Binary_Search(A, N, M):
	#初期化
	left = 0
	right = 10 ** 7
	ans = 0
	#累積和
	Asum = [0]
	for i in range(N):
		Asum.append(Asum[i] + A[-1 - i])

	leftj = [INF, INF]
	rightj = [0, 0]
	#二分探索
	while left <= right:
		mid = (left + right) // 2
		var = 0
		happiness = 0
		for i in range(N):
			ind = bisect.bisect_left(A, mid - A[i])
			ind = N - ind
			var += ind
			happiness += ind * A[i] + Asum[ind]

		# print(var, happiness)
		if var == M:
			return happiness
		elif var > M:
			leftj = min(leftj, [var, -mid])
			left = mid + 1
		else:
			ans = max(ans, happiness)
			rightj = max(rightj, [var, -mid])
			right = mid - 1

	# print(ans)
	# print(leftj)
	# print(rightj)

	ans = ans + (M - rightj[0]) * (-leftj[1])
			
	return ans


#処理内容
def main():
	N, M = getlist()
	A = getlist()
	A.sort()
	ans = Binary_Search(A, N, M)

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 53692
n, m = map(int, input().split())
A = list(map(int, input().split()))
count = 0

total = sum(A)
for i in range(n):
    if A[i] >= total / (4*m):
        count += 1
    else:
        continue
if count >= m:
    print("Yes")
else:
    print("No")

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

int main() {
    int n;
    cin >> n;

    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
     }
    for(int i=n-1;i>-1;i--){
        if(i==0) cout << a[i] << endl;
        else cout << a[i] << " ";
     }
    return 0;
}




Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define int long long

typedef long long ll;

int r, g, b, n;

signed main(){
    cin >> r >> g >> b >> n;

    int cnt = 0;

    for (int x = 0; x <= n/r+1; x++){
        for (int y = 0; y <= n/g + 1; y++){
            if ((n - (r * x + g * y)) % b == 0 && ((n - (r * x + g * y)) / b) >= 0) cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
	int i, j, k, N, L[101], count = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(L[i]));
	for (i = 1; i <= N - 2; i++) {
		for (j = i + 1; j <= N - 1; j++) {
			if (L[i] == L[j]) continue;
			for (k = j + 1; k <= N; k++) {
				if (L[k] != L[i] && L[k] != L[j] && L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) count++;
			}
		}
	}
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100005;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    sort(All(a));
    sort(All(b));
    if(n%2==1){
        cout<<b[n/2]-a[n/2]+1<<endl;
    }else{
        int x=a[n/2]+a[n/2-1];
        int y=b[n/2]+b[n/2-1];
        cout<<y-x+1<<endl;
    }
}

Measured memory_bytes: 6340
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
struct edge{int to;ll cost;};
typedef pair<ll,int> P;
const ll INF=1000000000000LL;
const ll MOD=1000000007LL;
const ll MAX=100010;
struct UnionFind{
    int par[MAX];//親
    int fukasa[MAX];//深さ
    UnionFind(){};
    //初期化
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            fukasa[i]=0;
        }
    }
    //木の根を求める
    int find(int x){
        if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
    }
    //xとyの集合を併合
    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y){
            return;
        }
        if(fukasa[x]<fukasa[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(fukasa[x]==fukasa[y]){
                fukasa[x]++;
            }
        }
    }
    //xとyが同じ集合に属する?
    bool same(int x,int y){
        return find(x)==find(y);
    }
};

int main(){
	UnionFind uf;
	int n,q;
	cin>>n>>q;
	uf.init(n);
	for(int i=0;i<q;i++){
		int com,x,y;
		cin>>com>>x>>y;
		if(com){
			if(uf.same(x,y)){
				cout<<1<<endl;
			}else{
				cout<<0<<endl;
			}
		}else{
			uf.unite(x,y);
		}
	}
	return 0;
}



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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s;
  std::cin >> s;

  std::vector<int64_t> l1(13, 0), l2(13, 0);

  if (s[0] == '?') {
    for (int64_t i = 0; i < 10; i++) {
      l1[i] = 1;
    }
  } else {
    l1[s[0] - '0'] = 1;
  }

  constexpr int64_t mod = 1000000007;
  for (int64_t i = 1; i < s.size(); i++) {
    if (s[i] == '?') {
      std::fill(l2.begin(), l2.end(), 0l);
      for (int64_t j = 0; j < 10; j++) {
        for (int64_t k = 0; k < 13; k++) {
          l2[(k * 10 + j) % 13] += l1[k];
          l2[(k * 10 + j) % 13] %= mod;
        }
      }
    } else {
      const int64_t n = s[i] - '0';

      for (int64_t j = 0; j < 13; j++) {
        l2[(j * 10 + n) % 13] = l1[j];
      }
    }
    std::swap(l1, l2);
  }

  std::cout << l1[5] << std::endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define dump(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  vector<ll> B(M);
  vector<ll> C(M);
  REP(i, M) cin >> B[i] >> C[i];
  priority_queue<P> pq;

  for(int i = 0; i < N; i++) {
    pq.push(P(A[i], 1));
  }

  for(ll i = 0; i < M; i++) {
    pq.push(P(C[i], B[i]));
  }
  ll ans = 0;
  ll wow = 0;
  for(int i = 0; i < N; i++) {
    P p = pq.top();
    pq.pop();
    ans += p.first;
    if(p.second > 1) {
      p.second--;
      pq.push(p);
    }
  }

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

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

static const int INFTY = 1 << 30;

class Edge {
public:
	int outVal, weight;
	Edge(int o, int w): outVal(o), weight(w){}
};

void BFS(int start, vector<Edge> verVal[], int distance[], int verNum) {

	for (int i = 0; i < verNum; i++) distance[i] = INFTY;
	queue<int> que;
	que.push(start);
	distance[start] = 0;

	while (!que.empty()) {
		int nowVerVal = que.front();
		que.pop();
		for (int i = 0; i < verVal[nowVerVal].size(); i++) {
			Edge nowE = verVal[nowVerVal][i];
			if (distance[nowE.outVal] != INFTY) continue;

			distance[nowE.outVal] = distance[nowVerVal] + nowE.weight;
			que.push(nowE.outVal);
		}
	}
}

void DiameterOfATree(vector<Edge> verVal[], int distance[], int verNum) {

	int target = 0;
	int maxDis = 0;

	for (int i = 0; i < 2; i++) {
		BFS(target, verVal, distance, verNum);

		maxDis = 0;
		for (int i = 0; i < verNum; i++) {
			if (distance[i] == INFTY) continue;
			if (maxDis < distance[i]) {
				maxDis = distance[i];
				target = i;
			}
		}
	}

	cout << maxDis << endl;
}

int main() {

	vector<Edge> verVal[100000];
	int distance[100000];
	int verNum;
	cin >> verNum;

	for (int i = 0; i < verNum-1; i++) {
		int first, second, weight;
		cin >> first >> second >> weight;

		verVal[first].push_back(Edge(second, weight));
		verVal[second].push_back(Edge(first, weight));
	}

	DiameterOfATree(verVal, distance, verNum);

	return 0;
}

Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  string s, t; cin >> s >> t;
  int m = s.size();
  int n = t.size();

  VV dp(m+1, V(n+1));

  rep(i, m) rep(j, n) {
    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
  }

  string ans = "";
  int i = m, j = n;
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i-1][j]) --i;
    else if (dp[i][j] == dp[i][j-1]) --j;
    else if (dp[i][j] == dp[i-1][j-1]+1) {
      ans = s[i-1] + ans;
      --i, --j;
    }
  }

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


Measured memory_bytes: 35584
#include <iostream>
using namespace std;
int main()
{
	int A[5] = {};
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	for (int i = 1; i < 5; ++i){
		for (int j = i; j >= 1; --j){
			if (A[j] > A[j - 1]) swap(A[j], A[j - 1]);
			else break;
		}
	}
	cout << A[0] << " " << A[1] << " " << A[2] << " " << A[3] << " " << A[4] << "\n";
	return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
multiset<int> s;
multiset<int>::iterator it;
int main(){
  int Lj4PdHRW;
  int i;
  int j;
  int k = 1<<30;
  int res = 0;
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    s.insert(rd_int());
  }
  while(s.size()){
    it = s.end();
    i = *(--it);
    s.erase(it);
    while(k/2 > i){
      k /= 2;
    }
    j = k - i;
    it = s.lower_bound(j);
    if(j == *it){
      res++;
      s.erase(it);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190925-1

// --- original code ---
// multiset<int> s;
// multiset<int>::iterator it;
// {
//   int i, j, k = 1<<30, res = 0;
// 
//   REP(rd_int()) s.insert(rd_int());
// 
//   while(s.size()){
//     it = s.end();
//     i = *(--it);
//     s.erase(it);
//     
//     while(k/2 > i) k /= 2;
//     j = k - i;
//     it = s.lower_bound(j);
//     if(j == *it){
//       res++;
//       s.erase(it);
//     }
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 9600
#include <iostream>

using namespace std;

class B {
	int N, ans{ 0 };
	string S;
public:
	void solve()
	{
		cin >> N >> S;
		int tmpCount{ 0 };
		int leftMask{ 0 }, rightMask{ 0 };
		int i{ 0 };

		for (int sep{ 1 }; sep < N; sep++)
		{
			leftMask = rightMask = tmpCount = 0;
			
			for (i = 0; i < sep; i++)
				leftMask |= (1 << (S[i] - 'a'));
			for (; i < N; i++)
				rightMask |= (1 << (S[i] - 'a'));
			
			for (i = 0; i < 26; i++)
			{
				if ((leftMask & (1 << i)) & (rightMask & (1 << i))) tmpCount++;
			}

			if (ans < tmpCount) ans = tmpCount;
			
		}
		cout << ans << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

ll divtwocnt(ll N) {
    if (N % 2 != 0) {
        return 0;
    }
    N /= 2;
    return divtwocnt(N) + 1;
}

void solve(long long N, std::vector<long long> a) {
    ll two_cnt = 0, one_cnt = 0, zero_cnt = 0;

    rep(i, N) {
        ll cnt = divtwocnt(a[i]);
        if (cnt == 0) {
            zero_cnt++;
        } else if (cnt == 1) {
            one_cnt++;
        } else {
            two_cnt++;
        }
    }

    if (one_cnt == 0) {
        if (two_cnt >= (zero_cnt - 1)) {
            cout << YES << endl;
            return;
        } else {
            cout << NO << endl;
            return;
        }
    } else {
        if (two_cnt >= zero_cnt) {
            if (one_cnt % 2 == 0 || ((one_cnt % 2 == 1) && (two_cnt >= 1))) {
                cout << YES << endl;
                return;
            } else {
                cout << NO << endl;
                return;
            }
        } else {
            cout << NO << endl;
            return;
        }
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

int search(int);

int main(){

  int s[100000],t;
  int n, q;
  int left,right,mid,key;
  int count = 0;
  int i,j;

  cin >> n;

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

  cin >> q;

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

    while(left < right){
      mid = (left+right)/2;
      if(s[mid] == key){
        count++;
	break;
      }else if(key < s[mid]){
	right = mid;
      }else{
	left = mid + 1;
      }
    }

  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1552
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

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

	int ok1 = 1;
	for(int i = 1; i < n; i++){
		if(a[i] <= a[i-1]) ok1 = 0;
	}
	if(ok1){
		cout << 1 << '\n';
		return 0;
	}

	int s = 1; // can't
	int e = n + 1; // can

	while(s + 1 < e){
		int m = (s + e) / 2;

		int ok = 1;

		map<int,int> f;
		int len = 0;
		for(int i = 0; i < n; i++){
			if(a[i] > len){
				len = a[i];
			} else {
				while(!f.empty() && f.rbegin()->first >= a[i]){
					f.erase(f.rbegin()->first);
				}
				f[a[i]-1]++;
				int cur = a[i]-1;
				while(f[cur] >= m){
					f.erase(cur);
					cur--;
					f[cur]++;
					if(cur < 0){
						ok = 0;
					}
				}
				if(!ok) break;
				len = a[i];
			}
		}
		if(ok){
			e = m;
		} else {
			s = m;
		}
	}
	cout << e << '\n';
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e,f,g,r[400][400],k;


    while(cin>>a>>b)
    {

       for(c=1;c<=a;c++)
       {

           for(d=1;d<=b;d++)
           {

               cin>>r[c][d];
           }
       }
       d=1;
       k=0;
       double h,i,j;
       for(c=d;c<=a-1;c++)
       {
           for(e=c+1;e<=a;e++)
           {
               g=0;
               for(f=1;f<=b;f++)
               {
                   g+=abs((r[c][f]-r[e][f])*(r[c][f]-r[e][f]));
               }
               h=sqrt(g);
               i=floor(h);
               j=ceil(h);
               if(i==j)
               {
                   k++;
               }
           }
           d++;



       }
       cout<<k<<endl;



    }








    return 0;
}


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

int main()
{
	int h,w;

	while(1){
		cin>>h>>w;

		if(h==0)
			break;

		else{
			for(int i=1; i<=w; i++)
				cout<<'#';
			cout<<endl;
			for(int i=1; i<=h-2; i++){
				cout<<'#';
				for(int j=1; j<=w-2; j++)
					cout<<'.';
				cout<<'#';
				cout<<endl;
			}
			for(int i=1; i<=w; i++)
				cout<<'#';
			cout<<endl;
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
N,K=map(int,input().split())
p=list(map(int,input().split()))
ave=[0]*(N-K+1)
tmp=0
for i in range(K):
    tmp+=(p[i]+1)/2
ave[0]=tmp
for i in range(1,N-K+1):
    ave[i]=ave[i-1]-(p[i-1]+1)/2 + (p[i+K-1]+1)/2
print(max(ave))


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

int main(void) {
	int M1, D1, M2, D2;
	scanf("%d %d %d %d", &M1, &D1, &M2, &D2);
	if (D2 == 1) printf("1\n");
	else printf("0\n");

	return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main() {
	int h, w, i, j;
	char c[101][101];

	scanf("%d %d", &h, &w);
	for (i = 0;i < h;i++) {
		for (j = 0;j < w + 1;j++) {
			scanf("%c", &c[i][j]);
		}
	}

	for (i = 0;i < h;i++) {
		for (j = 0;j < w + 1;j++) {
			printf("%c", c[i][j]);
		}
		for (j = 0;j < w + 1;j++) {
			printf("%c", c[i][j]);
		}
	}

	return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
S = [list(map(int,input().split()))[1:] for i in range(M)]
P = list(map(int,input().split()))

ans = 0
for b in range(2**N):
    for s,p in zip(S,P):
        c = 0
        for t in s:
            if b&(1<<(t-1)): c += 1
        if c%2 != p:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;
 
int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll ans=0,tmp=0;
    rep(i,n){
        if(s[i]=='B') tmp++;
        else ans+=tmp;
    }    

    cout<<ans<<endl;
}

Measured memory_bytes: 3700
N,M=map(int,input().split())

if M%N==0:
  print(M//N)
else:
  ans= (M//N)
  cnt=[]
  for i in range(1,M):
    if i*i > M:
      break
    if M%i==0:
      cnt.append(i)
      cnt.append(M//i)
      
  cnt.sort(reverse=True)
  for j in range(len(cnt)):
    if cnt[j] < ans:
      ans=cnt[j]
      break
  
  print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll now(100);
    ll x;
    ll cnt(0);
    cin >> x;
    while (now < x) {
        cnt++;
        now += now / 100;
    }
    cout << cnt << endl;
}


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

namespace Test
{
    class AIZU
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int[,] matrix = new int[n[0], n[1]];
            int[] vector = new int[n[1]];

            for(int i = 0; i < n[0]; i++)
            {
                int[] row = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for(int j = 0; j < n[1]; j++)
                {
                    matrix[i, j] = row[j];
                }
            }

            for(int j = 0; j < n[1]; j++)
            {
                vector[j] = int.Parse(Console.ReadLine());
            }
            for(int i = 0; i < n[0]; i++)
            {
                int sum = 0;
                for(int j=0; j < n[1]; j++)
                {
                    sum += matrix[i, j] * vector[j];

                }
                Console.WriteLine(sum);
            }
        }
        
    }
}



Measured memory_bytes: 18436
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b,c; cin >> a >> b >> c;

    if(a+b < c ) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

int main(){
    int h1,m1,h2,m2,K;
    cin>>h1>>m1>>h2>>m2>>K;
    
    int d=(h2-h1)*60+(m2-m1);
    cout<<(d-K)<<endl;
}


Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {

	string s;
	cin >> s;

	int sum = 0;
	REP(i, s.length()) {
		sum += s[i]-'0';
	}

	if (stoi(s)%sum == 0) {
		ANS("Yes");
	}
	else {
		ANS("No");
	}

	return 0;
}



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

a.sort()
ans = 1 << 60
for x in range(min(a), max(a)+1) :
  res = 0
  for j in range(n) :
    res += abs(x - a[j])**2
  ans = min(ans, res)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

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

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

int main(){
	ll N, M;
	cin >> N >> M;
	vector<pll> E;
	vll C;
	ll i, j, k;
	for (i = 0; i < M; i++){
		pll ab;
		ll c;
		cin >> ab.first >> ab.second >> c;
		ab.first--;
		ab.second--;
		E.push_back(ab);
		C.push_back(c);
	}
	vll D(N, -INF);
	D[0] = 0;
	ll score_at_N;
	for (i = 0; i < 2 * N; i++){
		for (j = 0; j < M; j++){
			D[E[j].second] = max(D[E[j].second], D[E[j].first] + C[j]);
		}
		if (i == N - 1) score_at_N = D[N - 1];
		if (i == 2 * N - 1 && D[N-1]>score_at_N){
			cout << "inf" << endl;
			return 0;
		}
	}
	cout << D[N - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
#include <algorithm>
#include <unordered_map>
int main(void){
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for(int i=0;i<n;i++)std::cin >> a[i];
	std::sort(a.begin(), a.end());
	double ans = a[0];
	for(int i=1;i<n;i++){
		ans = (ans + a[i]) / 2;
	}
	printf("%.9lf\n", ans);
}

Measured memory_bytes: 256