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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

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

    int N, K, Q;
    cin >> N >> K >> Q;

    vi a(N), order(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        order[i] = i;
    }

    auto sort_inx = [&a](vi& v) {
        sort(all(v), [&](int i, int j) {
            return a[i] < a[j];
        });
    };

    sort_inx(order);

    int ans = INT_MAX;
    for (int l = 0; l + Q <= N; l++) {
        vi take;
        auto store = [&](vi& cur) {
            sort_inx(cur);
            for (int t = 0; t < int(cur.size()) - K + 1; t++)
                take.push_back(cur[t]);
            cur.clear();
        };

        vi cur;
        for (int i = 0; i < N; i++) {
            if (a[i] < a[order[l]]) {
                store(cur);
            } else {
                cur.push_back(i);
            }
        }
        store(cur);

        sort_inx(take);
        if (take.size() >= Q) {
            ans = min(ans, a[take[Q - 1]] - a[take[0]]);
        }
    }

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



Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  ll n;
  cin >> n;
  ll ans = 0; 
  ll c = 0;
  while (n){
    n = n >> 1ll;
    ans += 1ll << c;
    c++;
  }
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

Measured memory_bytes: 256
import sys
S = int(input())

if S == 1000000000000000000:
    print(0, 0, 0, 1000000000, 1000000000, 0)
    sys.exit()

x2 = 10 ** 9
y2 = 1

x3 = S % x2
y3 = S // (x2)

x3 = x2 - x3
y3 += 1
print(0, 0, x2, y2, x3, y3)

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

using namespace std;
using ll = long long int;
using p = pair<int, ll>;

bool judge(const vector<int> &target)
{
  for(auto e : target)
  {
    if(e > 1)
    {
      return false;
    }
  }
  return true;
}

int main()
{
  int n, m;
  ll mod = 1000000007;
  cin >> n >> m;
  vector<int> a(n * m + 1, 0);
  vector<int> b(n * m + 1, 0);
  for(int i = 0; i < n; i++)
  {
    int temp;
    cin >> temp;
    a[temp]++;
  }
  for(int j = 0; j < m; j++)
  {
    int temp;
    cin >> temp;
    b[temp]++;
  }

  //不可能性の判定
  bool cana = judge(a);
  bool canb = judge(b);
  if(!cana && !canb)
  {
    cout << 0 << endl;
    return 0;
  }

  //累積和を計算
  vector<int> asum = a;
  vector<int> bsum = b;
  for(int i = 1; i <= n * m; i++)
  {
    asum[i] += asum[i - 1];
    bsum[i] += bsum[i - 1];
  }

  /*
   * 大きい方から埋めていくことを考える
   * もし埋めたい数字xがAとBの条件に現れているなら置く場所は一意に決まる(重複なく置くからそこに置かないと置く場所がない)
   * xがAにのみ現れる場合
   * このときxを置くことができるのはx < Biとなっている列に置くことができる
   * xがBにのみ現れる場合も同様でx < Aiとなっている行に置くことができる
   * xがAにもBにも現れない場合
   * xを置くことができるのはx < Aiとなっている行の数*x < Biとなっている列の数
   * このときすでにN * M - x個が置かれているのでそれを引く
   */
  ll result = 1;
  for(ll i = n * m; i > 0; i--)
  {
    if(a[i] == 1 && b[i] == 1)
    {
      result = result;
    }else if(a[i] == 1){
      result = (result * (bsum[n * m] - bsum[i])) % mod;
    }else if(b[i] == 1){
      result = (result * (asum[n * m] - asum[i])) % mod;
    }else{
      ll temp = (asum[n * m] - asum[i]) * (bsum[n * m] - bsum[i]);
      temp -= n * m - i;
      result = (result * temp) % mod;
    }
  }
  cout << result << endl;
  return 0;
}


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

int main(){
    ll n,h1,h2,ans=0,sum=0;
    cin>>n;
    cin>>h1;
    rep(i,n-1){
     cin>>h2;
     if(h1>=h2){
         sum++;
     }else{
         sum=0;
     }
     ans=max(ans,sum);
     h1=h2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        a: i64,
        b: i64,
        t: i64
    }

    println!("{}", (t / a) * b);
}



Measured memory_bytes: 4352
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>

using namespace std;


int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	int ans = 0;
	ans += x;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		ans += ((d - 1) / a) + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int dist_t[100010];
int dist_a[100010];

int n, v, u;
vector<int> g[100010];

void bfs(int s, int dist[100010]){
    queue<int> que;
    bool seen[100010];
    memset(seen, 0, sizeof(seen));
    que.push(s);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        if (seen[v]) continue;
        seen[v] = true;
        for(auto nv : g[v]){
            if (seen[nv]) continue;
            dist[nv] = dist[v]+1;
            que.push(nv);
        }
    }
}

int main(){
    cin >> n >> u >> v;
    u--, v--;
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    bfs(u, dist_t);
    bfs(v, dist_a);

    int ans = 0;
    rep(i, n){
        // cout << dist_t[i] << " " << dist_a[i] << endl;
        if (dist_a[i] > dist_t[i]) ans = max(ans, dist_a[i]-1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10044
# https://atcoder.jp/contests/abc126_b
# YYMM or MMYY


def is_month(n):
    return 1 <= n <= 12


S = input().strip()
n_upper = int(S[:2])
n_lower = int(S[2:])

if is_month(n_upper) and is_month(n_lower):
    print("AMBIGUOUS")
elif is_month(n_upper):
    print("MMYY")
elif is_month(n_lower):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int n,a[10];
int solve(int now,int num,int sum){
	if(now==n) return sum%2==0;
	int cnt=0;
	for(int i=num-1;i<=num+1;++i){
		cnt+=solve(now+1,a[now+1],sum*i);
	}
	return cnt;
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		scanf("%d",&a[i]);
	}
	int ans=0;
	ans=solve(0,a[0],1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

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

int main(){
    int h, w; cin >> h >> w;
    vector<string> grid(h);
    rep(i, h)cin >> grid[i];

    bool fg = true;
    rep(i, h){
        rep(j, w){
            if(grid[i][j]=='.')continue;
            bool ok = false;
            rep(k, 4){
                int y = i + dy[k], x = j + dx[k];
                if(y<0 or x<0 or y==h or x==w)continue;
                if(grid[y][x]=='#')ok = true;
            }
            if(!ok)fg = false;
        }
    }
    if(fg) cout << "Yes" << ln;
    else cout << "No" << ln;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int k,x,m;
 	cin>>k>>x;
 	m=k*500;
 	if(m>=x)
 		cout<<"Yes"<<endl;
 	else
 		cout<<"No"<<endl;
 	
	 	
 	return 0;
}
 	
 					

Measured memory_bytes: 3496
N = int(input())
X = list(map(int,input().split()))
ans = (100**2)*100
total = 0
for i in range(min(X),max(X)+1):
    for i2 in range(N):
        total += (X[i2] - i)**2
    if total <= ans:
        ans = total
    total = 0

print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

static class AFigureOnSurface
{
    static void Main()
    {
        var figures = new[] {
            new[] { 1,  8,  9 },
            new[] { 8, 16, 24 },
            new[] { 1,  2,  3 },
            new[] { 7,  8, 15 },
            new[] { 1,  9, 10 },
            new[] { 8,  9, 17 },
            new[] { 1,  7,  8 },
        };
        var input = Console.In.ReadToEnd()
            .Split( 
                new[] { '\r', '\n' },
                StringSplitOptions.RemoveEmptyEntries )
            .Select( (x, i) => new { row = x, k = i >> 3 } )
            .GroupBy( x => x.k, x => x.row )
            .Select( x => x.SelectMany( y => y ).ToArray() );
        var q = 
            from s in input
            let p = Enumerable.Range( 0, 64 )
                .Where( x => s[x] == '1' )
                .First()
            let match = figures
                .Select( (x, i) => new { fig = x, i } )
                .Where( x => p + x.fig[2] < 64 )
                .Where( x => x.fig.All( y => s[p + y] == '1' ) )
                .First()
            select (char)( 'A' + match.i );
        q.ToList().ForEach( Console.WriteLine );
    }
}

Measured memory_bytes: 6676
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct Cmb
{
	void init(long n)
	{
		long powmod(long a, long p)
		{
			long ans = 1;
			long mul = a;
			while (p > 0)
			{
				if ((p & 1) == 1)
					ans.modm(mul);
				p >>= 1;
				mul.modm(mul);
			}
			return ans;
		}

		++n;
		fact = new long[2][](n);
		fact[0][0] = 1;
		foreach (i; 1..n)
		{
			fact[i][0] = fact[i-1][0];
			fact[i][0].modm(i);
		}
		fact[n-1][1] = powmod(fact[n-1][0], mod - 2);
		foreach_reverse (i; 0..n-1)
		{
			fact[i][1] = fact[i+1][1];
			fact[i][1].modm(i+1);
		}
	}

	long get(long n, long r)
	{
		long res = fact[n][0];
		res.modm(fact[r][1]);
		res.modm(fact[n-r][1]);
		return res;
	}

	long[2][] fact;
}

void main()
{
	auto X = RD;
	auto Y = RD;

	if ((X+Y) % 3 == 0 && min(X, Y)*2 >= max(X, Y))
	{
		Cmb cmb;
		cmb.init(max(X, Y));
		auto num = (X+Y) / 3;
		auto a = min(X, Y);
		auto b = max(X, Y);
		auto d = (b - a) / 2;
		auto ans = cmb.get(num, num/2 - d);
		writeln(ans);
	}
	else
		writeln(0);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 17788
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

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

	let mut ans = 0;
	// 正正正
	let mut v1 = vec![0isize; n];
	for i in 0..n {
		v1[i] = xyz[i].0 + xyz[i].1 + xyz[i].2; 
	}
	v1.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..m {
		sum += v1[i];
	}
	ans = max(ans, sum);

	// 正正負
	for i in 0..n {
		v1[i] = xyz[i].0 + xyz[i].1 - xyz[i].2; 
	}
	v1.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..m {
		sum += v1[i];
	}
	ans = max(ans, sum);

	// 正負正
	for i in 0..n {
		v1[i] = xyz[i].0 - xyz[i].1 + xyz[i].2; 
	}
	v1.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..m {
		sum += v1[i];
	}
	ans = max(ans, sum);

	// 正負負
	for i in 0..n {
		v1[i] = xyz[i].0 - xyz[i].1 - xyz[i].2; 
	}
	v1.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..m {
		sum += v1[i];
	}
	ans = max(ans, sum);

	// 負正正
	for i in 0..n {
		v1[i] = - xyz[i].0 + xyz[i].1 + xyz[i].2; 
	}
	v1.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..m {
		sum += v1[i];
	}
	ans = max(ans, sum);

	// 負正負
	for i in 0..n {
		v1[i] = - xyz[i].0 + xyz[i].1 - xyz[i].2; 
	}
	v1.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..m {
		sum += v1[i];
	}
	ans = max(ans, sum);

	// 負負正
	for i in 0..n {
		v1[i] = - xyz[i].0 - xyz[i].1 + xyz[i].2; 
	}
	v1.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..m {
		sum += v1[i];
	}
	ans = max(ans, sum);

	// 負負負
	for i in 0..n {
		v1[i] = - xyz[i].0 - xyz[i].1 - xyz[i].2; 
	}
	v1.sort_by_key(|&x| std::cmp::Reverse(x));
	let mut sum = 0;
	for i in 0..m {
		sum += v1[i];
	}
	ans = max(ans, sum);

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


Measured memory_bytes: 2240
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

ll f(ll x){
	while(x%10 == 0)x /= 10;
	return x;
}

int main(){
	ll l = 10000000000, r = 99999999999;
	while(l < r){
		ll m = (l+r)/2;
		printf("? %lld",m);
		cout << endl;
		char c;
		cin >> c;
		if(c == 'Y'){
			r = m;
		}
		else l = m+1;
	}
	
	ll A = l;
	A = f(A);
	ll B = A+1;
	if(f(B) == 1){
		B -= 2;
		B *= 10;
		while(1){
			printf("? %lld",B);
			cout << endl;
			char c;
			cin >> c;
			if(c == 'N'){
				printf("! %lld",A);
				cout << endl;
				return 0;
			}
			else {
				A *= 10;
				B *= 10;
			}
		}
	}
	while(1){
		printf("? %lld",B);
		cout << endl;
		char c;
		cin >> c;
		if(c == 'Y'){
			printf("! %lld",A);
			cout << endl;
			return 0;
		}
		else {
			A *= 10;
			B *= 10;
		}
	}
}



Measured memory_bytes: 596
import java.util.*;
public class Main {
	//1100 start
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int w = sc.nextInt();
			if((w|n) == 0) break;
			int [] data = new int[11];
			for(int i = 0; i < n; i++){
				int v = sc.nextInt();
				data[v / w]++;
			}
			
			for(int i = data.length -1; i >= 0; i--){
				if(data[i] > 0){
					n = i + 1;
					break;
				}
			}
			int max = 0;
			for(int i = 0; i < n; i++){
				max = Math.max(max, data[i]);
			}
			
			double sum = 0.01;
			for(int i = 0 ; i< n; i++){
				double value;
				if(n == 1){
					value = (double)data[i] / max;
				}
				else{
					value = (double)data[i] / max * ((double)(n-1 - i) / (n - 1)) ;
				}
				//System.out.println("value = " + value + " n= " + n);
				sum += value;
			}
			System.out.println(sum);
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


int main() {
	ll n;
	cin >> n;
	cout << n * n * 3 << endl;
}





Measured memory_bytes: 764
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int find_cycle(int a, int m)
{
	int f = 0, x = 1;
	while(1)
	{
		++f;
		x = (a*x)%m;
		if(x == 1)
		{
			break;
		}
	}
	return f;
}
ll gcd(ll a, ll b)
{
	if( b == 0 )
	{
		return a;
	}
	else
	{
		return gcd(b, a%b);
	}
}

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

int main()
{
	int a1, a2, a3, m1, m2, m3;
	while(scanf("%d%d%d%d%d%d", &a1, &m1, &a2, &m2, &a3, &m3) != EOF)
	{
		if(a1 == 0)
		{
			break;
		}
		ll fx = find_cycle(a1, m1), fy = find_cycle(a2, m2), fz = find_cycle(a3, m3);

		cout << lcm(fx, lcm(fy, fz)) << endl;
	}
}

Measured memory_bytes: 1208
s = gets.strip

words = ["dream", "dreamer", "erase", "eraser"]

until s.empty? do
  reduced = false
  words.map do |w|
    if s[-w.size, w.size] == w
      s = s[0..-w.size - 1]
      reduced = true
      break
    end
  end

  unless reduced
    puts "NO"
    exit 0
  end
end

puts "YES"

Measured memory_bytes: 56304
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 123450
#endif

int N,M,Q;
set<string> S;

void solve() {
    cin>>N;
    string s;
    REP(i,N) {
        cin>>s;
        S.insert(s);
    }
    
    cout << S.size() << endl;
}

Measured memory_bytes: 19212
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
typedef priority_queue<int> p_queue;
typedef long long ll;
ll n,cnt;
ll lastpos;
struct robot{
	ll x;
	ll l;
}a[100010];
bool cmp(robot x,robot y){
	return (x.x+x.l)<(y.x+y.l);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].x>>a[i].l;
	}
	sort(a,a+n,cmp);
	int pos=0;
	ll num=-1e9;
	while(pos<n){
		if(a[pos].x-a[pos].l>=num)cnt++,num=a[pos].x+a[pos].l;
		pos++;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {

	int n, i, x;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		
		x = i;

		if (x % 3 == 0) {

			printf(" %d", i);
			continue;
		
		}

		do {


			if (x % 10 == 3) {

				printf(" %d", i);
				break;

			}

			else {
				x /= 10;
			}

		} while (x != 0);

		
	}

	printf("\n");
	
	return(0);

}


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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(0,i,n) cin>>a[i];
    int count = 0;
    bool even = true;
    while(even == true){
        rep(0,i,n){
            if(a[i]%2==0){
                a[i] /= 2;
            }else{
                even = false;
                break;
            }
        }
        if(even==false) break;
        count++;
    }
    cout << count << endl;
}

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

int main()
{
    int64_t N;
    int64_t P = 1;
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        P *= i;
        P %= 1000000007;
    }

    cout << P;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include<vector>
#include<numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
	int N;
	cin >> N;
	vector<int> B(N);
	rep(i, N-1) cin >> B.at(i);

	vector<int> A(N);

	rep(i, N){
		if (i == 0) A.at(0) = B.at(0);
		else if (i == N-1){
			A.at(i) = B.at(i-1);

		}
		else{
			A.at(i) = min(B.at(i-1), B.at(i));
		}
	}
	//rep(i, N) printf("%d ", A.at(i));
	//printf("\n");

	printf("%d\n", accumulate(A.begin(), A.end(), 0));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
   	ll n;
   	cin>>n;
	vector<ll> a(n+1),p(n+1,0);
	repA(i,1,n)
	{
		cin>>a[i];
		p[i]=p[i-1]+a[i];
		p[i]%=INF;
	}	
	ll ans=0;
	repA(i,1,n-1)
	{
		ll val=(a[i]%INF*((p[n]-p[i]+INF)%INF))%INF;
		ans+=val;
		ans%=INF;
	}
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 6368
def solve(a, b):
  if a % b == 0:
    return b
  else:
    return solve(b, a % b)
  
while True:
  try:
    a, b = map(int, input().split())
    lcm = solve(a,b)
    print(lcm, a * b // lcm)

  except:
    break
 


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

using namespace std;

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

bool dp[201010] = {0};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  dp[0] = true;
  vector<int> v({100, 101, 102, 103, 104, 105});
  int n = 6;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < x; j++) dp[j + v[i]] |= dp[j];
  }
  cout << dp[x] << endl;
  return 0;
}


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

using namespace std;

const int mod=1e9+7;

int main (){
	int h,w;
	cin >> h >> w;
	vector<string> grid(h);
	vector<vector<int>> dp(h, vector<int>(w,0));
	dp[0][0]=1;
	for(int i=0; i<h; ++i) cin >> grid[i];
	for(int i=0; i<h; ++i){
		for(int j=0; j<w; ++j){
			if(grid[i][j]=='.'){
				if(i+1<h) dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
				if(j+1<w) dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
			}
		}
	}
	cout << dp[h-1][w-1]%mod;
	return 0;
}



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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(auto& x : s)
        cin >> x;
    vector<vector<int>> edges(n);
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            if(s[i][j] == '1')
                edges[i].emplace_back(j);

    vector<int> col(n, -1);
    function<bool(int,int)> f = [&](int pos, int c){
        if(col[pos] != -1 && col[pos] != c)
            return false;
        if(col[pos] == -1)
            col[pos] = c;
        else if(col[pos] == c)
            return true;
        for(auto& ed : edges[pos]){
            if(!f(ed, !c))
                return false;
        }
        return true;
    };
    if(!f(0, 0)){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    for(int i = 0; i < n; ++i){
        vector<int> range(n, MOD);
        range[i] = 0;
        priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> que;
        que.emplace(0, i);
        while(!que.empty()){
            int t = que.top().second;
            que.pop();
            for(auto& ed : edges[t]){
                if(range[t] + 1 < range[ed]){
                    range[ed] = range[t] + 1;
                    que.emplace(range[ed], ed);
                }
            }
        }
        ans = max(ans, *max_element(range.begin(), range.end()) + 1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int x, i = 1;
    while (true)
    {
        cin >> x;
        if (x == 0)
        {
            break;
        }
        cout << "Case " << i << ": " << x << endl;
        i++;
    }

    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
int  pow(int x,int n) {int res=1; while(n){if(n&1) res=(res*x);x=(x*x);n>>=1;}return res;}
 
 int max_price(int arr[], int price[],int n , int w ){

 		int dp[n+1][w+1];
 		for(int i=0 ; i<=n ; i++){

 			for(int  j=0 ; j<=w ; j++){
 		if(i==0 || j==0) dp[i][j]=0;
 		else {

 		int inc=0, ex=0;
 		if(j>=arr[i])
 		inc = price[i] + dp[i-1][j-arr[i]];
 		ex = dp[i-1][j];
 		dp[i][j]=max(inc, ex);

 			}

 		}
 	}

	return dp[n][w];

 }
int32_t main()
{
	//paawan9s
	FIO;
	int n, w; cin>>n>>w;
	 mk(arr, n+1, int );
	 mk(price , n+1, int );
	 for(int i=1;i<=n;i++){
	 	cin>>arr[i];
	 	cin>>price[i];
	 	// cout<< arr[i]<< " "<< price[i]<< endl;
	 }
	 // for(int i=0;i<n;i++ ) cout<< arr[i];

	 cout<< max_price(arr, price, n, w);
	return 0;
}

Measured memory_bytes: 79232
#N = str(input())
N,A,B = map(int,input().split())
#X=list(map(int,input().split()))

if A==0:
    print(0)
    exit()
else:
    b=N//(A+B)
    x=N%(A+B)

    if x>A:
        print(b*A+A)
    else:
        print(b*A+x)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
#define max 6
int A[6];
int trace(int num[],int n)
{
	for(int k=0;k<n;k++)
	{
		if(k>0)
		cout<<" ";
		cout<<A[k];
	}
	cout<<endl;
}
int insertionSort(int num[],int n)
{
	for(int i=1;i<n;i++)
	{
		int v=num[i];
		int j=i-1;
		while(j>=0&&(num[j]>v))
		{
			num[j+1]=num[j];
			num[j--]=v;
		}
		trace(num,n);
	
	}
	return 0;
}
int main()
{
	int nn;
	cin>>nn;
	for(int i=0;i<nn;i++)
	{
		cin>>A[i];
	}
	trace(A,nn);
	
	
	insertionSort(A,nn);

	return 0;
}


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var count = s[0] == 'R' ? 1 : 0;

            for(int i = 1; i < 3; i++) {
                if(s[i] == 'R' && s[i - 1] == 'R') {
                    count++;
				} else if(s[i] == 'R') {
                    count = Math.Max(1, count);
				} else {
                    count = Math.Max(0, count);
                }
			}

            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 25860
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll unsigned long long int
typedef pair<ll,ll> p; 
 

int main() {
ll n,m;
string s;
cin>>n>>m;
if(n>=m)
    {
        while(n--)
        {
            s=s+to_string(m);
        }
    }
else
  {
        while(m--)
        {
            s=s+to_string(n);
        }
    }
cout<<s<<endl;
    
}

Measured memory_bytes: 256
function main(input) {
    var  input = input.split(/\n/).map(n => n.split(" ").map(v => +v));
    var N = input[0];
    var ans ="No";
    for (var i = 1; i<=N-2 ; i++){
        if (input[i][0]==input[i][1] && input[i+1][0]==input[i+1][1] && input[i+2][0]==input[i+2][1]) ans="Yes"        
    }

    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29696
#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
#include <set>
#include <vector>

using namespace std;

#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
public:
  double x, y;
  Point() {};
  Point(double x, double y): x(x), y(y) {}

  Point operator + (const Point &p) { return Point(x + p.x, y + p.y); }
  Point operator - (const Point &p) { return Point(x - p.x, y - p.y); }
  Point operator * (double d) { return Point(d * x, d * y); }
  Point operator / (double d) { return Point(x / d, y / d); }

  bool operator < (const Point &p) const {
    return (x != p.x ? x < p.x : y < p.y);
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

  friend ostream& operator << (ostream &os, Point &p) {
    return os << "Point(" << p.x << ", " << p.y << ")";
  }
};

class Segment {
public:
  Point p1, p2;
  Segment(Point p1, Point p2): p1(p1), p2(p2) {}
  friend ostream& operator << (ostream &os, Segment &seg) {
    return os << "<" << seg.p1 << ", " << seg.p2 << ">";
  }
};

#define BOTTOM 0
#define LEFT 1
#define RIGHT 2
#define TOP 3

class EP {
public:
  Point p;
  int id, st;
  EP() {}
  EP(Point p, int id, int st): p(p), id(id), st(st) {}
  bool operator < (const EP &ep) const {
    return (p.y == ep.p.y ? st < ep.st : p.y < ep.p.y);
  }
};

int manhattan_geo(vector<Segment> s) {
  vector<EP> EPs(s.size() * 2);

  for (int i = 0, k = 0; i < s.size(); i++) {
    if (s[i].p1.y == s[i].p2.y) {
      if (s[i].p1.x > s[i].p2.x) swap(s[i].p1, s[i].p2);
    } else if (s[i].p1.y > s[i].p2.y) swap(s[i].p1, s[i].p2);

    if (s[i].p1.y == s[i].p2.y) {
      EPs[k++] = EP(s[i].p1, i, LEFT);
      EPs[k++] = EP(s[i].p2, i, RIGHT);
    } else {
      EPs[k++] = EP(s[i].p1, i, BOTTOM);
      EPs[k++] = EP(s[i].p2, i, TOP);
    }
  }

  sort(EPs.begin(), EPs.end());

  set<int> bin_tree;
  int cnt = 0;

  for (int i = 0; i < EPs.size(); i++) {
    if (EPs[i].st == TOP) {
      bin_tree.erase(EPs[i].p.x);
    } else if (EPs[i].st == BOTTOM) {
      bin_tree.insert(EPs[i].p.x);
    } else if (EPs[i].st == LEFT) {
      set<int>::iterator b = bin_tree.lower_bound(s[EPs[i].id].p1.x);
      set<int>::iterator e = bin_tree.upper_bound(s[EPs[i].id].p2.x);
      cnt += distance(b, e);
    }
  }

  return cnt;
}

int main() {
  int n; cin >> n;
  vector<Segment> s;

  for (int i = 0; i < n; i++) {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    s.push_back(Segment(Point(x1, y1), Point(x2, y2)));
  }

  cout << manhattan_geo(s) << endl;
}

Measured memory_bytes: 14996
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

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

    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<int> dp(n + 1);
    deque<pair<int, int>> q;
    dp[n] = 0;
    q.push_back({n, 0});
    for (int i = n - 1; i >= 0; i--) {
        if (q.front().first - i > k) {
            q.pop_front();
        }
        if (s[i] == '1') {
            dp[i] = INT_MAX;
        } else {
            dp[i] = min(q.front().second + 1, (int)INT_MAX);
        }
        while (!q.empty() && q.back().second > dp[i]) {
            q.pop_back();
        }
        q.push_back({i, dp[i]});
    }
    if (dp[0] == INT_MAX) {
        cout << -1 << '\n';
        return 0;
    }
    vector<int> spisok;
    for (int i = 0; i <= n; i++) {
        if (s[i] == '0') {
            spisok.push_back(i);
        }
    }
    int ind = 0;
    int j = 0;
    while (ind != spisok.size() - 1) {
        while (dp[spisok[ind]] != dp[spisok[j]] + 1) {
            j++;
        }
        cout << spisok[j] - spisok[ind] << ' ';
        ind = j;
    }
    cout << '\n';

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 5920
import bisect

n = 10**5
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

num = [0] * (n + 1)

cnt = 0
for i in range(n + 1):
    if is_prime[i] and (i + 1) // 2 > 0:
        if is_prime[(i + 1) // 2]:
            cnt += 1
    num[i] = cnt

Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]

for l, r in LR:
    print(num[r] - num[l - 1])

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

n,m=map(int,input().split())
boola=[False]*(n+1)
boolb=[False]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  if b==n: boola[a]=True
  if a==1: boolb[b]=True

for i in range(2,n):
  if boola[i] and boolb[i]:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")

Measured memory_bytes: 6132
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int N, K;
double A[200000 + 10];

bool check(double l){
    int res = 0;
    for (int i = 0; i < N; ++i){
        res += (int)(ceil(A[i] / l)) - 1;
    }
    return res <= K;
}

int main() {
	cin >> N >> K;
    for (int i = 0; i < N; ++i){
        cin >> A[i];
    }

    double l = 0.0, m, r = 1e9+10;
    for (int i = 0; i < 1000; ++i){
        m = (l + r) / 2;
        if (check(m)){
            r = m;
        }else{
            l = m;
        }
    }

    cout << (int)ceil(m) << endl;     
	return 0;
}

Measured memory_bytes: 5244
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    ll h, w;
    ll ans = inf;
    cin >> h >> w;
    chmin(ans, (h % 3 ? w : 0));
    chmin(ans, (w % 3 ? h : 0));
    if(ans == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll h3 = h / 3;
    chmin(ans, max({h3 * w, (h - h3) * (w / 2), (h - h3) * (w - w / 2)}) -
                   min({h3 * w, (h - h3) * (w / 2), (h - h3) * (w - w / 2)}));
    h3++;
    chmin(ans, max({h3 * w, (h - h3) * (w / 2), (h - h3) * (w - w / 2)}) -
                   min({h3 * w, (h - h3) * (w / 2), (h - h3) * (w - w / 2)}));
    swap(h, w);
    h3 = h / 3;
    chmin(ans, max({h3 * w, (h - h3) * (w / 2), (h - h3) * (w - w / 2)}) -
                   min({h3 * w, (h - h3) * (w / 2), (h - h3) * (w - w / 2)}));
    h3++;
    chmin(ans, max({h3 * w, (h - h3) * (w / 2), (h - h3) * (w - w / 2)}) -
                   min({h3 * w, (h - h3) * (w / 2), (h - h3) * (w - w / 2)}));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (110)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
T1 mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  T1 tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

bool isPrime(int n){
  if(n == 1) return false;
  rep(i, 2, min((int)(pow(n, 0.5) + 1), n)){
    if(n % i == 0) return false;
  }
  return true;
}

/////////////////////////////////////////////////////////

void Main() {
  ll N; cin >> N;
  ll res = 0;
  ll sum = 0;
  ll num = 0;
  ll tmp = N;
  while(tmp > 0){
    num++;
    sum += tmp % 10;
    tmp /= 10;
  }
  chmax(res, sum);
  chmax(res, N / mypow(10LL, num - 1) - 1LL + 9LL * (num - 1LL));
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


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

using namespace std;

int main(){
	int b[3],i;
	for(i=0;i<3;i++){
		cin>> b[i];
	}
	if(b[0]==1 && b[1]==0){
		cout<< "Close"<<endl;
	}
	if(b[0]==0 && b[1]==1){
		cout<< "Close"<<endl;
	}
	if(b[0]==1 && b[1]==1){
		cout<< "Open"<<endl;
	}
	if(b[2]==1){
		cout<< "Open"<<endl;
	}
	if(b[0]==0 && b[1]==0 && b[2]==0){
		cout<< "Close"<<endl;
	}
	return 0;
}

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

int n, k;
long long t[100000];

int check(long long p)
{
	int i = 0;
	for (int j = 0; j < k; ++j)
	{
		long long s = 0;
		while (s + t[i] <= p){
			s += t[i];
			++i;
			if (i == n)return n;
		}
	}
	return i;
}

int solve(){
	long long left = 0, right = 100000 * 10000, mid;
	while (right - left > 1){
		mid = (left + right) / 2;
		int v = check(mid);
		if (v == n)right = mid;
		else left = mid;
	}
	return right;
}

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; ++i)cin >> t[i];
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 3876
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int count = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				count++;
			}
		}
		
		System.out.println(count);
	}
}


Measured memory_bytes: 26212
#include<cstdio>
#include<cmath>
#include <stdlib.h>
#include<algorithm>

using namespace std;

int main(){
	int p[5],pair[5],str[5],che[5];
	while( scanf("%d,%d,%d,%d,%d",&p[0],&p[1],&p[2],&p[3],&p[4]) != EOF ){
		sort(p,p+5);
		pair[0]=0;
		str[0]=0;
		che[0]=0;
		for(int i=1;i<5;i++){
			if(p[i]==p[i-1]){
				pair[i] = pair[i-1]+1;
			}
			else{
				pair[i]=0;
			}
			if(p[i-1]+1==p[i]){
				str[i] = str[i-1]+1;
			}
			else{
				str[i] = 0;
			}
			che[i]=0;
		}
		if(p[0]==1&&p[4]==13)str[4]++;
		for(int i=0;i<5;i++){
			che[pair[i]]++;
		}
		if(che[3]==1){
			printf("four card\n");
		}
		else if(che[2]==1&&che[1]==2){
			printf("full house\n");
		}
		else if(str[4]==4){
			printf("straight\n");
		}
		else if(che[2]==1){
			printf("three card\n");
		}
		else if(che[1]==2){
			printf("two pair\n");
		}
		else if(che[1]==1){
			printf("one pair\n");
		}
		else{
			printf("null\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2592
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2,vector<int>(n));

	rep(i, 2) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}

	int maxsum = 0;
	int sum = 0;

	rep(i,a[0].size()) {
		sum += a[0][i];
	}

	sum += a[1][n - 1];
	maxsum = sum;

	for (int i = n - 1; i >= 1; i--) {
		sum -= a[0][i];
		sum += a[1] [i - 1];
		maxsum = max(maxsum, sum);
	}

	cout << maxsum << endl;
} 

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

using namespace std;

const int inf = 0x3f3f3f3f;

int peso[100010], valor[100010], pd[100010];
int n, w;

void solve(){
  pd[0] = 0;
  for(int i=0 ; i<n ; i++){
    for(int j=100010-1 ; j>=0 ; j--){
      if(pd[j] != inf){
        //cout<<valor[i] <<" " << j<<endl;
        if( pd[j] + peso[i] <= w && pd[j + valor[i]] > pd[j] + peso[i]){
          pd[ j + valor[i] ] = pd[j] + peso[i];
        }
      }
    }
    //for(int j=0 ; j<15 ; j++)cout<<pd[j] << " ";
    //cout<<endl;
  }
}

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

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

  memset(pd, inf, sizeof pd);

  solve();

  int maior = 0;

  for(int i=0 ; i<100010 ; i++) {
    if(pd[i] != inf)
      maior = max(maior, i);
  }

  cout << maior << endl;
}

Measured memory_bytes: 1148
s = list(input())

set_s = sorted(set(s))
if len(set_s)%2==1:
    print('No')
if len(set_s)==4:
    print('Yes')
if len(set_s)==2:
    if list(set_s)==['N','S']:
        print('Yes')
    elif list(set_s)==['E','W']:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3060
using System;

namespace P0006_ReverseSequence
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            char[] output = input.ToCharArray(0, input.Length);
            
            for (int i = input.Length - 1; i >= 0; i--) 
            {
                Console.Write(output[i]);
            }

            Console.WriteLine("");

        }
    }
}

Measured memory_bytes: 5220