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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

struct UnionFind
{
    vector<int> par, sz;
    UnionFind(int n) : par(n), sz(n, 1) {
        for (int i = 0; i < n; ++i) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (sz[x] < sz[y]) swap(x, y);
        par[y] = x;
        sz[x] += sz[y];
        sz[y] = 0;
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return sz[root(x)];
    }
};


template<typename T>
struct edge {
    int src, to;
    T cost;
    // edge(int src, int to, T cost): src(src), to(to), cost(cost) {}
    // // G[i].push_back({src, to, cost}) requires no constructor
};

template<typename T>
T kruskal(vector<edge<T>> &es, int V) {

    UnionFind uf(V);
    T ret = 0;

    // sort destructively
    sort(es.begin(), es.end(), [](edge<T> &a,edge<T> &b){
            return a.cost < b.cost;
            });
    for (auto &e : es) {
        if (!uf.issame(e.src, e.to)) {
            ret += e.cost;
            uf.merge(e.src, e.to);
        }
    }

    // // sort only the order to check
    // vector<int> ord(es.size());
    // iota(ord.begin(), ord.end(), 0);
    // sort(ord.begin(), ord.end(), [&](int i,int j){
    //         return es[i].cost < es[j].cost;
    //         });
    // for (auto i : ord) {
    //     auto &e = es[i];
    //     if (!uf.issame(e.src, e.to)) {
    //         ret += e.cost;
    //         uf.merge(e.src, e.to);
    //     }
    // }

    return ret;
}

double d(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, m; cin >> n >> m;
  vector<double> x(n), y(n);
  
  for(int i=0;i<n;++i) {
    cin >> x[i] >> y[i];
  }

  vector<edge<double>> v;
  double su = 0;
  for(int i=0;i<m;++i) {
    int p, q; cin >> p >> q;
    p--; q--;
    v.push_back(edge<double>({p, q, -d(x[p], y[p], x[q], y[q])}));
    v.push_back(edge<double>({q, p, -d(x[p], y[p], x[q], y[q])}));
    su += d(x[p], y[p], x[q], y[q]);
  }

  double ans = kruskal(v, n);

  cout << su + ans << endl;
}



Measured memory_bytes: 4140
"""
Kをi分割する場合の数＝cmb(K+i-1,i-1)
両端が赤になる場合、両端が青になる場合、左端のみ赤になる場合、右端のみ赤になる場合についてそれぞれ計算すればよい。
"""
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

N,K = map(int,input().split())
for i in range(1,K+1):
    ans = 0
    #Kをi分割する場合の数
    divideK = cmb(K-i+i-1,i-1,p)
    #両端が赤の場合の置き方
    ans += divideK*cmb(N-K-(i+1)+i,i,p)%p
    ans %= p
    #両端が青の場合の置き方
    if i > 1:
        ans += divideK*cmb(N-K-(i-1)+i-2,i-2,p)%p
        ans %= p
    elif N-K == 0:
        ans += 1
    #左端のみが赤になる場合の置き方,右端のみが赤になる場合の置き方
    ans += divideK*cmb(N-K-i+i-1,i-1,p)*2%p
    ans %= p
    print(ans)

Measured memory_bytes: 167936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main {
	public static int partition(card[] A, int p, int r){
        final int x = A[r].num;
         
        int i = p - 1;
        for(int j = p; j < r; j++){
            if(A[j].num <= x){
                i++;
                 
                card tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
            }
        }
         
        card tmp = A[i + 1];
        A[i + 1] = A[r];
        A[r] = tmp;
         
        return i + 1;
    }
     
    public static void quicksort(card[] A, int p, int r){
        if(p < r){
            final int q = partition(A, p, r);
            quicksort(A, p, q - 1);
            quicksort(A, q + 1, r);
        }
    }
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int n=Integer.parseInt(br.readLine());
		card a[]=new card[n];
		for (int i=0;i<n;i++){
			String[] str=br.readLine().split(" ");
			a[i]=new card(str[0],Integer.parseInt(str[1]),i);
		}
		quicksort(a,0,n-1);
		String message="Stable";
		for (int i=0;i<n-1;i++){
			if(a[i].num==a[i+1].num && a[i].index>a[i+1].index){
				message="Not stable";
				break;
			}
		}
		pw.println(message);
		for (int i=0;i<n;i++){pw.println(a[i].suit+" "+a[i].num);};
		pw.close();
	}
}
class card{
	String suit;
	int num,index;
	public card(String s,int n,int i){
		this.suit=s;
		this.num=n;
		this.index=i;
	}
}

Measured memory_bytes: 69896
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return a

N=int(input())
a=list(map(int,input().split()))

l=[0]*N
l[0]=a[0]

for i in range(1,N):
    l[i]=egcd(l[i-1],a[i])

r=[0]*N
r[N-1]=a[N-1]
for i in range(N-2,-1,-1):
    r[i]=egcd(r[i+1],a[i])

ans=0
for i in range(N):
    if i==0: tmp=r[1]
    elif i==N-1: tmp=l[N-2]
    else: tmp=egcd(l[i-1],r[i+1])
    ans=max(tmp,ans)

print(ans)

Measured memory_bytes: 14440
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

int main() {

    string s, t;
    cin >> s >> t;

    vector<int> cnt_s(26, 0);
    vector<int> cnt_t(26, 0);

    for (auto c: s) cnt_s[c - 'a']++;
    for (auto c: t) cnt_t[c - 'a']++;

    for (int i = 0; i < 26; i++) {
        if (cnt_t[i] != 0 && cnt_s[i] == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    map<char, LL> mp;
    for (int i = s.size() - 1; i >= 0; i--) {
        mp[s[i]] = i + s.size();
    }

    vector<map<char, LL>> arr(s.size());
    for (int i = s.size() - 1; i >= 0; i--) {
        arr[i] = mp;
        mp[s[i]] = i;
    }

    LL pos = -1;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == t[0]) {
            pos = i;
            break;
        }
    }

    for (int i = 1; i < t.size(); i++) {
        char c = t[i];
        LL d = pos % s.size();
        pos += arr[d][c] - d;
    }

    cout << pos + 1 << endl;

}
























Measured memory_bytes: 167680
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int no;
    cin>>no;
    char ara[100000];
    cin>>ara;
    if(no>=3200)
    {
        cout<<ara<<endl;
    }
    else
    {
        cout<<"red"<<endl;
    }
   return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]

max_height = A[0]
counter = 0
for i in range(1, N):
    if max_height - A[i] > 0:
        counter += max_height - A[i]
    else:
        max_height = A[i]
print(counter)


Measured memory_bytes: 32188
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]
    }
    let mut a: Vec<usize> = a;
    let mut res = 0;
    for i in 1..n {
        if a[i - 1] > a[i] {
            res += a[i - 1] - a[i];
            a[i] += a[i - 1] - a[i];
        }
    }
    println!("{}", res);
}


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

using namespace std;

typedef long long ll;

int main(int, char**)
{
	ll n, ans = 0;
	cin >> n;

	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}

	double x = n;
	x = floor(sqrt(x));
	ll y = x;
	for (ll i = 1; i <= y; ++i) {
		ll x = (n - i)/i;
		if ((n - i)%i==0 &&  x > i)
			ans += x;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void function(int a, int b, int k, int f){
  if(k == 0){
    if(f == 0)printf("%d %d\n", a, b);
    else printf("%d %d\n", b, a);
    return;
  } else {
    if(a % 2 == 1)a--;
    a /= 2;
    b += a;
    k--;
    function(b, a, k, f);
  }
  
  return;
}

int main()
{
  int a,b,k;
  //cin >> a >> b >> k;
  scanf("%d %d %d", &a, &b, &k);
  int f = k %2;
  function(a, b, k, f);
  
  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0 && s[i] == 'L') ok = false;
    if (i % 2 == 1 && s[i] == 'R') ok = false;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut vec: Vec<usize> = vec![];
    for _ in 0..N {
        vec.push(read());
    }
    use std::collections::HashMap;
    let mut map: HashMap<usize, usize> = HashMap::new();
    for v in vec {
        {
            let entry = map.entry(v - 1).or_insert(0);
            *entry += 1;
        }
        let count = map.remove(&(v - 1)).unwrap();
        map.insert(v, count);
    }
    let mut max = 0;
    for (_i, v) in map {
        max = std::cmp::max(max, v);
    }
    println!("{}", N - max);
}


Measured memory_bytes: 18420
#include <iostream>
#include <string>

int main(void)
{
    int k;
    std::string s;
    std::cin >> k;  // 1 <= k <= 100
    std::cin >> s;

    if (s.length() <= k)
    {
        std::cout << s << std::endl;
    }
    else
    {
        std::cout << s.substr(0, k) << "..." << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int N, M, L;
vector<vector<int>> d;

void WF(){
    
    for(int k=0; k<N; k++){
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    
    
}


int main() {
    cin >> N >> M >> L;
    vector<int> R(L);
    d.resize(N);
    for(int i=0; i<N; i++){
        d[i].resize(N, INF);
        d[i][i] = 0;
    }
    
    for(int &r:R){
        cin >> r;
        r--;
    }
    
    sort(R.begin(), R.end());

    for(int i=0; i<M; i++){
        int a, b, c; cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    
    WF();
    
    int ans = INF;
    do {
        int cur = 0;
        for(int i=0; i<L-1; i++){
            cur += d[R[i]][R[i+1]];
        }
        ans = min(ans, cur);
        
    } while(next_permutation(R.begin(), R.end()));
    
    cout << ans << endl;
    
    return 0;
    
}





Measured memory_bytes: 384
/* Prime Numbers */

#include <stdio.h>
#include <math.h>

int primep(int);

int main(void) {
  int n, x, count = 0, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++) {
    scanf("%d", &x);
    if(primep(x)) count++;
  }

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

  return 0;
}

int primep(int x) {
  int i, m = sqrt(x);

  if(x == 2) return 1;
  if(x < 2 || x%2 == 0) return 0;
  for(i = 3; i <= m; i += 2)
    if(x%i == 0) return 0;
  return 1;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
	int N, Y;
	scanf("%d %d", &N, &Y);
	int c1 = Y / 10000;
	int c2 = Y / 5000;
	int c3 = Y / 1000;
	for (int i = 0; i <= c1; i++) {
		for (int j = 0; j <= c2; j++) {
			for (int k = 0; k <= c3; k++) {
				if (i + k + j == N) {
					int cur = i * 10000 + j * 5000 + k * 1000;
					if (cur == Y) {
						printf("%d %d %d\n", i, j, k);
						return 0;
					}
				}
				else if (i + k + j > N) {
					   break;
				}
			}
		}
	}
	printf(" -1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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 int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out






int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
set<char> right,left;
right.insert('y');
right.insert('u');
right.insert('i');
right.insert('o');
right.insert('p');
right.insert('h');
right.insert('j');
right.insert('k');
right.insert('l');
right.insert('n');
right.insert('m');

while(1){
int ans=0;
string s;

cin >>s;
if(s == "#"){
    break;
}
rep(i,s.size()){
  if(right.find(s[i])!=right.end()){
      s[i] = '%';
    }
  else{
      s[i] = '$';
  }         
}

for(int i=1;i<s.size();i++){
    if(s[i-1]!=s[i]){
        ans ++;
    }
    else{
        ans =ans;
    }
    
}
cout << ans << endl;


}





///////////////////////////////////////////////////////
return 0;}


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


int main(void){
  char n[3]; rep(i,3){
    cin >> n[i];
    if(n[i] == '7'){
      printf("Yes");
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

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

const ll MAX = 1e5;
const ll INF = 1e9;

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

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

  if (b % a == 0) {
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next()
  val ansS = s.inits.toList.tail.find{ t =>
    val l = t.length
    l % 2 == 0 && t.take(l/2) == t.drop(l/2)
  }.get
  println(ansS.length)
}


Measured memory_bytes: 55360
#include<iostream>
#include<cmath>

using namespace std;

int main() {
	int N;
	int v[50] = { 0 };
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> v[i];
	}
	int tmp;
	for (int i = 0;i < N - 1;i++) {
		for (int q = 0;q < N - 1;q++) {
			if (v[q] >= v[q + 1]) {
				tmp = v[q];
				v[q] = v[q + 1];
				v[q + 1] = tmp;
			}
		}
	}
	float ans = v[0];
	for (int i = 1;i < N;i++) {
		ans += v[i] * pow(2, i - 1);
	}
	cout << ans / pow(2, N-1) << endl;
}

Measured memory_bytes: 384
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m : usize,
    }

    if n >= 13{
        println!("{}",m);
    }else if n >= 6{
        println!("{}",m/2);
    }else{
        println!("0");
    }
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const int INF = 1e9+7;

int main(){
    int n,k; cin>>n>>k;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin>>h[i];
    sort(h.begin(),h.end());
    
    for(int i=n-1; i>=0; i--){
        if(k == 0) break;
        h[i] = 0;
        k--;
    }

    ll ans = 0;

    for(int i=0; i<n; i++){
        ans += h[i];
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
  int D;
  cin >> D;
  switch (D) {
    case 25:
      cout << "Christmas" << endl;
      break;
    case 24:
      cout << "Christmas Eve" << endl;
      break;
    case 23:
      cout << "Christmas Eve Eve" << endl;
      break;
    case 22:
      cout << "Christmas Eve Eve Eve" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int MAX = 100000 + 10;
int arr[MAX];
int main(){
  int n;
  scanf("%d", &n);
  for(int i = 1 ; i <= n ; i++){
    scanf("%d", &arr[i]);
  }
  int ans = 0;
  for(int i = 1 ; i <= n ; i++){
    if(i == arr[arr[i]])
      ans++;
  }
  printf("%d\n", ans/2);
  return 0;
}


Measured memory_bytes: 512
n = int(input())
v = [list(map(int, input().split())) for _ in range(n)]

dp = [[0, 0, 0] for _ in range(n + 5)]
for i in range(1, n + 1):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + v[i - 1][0]
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + v[i - 1][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + v[i - 1][2]
print(max(dp[n]))


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

#define ll long long

int main() {
    char b;
    scanf("%c", &b);
    if(b == 'A') {
        cout << "T" << endl;
    }
    if(b == 'T') {
        cout << "A" << endl;
    }
    if(b == 'G') {
        cout << "C" << endl;
    }
    if(b == 'C') {
        cout << "G" << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> ans(n);
    vector<int> a(n);
    ll calc = 0;
    for(int i=0; i<n; i++){
        ll k;
        cin >> k;
        a.at(i) = k;
        if(i%2==0) calc+=k;
        else calc -= k;
    }
    calc /= 2;
    ans.at(0) = calc;
    for(int i=1; i<n; i++){
        ans.at(i) = a.at(i-1) - ans.at(i-1);
    }
    for(int i=0; i<n; i++){
        cout << 2*ans.at(i) << " ";
    }
}


Measured memory_bytes: 3936
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn a() {
    let (a, b) = read!(i32, i32);
    println!("{}", max(0, a - 2 * b));
}

fn b() {
    let n = read!(usize);
    let d: Vec<usize> = read![[usize]];

    let mut ans = 0;
    for i in 0..(n - 1) {
        for j in (i + 1)..n {
            ans += d[i] * d[j];
        }
    }
    println!("{}", ans);
}

fn c() {
    unimplemented!();
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    b();
}


Measured memory_bytes: 4352
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: usize,
        B: usize,
        K: usize,
    }
    for i in A..min(B+1,A+K){
        println!("{}", i);
    }
    for i in max(A+K,B-K+1)..B+1{
        println!("{}", i);
    }
}

Measured memory_bytes: 4352
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);

  foreach (i; 0..n/4+1)
    if ((n-i*4)%7 == 0) {
      writeln("Yes");
      return;
    }

  writeln("No");
}


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

void solve(){
    int n, m;
    cin >> n >> m;
    cout << n * m;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#define inf 1000000000

using namespace std;

int n, m, l, S, t;
int g[305][305];
int p[20], e[20];
int G[20][20];

int dp[1<<17][20];

void WarshallFloyd()
{
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 0; j <= n; j++){
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}
}


int count(int s)
{
	int ret = 0;
	for(;s;s >>= 1) if(s&1) ret++;
	return ret;
}

int main(void)
{
	while(1){
		cin >> n >> m >> l >> S >> t;
		if(n == 0 && m == 0 && l == 0 && S == 0 && t == 0) break;
		
		for(int i = 1; i <= n; i++){
			for(int j = 0; j <= n; j++){
				g[i][j] = inf;
			}
		}
		
		int a, b, c;
		for(int i = 0; i < m; i++){
			cin >> a >> b >> c;
			g[a][b] = g[b][a] = c;
		}
		WarshallFloyd();
		
		p[0] = S, e[0] = 0;
		for(int i = 1; i <= l; i++){
			cin >> p[i] >> e[i];
		}
		
		for(int i = 0; i <= l; i++){
			for(int j = 0; j <= l; j++){
				G[i][j] = g[p[i]][p[j]];
			}
		}
		
		int N = 1 << l;
		for(int s = 0; s < N; s++){
			for(int j = 0; j <= n; j++){
				dp[s][j] = inf;
			}
		}
		dp[0][0] = 0;
		
		int next;
		for(int s = 0; s < N; s++){
			for(int j = 0; j <= l; j++){
				dp[s][0] = min(dp[s][0], dp[s][j] + G[j][0]);
				for(int k = 1; k <= l; k++){
					if(s & (1 << (k-1))) continue;
					next = s | (1 << (k-1));
					dp[next][k] = min(dp[next][k], dp[s][j] + G[j][k] + e[k]);
				}
			}
			
			for(int k = 1; k <= l; k++){
				if(s & (1 << (k-1))) continue;
				next = s | (1 << (k-1));
				dp[next][k] = min(dp[next][k], dp[s][0] + G[0][k] + e[k]);
			}
		}
		
		int ans = 0;
		for(int s = 0; s < N; s++){
			if(dp[s][0] <= t) ans = max(ans, count(s));
		}
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 8568
from itertools import zip_longest
s = input()
gotResult = False
# 2^n通り探索
for i in range(2**(len(s) - 1)):
  n = ['+'] * (len(s) - 1)
  formula = ""
  for j in range(len(s) - 1):
    if (i>>j)&1:
      n[len(s) - 1 - 1 - j] = '-'
  for num,op in zip_longest(s,n):
      formula += num if op == None else num + op
  if eval(formula) == 7:
    print(formula + '=' + str(eval(formula)))
    gotResult = True
    break
  if gotResult:
    break
      

Measured memory_bytes: 3064
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
priority_queue<int> Q;
signed main(void)
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,q;
    reg int ans=0;
    cin>>n>>q;
    for(int i=1;i<=n;++i)
	{
		int x;
		cin>>x;
		Q.push(x);
	}
	for(int i=1;i<=q;++i)
	{
		int u=Q.top();Q.pop();
		Q.push(u>>1);
	}
	while(!Q.empty())
		ans+=Q.top(),Q.pop();
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1400
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑



string ans = "no";
int main() {
	vector<pair<int, int> >v;
	for (int i = 0; i < 6; ++i) {
		int a, b;
		cin >> a >> b;
		if (a > b) { swap(a, b); }
		v.push_back(make_pair(a, b));
	}
	sort(all(v));

	if (v[0] == v[1] && v[2] == v[3] && v[4] == v[5] && v[0].first == v[2].first&&v[2].second == v[4].second&&v[0].second == v[4].first) { ans = "yes"; }
	cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	a.erase(unique(all(a)),a.end());
	int ans=a.size();
	if((n-ans)%2)ans--;
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    int n, k;
    int x[101];
    int tot = 0;
    cin >> n >> k;
    REP(i, n) {
        cin >> x[i];
        tot += min(x[i] * 2, (k-x[i]) * 2);
    }
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

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

H.sort()

ans = float('inf')
for i in range(n):
    if i+k>n:
        break
    tmp = abs(H[i+k-1]-H[i])
    if ans>tmp:
        ans = tmp

print(ans)


Measured memory_bytes: 16724
import java.util.*;

public class Main {
	static public void main(String args[]){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		long aa=1L;
		for(int i=0;i<n;i++){
			long a=sc.nextLong();
			if(Math.log10(a)+Math.log10(aa)>18||
			aa*a>1000000000000000000L){
			   //1000000000000000000L
				aa=-1;
			}
			else if(a==0){
				aa*=0;
			}
			else if(aa!=-1){
				aa*=a;
			}
		}
		System.out.println(aa);
	}
}



Measured memory_bytes: 60256
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for i in range(n)]
ans = 10**10
for i in range(2 ** n):
         tmp = [0] * (m+1)
         price = 0
         for j in range(n):
                  if (( i >> j ) & 1 ) == 1:
                           for k in range(m+1):
                                    tmp[k] += ca[j][k]
         for l in range(1,m+1):
                  if tmp[l] < x:
                           break
         else:
                  if ans > tmp[0]:
                           ans = tmp[0]
if ans == 10**10:
         print(-1)
else:
         print(ans)
                  


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

int main(int argc, char *argv[]){
  int H,W,N;
  cin>>H>>W;
  cin>>N;
  int M[H+1][W+1];
  int A[N+1];
  A[0]=0;
  for(int i=1; i<N+1; i++){
   // cout<<i<<endl;
    int a;
    cin>>a;
    A[i]=a;
  }
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
     	M[i][j]=-1;
    }
   }
  
  bool ret=false;
  int h=1,w=1;
  for(int j=1; j<N+1; j++){
    for(int i=1;i<=A[j]; i++){
      //cout<<w<<" ";
      if(w==0){
	w++;
	h++;
	ret=false;
      }
      if(w<=W){
	if(ret==false){
	  M[h][w]=j;
	  w++;
	}
	else{
	  M[h][w]=j;
	  w--;
	}
      }
      if(ret==false){
	if(w>W){
      w--;
	  M[h][w]=j;
	  h++;
	  ret=true;
	}
      }
    }
  }
  
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
     // cout<<i<<" "<<j<<endl;
        cout<<M[i][j]<<" ";
    }
    cout<<endl;
  }
}


 

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

ll memo[55];
ll sum[55];

ll f(ll n){
  if(n==0) return sum[0]=1;
  if(sum[n]) return sum[n];
  return sum[n]=2*f(n-1)+3;
}

ll dfs(ll n, ll x){
  if(x<=0) return 0;
  if(n==0) return 1;
  if(memo[n]&&sum[n]==x) return memo[n];
  ll ret=dfs(n-1,min(sum[n-1],x-sum[n-1]-2))+(sum[n]/2<x? 1:0)+dfs(n-1,min(sum[n-1],x-1));
  if(sum[n]==x) memo[n]=ret;
  return ret;
}

int main() {
  ll n,x;
  cin>>n>>x;
  f(n);
  cout<<dfs(n,x)<<endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

#define MAX 1000000005
 
typedef long long ll;
typedef pair<int, int> P;

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

    int one = min(k, a);
    int minus = max(0, k-a-b);

    cout << one - minus << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>


int main()
{
    int N,A,B;
    scanf("%d%d%d",&N,&A,&B);
    if(A>B||(N==1&&A!=B))
    {
        printf("0\n");
        return 0;
    }
    printf("%lld\n",(long long )(B-A)*(N-2)+1);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>


using namespace std;
int main()
{
	int A[4], cnt = 0;

	cin >> A[0] >> A[1] >> A[2];

	sort(A, A + 3);


	cnt += A[1] - A[0];
	cnt += A[2] - A[1];

	printf("%d", cnt);

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
//#define gcd __gcd
//#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

//OJ freopen Template
void OJF(const char* inp, const char* out) {
	if (strlen(inp) > 0) freopen(inp, "r", stdin);
	if (strlen(out) > 0) freopen(out, "w", stdout);
}

const int inf = INT_MAX;

signed main()
{
    //OJF("TRAIGLE.inp", "TRIAGLE.out");
	fastio();

	int n; cin >> n;
	int h[n + 1][3];
	int dp[n + 1][3];

	for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> h[i][j];
            dp[i][j] = 0;
        }
	}

	dp[0][0] = h[0][0];
	dp[0][1] = h[0][1];
	dp[0][2] = h[0][2];

	for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + h[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + h[i][1];
        dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + h[i][2];
	}

	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});

}


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

int main() {
  string S1, S2, S3;
  cin >> S1 >> S2 >> S3;

  cout << (char)toupper(S1[0]) << (char)toupper(S2[0]) << (char)toupper(S3[0]) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<map>

using namespace std;

const int MAX_SIZE = 2000001;

class PriorityQueue {
public:
	PriorityQueue() {
		for (int i = 0; i < MAX_SIZE; i++) {
			heap[i] = 0;
		}
		size = 0;
	}
	void insert(int n) {
		size++;
		heap[size] = n;
		
		int s = size;
		while (s > 1) {
			if (heap[s / 2] < heap[s]) {
				swap(heap[s / 2], heap[s]);
			}
			s /= 2;
		}
	}
	int extract() {
		long long res = heap[1];
		heap[1] = heap[size];
		size--;
		maxHeap(1);
		return res;
	}
	void maxHeap(int i) {
		int l = i * 2;
		int r = i * 2 + 1;
		int temp = i;
		if (l <= size && heap[temp] < heap[l]) {
			temp = l;
		}
		if (r <= size && heap[temp] < heap[r]) {
			temp = r;
		}
		if (temp != i) {
			swap(heap[temp], heap[i]);
			maxHeap(temp);
		}
	}

private:
	long long heap[MAX_SIZE];
	int size;
};

int main() {
	PriorityQueue pq;

	while (true) {
		string buf;
		int num;

		cin >> buf;
		if (buf == "end")break;
		else if (buf == "insert") {
			cin >> num;
			pq.insert(num);
		}
		else if (buf == "extract") {
			cout << pq.extract() << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 18816
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
 
using namespace std;
 
 
int main()
{	int n = 0;
 	cin>>n;
    vector<long long> v;
    vector<long long> v2;
 for(int i = 0;i<n;i++){
  int a = 0;
   cin>>a;
   v.push_back(a);
   v2.push_back(a);
 }
    sort(v2.begin(), v2.end());
    
 for(int i = 0;i<v.size();i++){
int sum = 0;
int si = v2.size() - 1;
if(v2[si]== v[i]){
    si--;
}
 cout<<v2[si]<<endl;
 }
}

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

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def bbs(v):
	s = [int(ci) for ci in list(str(v))]
	return sum(s)
	
def main(io):
	n, a, b = map(int, io().split())
	return sum([x for x in range(1,n+1) if a<= bbs(x) and bbs(x) <= b])

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 3404
#include <stdio.h>

int main(){
	int N,X,count=0;
	scanf("%d%d",&N,&X);
	int L[N],d[N];
	for(int i=0;i<N;i++){
		scanf("%d",&L[i]);
	}
	int j,ans;
	d[0]=0;
	for(j=1;j<=N+1;j++){
		d[j]=d[j-1]+L[j-1];
		if(d[j]>X)break;
	}
	/*while(d[j]<=X && count <= N+1){
		j++;
		d[j]=d[j-1]+L[j-1];
		count++;
	}*/
	printf("%d\n",j);
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int k=s.size(),cnt=0;
    rep(i,k){
        if(s[i]=='o')cnt++;
    }
    if(15-k+cnt>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

namespace Test
{
    class ForStudy
    {
        public static void Main(string[] args)
        {
            var list = new List<double>();
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                int[] s = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                double average = 0;
                foreach(int i in s)
                {
                    average += i;
                }
                average /= n;
                double variance = 0;
                foreach(int i in s)
                {
                    variance += Math.Pow(i - average, 2);
                }
                variance /= n;
                list.Add(Math.Sqrt(variance));
            }
            foreach(double i in list)
            {
                Console.WriteLine(i);
            }
            
        }

    }
}


Measured memory_bytes: 18388
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1100000000;
const int H_MAX = 10000;
const int N_MAX = 1000;

int main() {
	int h, n;
	cin >> h >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	int dp[H_MAX+1];
	dp[0] = 0; fill(dp+1, dp+H_MAX+1, INF);
	for (int j = 1; j <= h; j++) {
		for (int i = 0; i < n; i++) {
			dp[j] = min(dp[j], b[i]+dp[max(0, j-a[i])]);
		}
	}
	int ans = dp[h];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int n;
    cin>>n;
    for(int i=1;i<=9;i++)
    {
        if(n<=i*111)
        {
            cout<<i*111<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from collections import *
from heapq import *
from itertools import *
from operator import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    AS = list(map(int, input().split()))
    BS = list(map(int, input().split()))
    CS = list(map(int, input().split()))
    AS.sort()
    BS.sort()
    CS.sort()

    ans = 0
    for b in BS:
        a_idx = bisect_left(AS, b)
        c_idx = bisect_right(CS, b)
        if a_idx == 0 or c_idx == N: continue
        ans += a_idx*(N-c_idx)

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 22976
n,k=map(int,input().split())
if n*(2*k+2*n-1)<=k*n+(5*n**2-n)//2 and k-1<=n//2:
  pair=[[k+i,k+2*n-1-i] for i in range(n)]
  checked=[0]*(n)
  diff=k-1
  cnt=0
  for i in range(n):
    if checked[i]==0 and checked[i+diff]==0:
      checked[i]=1
      checked[i+diff]=1
      pair[i][0],pair[i+diff][0]=pair[i+diff][0],pair[i][0]
      cnt+=1
      if cnt==k-1:
        break
      diff-=2
      if diff<=0:
        diff=k-2
  ans=[]
  cand=set(range(k+2*n,k+3*n))
  checked=[0]*(n)
  for i in range(n):
    a,b=pair[i]
    if a+b!=2*k+2*n-1:
      checked[i]=1
      ans.append([a,b,a+b])
      cand.discard(a+b)
  for i in range(n):
    if checked[i]==0:
      a,b=pair[i]
      ans.append([a,b,cand.pop()])
  for a,b,c in ans:
    print(a,b,c)
else:
  print(-1)

Measured memory_bytes: 40380
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << "=" << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n);
    double p[n + 1]; rep(i, n) in(p[i + 1]);
    double q[n + 1]; rep(i, n) q[i + 1] = 1 - p[i + 1];

    double dp[n + 1][n + 1];
    dp[0][0] = 1; 
    repr(i, 1, n) dp[i][0] = dp[i - 1][0] * q[i];
    rep(i, n) repr(j, i + 1, n) dp[i][j] = 0;

    repr(i, 1, n + 1) {
        repr(j, 1, i + 1) {
            dp[i][j] = q[i]*dp[i - 1][j]
                     + p[i]*dp[i - 1][j - 1];
        }
    }

    double ans = 0;
    repr(j, (n + 1)/2, n + 1) {
        ans += dp[n][j];
    }

    std::cout<<std::setprecision(9);
    out(ans);
}

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

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


Measured memory_bytes: 70656
while True:
    try:
        N = int(input())
        H = list(map(int, input().split()))
        for i in range(len(H)):
            if H[i] > 0 and(i == 0 or H[i] > H[i-1]):
                H[i] -= 1
            if i > 0 and H[i] < H[i-1]:
                print("No")
                break
        else:
            print("Yes")
    except EOFError:
        break

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int dp[250][101];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,d; cin >> d >> n;
	int t[d];
	for(int i=0;i<d;i++){
		cin >> t[i];
	}
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	for(int i=0;i<250;i++){
		for(int j=0;j<101;j++){
			dp[i][j]=-1;
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]<=t[0]&&t[0]<=b[i]){
			dp[0][c[i]]=0;
		}
	}
	for(int i=0;i<d-1;i++){
		for(int j=0;j<101;j++){
			if(dp[i][j]<0)continue;
			for(int k=0;k<n;k++){
				if(a[k]<=t[i+1]&&t[i+1]<=b[k]){
					dp[i+1][c[k]]=max(dp[i+1][c[k]],dp[i][j]+abs(j-c[k]));
				}
			}
		}
	}
	int ma=0;
	for(int i=0;i<101;i++){
		ma=max(dp[d-1][i],ma);
	}
	cout << ma << endl;
}


Measured memory_bytes: 3244
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      boolean b = false;
      char c = '7';
      
      Scanner sc = new Scanner(System.in);
      String n = sc.next();
      for (int i =0; i < n.length(); i++) {
        if (n.charAt(i) == c) {
          b = true;
          break;
        }
      }
      if (b) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
}

Measured memory_bytes: 35668
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
m,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
print((m*3+n)//2)

Measured memory_bytes: 5700
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
int main()
{
    ll h,sum=0;
    cin>>h;
    while(h>0)
    {
        sum=sum*2+1;
        h/=2;
    }
    cout<<sum;
}


Measured memory_bytes: 256