akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

# dp[i][j] := 左からi個、右からj個取った状態での最大(最小)得点
dp = list2d(N+1, N+1, 0)
# 初期化：どちらの手番で使う場所かに合わせて-INFかINFにする
for i in range(N):
    turn = i & 1
    for j in range(i+1):
        k = i - j
        if turn == 0:
            dp[j][k] = -INF
        else:
            dp[j][k] = INF
# 最初の遷移の開始地点(ゲーム終了の状態)は0に
for i in range(N+1):
    dp[i][N-i] = 0
# 終了から順番に戻って見ていく
for i in range(N-1, -1, -1):
    turn = i & 1
    for j in range(i+1):
        k = i - j
        l = j
        r = N - 1 - k
        if turn == 0:
            # 先手番の遷移
            dp[j][k] = max(dp[j][k], dp[j+1][k] + A[l])
            dp[j][k] = max(dp[j][k], dp[j][k+1] + A[r])
        else:
            # 後手番の遷移
            dp[j][k] = min(dp[j][k], dp[j+1][k] - A[l])
            dp[j][k] = min(dp[j][k], dp[j][k+1] - A[r])
ans = dp[0][0]
print(ans)


Measured memory_bytes: 114268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

void show(int start, int count, const std::vector<int> &target) {
	while (count != 0) {
		if (std::find(target.begin(), target.end(), start % 12) != target.end()) {
			std::cout << start;
			--count;
			if (count != 0) std::cout << ' ';
		}
		++start;
	}
}
int min_case() {
	std::cout << 2 << ' ' << 5 << ' ' << 63;
	return 0;
}
int main() {
	int n;
	std::cin >> n;
	if (n == 3) return min_case();
	int mod8 = n % 8;
	n -= mod8;
	auto i = 2;
	for (; n > 0; ++i) {
		if (i % 6 != 1 && i % 6 != 5) {
			std::cout << i;
			--n;
			if (n != 0) std::cout << ' ';
		}
	}
	if (i != 2 && mod8 != 0) std::cout << ' ';
	switch (mod8) {
	case 0: return 0;
	case 1: show(i, mod8, std::vector<int>{6}); return 0;
	case 2: show(i, mod8, std::vector<int>{2, 4}); return 0;
	case 3: show(i, mod8, std::vector<int>{2, 4, 6}); return 0;
	case 4: show(i, mod8, std::vector<int>{2, 3, 4, 9}); return 0;
	case 5: show(i, mod8, std::vector<int>{2, 3, 4, 6, 9}); return 0;
	case 6: show(i, mod8, std::vector<int>{2, 3, 4, 6, 9, 0}); return 0;
	case 7: show(i, mod8, std::vector<int>{2, 3, 4, 6, 8, 9, 10, 0}); return 0;
	default: return 0;
	}
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		String relation;

		if(a > b){
			relation = ">";
		}else if(a < b){
			relation = "<";
		}else{
			relation = "==";
		}

		System.out.printf("a %s b\n", relation);
	}
}





Measured memory_bytes: 26216
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    lint A, B, K;
    cin >> A >> B >> K;
    if(K <= A) {
        cout << (A-K) << " " << B << endl;
    } else {
        cout << 0 << " " << max((lint)0, B-(K-A)) << endl;
    }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

const MOD: usize = 1e9 as usize + 7;

fn main() {
    input!{
      n: usize,
      m: usize,
      aa: [usize; m],
    }
    use std::collections::HashMap;
    let mut map = HashMap::new();
    for a in aa {
        map.entry(a).or_insert(true);
    }

    let mut dp = vec![0; n+1];
    dp[0] = 1;
    for i in 1..n+1 {
        if i >= 1 && !map.contains_key(&(i-1)) {
            dp[i] += dp[i-1];
            dp[i] %= MOD;
        }
        if i >= 2 && !map.contains_key(&(i-2)) {
            dp[i] += dp[i-2];
            dp[i] %= MOD;
        }
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 12540
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
int a, b, c;
cin >> a >> b >> c;
cout << c << " " << a << " " << b;
}

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

const int MAXN = 200005;

int n, x;
int a[MAXN];
long long sum[MAXN];

int main()
{
	scanf("%d%d", &n, &x);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		sum[i] = sum[i-1]+a[i];
	}
	long long ans = 1e18;
	for (int i = 1; i <= n; i++) {
		__int128 cur = 1ll*n*x+5ll*(sum[n]-sum[i-1])+(n-i+1ll)*x;
		int k = n-i+1;
		for (int j = i-1, d = 5; j >= 1; j -= k, d += 2) {
			if (j-k < 1) {
				cur += 1ll*d*sum[j];
				break;
			}
			cur += 1ll*d*(sum[j]-sum[j-k]);
		}
		ans = min((__int128)ans, cur);
	}
	cout << ans << endl;
	return 0; 
}


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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n,0);
    rep(i,n)cin >> a[i];
    sort(a.begin(),a.end());
    bool matching = false;
    rep(i,n-1){
        if(a[i] == a[i+1]){
            cout << "NO" << endl;
            matching = true;
            break;
            
        }
    }
    if(matching == false)cout << "YES" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 1792
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
G=[[] for i in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
from collections import deque
q=[0]
q=deque(q)
ans=[-1]*n
while len(q)>0:
    now=q.popleft()
    for i in G[now]:
        if ans[i]<0:
            ans[i]=now
            q.append(i)
print('Yes')
for i in range(1,n):
    print(ans[i]+1)


Measured memory_bytes: 92644
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  string s;
  map<string, int>M;
  cin >> n;
  for(int i=0; i<n; ++i){
    cin >> s;
    ++M[s];
  }
  cin >> m;
  for(int i=0; i<m; ++i){
    cin >> s;
    --M[s];
  }
  int ans = 0;
  for(auto [k, v] : M) ans = max(ans, v);
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>
#include <unordered_map>

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<string> s(N);
    for(int i=0;i<N;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    unordered_map<string,int> mp;
    long long ans=0;
    for(int i=0;i<N;i++){
        ans+=mp[s[i]];
        mp[s[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 17700
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#include<bitset>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=1e5+11;
int N,K,Ans,A[MAXN];
int main(){
    N=read(),K=read();
    if((N-1)%(K-1)) printf("%d\n",(N-1)/(K-1)+1);
    else printf("%d\n",(N-1)/(K-1));return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long int flag[200000] = {0};

int main() {

  long long int cnt = 1;

  vector< long long int > sosu;

  for ( long long int i = 2; i < 200000; i++ ) {

    if ( flag[i] == 0 ) {
      sosu.push_back( i );
      flag[i] = cnt;
      cnt++;
      for ( long long int j = 2; j * i < 200000; j++ ) {
	flag[j*i] = -1;
      }
    }

  }

  long long int n, p;

  while( true ) {

    cin >> n >> p;

    if ( n == -1 ) break;

    cnt = 1;

    while( true ) {
      if ( flag[n+cnt] > 0 ) {
	cnt = flag[n+cnt] - 1;
	break;
      }
      cnt++;
    }

    vector< long long int > ans;

    for ( long long int i = 0; i < p; i++ ) {
      for ( long long int j = i; j < p; j++ ) {
	ans.push_back( sosu[ cnt+i ] + sosu[ cnt+j ] );
      }
    }
    sort( ans.begin(), ans.end() );

    cout << ans[p-1] << endl;

  }

  return 0;

}

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

using LLI = long long int;

#define INF 0x334334334

int N;
LLI W;
LLI ans;
LLI WS[114514];
LLI vs[114514];
LLI dp[114][114][334];

int main() {
  scanf("%d%lld", &N, &W);
  for (int i=0; i<N; i++) {
    scanf("%lld%lld", &WS[i], &vs[i]);
  }

  fill(dp[0][0], dp[N+1][0], -INF);
  dp[0][0][0] = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<=N; j++) {
      for (LLI k=300; k>=0; k--) {
        dp[i+1][j][k] = dp[i][j][k];
      }
    }
    
    for (int j=0; j<N; j++) {
      LLI lim = min(W - j*WS[0]+4, 303LL);
      for (LLI k=lim-(WS[i]-WS[0]); k>=0; k--) {
        LLI w = k+WS[i]-WS[0];
        dp[i+1][j+1][w] = max(dp[i][j][k]+vs[i], dp[i+1][j+1][w]);
        //printf("dp[%d][%d][%lld]: %lld\n", i+1, j+1, w, dp[i+1][j+1][w]);
        if (w+(j+1)*WS[0] <= W) ans = max(ans, dp[i+1][j+1][w]);
      }
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 33024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int[] b = new int[n];
    for(int i = 0; i < n; i++) {
      int d = sc.nextInt();
      a[i] = d;
    }
    Arrays.sort(a);
    for(int i = 0; i < n; i++) {
      b[i] = 24 - a[i];
    }
    int ans = a[0];
    for(int k = a[0]; k >= 0; k--) {
      int flg = 0;
      int m1 = a[0];
      int m2 = 24;
      int pre = a[0];
      for(int i = 1; i < n; i++) {
        if(pre <= 12) {
          if(((a[i] - m1) >= k) && ((m2 - a[i]) >= k)) {
            pre = a[i];
            m1 = a[i]; 
          } else {
            if(((b[i] - m1) >= k) && ((m2 - b[i]) >= k)) {
              pre = b[i];
              m2 = b[i]; 
            } else {
              flg = 1;
              break;
            }
          }
        } else {
          if(((b[i] - m1) >= k) && ((m2 - b[i]) >= k)) {
            pre = b[i];
            m2 = b[i]; 
          } else {
            if(((a[i] - m1) >= k) && ((m2 - a[i]) >= k)) {
              pre = a[i];
              m1 = a[i]; 
            } else {
              flg = 1;
              break;
            }
          }
        }
      }
      if(flg == 0) {
        ans = k;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23380
#include <stdio.h>

int main()
{
   
     int a,b,c;
     scanf("%d %d",&a,&b);
     c=a/b;
     
     if(a%b==0)
     {
       printf("%d",c);
     }
     else
     {
       printf("%d",c+1);
     }
     
 
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int n;
	int a[20], v[100];
	int b;
	int c;
	int d;
	int f;
	
	scanf("%d", &n);
	
	for (b = 0; b < n; b++){
		scanf("%d %d", &a[b], &v[b]);
	}
	
	c = 0;
	
	d = v[c] - v[1];
	
	if (d > 0){
		c = c;
	}
	else if (d < 0){
		c += 1;
	}
	
	for (b = 2; b < n; b++){
		d = v[c] - v[b];
		if (d < 0){
			c = b;
		}
		else if (d > 0){
			c = c;
		}
		else if (d == 0){
			f = a[c] - a[b];
			
			if (f < 0){
				c = c;
			}
			else {
				c = b;
			}
		}
	}
	
	printf("%d %d\n", a[c], v[c]);
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;

    string s;
    cin >> s;

    int l = -1, r = -1;
    for (int i = 0; i < (int)s.size(); ++i) {
        if (s.at(i) == 'C') {
            l = i;
            break;
        }
    }
    for (int i = (int)s.size() - 1; i >= 0; --i) {
        if (s.at(i) == 'F') {
            r = i;
            break;
        }
    }

    if (l == -1 || r == -1)
        cout << "No\n";
    else if (l < r)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define  X first
#define  Y second

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 3e5+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

int a[maxN];
int main()
{
	int x,n;
	scanf("%d%d",&x,&n);
	unordered_map<int,int> mp;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mp[a[i]] = 1;
	}
	int ans = inf;
	for(int i=0;i<=10000;i++)
	{
		int y1 = x+i;
		int y2 = x-i;
		if(mp[y1] == 0 && mp[y2] == 0)
		{
			ans = y2;
		}
		else if(mp[y1] == 0)
		{
			ans = y1;
		}
		else if(mp[y2] == 0)
		{
			ans = y2;
		}
		if(ans != inf)
		{
			break;
		} 
	}
	cout<<ans<<endl;
	return 0;
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
// #define X real()
// #define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}


int max(int x, int y) {
    return (x>y) ? x : y;
}
int min(int x, int y) {
    return (x<y) ? x : y;
}

signed main() {
    int N, X, Y; cin >> N >> X >> Y;
    map<int, int> mp;

    int dist;
    REPS(i, 1, N) REPS(j, i+1, N+1) {
        dist = min(abs(j-i), min(abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)));
        mp[dist]++;
    }

    REPS(k, 1, N) {
        if (k == 1) {
            print(N);
            continue;
        }
        print(mp[k]);
    }

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef double db;
int n,d,x;
db ans;
int main() {
  scanf("%d%d%d",&n,&d,&x);
  for (int i = 0 ; i < n ; ++ i)
    ans += (i + 1.0) / (n - i);
  ans = ans * (d + (n - 0.5) * x);
  printf("%.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <random>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0)
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli h, w;

lli score(lli x, lli h, lli w) {
  lli a = (w-x)*h;
  lli b1 = x*(h/2), c1 = x*h-b1, b2 = (x/2)*h, c2 = x*h-b2;
  lli y1 = max({a,b1,c1}) - min({a,b1,c1}),
      y2 = max({a,b2,c2}) - min({a,b2,c2});
  return min(y1, y2);
}

int main() {
  cin >> h >> w;
  lli ans = 1e18;
  for (lli x=1; x<w; ++x) {
    ans = min(ans, score(x, h, w));
  }
  for (lli y=1; y<h; ++y) {
    ans = min(ans, score(y, w, h));
  }
  cout << ans << '\n';
  return 0;
}


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

int main()
{
	constexpr auto pow_mod = [](int64_t a, int64_t n, int64_t mod) {
		int64_t r = 1;
		for (; n; n >>= 1)
		{
			if (n & 1)
			{
				(r *= a) %= mod;
			}
			(a *= a) %= mod;
		}
		return r;
	};
	int64_t n, a, b, k, mod = 998244353;
	cin >> n >> a >> b >> k;
	int64_t fact[n + 1], fact_rev[n + 1];
	fact[0] = 1;
	for (int64_t i = 1; i <= n; i++)
	{
		fact[i] = fact[i - 1] * i % mod;
	}
	fact_rev[n] = pow_mod(fact[n], mod - 2, mod);
	for (int64_t i = n - 1; 0 <= i; i--)
	{
		fact_rev[i] = fact_rev[i + 1] * (i + 1) % mod;
	}
	int64_t ans = 0;
	for (int64_t i = 0; i <= n; i++)
	{
		int64_t j = (k - a * i) / b;
		if (j < 0 || n < j || a * i + b * j != k)
		{
			continue;
		}
		(ans += fact[n] * fact_rev[i] % mod * fact_rev[n - i] % mod * fact[n] % mod * fact_rev[j] % mod * fact_rev[n - j] % mod) %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
    string S;
    long long K;
    cin >> S;
    cin >> K;
    int size = S.size();
    int cnt1 = 0;
    for(int i = 0;i< size;i++){
        if(S[i] == '1')cnt1++;
    }
if(size == cnt1)cout << "1" << endl;
else{
    if(size<K){
        char ans;
        for(int i = 0; i<size;i++){
            if(S[i]!='1'){
            ans=S[i];
            break;
            }
        }
        cout << ans <<endl;
    }
    else{ 
    int cnt1_n = 0;
    for(int i = 0;i<K;i++){
         if(S[i] == '1')cnt1_n++;
    }
    if(cnt1_n == K){
        cout << "1" << endl;
    }
    else{
        char ans;
        for(int i = 0; i<size;i++){
            if(S[i]!='1'){
            ans=S[i];
            break;
            }
        }
        cout << ans <<endl;
    }
}
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if(S==U) A--;
	else B--;
	cout << A << " " << B << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    int d;
    int x[10][10];
    int cnt = 0;
    int buf1,buf2;

    cin >> n;
    cin >> d;

    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> x[i][j];
        }
    }

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            buf1 = 0;
            for(int k=0;k<d;k++){
                buf2 = x[i][k] - x[j][k];
                buf1 += buf2 * buf2;
            }

            if(sqrt(buf1) == (int)sqrt(buf1)) {
                cnt++;
            }
        }
    }

    cout << cnt;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    string o,e;
    cin>>o>>e;
    int p=0;
    while (p<min(o.size(),e.size())){
        cout<<o[p]<<e[p];
        p++;
    }if (o.size()>e.size())cout<<o[o.size()-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
dict={}
count=0
for i in a:
  if i not in dict:
    dict[i] = 1
    continue
  dict[i] += 1
for i,j in dict.items():
  if i > j:
    count += j
  elif i < j:
    count += j-i
print(count)

Measured memory_bytes: 17780
#include <bits/stdc++.h>
using namespace std;
int main() {
	//freopen("inp.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int n = 0;
	cin >> n;
	cin >> s;
	if (n & 1) {
		cout << "No";
		return 0;
	}
	
	int m = n / 2;
	if (s.substr(0, m) == s.substr(m, m)) {
		cout << "Yes";
	} else cout << "No";
	
	return 0;
}


Measured memory_bytes: 256
S = input()

flg = True

if 'RRR' in S and flg:
    flg = False
    print(3)

elif 'RR' in S and flg:
    flg = False
    print(2)

elif 'R' in S and flg:
    flg = False
    print(1)

else: print(0)

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

const int MAXN = 250005;
lint mod = 1e16 + 61;
const int base = 257;
int n, pos[MAXN];
char str[MAXN];
lint pwr[MAXN * 2];
lint inv[MAXN * 2];

lint ipow(lint x, lint p){
  lint ret = 1, piv = x;
  while(p){
    if(p & 1) ret = (__int128) ret * piv % mod;
    piv = (__int128) piv * piv % mod;
    p >>= 1;
  }
  return ret;
}

lint psum[MAXN];

int main(){
  mod++;
  cin >> n >> (str + 1);
  pwr[0] = inv[0] = 1;
  for(int i=1; i<MAXN * 2; i++){
    pwr[i] = pwr[i-1] * base % mod;
    inv[i] = ipow(pwr[i], mod - 2);
  }
  pos[0] = n;
  for(int i=1; i<=n; i++){
    pos[i] = pos[i-1];
    psum[i] = psum[i-1];
    if(str[i] == '<') pos[i]--;
    if(str[i] == '>') pos[i]++;
    if(str[i] == '+') psum[i] += pwr[pos[i]];
    if(str[i] == '-') psum[i] += mod - pwr[pos[i]];
    psum[i] %= mod;
  }
  lint H = psum[n];
  lint ret = 0;
  map<lint, int> mp;
  for(int i=n; i; i--){
    mp[psum[i]]++;
    __int128 Hv = H;
    if(pos[0] <= pos[i-1]) Hv *= pwr[pos[i-1] - pos[0]];
    else Hv *= inv[pos[0] - pos[i-1]];
    Hv += psum[i-1];
    Hv %= mod;
    ret += mp[Hv];
  }
  cout << ret << endl;
}



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

#define PI 3.14159265358979323846264338327950L
#define ll long long
#define lli long long int

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll sum = 0;
    unordered_map<int, int> maps;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        sum += temp;
        maps[temp]++;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int b, c;
        cin >> b >> c;
        if (maps.find(b) != maps.end()) {
            int amount = maps[b];
            maps.erase(b);
            maps[c] += amount;
            sum += (c - b) * amount;
        }
        cout << sum << "\n";
    }




    return 0;
}


Measured memory_bytes: 6640
/*input
3
-2 -5 -1
*/
#include <bits/stdc++.h>

#define f first
#define s second

using namespace std;

int N;

int main(){
	cin >> N; cout << 2*N-1 << endl;
	pair<int, int> hi = {-10e6+5, -1}; pair<int, int> lo = {10e6+5, -1};

	for(int i = 0; i < N; i++){
		int x; cin >> x;
		if (x < lo.f){
			lo.f = x; lo.s = i+1;
		}
		if (x > hi.f){
			hi.f = x; hi.s = i+1;
		}
	}
	if (abs(hi.f) > abs(lo.f)){
		for(int i = 0; i < N; i++){
			cout << hi.s << " " << i+1 << endl; 
		}
		for(int i = 1; i < N; i++){
			cout << i << " " << i+1 << endl;
		}
	}
	else{
		for(int i = 0; i < N; i++){
			cout << lo.s << " " << i+1 << endl;
		}
		for(int i = N-1; i > 0; i--){
			cout << i+1 << " " << i << endl; 
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    tmp=a[i+1]+a[i]
    if a[i+1]+a[i]<=x:
        continue
    elif x-a[i]>=0:
        a[i+1]-=a[i]+a[i+1]-x
    else:
        a[i+1]=0
        s=x-a[i]
        a[i]+=s
    ans+=tmp-a[i+1]-a[i]
print(ans)

Measured memory_bytes: 14252
n = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
kill_count = 0
for i in range(n):
    kill_num = min(a[i],b[i])
    kill_count += kill_num
    b[i] -= kill_num
    a[i] -= kill_num

    kill_num_ex = min(a[i+1],b[i])
    kill_count += kill_num_ex
    a[i+1] -= kill_num_ex
    b[i] -= kill_num_ex

print(kill_count)

Measured memory_bytes: 18476
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

// first: cost, second: key
typedef pair<int, int> vert;

static const int MAX   = 10000;
static const int INFTY = 1 << 20;
static const int WHITE = 0;
static const int BLACK = 2;

vector<vert> adjs[MAX];

void dijkstra(int n_v, int v_start) {
    priority_queue< vert, vector<vert>, greater<vert> > visitings;
    int color[MAX];
    int costs[MAX];

    for (int i = 0; i < n_v; i++) {
        costs[i] = INFTY;
        color[i] = WHITE;
    }

    costs[v_start] = 0;
    visitings.push( make_pair(0, v_start) );

    while (! visitings.empty()) {
        vert nearest = visitings.top();
        visitings.pop();

        int next_id = nearest.second;
        color[next_id] = BLACK;

        if ( costs[next_id] < nearest.first )
            continue;

        for (int i = 0; i < adjs[next_id].size(); i++) {
            int adj  = adjs[next_id][i].first;
            int cost = adjs[next_id][i].second;

            if (color[adj] == BLACK)
                continue;

            if (costs[next_id] + cost < costs[adj]) {
                costs[adj] = costs[next_id] + cost;
                visitings.push( make_pair(costs[adj], adj) );
            }
        }
    }

    for (int i = 0; i < n_v; i++) {
        cout << i << " " << costs[i] << "\n";
    }
}

int main() {
    std::ios::sync_with_stdio(false);

    int n_v;
    cin >> n_v;

    for (int i = 0; i < n_v; i++) {
        int vert_id, n_adjs;
        cin >> vert_id >> n_adjs;

        for (int j = 0; j < n_adjs; j++) {
            int adj, cost;
            cin >> adj >> cost;
            adjs[vert_id].push_back( make_pair(adj, cost) );
        }
    }

    dijkstra(n_v, 0);
}

Measured memory_bytes: 6324
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int j,k=0;
  for(int i=1;i<=n;i++){
    j=i%10+i/10%10+i/100%10+i/1000%10+i/10000%10;
    if(a<=j&&j<=b)k+=i;
  }
  cout << k;
  /*bool f=0;
  for(int i=1;i<=a;i++){
    if(i*n%a==b)f=1;
  }
  if(f)cout << "YES";
  else cout << "NO";*/
}


Measured memory_bytes: 256
a = list(input())
b = list(input())
c = list(input())

s = a[0]
a = a[1:]

while True:
    if s == 'a':
        if a == []:
            print('A')
            break
        s = a.pop(0)
    elif s == 'b':
        if b == []:
            print('B')
            break
        s = b.pop(0)
    else:
        if c == []:
            print('C')
            break
        s = c.pop(0)

Measured memory_bytes: 3188
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int H,W,A,B;
int main(){
	cin>>H>>W>>A>>B;
	rep(i,H){
		rep(j,W){
			if((i<B&&j<A)||(i>=B&&j>=A))cout<<1;
			else cout<<0;
			
		}
		cout<<endl;
	}
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int from,to,cost;};
int pow2(int n,int i){if(i==1)return n;return n*pow(n,i-1);};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,m;

signed main(){  
    
    int a;
    cin>>a;
    cout<<1.0-(double)(a/2)/(double)a<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

bool comp(PLL& l, PLL &r){
  if(l.second == r.second)l.first<r.first;
  return l.second < r.second;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N;cin >> N;
  vector<PLL> v(N);
  rep(i,N) cin >> v[i].first >> v[i].second;
  sort(all(v),comp);
  ll sum = 0;
  bool pos = true;
  rep(i,N){
    sum += v[i].first;
    if(sum > v[i].second) pos=false;
  }
  YesNo(pos);
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, k;
	cin >> n >> k;

	vl a(n+2);
	FOR(i,1,n+1) cin >> a[i];
	n += 2;

	vvl dp(n,vl(k+1,oo));
	dp[0][0] = 0;

	FOR(i,1,n) FOR(j,0,k+1) FOR(ii,0,i) {
		ll jj = j - (i-ii-1);
		if (jj < 0) continue;

		dp[i][j] = min(dp[i][j], dp[ii][jj] + max(a[i]-a[ii],0LL));
	}
	
	ll res = *min_element(all(dp[n-1]));
	cout << res << endl;
}



Measured memory_bytes: 1024
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

X, Y = imn()

ans = 0
while X <= Y:
    X *= 2
    ans += 1
print(ans)


Measured memory_bytes: 5556
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cctype>
#include <stack>
#include <map>
#include <cstring>
#include <sstream>
#include <set>
#include <list>
#include <fstream>
#include <iomanip>
#include <assert.h>

#define ll long long
#define ull unsigned long long
#define pii std::pair<int, int>
#define op                            \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);

const int INF = 0x3f3f3f3f;
const int maxn = (100000 + 10);
const int mod = (1e9 + 7);

int main()
{
    int k,x;
    scanf("%d %d",&k,&x);
    if(k*500>=x) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 764
n, k = map(int, input().split())
d = list(map(int, input().split()))

for i in range(n,100000):
  #print(i)
  res = 0
  for j in str(d):
    if j in str(i):
      res += 1
  if res == 0:
    print(i)
    exit()
    

Measured memory_bytes: 8980
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll X, Y;
	std::cin >> X >> Y;

	repeq(i, 0, X) {
		if (2 * i + 4 * (X - i) == Y) {
			std::cout << "Yes" << endl;
			return 0;
		}
	}
	std::cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3636
import copy
a = [[0 for i in range(100)] for j in range(100)]
b = copy.deepcopy(a)
n, m, l = map(int, input().split())
for i in range(n):
    a[i][:m] = map(int, input().split())
for i in range(m):
    b[i][:l] = map(int, input().split())
for i in range(n):
    for j in range(l):
        c = 0
        for k in range(m):
            c += a[i][k] * b[k][j]
        print(c, end='')
        if j < l - 1:
            print(' ', end='')
        else:
            print()

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

int main(){
	int n;
	cin >> n;
	for(; n--; ){
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double d = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));

		if(d+rb < ra) cout << 2 << endl;
		else if(d+ra < rb) cout << -2 << endl;
		else if(d <= ra+rb) cout << 1 << endl;
		else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int add(int x,int y){return x+y<mod?x+y:x+y-mod;}
void ade(int& x,int y){x+=y;if(x>=mod)x-=mod;}
int qpow(int x,int k)
{
	int r=1;
	while(k)
	{
		if(k&1)r=1ll*r*x%mod;
		k>>=1;x=1ll*x*x%mod;
	}
	return r;
}
int fac[2000200],ifac[2000200];
void init()
{
	int ma=2e6+10;fac[0]=1;
	for(int i=1;i<=ma;++i)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[ma]=qpow(fac[ma],mod-2);
	for(int i=ma-1;i>=0;--i)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}
int C(int x,int y)
{
	if(x<y||x<0||y<0)return 0;
	return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int g(int n,int m) { return add(C(n+m+2,m+1),mod-1); }
int f(int x,int y,int X1,int Y1,int X2,int Y2)
{
	int sx=abs(X1-x),mx=abs(X2-x);if(sx>mx)swap(sx,mx);
	int sy=abs(Y1-y),my=abs(Y2-y);if(sy>my)swap(sy,my);
	int res=(0ll+g(mx,my)-g(sx-1,my)-g(mx,sy-1)+g(sx-1,sy-1)+mod+mod)%mod;
	return res;
}
int calc(int X1,int X2,int Y1,int Y2){return C(X2-X1+Y2-Y1,X2-X1);}
main()
{
	init();
	scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6);
	scanf("%d%d%d%d%d%d",&y1,&y2,&y3,&y4,&y5,&y6);
	int p,q,u,v;
	int ans=0,ta;
	for(int i=x3;i<=x4;++i)
	{
		p=i,q=y4+1;
		ta=1ll*f(p,q-1,x1,y1,x2,y2)*f(p,q,x5,y5,x6,y6)%mod*(p+q)%mod;
		ade(ans,ta);
		u=i,v=y3-1;
		ta=1ll*f(u,v,x1,y1,x2,y2)*f(u,v+1,x5,y5,x6,y6)%mod*(u+v+1)%mod;
		ade(ans,mod-ta);
	}
	for(int i=y3;i<=y4;++i)
	{
		p=x4+1,q=i;
		ta=1ll*f(p-1,q,x1,y1,x2,y2)*f(p,q,x5,y5,x6,y6)%mod*(p+q)%mod;
		ade(ans,ta);
		u=x3-1,v=i;
		ta=1ll*f(u,v,x1,y1,x2,y2)*f(u+1,v,x5,y5,x6,y6)%mod*(u+v+1)%mod;
		ade(ans,mod-ta);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 15872
import java.util.*;

class Main {

   public static void main(String[] args) throws Exception {
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int y = sc.nextInt();
      int work;
      while (x != 0 || y != 0) {
         if (x > y) {
            work = x;
            x = y;
            y = work;
         }
         System.out.printf("%d %d\n", x, y);
         x = sc.nextInt();
         y = sc.nextInt();
      }
   }
}

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n;
    cin>>n;
    cout<<power(n,3);

}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3620
a,b,t = (int(i) for i in input().split())  
s=0
for i in range(t):
    if i%a==0 and not i==0:
        # print(i,a)
        s+=b
i+=1
if(i%a==0):
    # print(i,a)

    s+=b
print(s)

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

int main(){
	ll n; cin >> n;
	vector<string>s(n); vl p(n); rep(i,n)cin >> s[i] >> p[i];
	vector<tuple<string, int, int>> a(n);
	rep(i,n){
		get<0>(a[i]) = s[i];
		get<1>(a[i]) = p[i] * (-1);
		get<2>(a[i]) = i+1;
	}
	sort(a.begin(), a.end());
	rep(i,n)cout << get<2>(a[i])<< endl;
}

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

typedef long long int ll;
typedef vector<int> vi;            typedef vector<ll> vl;
typedef vector<vi> vvi;         typedef vector<vl> vvl;
typedef pair<int, int>     pii;    typedef pair<ll, ll> pll;
typedef vector<pii> vii;         typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
    while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
    int n, k; cin>>n>>k;
    vl h(n); forn(i, n) cin>>h[i];
    vl dp(n, INFL);
    dp[0] = 0;

    for(int i = 1; i<n; i++)
        for(int j = max(i - k, 0); j<i; j++)
            dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
    cout<<dp[n-1]<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef KARAN
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    int t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 1792
program main;
var
    n, i : longint;
    sum : int64;
begin
    readln(n);

    sum :=0;
    for i := 1 to n do
        if not ((i mod 3 = 0)or (i mod 5 = 0)) then
            sum := sum + i;

    writeln(sum);
end.

Measured memory_bytes: 1384
#include <iostream>
#include <iomanip>
#include <cassert>

#define debug(x) cout << #x << "==" << x << endl;

typedef long long ll;

const int INF = 1e+9 + 7;

using namespace std;

//入力
#define MAX_N 100000
int N, x;
int a[MAX_N + 1];

int main() {
  ios::sync_with_stdio(false);

  cin >> N >> x;

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

  ll sum = 0;
  for(int i = 0; i < N; i++) { sum += a[i]; }

  for(int i = 0; i < N - 1; i++) {
    if( x < a[i] ) {
      a[i] = x;
    }
    if ( x < a[i] + a[i+1] ) {
      a[i+1] -= a[i+1] + a[i] - x;
    }

  }


  ll new_sum = 0;
  for(int i = 0; i < N; i++) { new_sum += a[i]; }
  // for(int i = 0; i < N; i++) { cout << a[i] << " "; }
  cout << endl;
  cout << sum - new_sum << "\n";

  return 0;
}


Measured memory_bytes: 640