akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int a, b;

inline int max(int a, int b){
	return a > b ? a : b;
}

int main(){

	scanf("%d%d", &a, &b);
	printf("%d\n", max(a + b, max(a - b, a * b)));

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n,u,v;cin>>n>>u>>v;u--;v--;
    vector<vector<int>>t(n);
    rep(i,n-1){
        int a,b;cin>>a>>b;a--;b--;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    vector<int> s(n,-1),w(n,-1);//青木君が最短で来るときの移動回数
    queue<int> que;
    que.push(v);
    s[v]=0;
    while(que.size()){
        int x=que.front();que.pop();
        rep(i,t[x].size()){
            int y=t[x][i];
            if(s[y]==-1){
                que.push(y);
                s[y]=s[x]+1;
            }
        }
    }
    int res=0;
    que.push(u);
    w[u]=0;
    while(que.size()){
        int x=que.front();que.pop();
        rep(i,t[x].size()){
            int y=t[x][i];
            if(w[y]==-1){
                que.push(y);
                w[y]=w[x]+1;
            }
        }
    }
    rep(i,n){
        if(s[i]>w[i]){
            if(s[u]%2==0&&s[u]>2)chmax(res,s[i]-1);
            else chmax(res,s[i]-1);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 6656
from collections import deque

def main():
    import sys
    input = sys.stdin.readline

    S = input()
    T = input()

    len_S = len(S)-1
    len_T = len(T)-1
    # print(len_S)
    # print(len_T)
    # print(S)
    # print(T)
    ans = 0
    for i in range(len_S - len_T +1):
        cnt = len_T
        for j in range(len_T):
            # print("i:{} j:{}".format(i,j))
            # print(S[i+j])
            # print(T[j])
            if(S[i+j] != T[j]):
                cnt -= 1
        # print(cnt)
        # print(ans)
        ans = max(ans, cnt)
    print(len_T-ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9260
#include <bits/stdc++.h>
 
using namespace std;
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ll long long
#define ull unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define SORT(ary) sort(begin(ary), end(ary))
#define VL vector<ll>
#define VVL vector<VL>
#define PL pair<ll, ll>
#define VC vector<char>
#define VVC vector<VC>

void solve() {
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    VVL dp(n+1, VL(pow(2, x+y+z+1), 0));
    ll mask = pow(2, x+y+z+1)-1;
    ll except = ((((1 << x) + 1) << y) + 1) << (z-1);
    dp[0][0] = 1;
    REP(i, n) {
        REP(j, pow(2, x+y+z+1)) {
            REP(k, 10) {
                ll key = (((j << 1) + 1) << k) & mask;
                if((key & except) != except) {
                    dp[i+1][key] += dp[i][j];
                    dp[i+1][key] %= MOD;
                }
            }
        }
    }
    ll ans = 1;
    REP(i, n) {
        ans = (ans * 10) % MOD;
    }
    ll ex  = 0;
    REP(i, pow(2, x+y+z+1)) {
        ex += dp[n][i];
        ex %= MOD;
    }
    cout << (ans-ex+MOD)%MOD << "\n";
}

int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 86400
#include <bits/stdc++.h>
using namespace std;
#define X 3

const long long INF = 1LL << 30;

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> w(N), v(N);
  for(int n=0; n<N; n++){
    cin >> w[n] >> v[n];
  }
  
  vector<vector<long long int>> dp(N+1, vector<long long int>(M+1));
  
  for(int n=0; n<N; n++){
  	for(int m=0; m<M; m++){
      dp[n][m] = 0;
    }
  }

  for(int n=0; n<N; ++n){
  	for(int m=0; m<=M; ++m){
      dp[n+1][m] = max(dp[n+1][m], dp[n][m]);
      if(m-w[n] >= 0) dp[n+1][m] = max(dp[n+1][m], dp[n][m-w[n]] + v[n]);
    }
  }

  cout << dp[N][M] << endl;
}

Measured memory_bytes: 80256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, k] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const getPow = num => {
  let c = 0
  let t = num
  while (1) {
    if (t >= k) {
      return c
    }
    t *= 2
    c++
  }
}

const ans = _ => {
  let ans = ''

  let sum = 0
  for (let i = 1; i <= n; i++) {
    const res = (1 / n) * Math.pow(1 / 2, getPow(i))
    sum += res
  }
  return sum
}

console.log(ans())


Measured memory_bytes: 7628
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;



int main() {
  string S;
  cin >> S;
  int n=0;
  for(auto i : S){
    n++;
  }

  
  for(int i=0; i<n; i++){
    for(int j=i; j<=n; j++){
      string s;
      for(int k=0; k<i; k++){
	s.push_back(S[k]);
      }
      for(int k=j; k<n; k++){
        s.push_back(S[k]);
      }
      if(s == "keyence"){
	cout << "YES" << endl;
	return 0;
      }
    }
  }
  
  cout << "NO" << endl;


  return 0;
   

}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
typedef pair<ll, ll> P;
//const ll INF=1LL<<60;

const int INF=100000;
int c[11][11];
int main() {
  int h,w;
	cin>>h>>w;
	rep(i,10)rep(j,10){
    int x;
    cin>>x;
    c[i][j]=x;
  }
  rep(k,10)rep(i,10)rep(j,10){
    chmin(c[i][j],c[i][k]+c[k][j]);
  }
  ll kotae=0;
  rep(i,h)rep(j,w){
    int start;
		cin>>start;
    if(start!=-1&&start!=1)kotae+=c[start][1];
	}
  cout<<kotae<<endl;
  return 0;
}
  

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i*j == n) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}




Measured memory_bytes: 256
from collections import Counter
import sys


sys.setrecursionlimit(10 ** 6)


def dfs(x):
    res = True
    for e in edge[x]:
        if color[e] is None:
            color[e] = 0 if color[x] else 1
            res &= dfs(e)
        else:
            if color[e] == color[x]:
                res &= False
            else:
                res &= True
    return res


N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    edge[A].append(B)
    edge[B].append(A)

color = [None] * N
color[0] = 0
isBin = dfs(0)

if isBin:
    C = Counter(color)
    print(C[0] * C[1] - M)
else:
    print(N * (N - 1) // 2 - M)


Measured memory_bytes: 44156
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

signed main() {
	IOS();
	ll n;
	cin >> n;
	ll c = n % 2 == 1 ? n : n + 1;
	vector<P> ans;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (i + j != c) {
				ans.push_back(P(i, j));
			}
		}
	}
	dump(ans.size());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 512
import sys, math, re
from itertools import accumulate
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    if N == 1:
        print(1)
        return
        
    x, y = i2(N)
    d = {}

    for i in range(N):
        for j in range(N):
            if i == j:
                continue

            pair = (x[i]-x[j], y[i]-y[j])
            if not pair in d:
                d[pair] = 0
            
            d[pair] += 1

    print(N-max(d.values()))


if __name__ == "__main__":
    main()

Measured memory_bytes: 10120
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    string S;
    cin >> S;
    string ans = "No";
    if(S[0] == S[1] && S[1] == S[2]) ans = "Yes";
    if(S[2] == S[3] && S[1] == S[2]) ans = "Yes";
    
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N_MAX 123456

int main(void){
	char *a; int N, i, j;
	a=(char*)malloc((2*N_MAX+1)*sizeof(char));
	
	a[1]=0; for(i=2; i<=2*N_MAX; i++) a[i]=1;
	for(i=2; i<=(int)sqrt(2*N_MAX); i++){
		if(a[i]!=0) for(j=2*i; j<=2*N_MAX; j+=i) a[j]=0;
	}

	while(scanf("%d",&N) && N!=0){
		for(j=0, i=N+1; i<=2*N; i++) j+=a[i];
		printf("%d\n",j);
	}
	
	free(a);
	return 0;
}

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

int main() {
   
    int n;
    cin>>n;
    double vol ;
    double n1;
    
    n1 = n/3.0;
    // n2 = (n-n1)/2;
    // n3 = (n-n1-n2);
    vol =  n1*n1*n1;

    // cout<<vol;
    cout << fixed << setprecision(12) << vol<<"\n";
    return 0;

}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n, k = li()
h = list(li())

ans = 0
for hi in h:
    if hi >= k:
        ans += 1

print(ans)

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

int main(){
  long long n;
  cin>>n;
  string s;
  while(n>0){
      n--;
      s+=('a'+n%26);
      n=n/26;
  }
  reverse(s.begin(),s.end());
  cout<<s<<endl;
}


Measured memory_bytes: 3620
def task(n, a):
    total = 0
    tl = [0] * n
    tr = [0] * n

    for i in range(0, n):
        l = i - a[i]
        r = i + a[i]

        if l >= 0:
            tl[l] += 1

        if r < n:
            tr[r] += 1

    for i in range(0, n):
        if tl[i] > 0 and tr[i] > 0:
            total += tl[i] * tr[i]

    print(total)


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

task(n, a)


Measured memory_bytes: 32192
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      mut uv: [(Usize1, Usize1); n-1],
   }
   let mut ans = 0;
   for i in 0..n {
      ans += (i + 1) * (n - i);
   }
   for (u, v) in uv.iter() {
      if u < v {
         ans -= (u + 1) * (n - v);
      } else {
         ans -= (v + 1) * (n - u);
      }
   }
   println!("{}", ans);
}


Measured memory_bytes: 7732
/*
	边覆盖与不覆盖作为状态非常不好 dp
	可能有多个点覆盖这条边然后就转移不了
	考虑容斥, 这样子我就可以只关注图的某种连通性了
	说到连通性 dp, 常见套路是枚举断不断父边, 然后就可以做了 
*/
#include <bits/stdc++.h>
#define N 5005

using namespace std;

const int mod = 1e9 + 7;

int n;
int head[N], nex[N << 1], to[N << 1], cntE;
int f[N][N], g[N], siz[N], tmp[N];

inline void addE(int u, int v) {
	to[++cntE] = v;
	nex[cntE] = head[u], head[u] = cntE;
}
void dfs(int u, int fa) {
	f[u][siz[u] = 1] = 1;
	for(int i = head[u], v; i; i = nex[i]) {
		v = to[i];
		if(v == fa) continue;
		dfs(v, u);
		memset(tmp, 0, sizeof tmp);
		for(int i = 1; i <= siz[u]; ++i)
			for(int j = 0; j <= siz[v]; ++j)
				tmp[i + j] = (tmp[i + j] + 1LL * f[u][i] * f[v][j]) % mod;
		siz[u] += siz[v];
		for(int i = 1; i <= siz[u]; ++i)
			f[u][i] = tmp[i];
	}
	for(int i = 2; i <= siz[u]; ++i)
		f[u][0] = (f[u][0] - 1LL * f[u][i] * g[i] % mod + mod) % mod;
}

int main() {
	scanf("%d", &n);
	for(int i = 1, u, v; i < n; ++i) {
		scanf("%d %d", &u, &v);
		addE(u, v), addE(v, u);
	}
	
	g[0] = 1;
	for(int i = 2; i <= n; i += 2)
		g[i] = (i - 1LL) * g[i - 2] % mod;
	
	dfs(1, 0);
	
	printf("%d\n", mod - f[1][0]);
	return 0;
}



Measured memory_bytes: 97152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) {cin >> p[i];p[i]--;}
    rep(i,n) {cin >> q[i];q[i]--;}

    int pn=0, qn=0;
    vector<int> used(n);
    rep(i,n) used[i]=0;
    vector<int> fact(n);
    fact[0]=1;
    repi(i,1,n) fact[i] = fact[i-1]*i;
    rep(i,n){
        used[p[i]] = 1;
        rep(j,p[i]) pn+=(1-used[j])*fact[n-1-i];
    }
    rep(i,n) used[i]=0;
    rep(i,n){
        used[q[i]] = 1;
        rep(j,q[i]) qn+=(1-used[j])*fact[n-1-i];
    }
    cout << abs(pn-qn) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] nm = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int n = nm[0];
        int m = nm[1];
        int count = 0;
        int sum = a.Sum();
        for (int i = 0; i < n; i++)
        {
            if (sum <= 4 * m * a[i]) count++;
        }
        if (m <= count) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 28280
use std::cmp::max;
use std::collections::VecDeque;
use std::cmp::min;
use core::ops::Bound::Excluded;
use core::ops::Bound::Included;
use std::collections::BTreeSet;
use std::cmp::Ordering;
use std::fmt::Debug;

fn read_line() -> String {
    let mut buffer = String::new();
    std::io::stdin().read_line(&mut buffer).expect("No Line");
    buffer
}
fn read_lines<R, T: Fn(&str)->R> (count: usize, transformer: T) -> Vec<R> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(transformer(buffer.trim()));
        buffer.clear();
    }
    vec
}
fn read_value<T: std::str::FromStr>() -> T {
    read_line().trim().parse().ok().unwrap()
}
fn read_values<T: std::str::FromStr>() -> Vec<T> {
    read_line().trim().split(' ').map(|x| x.parse().ok().expect("Can't Parse")).collect::<Vec<T>>()
}
fn read_tabulate<T: std::str::FromStr>(count: usize) -> Vec<T> {
    let mut buffer = String::new();
    let mut vec = Vec::with_capacity(count);
    for _ in 0 .. count {
        std::io::stdin().read_line(&mut buffer).expect("No Line");
        vec.push(buffer.trim().parse().ok().expect("Can't Parse"));
        buffer.clear();
    }
    vec
}
macro_rules! define {
    () => {};
    ($($token:tt)*) => {
        let mut iter = read_values::<String>().into_iter();
        define_iter!(iter, $($token)*);
    };
}
macro_rules! define_iter {
    ($iter:expr) =>{};
    ($iter:expr,) =>{};
    ($iter:expr, $id:ident:$t:tt $($tail:tt)*) => {
        let $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        define_iter!($iter, $($tail)*);
    };
    ($iter:expr, mut $id:ident:$t:tt $($tail:tt)*) => {
        let mut $id: $t = $iter.next().unwrap().parse().ok().expect("Can't Parse");
        define_iter!($iter, $($tail)*)
    };
}
macro_rules! freeze {
    ($($id:ident), *) => {
        $(let $id = $id;)*
    };
}
struct KeyValue<K, V> {
    key: K,
    value: V
}
impl <K: PartialOrd, V> PartialEq for KeyValue<K, V> {
    fn eq(&self, other: &Self) -> bool {
        self.key.eq(&other.key)
    }
}
impl <K: PartialOrd, V> Eq for KeyValue<K, V> {}
impl <K: PartialOrd, V> PartialOrd for KeyValue<K, V> {
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        self.key.partial_cmp(&other.key)
    }
}
impl <K: PartialOrd, V> Ord for KeyValue<K, V> {
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.key.partial_cmp(&other.key).ok_or("Can't Compare").unwrap()
    }
}
fn main() {
    define! {
        x: i64
    }
    let mut result = x / 11 << 1;
    if x % 11 > 6 {
        result += 2;
    }else if x % 11 > 0 {
        result += 1;
    }
    println!("{}", result);
}


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

int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  for(int i=l; i<=r; i++){
    if(i%d==0)ans++;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3544
#include<cstdio>
#include<algorithm>
using namespace std;

char s1[1001], s2[1001];
int n1, n2, dp[1001][1001], INF = 1000000000;

int main() {
  scanf("%s%s", s1, s2);
  while (s1[n1] != 0) n1++;
  while (s2[n2] != 0) n2++;
  for (int i = 0; i <= n1; i++) for (int j = 0; j <= n2; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 0; i <= n1; i++) dp[i][0] = i;
  for (int i = 0; i <= n2; i++) dp[0][i] = i;
  for (int i = 0; i < n1; i++) {
    for (int j = 0; j < n2; j++) {
      dp[i+1][j+1] = min(dp[i][j], min(dp[i][j+1], dp[i+1][j])) + 1;
      if (s1[i] == s2[j]) dp[i+1][j+1] = min(dp[i][j], dp[i+1][j+1]);
    }
  }
  printf("%d\n", dp[n1][n2]);
}



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

int main() {
	string s;
	cin >> s;
	int n;
	n = s.length();
	if (s[n-1] == 's') cout << s << "es" << endl;
	else cout << s << "s" << endl;
	return 0;
}

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

int main(){
	int n, m, l;
	cin >> n >> m >> l;
	int a[100][100], b[100][100];
	long int c[100][100] = {0};
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for(int j = 0; j < m; j++){
		for(int k = 0; k < l; k++){
			cin >> b[j][k];
		}
	}
	for(int i = 0; i < n; i++){
		for(int k = 0; k < l; k++){
			for(int j = 0; j < m; j++) c[i][k] += a[i][j] * b[j][k];
		}
		for(int k = 0; k < l-1; k++) cout << c[i][k] << ' ';
		cout << c[i][l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1324
#include<bits/stdc++.h>
using namespace std;
#define int long
using namespace std;
main(){
  int n,m,inf=1e8;
  cin>>n>>m;
  
  vector<int> dp((1<<n),inf),vislist;
  vector<bool> visited((1<<n),false);
  dp[0]=0;
  visited[0]=true;
  
  for(int i=0;i<m;++i){
    int a,b,c,k;
    cin>>a>>b;
    c=0;
    for(int i=0;i<b;++i){
      cin>>k;
      c|=(1<<(k-1));
    }
    dp[c]=min(dp[c],a);
    if(!visited[c]){
      visited[c]=true;
      vislist.push_back(c);
    }
  }
  bool ref=true;
  while(ref){
    ref=false;
    int vs=vislist.size();
    for(int i=0;i<vs;++i)for(int j=0;j<vs;++j){
      int p=vislist[i],q=vislist[j];
      if(p==q)continue;
      int pq=(p|q);
      if(!visited[pq]){
        ref=true;
        visited[pq]=true;
        vislist.push_back(pq);
        dp[pq]=dp[p]+dp[q];
      }
      else if(dp[pq]>dp[p]+dp[q]){
        ref=true;
        dp[pq]=dp[p]+dp[q];
      }
    }
  }
  int r=dp[(1<<n)-1];
  cout<<(r<inf?r:-1);
}

Measured memory_bytes: 384
#!/usr/bin/env python3

numbers = input().split(" ")
x = int(numbers[0])
k = int(numbers[1])
d = int(numbers[2])

if abs(x) - k * d > 0:
    print(abs(x) - k * d)
else:
    r = abs(x) % d
    q = abs(x) // d
    if (k - q) % 2 == 0:
        print(r)
    else:
        print(abs(r - d))



Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int K, N, p[202020];
int s[202020];

void solve() {
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    FOR(i, 1, N + 1) {
        s[i] = s[i - 1] + p[i - 1] + 1;
    }
    double ans = 0;
    FOR(i, 0, N) {
        if (i + K > N)
            break;
        chmax(ans, (s[i + K] - s[i]) / 2.0);
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    FOR(N)
        cin >> p[i];
    solve();
    return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SP cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

ll modpow(ll a, ll n) {
    ll r = 1;
    while (n) r = r * ((n % 2) ? a : 1) % mod, a = a * a % mod, n >>= 1;
    return r;
}

ll comb(int p_, int q_) {
    if (p_ < 0 || q_ < 0 || q_ > p_) return 0;
    ll p = 1, q = 1;
    q_ = min(q_, p_ - q_);
    FORE(i, 1, q_) {
        p = p * p_ % mod;
        q = q * i % mod;
        p_--;
    }

    return p * modpow(q, mod - 2) % mod;
}

ll hcomb(int p, int q) { return (p == 0 && q == 0) ? 1 : comb(p + q - 1, q); }

map<ll, int> enumpr(ll n) {
    map<ll, int> v;

    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            v[i]++;
            n /= i;
        }
    }
    if (n > 1) v[n]++;
    return v;
}

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

    ll n, m;
    cin >> n >> m;

    auto V = enumpr(m);

    ll ret = 1;
    for (auto &v : V) {
        ret = ret * hcomb(n, v.second) % mod;
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
//Binary Search Tree II
//2019-01-11
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x -> left != NIL)
    x = x -> left;

  return x;

}

Node treeMaximum(Node x){
  while(x -> right != NIL)
    x = x -> right;

  return x;

}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u -> key)
    return u;

  else if(k < u -> key)
    return treeSearch(u -> left, k);
  else
    return treeSearch(u -> right, k);

}

Node treeSuccessor(Node x){
  Node A;

  if(x -> right != NIL)
    return treeMinimum(x -> right);

  A = x -> parent;

  while(A != NIL && x == A -> right){
    x = A;
    A = A ->parent;
  } 

  return A;
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z -> left == NIL || z -> right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y -> left != NIL)
    x = y -> left;
  else
    x = y ->right;

  if(x != NIL)
    x -> parent = y -> parent;

  if(y -> parent == NIL)
    root = x;
  else if(y == y -> parent -> left)
    y -> parent -> left = x;
  else
    y -> parent -> right = x;

  if(y != z)
    z -> key = y -> key;

  free(y);

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z -> key < x -> key)
      x = x -> left;
    else
      x = x -> right;

  }
  z -> parent = y;

  if(y == NIL)
    root = z;
  else if(z -> key < y -> key)
    y -> left = z;
  else
    y -> right = z;

}

void inorder(Node u){
  if(u == NIL){
    return;
  }
  inorder(u -> left);
  printf(" %d", u -> key);
  inorder(u -> right);
  

}
void preorder(Node u){
  if(u == NIL){
    return;
  }
    printf(" %d", u -> key);
    preorder(u -> left);
    preorder(u -> right);
  
}

void Print_re(int X){
  Node A;
  A = treeSearch(root, X);

  if(A != NIL)
    printf("yes\n");
  else
    printf("no\n");

}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  if(n > 500000){
    printf("命令の数が大きすぎます。\n");
    exit(1);
  }

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20452
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

int ceil(int a,int b){
	return (a+b-1)/b;
}

ll gcd(ll a,ll b){
	ll p;

	if (b > a){
		p = a;
		a = b;
		b = p;
	}

	while(b != 0){
		p = a % b;
		a = b;
		b = p;
	}
	return a;
}

int main(){
	ll N,K;
	cin >> N >> K;
	ll x[N];
	REP(i,N) cin >> x[i];
	ll ret = 10000000001;

	REP(i,N-K+1){
		ll left = x[i];
		ll right = x[i+K-1];
		ll tmp = min(abs(left) + abs(right - left), abs(right) + abs(right - left));
		if(ret > tmp) ret = tmp;
	}

	cout << ret << endl;

	return 0;
}


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

int main()
{
   char a,b;
   cin>>a>>b;
   if(a>b)
    cout<<">"<<endl;
   if(a<b)
    cout<<"<"<<endl;
   if(a==b)
    cout<<"="<<endl;
   return 0;
}


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

using namespace std;

char tbl[][16] = {" ",
                  "',.!?"   , "abcABC", "defDEF"  ,
                  "ghiGHI"  , "jklJKL", "mnoMNO"  ,
                  "pqrsPQRS", "tuvTUV", "wxyzWXYZ"
                  };
int len[10] = {1, 5, 6, 6, 6, 6, 6, 8, 6, 8};

int main()
{
    char s[10002];
    
    while (~scanf("%s", s)){
        int itr = 0;
        for (int i = 0; s[i]; i++){
            if (s[i] != s[i + 1]){
                if (s[i] != '0')
                    printf("%c", tbl[s[i] - '0'][itr % len[s[i] - '0']]);
                itr = -1;
            }
            if (s[i] == '0' && s[i - 1] == '0') printf(" ");
            itr++;
        }
        printf("\n");
    }
    
    return (0);
}

Measured memory_bytes: 1108
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

using namespace std;
typedef pair<int, int> P;

#define INF (1 << 29)

vector<P> edge[108];
int n, m, ans;
int a[1080], b[1080], c[1080];
int dist[108];

void dijkstra(int s){
  for(int i = 0;i < n;i++)dist[i] = INF;
  dist[s] = 0;
  priority_queue<P, vector<P>, greater<P> > pq;
  pq.push(P(0,s));

  while(!pq.empty()){
    P tmp = pq.top();pq.pop();
    int d = tmp.first;
    int from = tmp.second;
    if(dist[from] < d)continue;
    for(int i = 0;i < edge[from].size();i++){
      int to = edge[from][i].first;
      int c = edge[from][i].second;
      if(dist[from] + c < dist[to]){
	dist[to] = dist[from] + c;
	pq.push(P(dist[to], to));
      }
    }
  }  
}

int main(){
  cin >> n >> m;
  for(int i = 0;i < m;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--,b[i]--;
    edge[a[i]].push_back(P(b[i], c[i]));
    edge[b[i]].push_back(P(a[i], c[i]));
  }

  for(int i = 0;i < m;i++){
    dijkstra(a[i]);
    if(dist[b[i]] != c[i])ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int N, Q; string S; cin >> N >> Q >> S;
    
    int cnt[N + 1] = {};
    REP(i, 1, N) {
        if (S[i - 1] == 'A' && S[i] == 'C') cnt[i + 1] = cnt[i] + 1;
        else cnt[i + 1] = cnt[i];
    }

    REP(i, 0, Q) {
        int l, r; cin >> l >> r;
        cout << cnt[r] - cnt[l] << endl;
    }

    return 0;
}

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


int main()
{
int a,b;
scanf("%d %d",&a,&b);
if (a<=b){
    for(int i=0;i<b;i++)
    printf("%d",a);
}
else {for(int i=0;i<a;i++)
    printf("%d",b);}

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
#include<stdint.h>
#include<limits.h>

#include<sstream>
using namespace std;

 
int main() {
	string s;
	int v[100001] = {}, rez[100001] = {};

	cin >> s;
	v[s.size() - 1] = 1;
	for (int i = s.size()-2;i >= 0;i--)
	{
		if (s[i] == s[i + 1]&&s[i]=='R')
		{
			v[i] = v[i + 1];
			v[i]++;
			if (v[i] % 2 == 0) {
				rez[i + v[i]]++;
			}
			else {
				rez[i + v[i] - 1]++;
			}
		}
		else {
			if(s[i]=='R')
				rez[i]++;
			v[i] = 1;
		}
	}

	v[0] = 1;
	for (int i = 1;i <s.size();i++)
	{
		if (s[i] == s[i - 1] && s[i] == 'L')
		{
			v[i] = v[i - 1];
			v[i]++;
			if (v[i] % 2 == 0) {
				rez[i - v[i]]++;
			}
			else {
				rez[i - v[i] + 1]++;
			}
		}
		else {
			if (s[i] == 'L')
				rez[i]++;
			v[i] = 1;
		}
	}

	for (int i=0;i<s.size();i++)
	{
		cout << rez[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
    int a,b,c;
    // スペース区切りの整数の入力
    scanf("%d %d",&a,&b);
    c = 0 ;
    // 出力
    if (a == 1) {c += 300000;}
    if (a == 2) {c += 200000;}
    if (a == 3) {c += 100000;}
    if (b == 1) {c += 300000;}
    if (b == 2) {c += 200000;}
    if (b == 3) {c += 100000;}
    if (a == 1 && b == 1) {
    	c += 400000;
    }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) {
    cin >> a[i];
    b[n - 1 - i] = a[i];
  }
  rep(i, n) {
    cout << b[i];
    if (i == n - 1) break;
    cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3092
import math


def main():
    A, B, H, M = list(map(float, input().split()))
    a = H * 30 + M / 2
    b = M * 6
    theta = abs(a - b)
    C = A**2 + B**2 - 2 * A * B * math.cos(math.radians(theta))
    c = math.sqrt(C)
    if theta == 180:
        c = A + B
    elif theta == 0:
        c = abs(A - B)
    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9304
#include<stdio.h>
int main(void){
    int X;
    X=0; 
    scanf("%d",&X);
    if(400<= X && X <=599)printf("8");
    else if(600<= X && X <=799)printf("7");
    else if(800<= X  && X <=999)printf("6");
    else if(1000<= X  && X <=1199)printf("5");
    else if(1200<= X  && X <=1399)printf("4");
    else if(1400<= X  && X <=1599)printf("3");
    else if(1600<= X  && X <=1799)printf("2");
    else if(1800<= X  && X <=1999)printf("1");
return 0;
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;

#define pb push_back
#define fst first
#define snd second
#define ALL(cont) cont.begin(), cont.end()
#define mset(a,b) memset(a,b,sizeof(a));
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i, a, b) for (int i = a, almo5t = b; i < almo5t; ++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
struct pt {  // for 3D add z coordinate
	double x,y;
	pt(double x, double y):x(x),y(y){}
	pt(){}
	double norm2(){return *this**this;}
	double norm(){return sqrt(norm2());}
	bool operator==(pt p){return abs(x-p.x)<=EPS&&abs(y-p.y)<=EPS;}
	pt operator+(pt p){return pt(x+p.x,y+p.y);}
	pt operator-(pt p){return pt(x-p.x,y-p.y);}
	pt operator*(double t){return pt(x*t,y*t);}
	pt operator/(double t){return pt(x/t,y/t);}
	double operator*(pt p){return x*p.x+y*p.y;}
//	pt operator^(pt p){ // only for 3D
//		return pt(y*p.z-z*p.y,z*p.x-x*p.z,x*p.y-y*p.x);}
	double angle(pt p){ // redefine acos for values out of range
		return acos(*this*p/(norm()*p.norm()));}
	pt unit(){return *this/norm();}
	double operator%(pt p){return x*p.y-y*p.x;}
	// 2D from now on
	bool operator<(pt p)const{ // for convex hull
		return x<p.x-EPS||(abs(x-p.x)<=EPS&&y<p.y-EPS);}
	bool left(pt p, pt q){ // is it to the left of directed line pq?
		return (q-p)%(*this-p)>EPS;}
	pt rot(pt r){return pt(*this%r,*this*r);}
	pt rot(double a){return rot(pt(sin(a),cos(a)));}
};
pt ccw90(1,0);
pt cw90(-1,0);
int sgn2(double x){return x<0?-1:1;}
struct ln {
	pt p,pq;
	ln(pt p, pt q):p(p),pq(q-p){}
	ln(){}
	bool has(pt r){return dist(r)<=EPS;}
	bool seghas(pt r){return has(r)&&(r-p)*(r-(p+pq))<=EPS;}
//	bool operator /(ln l){return (pq.unit()^l.pq.unit()).norm()<=EPS;} // 3D
	bool operator/(ln l){return abs(pq.unit()%l.pq.unit())<=EPS;} // 2D
	bool operator==(ln l){return *this/l&&has(l.p);}

	double angle(ln l){return pq.angle(l.pq);}
	int side(pt r){return has(r)?0:sgn2(pq%(r-p));} // 2D
	pt proj(pt r){return p+pq*((r-p)*pq/pq.norm2());}
	pt ref(pt r){return proj(r)*2-r;}
	double dist(pt r){return (r-proj(r)).norm();}

};
int main()
{
    FIN;
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#define endl '\n'
#endif
    double x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    ln l = ln(pt(x1,y1),pt(x2,y2));
    int q;cin>>q;
    while(q--){
        double x,y;cin>>x>>y;
        pt pr = l.ref(pt(x,y));
        cout<<fixed<<setprecision(12)<<pr.x<<' '<<pr.y<<endl;
    }
    return 0;
}



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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

using pii = pair<int, int>;

int H, W;
string S[1111];
int dist[1111][1111];

int bfs() {
  queue<pii> que;
  rep (i, H) {
    rep (j, W) {
      if (S[i][j] == '#') {
        que.push({i, j});
        dist[i][j] = 0;
      } else {
        dist[i][j] = -1;
      }
    }
  }

  int Max = 0;
  while (que.size()) {
    pii p = que.front(); que.pop();
    int y = p.first, x = p.second;
    rep (i, 4) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 or nx < 0 or ny >= H or nx >= W) continue;
      if (dist[ny][nx] != -1) continue;
      dist[ny][nx] = dist[y][x] + 1;
      chmax(Max, dist[ny][nx]);
      que.push({ny, nx});
    }
  }

  return Max;
}

signed main() {
  cin >> H >> W;
  rep (i, H) {
    cin >> S[i];
  }

  int ans = bfs();

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 26292
#include<stdio.h>
int main () {
	long long int n, i, count = 0;
	scanf("%lld", &n);
	long long int arr[n];
	for (i = 0; i < n; i++) {
		scanf("%lld", &arr[i]);
//		printf("%lld\n", arr[i]);
	}
	for (i = 1; i < n - 1; i++) {
		if (arr[i] < arr[i + 1] && arr[i] > arr[i - 1]) {
			count++;
		}
		if (arr[i] > arr[i + 1] && arr[i] < arr[i - 1]) {
			count++;
		}
	}
	printf("%lld\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int a, b, c;
  cin >> a >> b >> c;
  Yes(a < b && b < c);
  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int NIL = -1;
const long long INF = 1LL << 60;
const long long MOD = 1e9+7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int N; cin >> N;
  vector<vector<int>> to(N), cost(N);
  for (int i = 0; i < N-1; ++i) {
    int u, v, w; cin >> u >> v >> w;
    u--; v--;
    to[u].push_back(v);
    to[v].push_back(u);
    cost[u].push_back(w);
    cost[v].push_back(w);
  }
  vector<int> ans(N, -1);
  queue<int> q;
  ans[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < to[v].size(); ++i) {
      int u = to[v][i];
      int w = cost[v][i];
      if (ans[u] != -1) continue;
      ans[u] = (ans[v] + w) % 2;
      q.push(u);
    }
  }

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


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

int main() {
  int A,B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    int x,y;
    x = i/1000;
    y = (i%10)*10+(i%100)/10;
    if (x==y) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
constexpr long long MOD = 1000000007;

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

int main()
{
  int N, K, S;
  std::cin >> N >> K >> S;
  if(S != 1000000000)
  {
    for(int i = 0; i < K; ++i)
    {
      std::cout << S << " ";
    }
    for(int i = K; i < N; ++i)
    {
      std::cout << S + 1 << " ";
    }
  }
  else
  {
    for(int i = 0; i < K; ++i)
    {
      std::cout << S << " ";
    }
    for(int i = K; i < N; ++i)
    {
      std::cout << 1 << " ";
    }
  }
  std::cout << std::endl;
  return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>

using namespace std;

int X, Y;
int field[15 + 2][15 + 2];
int dp[15 + 2][15 + 2];

void solve() {
	for (int i = 1; i <= X; i++) {
		if (field[0][i] == 0) {
			dp[0][i] = 1;
		}
	}
	for (int y = 0; y < Y; y++) {
		for (int x = 1; x <= X; x++) {
			if (field[y][x] == 2) {
				if (field[y + 2][x] != 1) {
					dp[y + 2][x] += dp[y][x];
				}
			} else if (field[y][x] == 0) {
				if (field[y + 1][x - 1] == 0) {
					dp[y + 1][x - 1] += dp[y][x];
				}
				if (field[y + 1][x] != 1) {
					dp[y + 1][x] += dp[y][x];
				}
				if (field[y + 1][x + 1] == 0) {
					dp[y + 1][x + 1] += dp[y][x];
				}
			}
		}
	}
	int sum = 0;
	for (int y = Y; y <= Y + 1; y++) {
		for (int x = 1; x <= X; x++) {
			sum += dp[y][x];
		}
	}
	printf("%d\n", sum);
}

int main() {
	while (scanf("%d %d ", &X, &Y) == 2) {
		if (X == 0 && Y == 0) {return 0;}

		fill(dp[0], &dp[15 + 2 - 1][15 + 2], 0);
		fill(field[0], &field[15 + 2 - 1][15 + 2], 1);
		for (int y = Y; y <= Y + 1; y++) {
			for (int x = 1; x <= X; x++) {
				field[y][x] = 2;
			}
		}
		for (int i = 0; i < Y; i++) {
			for (int j = 1; j <= X; j++) {
				scanf("%d ", &field[i][j]);
			}
		}
		/*
		for (int i = 0; i < Y + 2; i++) {
			for (int j = 0; j < X + 2; j++) {
				printf("%d ", field[i][j]);
			}
			printf("\n");
		}
		*/
		solve();
		/*
		for (int i = 0; i < Y + 2; i++) {
			for (int j = 0; j < X + 2; j++) {
				printf("%2d ", dp[i][j]);
			}
			printf("\n");
		}
		*/
	}
}

Measured memory_bytes: 0
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
int N;
vector<string> res;

void dfs(int idx, int max_d, string str) {
  if (idx == N - 1) {
    res.push_back(str);
  } else {
    for (int i = 0; i <= max_d + 1; ++i) {
      string tmp = str;
      tmp += 'a' + i;
      dfs(idx + 1, max(i, max_d), tmp);
    }
  }
}

int main() {
  cin >> N;

  dfs(0, 0, "a");

  for (int i = 0; i < res.size(); ++i) {
    cout << res[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
int c[3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  FOR(i, 0, sz(s)) c[s[i]-'a']++;
  sort(c, c+3);
  cout << (c[2]-c[0]<=1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
n,m,x,y = map(int,input().split())
d = "War"
l_x = sorted(list(map(int,input().split())))[::-1]
l_y = sorted(list(map(int,input().split())))
for i in range(x+1,y+1):
  if l_x[0]<i and l_y[0]>=i:
    d = "No War"
    break
print(d)


Measured memory_bytes: 3060