akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

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

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:i32 = read();
    let k:i32 = read();
    let mut h:Vec<i32> = (0..n).map(|_| read()).collect();

    h.sort();

    let mut ans:i32 = 2000000000;
    for i in 0..n-k+1 {
        let i = i as usize;
        let k = k as usize;
        //debug!(i,i+k-1,h[i+k-1],h[i]);
        ans = min(ans, h[i+k-1]-h[i]);
    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
import sys
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    sys.exit()

limit = 10 ** 18
ans = A[0]
for i in range(1,N):
    ans = ans * A[i]
    if ans > limit:
        print("-1")
        sys.exit()

print(ans)

Measured memory_bytes: 84648
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int DIV = 1'000'000'007;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M + 1);
    for (int m = 0; m < M; m++) cin >> a[m];
    a[M] = 0;

    vector<int> dp(N + 1);
    dp[0] = 1;
    int i = 0;

    if (a[0] == 1) {
        dp[1] = 0;
        i++;
    } else {
        dp[1] = 1;
    }

    for (int n = 2; n <= N; n++) {
        if (a[i] == n) {
            dp[n] = 0;
            i++;
        } else {
            dp[n] = dp[n - 1] + dp[n - 2];
            dp[n] %= DIV;
        }
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 1024
N, M = map(int,input().split())
A = list(map(int, input().split())) 

sumA = sum(A)
ans_list = [0]*N
for i in range(N):
    if (A[i]/sumA)>=(1/(4*M)):
        ans_list[i] = 1
if ans_list.count(1) >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        H,W = list(map(int, input().split()))
    else:
        pass

    if H == W :
        print(H+W)
    else :
        print(max(H,W)*2-1)
if __name__ =='__main__':
    main()

Measured memory_bytes: 21756
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int H, W, K;
  while (cin >> H >> W >> K) {
    vector<string> S(H);
    for (auto& x : S) cin >> x;
    vec<int, 2> sum = make_v(H, W + 1, 0);
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) sum[i][j + 1] = sum[i][j] + (S[i][j] == '1');
    }
    int res = 1 << 25;
    for (int m = 0; m < (1 << (H - 1)); m++) {
      int cut = 0;
      for (int i = 0; i < H; i++) cut += (m >> i) & 1;
      int cost = cut;
      int p = 0;
      for (int j = 0; j < W;) {
        vector<int> tot(cut + 1, 0);
        int k = 0;
        for (int i = 0; i < H; i++) {
          tot[k] += sum[i][j + 1] - sum[i][p];
          if ((m >> i) & 1) ++k;
        }
        bool ok = true;
        for (int x : tot) ok &= x <= K;
        if (!ok) {
          if (p == j) goto dame;
          ++cost;
          p = j;
        } else {
          ++j;
        }
      }
      chmin(res, cost);
      dame:;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int H, W, i, j;
    char a[100][101];

    scanf("%d %d", &H, &W);
    
    for(i=0; i<H; i++){
        scanf("%s", a[i]);
    }

    for(i=0; i<W+2; i++)
        printf("#");
    printf("\n");

    for(i=0; i<H; i++){
        printf("#");
        
        for(j=0; j<W; j++){
            printf("%c", a[i][j]);
        }

        printf("#\n");
    }

    for(i=0; i<W+2; i++)
        printf("#");
    printf("\n");

    return 0;
}

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

int N, M;
#define MAX_N 300
#define MAX_M 300
int A[MAX_N][MAX_M];
bool E[MAX_M]; int F[MAX_M];
int C[MAX_N];
int R = INT_MAX;

int main() {
  cin >> N >> M;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < M; ++j) {
      int a; cin >> a; --a; A[i][j] = a;
    }
  }
  for(int i = 0; i < N; ++i) ++F[A[i][0]];
  for(int r = 0; r < M; ++r) {
    for(int i = 0; i < N; ++i) {
      while(E[A[i][C[i]]]) {
        --F[A[i][C[i]]]; ++C[i]; ++F[A[i][C[i]]];
      }
    }
    int j = max_element(F, F + M) - F;
    R = min(R, F[j]);
    E[j] = true;
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define db double
#define pb push_back
#define mpr make_pair
#define andl "\n"
#define f first
#define s second
#define mset(x,y) memset(x,y,sizeof(x))
#define fr(i,n) for(long long int i=0;i<n;i++)
#define trace(it,x) for(auto it = (x).begin(); it != (x).end(); it++)
#define mod 1000000007
#define fastio ios::sync_with_stdio (false); cin.tie (0); cout.tie (0);
#define runtime cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
using namespace std;
 
// convert number to string to_string(x);
// convert string to number stoi();

ll fact[3000];
 
ll mulmod(ll x,ll y)
{
    return ((x%mod)*(y%mod))%mod;
}
 
ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mulmod(z, x);
        x = mulmod(x, x);
        y /= 2;
    }
    return z;
}
 
ll ncr(ll n,ll r)
{
    return mulmod(fact[n],binpow(mulmod(fact[n-r],fact[r]),mod-2));
}

 
// ll pwr(ll n,ll m)
// {
//   if(n==1 || m==0)
//     return 1;
 
//   ll x=pwr(n,m/2);
//   if(m%2==0)
//     return x*x;
//   else
//     return n*x*x;
// }
 
// ll pwr(ll n,ll m,ll b)
// {
//   if(n==1 || m==0)
//     return 1;
 
//   ll x=pwr(n,m/2,b);
//   if(m%2==0)
//     return ((x%b)*(x%b))%b;
//   else
//     return ((n%b)*(((x%b)*(x%b))%b))%b;
// }

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

  fact[0]=1;
  for(ll i=1;i<3000;i++)
  fact[i]=(i*fact[i-1])%mod;

  ll ans=0;

  for(ll i=1;i<=n/3;i++)
  	ans=(ans+ncr(n-3*i+i-1,i-1))%mod;

  cout << ans;
  runtime
}

Measured memory_bytes: 3800
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

fn main() {
    input!{
        n: usize,
        xu: [(f64, chars); n]
    }
    let mut ans = 0.;
    for (x, u) in xu {
        if u == &['J', 'P', 'Y'] {
            ans += x;
        } else {
            ans += x * 380000.;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
li = list(map(int, input().split()))

ans = 1
inc = 0
tmp = li[0]
for a in li[1:]:
    if inc * (a - tmp) < 0:
        ans += 1
        inc = 0
    else:
        inc += a - tmp
    tmp = a

print(ans)


Measured memory_bytes: 15020
#include <iostream>

using namespace std;

int main(){
int K ;
cin >> K;
int a = 0;
int b = -1;
int c = 7;
int d = 0;
for(int i = 0; i < 10000000; i++)
{
 a = (c + d)% K;
  if(a == 0)
  {
  b = i+1;
  break;
  } 
 d = a;
 c = (c*10)%K;
}
cout << b << endl;
return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
    double n;
    cin>>n;
    int k=n/1.08;
    if(int(k*1.08)==n) cout<<k<<endl;
    else if(int((k+1)*1.08)==n) cout<<k+1<<endl;
    else cout<<":(";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N, A, B;
    cin >> N >> A >> B;
    ll SET=A+B;
    ll R=N/SET;
    ll AMARI=N%SET;
    if(AMARI<=A){
        cout << R*A+AMARI << endl;
    }
    else{
        cout << R*A+A << endl;
    }
}

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

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    double bottle = a*a*b;
    double ans;
    if(x >= bottle/2.0){
        double space = bottle - x;
        double t = space*2.0 / a / a;
        ans = atan(t / a) * 180.0 / M_PI;
    }else{
        double t = x*2.0 / a / b;
        ans = atan(b / t) * 180.0 / M_PI;
    }
    cout << fixed;
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{
    public void AtCoder(){
        string[] s;
		s = Console.ReadLine().Split(' ');
		int n = int.Parse(s[0]);
		int[] l = new int[n];
		int[] r = new int[n];
		for(int i=0; i<n; i++){
		    s = Console.ReadLine().Split(' ');
		    l[i] = int.Parse(s[0]);
		    r[i] = int.Parse(s[1]);
		}
		bool[] f = new bool[n];
		
		int[] x = new int[n];
		for(int i=0; i<n; i++) x[i] = r[i];
		int[] ordx = new int[n];
		for(int i=0; i<n; i++){
		    ordx[i] = i;
		}
		Array.Sort(x, ordx);
		int[] y = new int[n];
		for(int i=0; i<n; i++) y[i] = l[i];
		int[] ordy = new int[n];
		for(int i=0; i<n; i++){
		    ordy[i] = i;
		}
		Array.Sort(y, ordy);
		
		long ans0 = 0;
		int ix = 0;
		int iy = n - 1;
		int p = 0;
		bool skip = false;
		while(!skip){
		    skip = true;
		    if(ix<n && x[ix] < p){
		        skip = false;
		        ans0 += Math.Abs(p - x[ix]);
		        p = x[ix];
		        ix++;
		    }
		    if(iy>-1 && y[iy] > p){
		        skip = false;
		        ans0 += Math.Abs(p - y[iy]);
		        p = y[iy];
		        iy--;
		    }
		}
        ans0 += Math.Abs(p);
        
		long ans1 = 0;
		ix = 0;
		iy = n - 1;
		p = 0;
		skip = false;
		f = new bool[n];
		while(!skip){
		    skip = true;
		    if(iy>-1 && y[iy] > p){
		        skip = false;
		        ans1 += Math.Abs(p - y[iy]);
		        p = y[iy];
		        iy--;
		    }
		    if(ix<n && x[ix] < p){
		        skip = false;
		        ans1 += Math.Abs(p - x[ix]);
		        p = x[ix];
		        ix++;
		    }
		}
		ans1 += Math.Abs(p);
		
		Console.WriteLine(Math.Max(ans0, ans1));
    }
    
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}

Measured memory_bytes: 19656
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

int main() {
  int x;
  cin>>x;
  cout<<x*x*x<<endl;
}


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

using namespace std;

typedef long long Int;

int vis[100001];

int main()
{
    int M, N;
    
    scanf("%d %d", &N, &M);
    
    int prev, now;
    for (int i = 0; i < M; i++){
        scanf("%d", &now);
        now--;
        if (i){
            vis[min(prev, now)]++;
            vis[max(prev, now)]--;
        }
        prev = now;
    }
    
    Int ans = 0;
    for (int i = 0; i < N - 1; i++){
        Int A, B, C;
        scanf("%lld %lld %lld", &A, &B, &C);
        if (i) vis[i] += vis[i - 1];
        ans += min(A * vis[i], B * vis[i] + C);
    }
    
    printf("%lld\n", ans);
}

Measured memory_bytes: 1580
#include<cstdio> 
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int d;
	scanf("%d",&d);
	int s=0;
	for (int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		if (1ll*x*x+1ll*y*y<=1ll*d*d){
			s++;
		}
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 3224
package main
 
import (
    "bufio"
    "bytes"
    "fmt"
    "io"
    "os"
    "strconv"
    "strings"
)
 
// M is large primary number
const M = 1046527
 
func main() {
    fmt.Println(answer(os.Stdin))
}
 
func answer(r io.Reader) string {
    H := make([]string, M)
    sc := bufio.NewScanner(r)
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
 
    buf := bytes.Buffer{}
    for i := 0; i < n; i++ {
        sc.Scan()
        ss := strings.Fields(sc.Text())
        switch ss[0] {
        case "insert":
            insert(H, ss[1])
        case "find":
            if find(H, ss[1]) {
                buf.WriteString("yes\n")
            } else {
                buf.WriteString("no\n")
            }
        }
    }
    return strings.TrimRight(buf.String(), "\n")
}
 
func atoi(char byte) int {
    switch char {
    case 'A':
        return 1
    case 'C':
        return 2
    case 'G':
        return 3
    case 'T':
        return 4
    default:
        return 0
    }
}
 
func getKey(str string) int {
    sum, p := 0, 1
    for i := 0; i < len(str); i++ {
        sum += p * atoi(str[i])
        p *= 5
    }
    return sum
}
 
func h1(key int) int {
    return key % M
}
 
func h2(key int) int {
    return 1 + key%(M-1)
}
 
func find(H []string, str string) bool {
    key := getKey(str)
    h := 0
    for i := 0; ; i++ {
        h = (h1(key) + i*h2(key)) % M
        if H[h] == str {
            return true
        } else if len(H[h]) == 0 {
            return false
        }
    }
}
 
func insert(H []string, str string) []string {
    key := getKey(str)
    for i := 0; ; i++ {
        h := (h1(key) + i*h2(key)) % M
        if H[h] == str {
            return H
        } else if len(H[h]) == 0 {
            H[h] = str
            return H
        }
    }
}



Measured memory_bytes: 45884
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

struct union_find {
	vector<int> uf;
	vector<int> num;

	union_find(int n):uf(2 * n, -1), num(2 * n, 0) {
		fill(num.begin(), num.begin() + n, 1);
	}

	inline bool root(int x) const {
		return uf[x] < 0;
	}

	inline int find(int x) {
		return root(x) ? x : uf[x] = find(uf[x]);
	}

	inline void unite(int x, int y) {
		x = find(x);
		y = find(y);

		if(x == y) return;

		if(uf[x] > uf[y]) {
			swap(x, y);
		}

		num[x] += num[y];
		uf[x] += uf[y];
		uf[y] = x;
	}

	inline int number_of_sets() const {
		return count_if(uf.begin(), uf.begin() + uf.size() / 2, [](int x) { return x < 0; });
	}
};

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

	for(int n, p1, p2; cin >> n >> p1 >> p2 && (n | p1 | p2);) {
		const int V = p1 + p2;
		union_find uf(V);

		bool has_no = false;
		rep(i, n) {
			int x, y;
			string s;
			cin >> x >> y >> s;
			--x; --y;

			if(s[0] == 'n') { // no
				y += V;
				has_no = true;
			}

			uf.unite(x, y);
			uf.unite(x + V, (y + V) % (2 * V));
		}

		if(p1 == 0) {
			cout << (has_no ? "no" : "end") << endl;
			continue;
		}

		if(p2 == 0) {
			if(has_no) {
				cout << "no" << endl;
				continue;
			}

			rep(i, V) {
				cout << i + 1 << endl;
			}
			cout << "end" << endl;
			continue;
		}

		const int m = uf.number_of_sets();

		vector<int> idx, a, b;
		idx.reserve(m);
		a.reserve(m);
		b.reserve(m);

		rep(i, V) {
			if(uf.root(i) || uf.root(i + V)) {
				idx.emplace_back(i);
				a.emplace_back(uf.num[i]);
				b.emplace_back(uf.num[i + V]);
			}
		}

		vector<vector<int>> dp(m + 1, vector<int>(V + 1, 0));
		dp[0][0] = 1;

		rep(i, m) {
			rep(j, V - a[i]) {
				dp[i + 1][j + a[i]] += dp[i][j];
			}

			rep(j, V - b[i]) {
				dp[i + 1][j + b[i]] += dp[i][j];
			}
		}

		if(dp[m][p1] != 1) {
			cout << "no" << endl;
			continue;
		}

		int sum = p1;
		vector<bool> which(m);
		for(int i = m - 1; i >= 0; --i) {
			if(dp[i][sum - a[i]] == 1) {
				which[i] = true;
				sum -= a[i];
			}
			else {
				which[i] = false;
				sum -= b[i];
			}
		}

		rep(i, V) {
			bool T = true;
			int r = uf.find(i);

			if(r >= V) {
				r = uf.find(r - V);
				T = false;
			}

			const int id = lower_bound(idx.begin(), idx.end(), r) - idx.begin();
			if(which[id] == T) cout << i + 1 << endl;
		}

		cout << "end" << endl;
	}

	return EXIT_SUCCESS;
}

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

using namespace std;

int main(){
    int x, y;
    while(scanf("%d%d", &x, &y) == 2 && x || y ){
        if(x > y) cout << y << " " << x << endl;
        else cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
/*
 *  Lang    : C++
 *  Author  : little_angel
 */
#include <bits/stdc++.h>

using namespace std;
#define int long long

int dp[3001][3001], a[3001];

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

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int l = n - 1; l >= 0; --l) {
        dp[l][l] = a[l];
        for (int r = l + 1; r < n; ++r)dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
    }
    cout << dp[0][n - 1] << endl;
}

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

int main(){
  int N,M,C;
  cin>>N>>M>>C;
  
  vector<int>B(M);
  
  int sum=0;
  
  
  for(int i=0;i<M;i++){
    cin>>B.at(i);
  }
  
 int x=0;
 
  
  for(int j=0;j<N;j++){
    int sum=0;
    vector<int> S(M);

  for(int i=0;i<M;i++){
    
 cin>>S.at(i);
    sum+=S.at(i)*B.at(i);
    
    if(i==M-1&&sum+C>0){
      
      x++;
    }
  }
  }
  
    cout<<x<<endl;
}

  
  
  

      
    
  
  
  
    
    
      
    
    



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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int a,b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
	return 0;
}



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

int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] && s[0] == s[2] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0 ;
}


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

char M[6][6];
int ans = 0;
int h, w, k;

void solve(int index, string str){
	if(index < str.size()){
		solve(index+1, str);
		str[index] = '1';
		solve(index+1, str);
	}
	else{
		char tmp[6][6];
		for(int i=0; i < h; i++)
			for(int j=0; j < w; j++) 
				tmp[i][j] = M[i][j];
		
		for(int i=0; i < h; i++)
			if(str[i] == '1')
				for(int j=0; j < w; j++) tmp[i][j] = '$';
		for(int j=0; j < w; j++)
			if(str[h+j] == '1')
				for(int i=0; i < h; i++) tmp[i][j] = '$';
		int c = 0;
		
		for(int i=0; i < h; i++)
			for(int j=0; j < w; j++)
				if(tmp[i][j] == '#') c++;

		if(c == k) ans++;
	}
}


int main(){
	cin >> h >> w >> k;
	
	for(int i=0; i < h; i++)
		for(int j=0; j < w; j++) cin >> M[i][j];
	
	string aux;
	for(int i=0; i < h+w; i++) aux += "0";
	solve(0, aux);

	cout << ans << endl;
}


Measured memory_bytes: 3640
/*
                                             ::                     ::
                                             ':                     :
                                              :.                    :
                                           ;' ::                   ::  '
                                          .'  ';                   ;'  '.
                                         ::    :;                 ;:    ::
                                         ;      :;.             ,;:     ::
                                         :;      :;:           ,;"      ::
                                         ::.      ':;  ..,.;  ;:'     ,.;:
                                          "'"...   '::,::::: ;:   .;.;""'
                                              '"""....;:::::;,;.;"""
                                          .:::.....'"':::::::'",...;::::;.
                                         ;:' '""'"";.,;:::::;.'""""""  ':;
                                        ::'         ;::;:::;::..         :;
                                       ::         ,;:::::::::::;:..       ::
                                       ;'     ,;;:;::::::::::::::;";..    ':.
                                      ::     ;:"  ::::::"""'::::::  ":     ::
                                       :.    ::   ::::::;  :::::::   :     ;
                                        ;    ::   :::::::  :::::::   :    ;
                                         '   ::   ::::::....:::::'  ,:   '
                                          '  ::    :::::::::::::"   ::
                                             ::     ':::::::::"'    ::
                                             ':       """""""'      ::
                                              ::                   ;:
                                              ':;                 ;:"


                                                     P_r_A_d_Y
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void cs(int &x)
{
    cout << "Case #" << x << ": ";
}
bool cmp(string a, string b)
{
    return a + b < b + a;
}
int n,m,q,ans=0;
vector<vector<int>>qw;
vector<int>v;
void help(int i,int val)
{
    if(i==n)
    {
        int cnt=0;
        for(int j=0;j<q;j++)
        {
            if(v[qw[j][1]-1]-v[qw[j][0]-1]== qw[j][2])
                cnt+=qw[j][3];
        }

        ans=max(ans,cnt);
        return ;
    }


    for(int p=val;p<=m;p++)
    {
        v[i]=p;
        help(i+1,p);
    }


}
int32_t main()
{
    fastIO;
    // int t; cin >> t;
    // int x = 1;
    // while (t--)
    // {

        cin>>n>>m>>q;
        qw.resize(q,vector<int>(4));
        v.resize(n);

        for(int i=0;i<q;i++)
        {
            cin>>qw[i][0]>>qw[i][1]>>qw[i][2]>>qw[i][3];
        }

        help(0,1);
        cout<<ans<<endl;

    //}
    return 0;
}


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

int main(void) {
	// in
	long long a, b;
	std::cin >> a >> b;

	bool is_a_even, is_b_even;
	is_a_even = (a % 2 == 0);
	is_b_even = (b % 2 == 0);
	
	int n_sector = 0;
	long long seed = 0;
	if(is_a_even) {
		if(!is_b_even) {
			n_sector = (b - a + 1) / 2;
			seed = 0;
		}
		else {
			n_sector = (b - a) / 2;
			seed = b;
		}
	}
	else {
		if(!is_b_even) {
			n_sector = (b - a) / 2;
			seed = a;
		}
		else {
			n_sector = (b - a - 1) / 2;
			seed = a ^ b;
		}
	}

	long long seed2 = (n_sector % 2 == 0 ? 0 : 1);
	long long f_ab = seed ^ seed2;

	std::cout << f_ab << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,i,d;
  scanf("%d",&a);
int b[a],c[a];
  
  for(i=0;i<a;++i)
  {
  scanf("%d",&b[i]);
    d=b[i]-1;
  c[d]=i+1;
  }

 for(i=0;i<a;++i)
 {printf("%d ",c[i]);}

return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

vector<lint> table[10];
void init(int d){
    lint x = d * 2; lint m = 0, c = 0;
    if(x > 9){
        x -= 9; c++;
    }
    while(x != d){
        table[d].push_back(c);
        x += d;
        if(x > 9){
            x -= 9; c++;
        }
    }
    table[d].push_back(c);
}

int main(){
    rep(d, 10) init(d);

    ii(M);
    lint res = 0; vector<lint> vec;
    rep(i, M){
        lint d, c; cin >> d >> c;
        if(c > 1){
            res += c - 1;
            lint s = table[d].size();
            lint p = table[d][(c-2) % s], q = table[d].back();
            res += ((c - 2) / s) * q + p;
        }
        lint t = d * c;
        while(t > 9){
            lint s = 0;
            while(t > 0){
                s += (t % 10); t /= 10;
            }
            t = s;
        }
        vec.push_back(t);
    }
    
    rep(i, M - 1){
        if(vec[i] + vec[i+1] > 9){
            res++;
            vec[i+1] -= 9;
        }
        res++; vec[i+1] += vec[i];
    }
    out(res);
}

Measured memory_bytes: 2424
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        for d in range(N//7 + 1):
            for c in range(N//4 + 1):
                if d*7 + c *4 == N:
                    print('Yes')
                    exit()
        print('No')


# Run main
if __name__ == '__main__':
    AtCoder().main()

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

int main() {
  int N;
  cin >> N ;
  
  int x = 0;
  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    x += (r - l) + 1;
	}    
  cout << x << endl;
}

Measured memory_bytes: 3524
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    int a, b, c; cin >> a >> b >> c;
    if ((a + b == c) || (a + c == b) || ( b + c == a)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

vector<ll> a;
vector<ll> p;

ll solve(ll n, ll x){
	if(n == 0 && x >= 1){
		return 1;
	}else if(x == 1){
		return 0;
	} else if (1 <= x && x <= 1 + a[n-1]){
		return solve(n-1, x-1);
	} else if (x == a[n-1] + 2){
		return p[n-1] + 1;
	} else if (2 + a[n-1] < x <= 2 + 2 *a[n-1]){
		return p[n-1] + 1 + solve(n-1, x-2-a[n-1]);
	} else if (x >= a[n-1] + 3){
		return 2 * p[n-1] + 1;
	}
}

int main(){
	ll n,x;
	cin >> n >> x;
	a.resize(n+1,0);
	p.resize(n+1,0);
	a[0] = 1;
	p[0] = 1;
	REP(i,n){
		a[i] = 2*a[i-1] + 3;
		p[i] = 2*p[i-1] + 1;
	}
	ll ans = solve(n, x);
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn calc(mut x: i32) -> i32 {
    let mut sum = 0;
    while x != 0 {
        sum += x % 10;
        x /= 10;
    }
    sum
}

fn main() {
    let v: Vec<i32> = read_vec();
    let (n, a, b) = (v[0], v[1], v[2]);
    let mut total = 0;
    for i in 1..n+1 {
        let sum = calc(i);
        if a <= sum && sum <= b {
            total += i;
        }
    }
    println!("{}", total);
}


Measured memory_bytes: 4352
import java.util.*;
 
public class Main {
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A = sc.nextLong();
		long B = sc.nextLong();
		if (B < A || (N == 1 && A != B)) {
			System.out.println(0);
		} else if (A == B) {
			System.out.println(1);
		} else {
			long min = A+B+(N-2)*A;
			long max = A+B+(N-2)*B;
			System.out.println(max-min+1);
		}
	}
}

Measured memory_bytes: 22868
N = int(input())
A = list(map(int, input().split()))
A_MAX = max(A)

def eratosthenes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    
    return [i for i in range(n+1) if is_prime[i]]

primecount = {}
primenum = [-1] * (A_MAX+1)
for p in eratosthenes(A_MAX):
    primecount[p] = 0
    for i in range(p, A_MAX+1, p):
        primenum[i] = p
    
for a in A:
    while a > 1:
        p = primenum[a]
        while a % p == 0:
            a //= p
        primecount[p] += 1

primecount[1] = 1
cnt = max(primecount.values())

if cnt == 1:    
    print('pairwise coprime')
elif cnt < N:
    print('setwise coprime')
else:
    print('not coprime')
        



Measured memory_bytes: 197876
/*input
10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double

typedef pair<int,int> pi;

typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define mp make_pair
#define pb push_back

#define gcd __gcd

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int n,i,j,k,l;
int a[300001];

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  cin >> n;
  n*=3;
  for(i = 0;i < n;i++)cin >> a[i];
  sort(a,a+n);
  i = 0;
  j = n-1;
  k = n-2;
  int ans = 0;
  while(i < k){
    ans += a[k];
    i++;
    j-=2;
    k-=2;
    //i++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll a,b,c,x,y;


int main(){
	cin>>a>>b>>c>>x>>y;
	
	ll s1 = a*x + b*y;
	ll s2 = c*2*x + b*(max(0LL,y-x));
	ll s3 = c*2*y + a*(max(0LL,x-y));

	cout<<min(s1,min(s2,s3))<<endl;

}


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

long long gcd(long x, long y)
{    if (y == 0)
        return x;
    return gcd(y, x % y);}
long long lcm(long x, long y){ return x * y / gcd(x, y);}

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


int main()
{
    int N,M,s[10]={};
    char c[10]={};
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>s[i]>>c[i];
    }

    for(int i=0;i<pow(10.0,N);i++){
        int f=0;
        string S = to_string(i);
        if(S.length()!=N)continue;
        for(int i=0;i<M;i++){
            if(S[s[i]-1]!=c[i]){
                f=1;
                break;
            }
        }

        if(f==0){
            cout<<i<<endl;
            return 0;
        }

    }
    cout<<-1<<endl;

    return 0;
}

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

int main() {
 int n,m=0;
  cin >> n;
 vector<int> v(n);
 for (int i=0;i<n;i++)
   cin >> v.at(i);
 sort(v.begin(),v.end());
 reverse(v.begin(),v.end());
 for(int i=0;i<n;i++) {
  for(int j=0;j<n;j++) {
    if (i==j)
      continue;
    if (v.at(i)==v.at(j))
      v.at(j)=0;
  }
 }
 for (int i=0;i<n;i++) {
   if(v.at(i)!=0)
     m++;
 }
 cout << m << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int eve[105];
int main()
{
	int a,sum=0,ans=0;cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>eve[i];
		sum+=eve[i];
	}
	double c=(double)sum/a+0.5;
	int k=floor(c);
	for(int i=1;i<=a;i++)
	{
		int m=abs(k-eve[i]);
		ans+=m*m;
	}
	cout<<ans;
}

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

int main(){
    int n;
    cin>>n;
    if(n/100==1){
        cout<<"9";
    }else if(n/100==9){
        cout<<"1";
    }else{
        cout<<n/100;
    }
    if((n%100)/10==1){
        cout<<"9";
    }else if((n%100)/10==9){
        cout<<"1";
    }else{
        cout<<(n%100)/10;
    }
    if(n%10==1){
        cout<<"9";
    }else if(n%10==9){
        cout<<"1";
    }else{
        cout<<n%10;
    }
    cout<<endl;
}


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

int main(){
  int N,K;
  cin >> N >> K;

  vector<int> perm(N);
  for(int i=0; i<N; i++){
    cin >> perm.at(i);
    perm.at(i)--; // 1-indexed -> 0-indexed
  }

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int logK= 31- __builtin_clz(K);
  vector<vector<int>> trans(logK+1, vector<int>(N)); // trans.at(d).at(v): 頂点vから 2^d回操作したあとの遷移先
  trans.at(0)= perm;
  for(int d= 1; d<= logK; d++){
    for(int i=0; i<N; i++){
      trans.at(d).at(i)= trans.at(d-1).at(trans.at(d-1).at(i));
    }
  }
  
  vector<vector<int64_t>> sums(logK+1, vector<int64_t>(N)); // sums.at(d).at(v): 頂点vから 2^d回操作したあとのスコア
  vector<vector<int64_t>> cummaxs(logK+1, vector<int64_t>(N)); // cummaxs.at(d).at(v): 頂点vから 1回以上2^d回以下操作したあとの最大スコア
  for(int d=0; d<= logK; d++){
    for(int i=0; i<N; i++){
      sums.at(d).at(i)= (d > 0) ? sums.at(d-1).at(i)+ sums.at(d-1).at(trans.at(d-1).at(i))
                                : data.at(trans.at(0).at(i));
      cummaxs.at(d).at(i)= (d > 0) ? max(cummaxs.at(d-1).at(i), sums.at(d-1).at(i)+ cummaxs.at(d-1).at(trans.at(d-1).at(i)))
                                   : data.at(trans.at(0).at(i));
    }
  }

  vector<int64_t> memoK(N); // memoK.at(v): 頂点vから 1回以上K回以下操作したあとのスコアの最大値
  for(int i=0; i<N; i++){
    int64_t score_i= INT64_MIN;
    int64_t walkthrough= 0;
    int v_walk= i;
    for(int d= logK; d>= 0; d--){
      if(K & (1<<d)){
        score_i= max(score_i, walkthrough+ cummaxs.at(d).at(v_walk));
        walkthrough+= sums.at(d).at(v_walk);
        v_walk= trans.at(d).at(v_walk);
      }
    }
    memoK.at(i)= score_i;
  }

  int64_t ans= INT64_MIN;
  for(auto score:memoK){
    ans= max(ans, score);
  }

  cout << ans << endl;
}

Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s = "abcdefghijklmnopqrstuvwxyz";
	
	char c; cin>>c;
	for(int i =0; i < int(s.size()); i++){
		if(s[i] ==c){
			cout<<s[i+1];
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[3005], t[3005];
int dp[3005][3005];
int pv1[3005][3005], pv2[3005][3005];
int main(){
    scanf("%s%s", s+1, t+1);
    int n = strlen(s+1), m = strlen(t+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i] == t[j]){
                dp[i][j] = dp[i-1][j-1] + 1;
                pv1[i][j] = i-1, pv2[i][j] = j-1;
            }
            if(dp[i][j] < dp[i][j-1]){
                dp[i][j] = dp[i][j-1];
                pv1[i][j] = i, pv2[i][j] = j-1;
            }
            if(dp[i][j] < dp[i-1][j]){
                dp[i][j] = dp[i-1][j];
                pv1[i][j] = i-1, pv2[i][j] = j;
            }
        }
    }
    if(dp[n][m] == 0){
        return 0;
    }
    int y = n, x = m;
    vector<char> ans;
    while(y > 0 && x > 0){
        int vy = y, vx = x;
        vy = pv1[y][x];
        vx = pv2[y][x];
        if(y-1 == vy && x-1 == vx) ans.push_back(s[y]);
        y = vy, x = vx;
    }  
    reverse(ans.begin(), ans.end());
    for(int i=0;i<ans.size();i++) printf("%c", ans[i]);
}

Measured memory_bytes: 105984
h, w = map(int, input().split())
s = [[0 if c == '#' else 1 for c in input()] for _ in range(h)]

directions = [(0, -1), (-1, 0), (0, 1), (1, 0)]
dist = [[-1 for _ in range(w)] for _ in range(h)]
dist[0][0] = 0
q = [(0, 0)]
for y, x in q:
    for dy, dx in directions:
        ny, nx = y + dy, x + dx
        if (ny < 0 or h <= ny) or (nx < 0 or w <= nx):
            continue
        if not s[ny][nx]:
            continue
        if dist[ny][nx] >= 0:
            continue
        dist[ny][nx] = dist[y][x] + 1
        q.append((ny, nx))

if dist[-1][-1] < 0:
    print(-1)
else:
    print(sum(sum(si) for si in s) - dist[-1][-1] - 1)

Measured memory_bytes: 9028
n = int(input())
h = list(map(int, input().split()))
for i in range(n - 1, 0, -1):
    if h[i] < h[i - 1]:
        h[i - 1] -= 1
for i in range(n - 1):
    if h[i] > h[i + 1]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 15020
#include<stdio.h>
#include<string.h>
int main() {

	
	
	int a, b, c;
	scanf("%d%d%d",&a,&b,&c);
	if((a>=c && c>=b) || (a<=c && c<=b ))
	printf("Yes");
	else printf("No");

	return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <bitset>

using namespace std;

int main(){
	int N;
	while(cin >> N){
		bitset<2000*2000> bits;
		bits.reset();
		bits.set(0, true);
		int sum = 0;
		for(int i=0;i<N;i++){
			int A; cin >> A;
			sum += A;
			bits |= bits << A;
		}
		for(int i=(sum+1)/2;;i++){
			if(bits[i]){ cout << i << endl; break; }
		}
	}
}


Measured memory_bytes: 1792
// Problem : F - XOR Tree
// Contest : AtCoder Petrozavodsk Contest 0...
// URL : https://apc001.contest.atcoder.jp/tasks/apc001_f
// Memory Limit : 256.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
#define range(i, s, t)  for (int (i) = s; (i) <= (int)t; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c;
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
int n;
const int N = 100010;
int val[N], cnt[N], done[N], dp[N];
int main() {
	n = qread();
	rep(i, n - 1) {
		int u = qread(), v = qread(), a = qread();
		val[u] ^= a; val[v] ^= a;
	}
	int ans = 0;
	rep(i, n) {
		cnt[val[i]]++;
	}
	repn(i, 15) {
		ans += cnt[i] / 2;
		cnt[i] %= 2;
	}
	int msk = 0;
	repn(i, 15) if (cnt[i] == 1) msk |= lsh(i);
	rep(i, lsh(16)) {
		int x = 0;
		rep(j, 16) 
			if (i & lsh(j)) {
				x ^= j;
			}
		done[i] = (x == 0);
	}
	rep(i, lsh(16)) {
		if (i & 1) continue;
		int j = i;
		while (j > 0) {
			if (done[j]) {
				dp[i] = max(dp[i], dp[i ^ j] + 1);
			}
			j = i & (j - 1);
		}
	}
	cout << ans + __builtin_popcount(msk) - dp[msk] << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
using namespace std;

int main() {
	char X, Y;
	cin >> X >> Y;
	if (int(X) > int(Y))cout << ">";
	else if (int(X) < int(Y))cout << "<";
	else cout << "=";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    // 同じ長さの組を探して最大の2つを取り出す
    sort(a.begin(), a.end(), greater<>());
    vi candidate;
    int64_t temp = 1;
    rep(i,n-1){
        if((a.at(i) != a.at(i+1))){
            if(temp>=4){
                candidate.push_back(a.at(i));
                candidate.push_back(a.at(i));
            }else if(temp<4 && temp>=2){
                candidate.push_back(a.at(i));
            }
            temp = 1;
            continue;
        }
        temp++;
        if(i == n-2){
            if(temp>=4){
                candidate.push_back(a.at(i));
                candidate.push_back(a.at(i));
            }else if(temp<4 && temp>=2){
                candidate.push_back(a.at(i));
            }
        }
    }
    if(candidate.size()>=2){
        cout << candidate.at(0) * candidate.at(1) << endl;
    }else{
        cout << 0 << endl;
    }
}

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

using namespace std;

#define MAX_N 105
int N,T;

int main(){
    int c,t;
    while(cin >> N >> T){
        int ans = INT_MAX;
        for(int i = 1; i <= N; ++i){
            cin >> c >> t;
            if(t <= T) ans = min(ans, c);
        }
        if(ans == INT_MAX) cout << "TLE" << endl;
        else cout << ans << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int a[200001];

int main(){
    cin >> N;
    for(int i=1;i<N;i++) cin >> a[i];
    map<int,int> mp;
    for(int i=1;i<N;i++){
        mp[i] = 0;
    }
    for(int i=1;i<N;i++){
        mp[a[i]]++;
    } 
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        cout << itr->second << endl;
    }
    cout << 0 << endl;
}


Measured memory_bytes: 13788
#include<bits/stdc++.h>
using namespace std;
int main()
{	int a,b,c;
	cin>>a>>b;
	for(int i=b/a;;i++)
	{
		if(i*a-(i-1)>=b)
		{
			c=i;
			break;
		}
			
	}
	cout<<c;
}

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

#define N 16

int map[ N ][ N ];
int w, h;
int k_operafan[ N ][ N ];

int dpFSA (
  int x,
  int y
  )
{
  if ( x < 0 || y < 0 || x >= w )
  {
    return ( 0 );
  }
  else if ( y >= h )
  {
    return ( 1 );
  }
  else if ( ~k_operafan[ x ][ y ] ) ;
  else if ( map[ x ][ y ] == 1 )
  {
    k_operafan[ x ][ y ] = 0;
  }
  else if ( map[ x ][ y ] == 2 )
  {
    k_operafan[ x ][ y ] = dpFSA ( x, y + 2 );
  }
  else if ( y == h - 1 )
  {
    k_operafan[ x ][ y ] = 1;
  }
  else
  {
    k_operafan[ x ][ y ] = ( map[ x - 1 ][ y + 1 ] == 2
                           ? 0 : dpFSA ( x - 1, y + 1 ) )
                         + dpFSA ( x, y + 1 )
                         + ( map[ x + 1 ][ y + 1 ] == 2
                           ? 0 : dpFSA ( x + 1, y + 1 ) );
  }

  return ( k_operafan[ x ][ y ] );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int x, y;

  for ( ; ; )
  {
    int res = 0;

    scanf ( "%d%d", &w, &h );
    if ( !( w | h ) ) break ;

    for ( y = 0; y < h; ++y )
    for ( x = 0; x < w; ++x )
    {
      scanf ( "%d", &map[ x ][ y ] );
    }

    memset ( k_operafan, -1, sizeof ( k_operafan ) );
    for ( x = 0; x < w; ++x )
    {
      res += dpFSA ( x, 0 );
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0