akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;
const ll N = 2e5+9;
const ll m = 1e9 + 7;
// const ll inf= 1e14;
const ll mod =163577857;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }

int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif     
    ll T= 1;
    // cin >> T;
    while(T--){
        ll n,x;cin>>n>>x;
        if(n==2){
            if(x==2){
                cout<<"Yes\n 1\n2\n3\n";
            }
            else{
                cout<<"No\n";
            }
        }
        else if(x == 1 || x == (2*n-1)){
            
                cout<<"No\n";
        }
        else{

            cout<<"Yes\n";
            bool used[2*n];
            ll a[2*n];
            memset(used,0,sizeof(used));
            n--;
            memset(a,0,sizeof(a));
            if(x==2){
                a[n-1] = x+1;
                a[n] = x;
                a[n+1] = x-1;
                a[n+2] = x+2;
                used[x] = 1;used[x+1] = 1;
                used[x-1] = 1;used[x+2] = 1;
            }
            else{

                a[n-1] = x-1;
                a[n] = x;
                a[n+1] = x+1;
                a[n+2] = x-2;
                used[x] = 1;used[x+1] = 1;
                used[x-1] = 1;used[x-2] = 1;

            }
            n++;
            std::vector<ll> un;
            for(int i = 1;i<2*n;i++){
                if(!used[i]){
                    un.pb(i);
                }
            }
            ll in = 0;
            for(int i = 0;i<2*n-1;i++){
                if(a[i] == 0){
                    cout<<un[in]<<'\n';
                    in++;
                }
                else{
                    cout<<a[i]<<'\n';
                }
            }
        }

    }
   
}   

Measured memory_bytes: 7128
from math import ceil

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

a.reverse()

max_tree = [0] * (n+1)
min_tree = [0] * (n+1)

max_tree[0] = a[0]
min_tree[0] = a[0]
for i in range(1, n+1):
    max_tree[i] = max_tree[i-1] + a[i]
    min_tree[i] = ceil(min_tree[i-1]/2) + a[i]

max_tree.reverse()
min_tree.reverse()

if min_tree[0] > 1:
    print(-1)
    exit()

a.reverse()
possible = [0] * (n+1)
possible[0] = 1

for i in range(1, n+1):
    possible[i] = min((possible[i-1]-a[i-1])*2, max_tree[i])

print(sum(possible))


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

int main(){
  string S;
  cin >> S;
  int i = 7;
  if(S == "SUN"){
    cout << i << endl;
  }
  else if(S == "MON"){
    cout << i - 1 << endl;
  }
  
  else if(S == "TUE"){
    cout << i - 2 << endl;
  }
  
  else if(S == "WED"){
    cout << i - 3 << endl;
  }
  
  else if(S == "THU"){
    cout << i - 4 << endl;
  }
  
  else if(S == "FRI"){
    cout << i - 5 << endl;
  }
  
  else {
    cout << i - 6 << endl;
  }
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let w: usize = iterator.next().unwrap().parse().unwrap();
    let h: usize = iterator.next().unwrap().parse().unwrap();
    let x: usize = iterator.next().unwrap().parse().unwrap();
    let y: usize = iterator.next().unwrap().parse().unwrap();

    let area: f64 = w as f64 * h as f64 / 2f64;

    let multi: char = if x * 2 == w && y * 2 == h {
        '1'
    } else {
        '0'
    };

    return format!("{} {}", area, multi);
}


Measured memory_bytes: 4352
use std::cmp::{min,max};
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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::VecDeque;
fn main(){
    input!{
        n:usize,
        s:chars,
        k:usize,
    }
    let t = s[k-1];
    let ans:String = s.iter().map(|&c| {
        if c != t {
            '*'
        } else {
            c
        }
    }).collect();
    println!("{}",ans);
}

Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = [int(x) - 1 for x in readline().split()]
assert len(A) == N


def solve():
    cur = 0
    seen = {0: 0}
    tele = [0]
    loop = []
    loopenter = -1
    while True:
        nxt = A[cur]
        if nxt in seen:
            loopenter = seen[nxt]
            loop = tele[loopenter:]
            break
        seen[nxt] = len(tele)
        tele.append(nxt)
        cur = nxt

    if K < loopenter:
        return tele[K]
    k = (K - loopenter) % len(loop)
    return loop[k]


if __name__ == "__main__":
    print(solve() + 1)


Measured memory_bytes: 40224
#include <iostream>
#include <vector>
#include <algorithm>

class solver
{
public :
	solver(int n, int z, std::vector<int> _v, std::vector<int> _w);
	void solve();

private:
	const int n;
	const int z;
	const std::vector<int> w;
	const std::vector<int> v;
	std::vector<std::vector<int> > dp;
};


solver::solver(int _n, int _z, std::vector<int> _w, std::vector<int> _v) : n(_n), z(_z), w(_w), v(_v) 
{
	dp.resize(n + 1);
	for (int i = 0; i <= n; ++i) dp.at(i).resize(z + 1);
	std::fill(dp.at(n).begin(), dp.at(n).end(), 0);	
}

void solver::solve()
{
	for (int i = n - 1; i >= 0; i--) for (int j = 0; j <= z; j++) {
		if (j < w[i]) dp[i][j] = dp[i + 1][j];
		else dp[i][j] = std::max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]);
	}
	std::cout << dp[0][z] << std::endl;
}

int main()
{
	int n; // ???????????°
	int z; // ???????????¶???????????????
	std::vector<int> v;
	std::vector<int> w;

	std::cin >> n >> z;
		
	v.resize(n);
	w.resize(n);

	for (int i = 0; i < n; ++i)
	{
		//std::cin >> v.at(i) >> w.at(i);
		std::cin >> w.at(i) >> v.at(i);
	}

	solver solver(n, z, v, w);
	solver.solve();


	return 0;
	
}

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

using namespace std;

char s[100];
int n,ans;

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=1;i<=n;++i) ans+=s[i]=='o';
	puts(15-n+ans>7?"YES":"NO");
	
	return 0;
}
			

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)
const int nax=2e5+5;
void solve(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a+b) cout<<min(a,k)<<'\n';
    else cout<<a-(k-(a+b))<<'\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int N; cin >> N;
  long int A[N], num[N] = {0};
  for(int i = 0; i < N; i++){
    cin >> A[i];
    num[A[i] - 1] += 1;
  }
  long int total_ptns = 0;
  for(int i = 0; i < N; i++) total_ptns += num[i] * (num[i] - 1) / 2;
  for(int i = 0; i < N; i++) cout << total_ptns - (num[A[i] - 1] - 1) << endl;
  return 0;
}

Measured memory_bytes: 5760
#include<iostream>

using namespace std;

int main(){
  long long n, a, b, x[100009], ans=0;
  cin >>n >> a >> b;
  for(int i=0;i<n;i++)cin >> x[i];
  for(int i=1;i<n;i++){
    ans += min((x[i]-x[i-1])*a, b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import copy
n = int(input())
x = list(map(int, input().split()))
sort_x = sorted(copy.copy(x))

middle = int(n/2) - 1
next_middle = middle + 1

for i in range(n):
  if x[i] <= sort_x[middle]:
    print(sort_x[next_middle])
  elif x[i] >= sort_x[next_middle]:
    print(sort_x[middle])


Measured memory_bytes: 25732
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll n,k,q,ans;
ll a[Max];
//ll score[Max];
void solve(){
	cin>>n;
	cout<<n*n*n;
}
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> cnt(6);
    vector<double> a{165, 170, 175, 180, 185, 9999};
    for (int i = 0; i < n; ++i) {
        double x;
        cin >> x;
        for (int j = 0; j < 6; ++j) {
            if(x < a[j]){
                cnt[j]++;
                break;
            }
        }
    }
    for (int i = 0; i < 6; ++i) {
        cout << i+1 << ":" << string(cnt[i], '*') << "\n";
    }
    return 0;
}


Measured memory_bytes: 3116
import numpy as np
N = int(input())
P = list(map(float, input().split()))
dp = np.zeros((N+1,N+1),dtype=float)
dp[0,0] = 1

for i in range(N):
    dp[i+1] += dp[i] * (1-P[i])
    dp[i+1][1:] += dp[i][:-1] * P[i]
print(sum(dp[N, N//2+1:]))

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

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

int main() {
    string w; cin >> w;
    sort(w.begin(),w.end());
    int cnt = 1;
    rep(i,w.size()){
        if(w[i] == w[i+1]){
            cnt++;
        }else{
            if(cnt % 2 != 0){
                cout << "No" << endl;
                return 0;
            }
            cnt = 1;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
use std::collections::HashSet;
use std::borrow::Borrow;
use std::ops::IndexMut;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let v: Vec<String> = read_vec();
    let a: &str = v[0].as_str();
    let b: &str = v[1].as_str();

    if a == "H" {
        if b == "H" {
            println!("H")
        } else {
            println!("D")
        }
    } else {
        if b == "H" {
            println!("D")
        } else {
            println!("H")
        }
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

    ll a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
}



Measured memory_bytes: 3124
#include <stdio.h>
#include <limits.h>

int cnt = 0;

void merge(int *A, int left, int mid, int right) {
  int n1, n2, L[500000], R[500000], i, j, k;
  n1 = mid - left;
  n2 = right - mid;
  for (i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = INT_MAX;
  i = j = 0;
  for (k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
    cnt++;
  }
}

void mergeSort(int *A, int left, int right) {
  int mid;
  if (left + 1 < right) {
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  int n, A[500000],i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  mergeSort(A, 0, n);
  for (i = 0; i < n; i++) {
    printf("%d", A[i]);
    if (i != n - 1) {
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 5624
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

template <typename T>
struct service {
  int side;
  vector<T> dat;
  vector<T> init;
  service(int n, T x): side(csqrt(n)), dat(side * side, x), init(side, x) {
  }
  void discard_init(int alpha) {
    if (init[alpha] < 0) { return; }
    for (int i = alpha * side; i < (alpha + 1) * side; ++i) {
      dat[i] = init[alpha];
    }
    init[alpha] = -1;
  }
  void update(int s, int t, T x) {
    discard_init(s / side);
    discard_init(t / side);
    int i = s;
    while (i < t && i % side != 0) {
      dat[i] = x;
      ++i;
    }
    while (i + side <= t) {
      init[i / side] = x;
      i += side;
    }
    while (i <= t) {
      dat[i] = x;
      ++i;
    }
  }
  T find(int i) {
    if (init[i / side] >= 0) {
      return init[i / side];
    } else {
      return dat[i];
    }
  }

  static int csqrt(int n) {
    int k = 1;
    while (k * k < n) { ++k; }
    return k;
  }
};

int main() {

  int N, Q;
  cin >> N >> Q;
  service<lli> srv(N+10, (1LL<<31)-1);
  REP(query, Q) {
    int T; cin >> T;
    // cerr << stringify(srv.dat, srv.init, srv.side) << endl;
    if (T == 0) {
      lli S, T, X; cin >> S >> T >> X;
      // cerr << "query: update " << stringify(S, T, X) << endl;
      srv.update(S, T, X);
    } else {
      int I; cin >> I;
      // cerr << "query: find " << I << endl;
      // cerr << "answer: " << srv.find(I) << endl;
      cout << srv.find(I) << endl;
    }
  }
  return 0;
}



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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    while(A > 0 && C > 0)
    {
        C -= B;
        if(C <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  if ((A + B) < (C + D)) {
    cout << "Right"  << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
int h[100005];
vector<int> g[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;
  REP(i, n) cin >> h[i];

  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int count = 0;
  REP(i, n) {
    int t = h[i];
    bool f = true;
    REP(j, g[i].size()) {
      if(t <= h[g[i][j]]) {
        f = false;
        break;
      }
    }
    if(f) count++;
  }

  cout << count << endl;
}


Measured memory_bytes: 9128
open Scanf
open Printf
       
let id x = x
let tuple x y = (x, y)
             
let calc_rh a h w r c =
  let bh = 10007 in
  let bv = 999983 in
  let rec pow x n =
    if n = 0 then 1
    else if n mod 2 = 0 then let y = pow x (n / 2) in y * y
    else x * pow x (n-1) in
  let rh a b i j =
    let rec iter r k =
      if k = j then r
      else iter (r * b + a.(k)) (k+1) in
    iter 0 i
  in
  let bh' = pow bh c in
  let ta = Array.make_matrix h (w - c + 1) 0 in
  let rec set_ta i j =
    if i = h then ()
    else if j = w - c + 1 then set_ta (i+1) 0
    else begin
        if j = 0 then ta.(i).(j) <- rh a.(i) bh 0 c
        else ta.(i).(j) <- ta.(i).(j-1) * bh + a.(i).(j+c-1) - a.(i).(j-1) * bh';
        set_ta i (j+1)
      end
  in
  let bv' = pow bv r in
  let rht = Array.make_matrix (h - r + 1) (w - c + 1) 0 in
  let rec set_rht i j =
    if j = w - c + 1 then ()
    else if i = h - r + 1 then set_rht 0 (j+1)
    else begin
        if i = 0 then rht.(i).(j) <- rh (Array.init r (fun k -> ta.(k).(j))) bv 0 r
        else rht.(i).(j) <- rht.(i-1).(j) * bv + ta.(i+r-1).(j) - ta.(i-1).(j) * bv';
        set_rht (i+1) j
      end
  in
  set_ta 0 0;
  set_rht 0 0;
  rht
    
let () =
  let h, w = scanf "%d %d " tuple in
  let fld = Array.init h (fun _ ->
                          let s = scanf "%s " id in
                          Array.init w (fun i -> 
                                        Char.code s.[i]
                                     )
                         ) in
  let r, c = scanf "%d %d " tuple in
  let ptn = Array.init r (fun _ ->
                          let s = scanf "%s " id in
                          Array.init c (fun i -> 
                                        Char.code s.[i]
                                       )
                         ) in
  let ft = calc_rh fld h w r c in
  let pt = calc_rh ptn r c r c in
  let rec loop i j =
    if i = h - r + 1 then ()
    else if j = w - c + 1 then loop (i+1) 0
    else begin
        if ft.(i).(j) = pt.(0).(0) then printf "%d %d\n" i j;
        loop i (j+1)
      end
  in
  loop 0 0

Measured memory_bytes: 28396
6# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,M,Q=map(int,input().split())
    x=[[0]*N for _ in range(N)]
    for i in range(M):
        L,R=map(lambda x: int(x)-1,input().split())
        x[L][R]+=1
    S=[[0]*(N+1) for _ in range(N+1)]
    for i in range(N):
        for j in range(N):
            S[i+1][j+1]=S[i+1][j]+S[i][j+1]-S[i][j]+x[i][j]
    for _ in range(Q):
        p,q=map(lambda x: int(x)-1,input().split())
        print(S[q+1][q+1]-S[q+1][p]-S[p][q+1]+S[p][p])

if __name__ == '__main__':
    main()


Measured memory_bytes: 58332
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)




#ifdef _MSC_VER
#include <intrin.h>

#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>


#include"atcoder/all"
using namespace atcoder;
using namespace std;


#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << endl
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;



void solve() {
	int N, M; cin >> N >> M;
	vector<int>A(N), B(M);
	REP(i, N)cin >> A[i];
	REP(i, M)cin >> B[i];
	vector<int>C = convolution(A, B);
	print_space(C);
}



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

	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 27240
package main

import (
	"fmt"
)

var h, w int
var ss [][]byte

func main() {
	fmt.Scan(&h, &w)

	ss = make([][]byte, h)
	for i := range ss {
		fmt.Scan(&ss[i])
	}

	m := -1
	for s := 0; s < h; s++ {
		for t := 0; t < w; t++ {
			if ss[s][t] != '.' {
				continue
			}
			cs := calc(s, t)
			for i := range cs {
				for j := range cs[i] {
					if cs[i][j] > m {
						m = cs[i][j]
					}
				}
			}
		}
	}
	fmt.Println(m)
}

func calc(y, x int) [][]int {
	cnts := make([][]int, h)
	for i := range cnts {
		cnts[i] = make([]int, w)
		for j := range cnts[i] {
			cnts[i][j] = -1
		}
	}

	qs := make([][]int, 0)
	qs = append(qs, []int{y, x})
	cnts[y][x] = 0
	for len(qs) > 0 {
		q := qs[0]
		cy, cx := q[0], q[1]
		for _, d := range [][]int{{1, 0}, {-1, 0}, {0, 1}, {0, -1}} {
			ny, nx := cy+d[0], cx+d[1]
			if ny >= 0 && ny < h && nx >= 0 && nx < w && ss[ny][nx] == '.' && cnts[ny][nx] == -1 {
				cnts[ny][nx] = cnts[cy][cx] + 1
				qs = append(qs, []int{ny, nx})
			}
		}
		qs = qs[1:]
	}
	return cnts
}


Measured memory_bytes: 5504
n = int(input())
S = list(map(int, input().split(" ")))
n = int(input())
T = list(map(int, input().split(" ")))
def divide(A,a):
    left = 0
    right = len(A)
    
    while left < right:
        mid = (left + right)//2
        if a < A[mid]:
            right = mid
        elif A[mid] < a:
            left = mid + 1
        else:
            return True
    return False
cnt = 0
for t in T:
    if t < S[0] or S[-1] < t:
        continue
    if divide(S,t):
        cnt += 1
print(cnt)



Measured memory_bytes: 16708
n,m=map(int,input().split())
l=sorted(map(int,input().split()),reverse=True)
sum_1=sum(l)
miman=1/(4*m)
#print(m,n,l,sum_1,miman)
bl=True
for i in range(m):
    if l[i]/sum_1<miman:
        bl=False
        print("No")
        break
if bl :print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<list>
#include<string>
#include<cstring>
#include<set>
#include<vector>
#define ll long long
#define memset(a,n) memset(a,n,sizeof(a))
#define mp make_pair
#define pb push_back
using namespace std;
const int maxn = 1e5 + 100;

vector<int> q[maxn];
int a[maxn];

int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i = 1 ;i <= n;i++) scanf("%d",&a[i]);
    for(int i = 0; i < m;i++){
        int x,y;scanf("%d%d",&x,&y);
        q[x].push_back(y);
        q[y].push_back(x);
    }
    int ans = 0;
    for(int i = 1;i <= n;i++){
        int cur = a[i];
        if(q[i].empty()) {
            ans++;continue;
        }
        int ok = 1;
        for(int j : q[i]) {
            if(cur <= a[j]) {
                ok = -1;break;
            }
        }
        if(ok == 1) ans++;
    }
    printf("%d\n",ans);
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    char c;
    cin >> c;
    c++;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,k,a[3000000],b[3000000],ans=0,zero=0;
main() {
	cin>>n>>k;++k;
	for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]);
	for(int i=30;i>=0;i--) {
		if(k>>i&1) {
			zero^=(1<<i);
			int res=0;
			for(int i=1;i<=n;i++) {
				if(!(a[i]&zero)) {
					res+=b[i];
				}
			}
			ans=max(ans,res);
		}
		zero^=(1<<i);
	}
	cout<<ans<<"\n";
}

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

using namespace std;

int main(void)
{
  int N; cin >> N;
  vector<int> a(3*N);
  for(int i = 0; i < 3*N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int count = 0;
  long long ans = 0;
  for(int i = 3*N-2; i >= 0; i-= 2)
  {
    count++;
    ans += a[i];
    if(count == N) break;
  }
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;

int main() {

    int n;
    cin >> n;
    ll a[n];
    long long dp[n][n];

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

    for(int l = n - 1; l >= 0; --l) {

        for(int r = l; r < n; ++r) {

            if(l == r)
                dp[l][r] = a[r];
            else
                dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
            // for(int i = 0; i < n; ++i) {
            //     for(int j = 0; j < n; ++j) {
            //         cout << dp[i][j] << " ";
            //     }
            //     cout << endl;
            // }
        }
    }

    cout << dp[0][n-1];

    return 0;
}

Measured memory_bytes: 70528
#include<iostream>
#include<map>
using namespace std;
int main(){
	int n,x;
	while(cin>>n,n){
		map<int,int> mp;
		for(int i=0;i<n;i++){
			cin>>x;
			mp[x]++;
		}
		for(int i=0;i<10;i++){
			if(mp[i]==0)
			cout<<'-'<<endl;
			else{
				for(int j=0;j<mp[i];j++)
				cout<<'*';
				cout<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.math.BigDecimal;
//import java.lang.reflect.Array;
//import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String line = br.readLine();
			do {
				String[] in = line.split(" ", 0);
				//???????????????????¨????
				double x = ( Double.parseDouble(in[4]) * Double.parseDouble(in[2]) - Double.parseDouble(in[1]) * Double.parseDouble(in[5])) / ( Double.parseDouble(in[4]) * Integer.decode(in[0]) - Double.parseDouble(in[1]) * Double.parseDouble(in[3]) );
				double y = ( Double.parseDouble(in[3]) * Double.parseDouble(in[2]) - Double.parseDouble(in[0]) * Double.parseDouble(in[5])) / ( Double.parseDouble(in[3]) * Integer.decode(in[1]) - Double.parseDouble(in[0]) * Double.parseDouble(in[4]) );
				BigDecimal out1 = ( new BigDecimal(x) ).setScale(3, BigDecimal.ROUND_DOWN);
				BigDecimal out2 = ( new BigDecimal(y) ).setScale(3, BigDecimal.ROUND_DOWN);
				System.out.println(out1 + " " + out2);
				//???????????§??????
				line = br.readLine();
			} while (line != null);

		} catch (Exception e) {
			// TODO: handle exception
			System.exit(0);
		}

	}

}

Measured memory_bytes: 24604
import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    bit = [0] * (N+1)

    def add(x, a):
        while x <= N:
            bit[x] += a
            x += x & -x

    def sum(x):
        ret = 0
        while x != 0:
            ret += bit[x]
            x -= x & -x
        return ret

    c = list(map(int, input().split()))
    lr = [None] * Q
    for i in range(Q):
        l, r = map(int, input().split())
        lr[i] = (i, l, r)
    lr.sort(key=lambda x: x[2])
    ans = [None] * Q
    last_idx = [-1] * (N+1)
    j = 0
    for i, l, r in lr:
        while j < r:
            if last_idx[c[j]] == -1:
                last_idx[c[j]] = j
            else:
                add(last_idx[c[j]]+1, -1)
                last_idx[c[j]] = j
            add(j+1, 1)
            j += 1
        ans[i] = sum(r) - sum(l-1)
    for a in ans:
        print(a)
            
if __name__ == "__main__":
    main()

Measured memory_bytes: 175736
package main

import "fmt"

func main() {
  var x int
  fmt.Scan(&x)
  // (1 + 2 + ... + n) >= x
  // n^2 + n >= x*2 を満たす最大の整数値 n
  for n := 0; n <= x; n++ {
    if n * (n+1) >= 2*x {
      fmt.Println(n);
      return
    }
  }
}

Measured memory_bytes: 512
def norm(m, n)
  m**2 + n**2
end

def isGaussPrime(real, imaginary)
  real, imaginary = real.abs, imaginary.abs
  if real == 0
    return imaginary&3 == 3 && isPrime(imaginary)
  end
  if imaginary == 0
    return real&3 == 3 && isPrime(real)
  end
  isPrime(norm(real, imaginary))
end

def isPrime(n)
  return n == 2 if n&1 == 0
  for i in 3...n do
    return false if n % i == 0
  end
  n != 1
end

gets.to_i.times do
  m, n = gets.split.map(&:to_i)
  puts isGaussPrime(m, n) ? "P" : "C"
end

Measured memory_bytes: 6112
#include <bits/stdc++.h>
using namespace std;
const int MAX = 400400;
const int MOD = 1e9+7;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

struct Combination {
    vector<ModInt<MOD>> fact;
    Combination(int n) : fact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i-1] * i);
        }
    }
    ModInt<MOD> operator() (int n, int r) {
        if (r < 0 || r > n) return 0;
        return fact[n]/(fact[n-r]*fact[r]);
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    Combination com(MAX);

    ModInt<MOD> ans = 0;
    for (int i = 0; i <= min(n-1, k); i++) {
        ans += (com(n, i) * com(n-1, i));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()

//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;

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

const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}

int n;
vector<P> red, blue;

bool compare_red(const P &lhs, const P &rhs)
{
    //if(lhs.fi > rhs.fi && lhs.se > rhs.se) return true;
    //if(lhs.fi == rhs.fi && lhs.se > rhs.se) return true;
    //return false;
    if(lhs.se > rhs.se) return true;
    return false;
}

bool compare_blue(const P &lhs, const P &rhs)
{
    //if(lhs.fi < rhs.fi && lhs.se < rhs.se) return true;
    //if(lhs.fi == rhs.fi && lhs.se < rhs.se) return true;
    //return false;
    if(lhs.fi < rhs.fi) return true;
    return false;
}

void init()
{
}

void solve()
{
    int ans = 0;
    sort(red.begin(), red.end(), compare_red);
    sort(blue.begin(), blue.end(), compare_blue);
    REP(i, n){
        P &cur_b = blue[i];
        //int diff = -1;
        //int pos = -1;
        REP(j, red.size()){
            if(red[j].fi < cur_b.fi && red[j].se < cur_b.se){
                ////int diff_cur = cur_b.fi - red[j].fi + cur_b.se - red[j].se;
                //int diff_cur = max(cur_b.fi - red[j].fi, cur_b.se - red[j].se);
                //if(diff == -1 || diff > diff_cur){
                //    diff = diff_cur;
                //    pos = j;
                //}
                ans++;
                red.erase(red.begin() + j);
                break;
            }
        }
        //if(pos != -1){
        //    ans++;
        //    red.erase(red.begin() + pos);
        //}
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n){
        int a, b;
        cin >> a >> b;
        red.pb(mp(a, b));
    }
    REP(i, n){
        int a, b;
        cin >> a >> b;
        blue.pb(mp(a, b));
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
while True:
    l = input().split()
    op =l[1]
    if op == "?":
        break
    a,b = int(l[0]),int(l[2])
    
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    else:
        print(a//b)


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n[3];
    string res;
    cin >> n[0] >> n[1] >> n[2];
    sort(n, n+3);
    if(n[0] == 5 && n[1] == 5 && n[2] == 7) res = "YES";
    else res = "NO";
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n,min,max,i,x;
    long sum = 0;
    min = 1000000;
    max = -1000000;
    cin >> n;
    for(i = 0;i < n;i++){
        cin >> x;
        sum += x;
        if(x > max) max = x;
        if(x < min) min = x;
    }
    cout << min << " " << max << " " << sum <<endl;
    return 0;
}

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

void solve()
{
    int n;
    cin >> n;
    char c[200005];
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    int op = 0;
    int l = 0, r = n - 1;
    while (l < r) {
        for (; c[l] != 'W' && l < r; ++l) {}
        for (; c[r] != 'R' && l < r; --r) {}
        if (l >= r) {
            break;
        }
        ++op;
        ++l;
        --r;
    }
    cout << op << endl;
}

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

    /* int T; */
    /* cin >> T; */
    /* for (int t = 0; t < T; ++t) { */
        solve();
    /* } */
    return 0;
}


Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] h = new int[100000];
		int[] w = new int[100000];
		int[] t = new int[100000];
		int n = 0;
		int a =1;
		int k=0;
		suuzi[] p =new suuzi[150*150];
		int q =0;
		int g=0;
		suuzi r ;
		suuzi b = new suuzi();
		for(int i=0;i<100000;i++){
			h[i]=sc.nextInt();
			w[i]=sc.nextInt();
			t[i]=h[i]*h[i]+w[i]*w[i];
			if(h[i]==0&&w[i]==0){
				n=i;
				break;
			}

		}
		for(int l=1;l<=150;l++){
			for(k=l+1;k<=150;k++){
				suuzi m = new suuzi();
				m.x=l;
				m.y=k;
				m.z=l*l+k*k;
				p[q]=m;
				q=q+1;
			}
		}
		q=q-1;
	   while(a==1){
		   a=0;
		   for(int i=0;i<q;i++){
			   if(p[i].z>p[i+1].z){
				   r=p[i];
				   p[i]=p[i+1];
				   p[i+1]=r;
				   a=1;
			   }
			   if(p[q].z==p[i+1].z&&p[i].x>p[i+1].x){
				   r=p[i];
				   p[i]=p[i+1];
				   p[i+1]=r;
				   a=1;
			   }
				   
		   }
	   }

		while(g<n-1){
			b.x =h[g];
			b.y =w[g];
			g=g+1;
				for(int l=0;l<q;l++){
					if(b.x==p[l].x&&b.y==p[l].y){
						System.out.println(p[l+1].x+" "+p[l+1].y);
						
		}
		
	}
				while(g==n-1){
					b.x =h[g];
					b.y =w[g];
					g=g+1;
						for(int l=0;l<q;l++){
							if(b.x==p[l].x&&b.y==p[l].y){
								System.out.println(p[l+1].x+" "+p[l+1].y);
								
				}
				
			}
				}

}
	}
}
class suuzi{
	int x;int y;int z;
}

Measured memory_bytes: 24192
#include <stdio.h>
int main(){
    int a[200],b[200],c[200],i;
    int don = 0;
    int ei = 0;
    int tyo = 0;

    for(i=0;i < 200;i++){
       scanf("%d %d %d",&a[i],&b[i],&c[i]);
       if(a[i] >= b[i] + c[i]){
           break; 
       } else if (b[i] >= a[i] + c[i]){
           break;
       } else if (c[i] >= a[i] + b[i]){
           break;
       }

       if(a[i]*a[i] == b[i]*b[i] + c[i]*c[i]){
           tyo = tyo + 1;
           continue;
       } else if (b[i]*b[i] == a[i]*a[i] + c[i]*c[i]){
           tyo = tyo + 1;
           continue;
       } else if (c[i]*c[i] == b[i]*b[i] + a[i]*a[i]){
           tyo = tyo + 1;
           continue;
       }

       if(a[i]*a[i] > b[i]*b[i] + c[i]*c[i]){
           don = don + 1; 
           continue;
       } else if (b[i]*b[i] > a[i]*a[i] + c[i]*c[i]){
           don = don + 1;
           continue;
       } else if (c[i]*c[i] > b[i]*b[i] + a[i]*a[i]){
           don = don + 1;
           continue;
       }

       if(a[i]*a[i] < b[i]*b[i] + c[i]*c[i]){
           ei = ei + 1;
       } else if (b[i]*b[i] < a[i]*a[i] + c[i]*c[i]){
           ei = ei + 1;
       } else if (c[i]*c[i] < b[i]*b[i] + a[i]*a[i]){
           ei = ei + 1;
       }
    
    }

    printf("%d %d %d %d\n",don+tyo+ei,tyo,ei,don);
    return 0;
}


Measured memory_bytes: 2048
import numpy as np

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

ans = []
for i, e in enumerate(a, 1):
    ans += [i] * e

ans = np.array(ans, dtype=np.int16)
ans = ans.reshape((h, w))

ans[1::2, :] = ans[1::2, ::-1]

for ar in ans:
    print(*ar)


Measured memory_bytes: 13240
import math
def gcd(x,y):
    if y == 0:
        return x
    return gcd(y,x%y)
def lcm(x,y):
    return x*y//gcd(x,y)
N = int(input())
if N == 1:
    print(int(input()))
else:
    ans = int(input())
    for i in range(N-1):
        J = int(input())
        ans = lcm(ans,J)
    print(ans)

Measured memory_bytes: 9192
// <------------- Template -----------------------> //

/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
*/

#pragma optimization_level 3   									//Comment optimisations for an interatcive problem - use endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x,m,a,y,b,k,c;
string s;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>k>>n;
	vll a(n);
	for(ll i=0;i<n;i++) cin>>a[i];

	ll ans =a[n-1]-a[0] ;
	for(ll i=1;i<n;i++) {
		ans = min(ans,a[i-1] + k - a[i]);
	}
	cout<<ans;
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 236544
import numpy as np

n = int(input())
a = [int(i) for i in input().split()] 
a = np.array(a)
x = np.zeros(n)

x[0] = sum(a) - (2*(sum(a[1::2])))

for i in range(n-1):
    x[i+1] = 2*a[i] - x[i]

print(' '.join(map(str, map(int, x))))


Measured memory_bytes: 23088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;


int main(void) {
  string s,t;
  cin >> s >> t;
  int cnt = 0;
  vi kouho;
  rep(i,s.size()-t.size()+1){
    bool flag = true;
    rep(j,t.size()){
      if(s[i+j] == '?' || s[i+j]==t[j])continue;
      flag = false;
      break;
    }
    if(flag) kouho.push_back(i);
  }
  string ans = "";
  if(kouho.size()){
    vs dash;
    for(auto k: kouho){
      
      string p = s;
      p.replace(k,t.size(),t);
      rep(i,p.size()){
        if(p[i]=='?')p[i] = 'a';
      }
      dash.push_back(p);
    }
    sort(ALL(dash));
    cout << dash[0] << endl;
  }
  else cout << "UNRESTORABLE" << endl;
}






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

int G[5]={};

int main()
{
    int a,b;

    for(int i = 0;i < 3;i++){
        cin >> a >> b;

        G[a-1]++;
        G[b-1]++;
    }

    for(int i = 0;i < 4;i++){
        if(G[i] >= 3){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int ans = 1;
  int max = 0;
  for (int i=1; i<n+1; i++){
    int times = 0;
    int m = i;
    while (m%2 == 0){
      m = m/2;
      times ++;
    }
    if (times > max){
      max = times;
      ans = i;
    }
  }
  cout << ans << endl;
}   

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		List<TreeSet<Key>> list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new TreeSet<>());
		}
		Key[] arr = new Key[m];
		for (int i = 0; i < arr.length; i++) {
			Key k = new Key();
			sa = br.readLine().split(" ");
			k.a = Integer.parseInt(sa[0]);
			k.b = Integer.parseInt(sa[1]);
			sa = br.readLine().split(" ");
			for (int j = 0; j < sa.length; j++) {
				int o = Integer.parseInt(sa[j]) - 1;
				o = 1 << o;
				k.c |= o;
			}
			arr[i] = k;
		}
		br.close();

		int n2 = 1 << n;
		int[] dp = new int[n2];
		Arrays.fill(dp, 100000000);
		dp[0] = 0;
		for (int i = 0; i < n2; i++) {
			for (int j = 0; j < m; j++) {
				int k = arr[j].c | i;
				dp[k] = Math.min(dp[k], dp[i] + arr[j].a);
			}
		}
		if (dp[n2 - 1] == 100000000) {
			System.out.println(-1);
		} else {
			System.out.println(dp[n2 - 1]);
		}
	}

	static class Key {
		int a, b, c;
	}
}


Measured memory_bytes: 24532