akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N, M, X = map(int, input().split())
C = np.zeros(N)
A = np.zeros((N, M))


for n in range(N):
    s = list(map(int, input().split()))
    C[n] = s[0]
    A[n] = s[1:]

C_MIN = -1
for i in range(2 ** N):
    C_SUM = 0
    A_SUM = np.zeros(M)
    for j in range(N):
        if ((i >> j) & 1):
            C_SUM += C[j]
            A_SUM += A[j]
    if np.all(A_SUM >= X):
        if C_SUM < C_MIN or C_MIN == -1:
            C_MIN = C_SUM
            
if C_MIN == -1:
    print("-1")
else:
    print(int(C_MIN))

Measured memory_bytes: 27244
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define speedrap ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int be(int a,int b,int mod) {if(b == 0) return 1; if(b%2 == 1) return (a*be(a,b-1,mod))%mod; else return (be(a,b/2,mod)*be(a,b/2,mod))%mod;}
const int mod = 1e9 + 7;
#define PI 3.14159265359
#define pf push_front
#define pb push_back
#define bitcount __builtin_popcountll
#define setbitcnt __builtin_ctz
#define sc(a) scanf("%d", &a);
#define sz(s) (int)s.size()
#define eb emplace_back
#define pf push_front
#define mkp(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define roundup(a,b)  std::cout << std::fixed;std::cout << std::setprecision(b); std::cout << a
const int siz = (1e5 + 10);
const int logi = 21;
const double epsilon = 1e-6;
bool cmp(const int &a,const int &b)
{
  return (abs(a-b)>1);
}


signed main()
{
	#ifndef ONLINE_JUDGE
 	freopen("in.txt", "r", stdin);
 	freopen("out.txt", "w", stdout);
 	#else
// // online submission
 	#endif 
	speedrap
	int t;
	t = 1;
	//cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		set<int> s1;
		set<int> s2;
		set<int> s3;
		s1 = {2, 4, 5, 7,9};
		s2 = {0, 1, 6, 8};
		s3 = {3};
		int d = s[s.length()-1]-'0';

		if(s1.find(d) != s1.end())
		{
			cout<<"hon";
		}

		if(s2.find(d) != s2.end())
		{
			cout<<"pon";
		}

		if(d == 3)
		{
			cout<<"bon";
		}
	}
}

Measured memory_bytes: 3660
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=10000+10;
int n;
ll a[N];
int main() {
    while(~scanf("%d",&n)){
        ll x;
        ll n1=0,n2=0;
        for(int i=0;i<n;i++){
            scanf("%lld",&a[i]);
        }
        for(int i=0;i<n;i++){
            scanf("%lld",&x);
            if(x>a[i]){
                if((x-a[i])%2==1){n2++;n1+=((x+1)-a[i])/2;}
                else {n1+=(x-a[i])/2;}
            }
            else {
                n2+=(a[i]-x);
            }
 
        }
 
        if(n1>=n2) printf("Yes\n");
        else {
            printf("No\n");
        }
    }
 
    return 0;
}

Measured memory_bytes: 1700
#include<iostream>
using namespace std;
int main() {
	long long a, b, n, ans; cin >> a >> b >> n;
	ans = a * (b - 1) / b - a * ((b - 1) / b);
	if (n < b) {
		ans = a * n / b - a * (n / b);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
using namespace std;

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

const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl

ll a[3 * maxn];
priority_queue<ll, vector<ll>, greater<ll> > que_1;
priority_queue<ll> que_2;

ll suffix[3 * maxn];

int main() {
    //freopen(".in", "r", stdin);
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= 3 * n; i++) {
        scanf("%lld", &a[i]);
    }
    ll prefix = 0;
    for (int i = 1; i <= n; i++) {
        que_1.push(a[i]);
        prefix += a[i];
    }
    ll sum = 0;
    for (int i = 3 * n; i >= n + 1; i--) {
        if (que_2.size() == n) {
            if (a[i] >= que_2.top()) {
                suffix[i] = sum;
                continue;
            }
            sum -= que_2.top();
            que_2.pop();
        }
        que_2.push(a[i]);
        sum += a[i];
        if (que_2.size() == n) suffix[i] = sum;
    }
    ll ans = -LL_INF;
    for (int i = n + 1; i <= 2 * n + 1; i++) {
        ans = max(ans, prefix - suffix[i]);
        if (a[i] <= que_1.top()) continue;
        prefix -= que_1.top();
        que_1.pop();
        prefix += a[i];
        que_1.push(a[i]);
    }
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> t(n + 1), x(n + 1), y(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for (int i = 1; i <= n; ++i) {
        int t_diff = t[i] - t[i - 1];
        int x_diff = abs(x[i] - x[i - 1]);
        int y_diff = abs(y[i] - y[i - 1]);
        if (t_diff % (x_diff + y_diff)) {
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll n, m;
        cin >> n >> m;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
        }
        sort(v.begin(), v.end());
        vector<pair<ll,ll>> a(m);
        for(i = 0; i < m; i++){
            cin >> a[i].ss >> a[i].ff;
        }
        sort(a.begin(), a.end());
        ll cnt = 0;
        for(i = m - 1; i >= 0; i--){
            while(a[i].ss--){
                if(v[cnt] >= a[i].ff){
                    cnt = n;
                    break;
                }
                v[cnt++] = a[i].ff;
                if(cnt == n){
                    break;
                }
            }
            if(cnt == n){
                break;
            }
        }
        ll ans = 0;
        for(i = 0; i < n; i++){
            ans += v[i];
        }
        cout << ans;
    }

    return 0;
}


Measured memory_bytes: 5532
def bubble_sort(A, N):
    A = list(A)
    for i in range(1, N):
        for j in range(0, N-i):
            if A[j][1] > A[j+1][1]:
                A[j], A[j+1] = A[j+1], A[j]
    tmp = []
    for x, y in A:
        tmp.append(x+str(y))
    return tmp


def selection_sort(A, N):
    A = list(A)
    for i in range(0, N-1):
        pivot = i
        for j in range(i+1, N):
            if A[pivot][1] > A[j][1]:
                pivot = j
        if pivot != i:
            A[pivot], A[i] = A[i], A[pivot]
    tmp = []
    for x, y in A:
        tmp.append(x+str(y))
    return tmp


N = int(input())
X = list(map(str, input().split()))
A = []
for x in X:
    A.append((x[0], int(x[1])))
A = tuple(A)
a = bubble_sort(A, N)
print(*a)
print('Stable')
b = selection_sort(A, N)
print(*b)
if a == b:
    print('Stable')
else:
    print('Not stable')



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

int main(){
	long long A, C;
	float B;
	cin >> A >> B;
	
	int D = B * 100 + 0.5;
	
	C = (A/100)*D + ((A%100)*D)/100;
	cout << C << endl;
}


Measured memory_bytes: 3692
from fractions import gcd
from math import sqrt
from heapq import *
from math import factorial
from collections import defaultdict

N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
m=(N//g)*(M//g)*g
a=0
b=0
A=m//N
B=m//M
t=True
while(a<N):
    if S[a]==T[b]:
        a+=B
        b+=A
    else:
        print(-1)
        quit()
print(m)


Measured memory_bytes: 66156
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int c[21] = {};
	for (int i = 0; i < m; i++)
		cin >> c[i];
	int dp[50001] = {};
	fill_n(dp, n+1, INT_MAX / 2);
	dp[0] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = c[i]; j <= n; j++) {
			dp[j] = min(dp[j], dp[j-c[i]] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1364
N = list(map(int,input().split()))#array = list(map(int, input().strip().split()))
job = list(input())

AB = N[1] + N[2]
x = 0
y = 0

for i in range(N[0] ):
    if job[i] == "a":
        if x < AB:
            x += 1
            print("Yes")
        else:
            print("No")
    
    elif job[i] == "b":
        if x < AB and y < N[2]:
            x += 1
            y += 1
            print("Yes")
        else:
            print("No")
            
    elif job[i] == "c":
        print("No")

Measured memory_bytes: 9936
N, M = map(int, input().split())
lst_n = [input() for _ in range(N)]
lst_m = [input() for _ in range(M)]

for idx1 in range(N - M + 1):
    lst_j = [x for x in lst_n[idx1 : idx1 + M]]
    for idx2 in range(N - M + 1):
        lst_k = [y[idx2 : idx2 + M] for y in lst_j]
        if lst_k == lst_m:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <set>

using namespace std;
#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 rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	int max1 = max({ a,b,c });
	print(9 * max1 + a + b + c);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1 << 29;
const double EPS = 1e-9;

lint divisor(lint n) {
	lint min = INF, tmp, cnt;
	for (lint i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			tmp = n / i;
			cnt = 0;
			while (tmp != 0) {
				tmp /= 10;
				++cnt;
			}
			min = min > cnt ? cnt : min;
		}
	}
	return min;
}

int main() {

	cin.tie(0);

	lint N;
	cin >> N;

	cout << divisor(N);

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
A = [int(input()) for _ in range(n)]

prime_dict = defaultdict(lambda : True)
prime_dict[0],prime_dict[1] = False,False
finished = defaultdict(lambda : False)

ans = 0
for a in A:
    if not finished[a]:
        root_a = int(a**0.5)
        for i in range(2,root_a + 1):
            if a % i == 0:
                prime_dict[a] = False
                break
        finished[a] = True
    if prime_dict[a]:
        ans += 1

print(ans)











Measured memory_bytes: 7272
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    int n;
    cin>>n;
    V<int> h(n);
    cinf(n,h);
    reverse(all(h));
    bool ok=1;
    for(int i=1;i<n;i++){
        if(h[i]>h[i-1]){
            if(h[i]-h[i-1]>1){
                ok=0;
                break;
            }
            h[i]--;
        }
    }
    cout<<(ok?"Yes":"No")<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3780
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇
    let x = io.read::<i64>();
    for i in 1..999999999 {
        if (i + 1) * (i + 2) / 2 > x {
            let n = x - i * (i + 1) / 2;
            io.writeln(i + if n > 0 { 1 } else { 0 });
            return;
        }
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for (int i=1;i<=(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll n;
    cin>>n;
    ll ans =0;
    rep(i,n){
        if(i%3==0 || i%5==0) continue;
        ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5 + 5;


signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    
    string s; cin >> s;
    for (auto& c : s) {
        if (c == '?') c = 'D';
    }
    cout << s << endl;
    return 0;
}

/*

*/

Measured memory_bytes: 3692
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0; ;
		//int t = int.Parse(Console.ReadLine());
		//string str = Console.ReadLine();
		///int[] vals = parseAry(Console.ReadLine().Split(cs));
		//int n = int.Parse(Console.ReadLine());

		//int num = vals[0];

		int n=int.Parse(Console.ReadLine());
		int res = 1;
		List<String> li=new List<string>();
		li.Add(Console.ReadLine());
		for ( int i = 1; i < n;i++ ){
			string str=Console.ReadLine();
			if(li.Contains(str)){res=0;break;}
			li.Add(str);
			if ( li[i - 1][li[i - 1].Length - 1] != li[i][0] ) { res = 0; break; }

		}
			if ( res == 1 ) {
				Console.WriteLine("Yes");
			} else {

				Console.WriteLine("No");
			}
		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}
	
	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
cin>>n;
bool flag=false;
for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
        if(i*4+j*7==n){
            flag=true;
        }
    }
}
if(flag){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}












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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    //cout << 1 << endl;
    cout << max(A*B, C*D);
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, W;
	cin >> n >> W;
	vector<int> w(n), v(n);
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	long long 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 {
				dp[i][j] = dp[i - 1][j];
				if (j >= w[i - 1]) {
					dp[i][j] = max(dp[i][j], v[i - 1] + dp[i - 1][j - w[i - 1]]);
				}
			}
		}
	}
	cout << dp[n][W];
	return 0;
}

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

int main() {
  int a, b, c;
  int x;
  cin >> x;
  a = x / 100;
  b = (x - a * 100) / 10;
  c = x - a * 100 - b * 10;
  cout << a + b + c << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer N = Integer.parseInt(scanner.next());
        Integer M = Integer.parseInt(scanner.next());
        Integer[] digit = new Integer[N];

        Arrays.fill(digit, -1);
        for (int i = 0; i < M; i++) {
            Integer S = Integer.parseInt(scanner.next());
            Integer C = Integer.parseInt(scanner.next());
            if(digit[S-1] == -1 || digit[S-1] == C) {
                digit[S-1] = C;
            } else {
                System.out.println(-1);
                System.exit(0);
            }
        }

        boolean first = true;
        for (int i = 0; i < digit.length; i++) {
            if(digit[0] == 0 &&  digit.length > 1) {
                System.out.println(-1);
                System.exit(0);
            } else if(digit[i] == -1 && first && digit.length > 1) {
                digit[i] = 1;
            } else {
                if(digit[i] == -1)  digit[i] = 0;
            }
            first = false;
        }

        String kekka = new String();
        for (Integer n: digit) kekka += n;
        System.out.println(kekka);

    }
}


Measured memory_bytes: 23252
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    x, y = ns()

    for i in range(x + 1):
        if y == 2*i+4*(x-i):
            print("Yes")
            exit(0)

    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10716
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;cin>>s>>t;
	if(t.size()>s.size()){cout<<"UNRESTORABLE";return 0;}
	string ans="";
	for(int i=0;i<=s.size()-t.size();++i){
		bool f=1;
		for(int j=0;j<t.size();++j){
			if(s[j+i]!='?'&&s[j+i]!=t[j]){f=0;break;}
		}
		if(f){
			string ss="";
			int j=0;
			for(;j<i;++j)ss+=(s[j]=='?'?'a':s[j]);
			for(;j<t.size()+i;++j)ss+=(t[j-i]);
			for(;j<s.size();++j)ss+=(s[j]=='?'?'a':s[j]);
			if(ans=="")ans=ss;
			else ans=min(ans,ss);
		}
	}
	if(ans!="")cout<<ans<<endl;
	else cout<<"UNRESTORABLE";
	return 0;
}


Measured memory_bytes: 3572
#define r(a,i)for(i=0;i<a;i++)
#define s (scanf("%d",&w),w)
#define c(a,b)a=a<b?a:b
i,j,w,n,m,d[999],p[999];main(){n=s;m=s;r(n,i)d[i]=s;r(n,i)p[i]=1e9;r(m,j){s;r(n,i)c(p[i],p[i+1]+w*d[n-i-1]);}printf("%d\n",*p),exit(0);}

Measured memory_bytes: 604
#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;

//auto

int main(){
int n,k;
cin>>n>>k;
int h;
int sum=0;
rep(i,n){
  cin>>h;
  if(h>=k)sum++;
}
  cout<<sum<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	if (n == 0) {
		cout << 0 << endl;
		exit(0);
	}
	string s = "";
	while (n != 0) {
		if (n % -2 != 0) {
			s = "1" + s;
			--n;
		}
		else {
			s = "0" + s;
		}
		n /= -2;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll cnt[1000000];
int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'C') cnt[i]++;
		if (i > 0) cnt[i] += cnt[i - 1];
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int k;
		cin >> k;
		ll ans = 0;
		ll sum = 0;
		int L = 0;
		if (S[0] == 'D') sum += cnt[k - 1] - cnt[1], L++;
		for (int j = 1; j + 1 < N; j++) {
			if (S[j] == 'M') {
				ans += sum;
			}
			if (S[j] == 'D') {
				L++;
				ll add = cnt[min(j + k - 1, N - 1)];
				add -= cnt[min(j, N - 1)];
				sum += add;
			}
			else if (S[j] == 'C') {
				sum -= L;
			}
			if (j >= k - 1 && S[j - k + 1] == 'D') L--;
		}
		cout << ans << endl;
	}

}


Measured memory_bytes: 9220
#include<string>
#include<iostream>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	
    int num;
    vector<int> d;
  	int tmp;	
  
  	cin >>num;
  
  	for(int i=0;i<num;i++){
      cin>>tmp;
      d.push_back(tmp);
    }
  
 	sort(d.begin(),d.end());
  	
  	cout<<d[num/2]-d[num/2-1];	
      
	return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        int K = sc.nextInt();
        int answer;
        int[] array = new int[number];
        for(int i = 0;i<number;i++){
            array[i] = sc.nextInt();
        }
        
       answer = number -K;
       if(answer%(K-1) == 0){
           System.out.print(answer/(K-1) + 1);
       }else{
           System.out.print(answer/(K-1) +2);
       }
        
    }
    
}


Measured memory_bytes: 48860
s = input()
s = s.split()
n = []

for i in s:
    n.append(int(i))

a = n[0]
b = n[1]

print("a",end = " ")

if a > b:
    print(">",end = " ")
elif a < b:
    print("<",end = " ")
else:
    print("==",end = " ")

print("b")


Measured memory_bytes: 5596
n = int(input())
sp = [input().split() + [i] for i in range(n)]
for i in sp:
    i[1] = int(i[1])
sp.sort(key=lambda x: x[1], reverse=True)
sp.sort(key= lambda x: x[0])
for i in sp:
    print(i[2] + 1)

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

using namespace std;

typedef long long ll;
const ll mod=1e9+7;
ll a[5000];
int main()
{
	ll n,k;
	ll ans=0;
	ll temp=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=n;i<2*n;i++){
		a[i]=a[i-n];
	}
//	cout<<n;
	for(int i=0;i<n;i++){
		for(int j=n;j<2*n;j++){
			if(a[i]>a[j])ans++;
		}
//		cout<<ans<<" ";
		for(int k=i+1;k<n;k++){
//			if(k==n) continue;
			if(a[i]>a[k]) temp++;
		}
	}
//	cout<<ans<<" "<<temp<<endl;
	cout<<(((k*(k-1)/2)%mod*ans%mod)%mod+(temp*k)%mod)%mod; 
	return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [X, Y] = input[0].map(Number);

  for (let i = 0; i <= X; i++) {
    const legCount = i * 2 + (X - i) * 4;

    if (legCount === Y) {
      return "Yes";
    }
  }

  return "No";
};

console.log(main(read()));


Measured memory_bytes: 29600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> p;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
vector<ll> diviser(ll X){
    vector<ll> res;
    for(ll i=1;i*i<=X;++i){
        if(X%i==0){
            res.push_back(i);
            if(i!=X/i) res.push_back(X/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}
int main(){
    ll N;cin>>N;
    auto res1=diviser(N-1);
    auto res2=diviser(N);
    ll ans=(int)res1.size()-1;
    for(auto it:res2){
        if(it==1) continue;
        ll M=N;
        while(M%it==0) M/=it;
        if(M%it==1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;

    vector <int> a(n);

    loop(i,0,n) cin>>a[i];

    int ans=0;

    for(int i=0;i<n;)
    {
        int j=i+1;
        int c=0;
        while(j<n and a[j]<=a[j-1])
        {
            j++;
            c++;
        }
        i=j;
        ans=max(ans,c);
    }

    cout<<ans;


    return 0;
}


Measured memory_bytes: 3968
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}




// long search(string &s,vector<bool> dig){
//   long ans = 0;
//   int num = atoi(numStr.c_str());






//   return ans;
// }




int main() {

  string s;

  cin >> s;

  long ans = 0;

  long n = s.size();


  // vector<bool> dig(n-1,false);
  vector<long> dig(n);
  for (int i = 0; i < n; ++i) {
    dig[i] = (long)(s[i] - '0');
  }

  //n-1の区間の全列挙
  for (int i = 0; i < (1 << (n - 1)); i++) {
    long count = 1;
    for (int j = 0; j < n - 1; j++) {
      if (i & (1 << j)) { //一致したなら+がある
        for (int l = 0; l < count; l++) {
          ans += dig[j - l] * pow(10, l);
        }
        count = 1;
      } else {
        count++;
      }
    }

    
    for (int l = 0; l < count; l++) {
      ans += dig[n-1 - l] * pow(10, l);
    }

  }




  // ans = search(s,dig);




  cout << ans;


}




















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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  int sum = 0;
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(sum %10 != 0){
    cout << sum << endl;
  }
  else{
    for(int i=0; i<N; i++){
      if(vec.at(i) %10 != 0){
        cout << sum -vec.at(i) << endl;
        break;
      }
      if(i == N-1){
        cout << 0 << endl;
      }
    }
  }
}

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



using namespace std;
typedef long long ll;

int main(){
  double a,b,h,m;
  double pi = 3.141592653589793238;

  cin >> a >> b >> h >> m;

  

  double cdeg;

  //cdeg

  double hdeg = (h + m/60.0f)/12.0f * 360.0f - 180.0f;

  double mdeg = (m/60.0f)*360.0f - 180.0f;
  double subdeg = hdeg-mdeg;

  cdeg = subdeg;

  double res = sqrt(pow(a,2.0f) + pow(b,2.0f) - 2.0f*a*b*cos(cdeg * pi / 180.0f));
  cout << std::fixed << std::setprecision(15) << res << endl;
}

Measured memory_bytes: 4248
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int k;
  cin >> k;
  if (k == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int r = 0;
  for (int i = 1; i <= 1000000; ++i) {
    r = (10 * r + 7) % k;
    if (r == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3568
N, K = map(int, input().split())
p = list(map(int, input().split()))
s = sum(p[:K])
m = sum(p[:K])
if K == N:
  print((s + N) / 2)
else:
  for i in range(K, N):
      s = s - p[i - K] + p[i]
      if s >= m:
        m = s
  print((m + K) / 2)


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;

const int N = 7;

int n, m;
int dig[N];

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

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

    cin >> n >> m;
    for (int i=1;i<=m;i++){
        int a, b;
        cin >> a >> b;
        if (a > n){
            cout << -1 << el;
            return 0;
        }
        if (dig[a] == -1) dig[a] = b;
        else if (dig[a] != b){
            cout << -1 << el;
            return 0;
        }
    }

    if (dig[1] <= 0){
        if (n > 1){
            if (dig[1] == 0) cout << -1 << el;
            else{
                cout << 1;
                for (int i=2;i<=n;i++){
                    cout << max(dig[i], 0);
                }
                cout << el;
            }
        } else{
            cout << 0 << el;
        }
        return 0;
    }

    for (int i=1;i<=n;i++){
        cout << max(dig[i], 0);
    }
    cout << el;

    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)

    tailrec fun printCase(no: Int) {
        val x =scanner.nextInt()
        if (x != 0) {
            println("Case ${no}: ${x}")
            printCase(no + 1)
        }
    }
    printCase(1)
}



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

int main() {

    int k; cin >> k;
    int ans = -1;
    int now = 7;
    for (int i = 1; i <= k+10; i++) {
        if (now % k == 0) {
            ans = i;
            break;
        }
        else {
            now = 10 * now + 7;
            now %= k;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  vector<int> A(5);
  vector<int> B(5,0);
  for(int i=0;i<5;i++){
    cin >> A.at(i);
    if(A.at(i)%10==0){
      B.at(i) = 0;
    }else{
      B.at(i) = 10 - (A.at(i)%10);//A=14 なら B=6
    }
  }
  int sum=0;
  int maxB=0;
  for(int i=0;i<5;i++){
    sum += (A.at(i)+B.at(i));
    maxB = max(maxB,B.at(i));
  }
  cout << sum - maxB << endl;
}

Measured memory_bytes: 256
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;                         

const int N = (int)5e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int a[10];
void solve () {
	string s;
	cin >> s;
	for (int i = 0 ; i < sz (s); i ++) {
	    char c = s[i];
		if (c == 'N') a[1] = 1;
		if (c == 'S') a[2] = 1;
		if (c == 'W') a[3] = 1;
		if (c == 'E') a[4] = 1;
	}
	if (a[1] + a[2] == 1 || a[3] + a[4] == 1) {
		cout << "No";
	}
	else cout << "Yes";
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int max_n = min(A,B);
  int min_n;
  if(A + B <= N) min_n = 0;
  else min_n = A + B - N;
  cout << max_n << " " << min_n << endl;
}

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

int N, A, B, C, D;

int main() {
	scanf("%d%d%d%d%d", &N, &A, &B, &C, &D);
	--N;
	for (int i = 1; i <= N; ++i) {
		long long l = 1LL * C * i - 1LL * D * (N - i);
		long long r = 1LL * D * i - 1LL * C * (N - i);
		//cerr << l << ' ' << r << endl;
		if (l <= B - A && B - A <= r) return printf("YES\n"), 0;
	}
	printf("NO\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef  long double ld;
#define inc(i,a,b)  for(long long int i=a;i<=b;i++)
#define dec(i,a,b)  for(long long int i=a;i>=b;i--)
#define fast   ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb  push_back
#define all(c)  (c).begin(),(c).end()
#define lv  vector<ll>
#define cv  vector<char>
#define dv  vector<ld>
#define rall(c)  (c).rbegin(),(c).rend()
#define lpr pair<ll,ll>
#define mp make_pair
#define input(c) ll c;cin>>c;
#define lmap map<ll,ll>
#define vinp(a,n) inc(i,1,n){ input(k); a.pb(k); }
#define LIM 1000000007
#define F first
#define S second
#define fr(n) inc(i,0,n-1)
#define fri(n,a) inc(i,0,n-1){ cin>>a[i]; }
void solve()
{
	ll i,j;
	ll n;
	cin>>n;
	ll a[n];
	ll sum=0;
	fri(n,a);
	fr(n-1)
	{
		inc(j,i+1,n-1)
		sum+=a[i]*a[j];
	}
	cout<<sum;
}
int main()
{
	fast;
	ll t=1;
    //cin>>t;
	while(t--)
    solve();
}


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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a + b == c + d){
        cout << "Balanced" << endl;
    }else if(a + b > c + d){
        cout << "Left" << endl;
    }else{
        cout << "Right" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		for(;;){
			String x = sc.next();
			if(x.equals("0")) break;
			int sum = 0;
			for(int i = 0; i < x.length(); ++i){
				sum += (x.charAt(i) - '0');
			}
			System.out.println(sum);
		}
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


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

using namespace std;

#define ZFor(i,n) for(int i=0;i<n;i++)
#define WFor(i,n) for(int i=1;i<=n;i++)
#define Max -2100000000
#define Min 2100000000

typedef pair<int,int> P;

int main(void){
	
	int n,a,b,c[10000],pizzakal,kal=0,dll=0,ans=0;
	
	scanf("%d",&n);
	scanf("%d %d",&a,&b);
	scanf("%d",&pizzakal);
	ZFor(i,n) scanf("%d",&c[i]);
	sort(c,c+n,greater<int>());
	kal=pizzakal;
	dll=a;
	
	//printf("%d %d\n",kal,dll);
	
	ans=kal/dll;
	
	
	
	ZFor(i,n){
		kal+=c[i];
		dll+=b;
		if(ans<kal/dll){
		//	printf("%d %d %d\n",i,kal,dll);
			ans=kal/dll;
		//	printf("%d %d\n",i,ans);
		}
	}
	
	printf("%d\n",ans);
	
	return 0;
}

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

class E
{
    private const long M = 1000000007;

    static void Main()
    {
        int n = Int32.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(Int32.Parse).ToList();

        int[] count = {0, 0, 0};
        long ans = 1;

        for (int i = 0; i < n; i++)
        {
            int j = -1;
            int k = 0;
            if (a[i] == count[0]) { j = 0; k++; }
            if (a[i] == count[1]) { j = 1; k++; }
            if (a[i] == count[2]) { j = 2; k++; }
            if (j >= 0) ++count[j];
            ans = (ans * k) % M;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 17632
def main():
  n=int(input())
  a=list(map(int,input().split()))
  b=list(map(int,input().split()))
  c=[a[i]-b[i] for i in range(n)]
  c0=sum([ci for ci in c if ci>0])
  c1=sum([-2*((ci+2-1)//2) for ci in c if ci<0])
  print('Yes' if c1>=2*c0 else 'No')
if __name__=='__main__':
  main()


Measured memory_bytes: 4852
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Random;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int D;
	int[] c;
	int[][] s;

	int[] ans;

	long score(int[] a, int dd) {
		int[] last = new int[26];

		long res = 0;

		for (int d = 0; d < dd; d++) {
			res += s[d][a[d]];
			last[a[d]] = d + 1;

			for (int j = 0; j < 26; j++) {
				res -= (c[j] * (d + 1 - last[j]));
			}
//			System.err.println(res);
		}
		return res ;
	}
	
	
	long score2(int[] a) {
		long res = 0;
		for(int i=0;i<26;i++) {
			res += scores(i, a);
		}
		return res;
	}
	//問題iについてのスコア
	long scores(int i, int[] a) {
		int last = 0;
		long res = 0;

		for (int d = 0; d < D; d++) {
			if(a[d] == i) {
				res += s[d][i];
				last = d + 1;
			}

			res -= (c[i] * (d + 1 - last));
		}
		return res ;		
	}

	public void _main(String[] args) {
		long st = System.currentTimeMillis();
		Scanner sc = new Scanner(in);

		D = sc.nextInt();
		c = new int[26];
		for (int i = 0; i < 26; i++) {
			c[i] = sc.nextInt();
		}

		s = new int[D][26];
		for (int i = 0; i < D; i++) {
			for (int j = 0; j < 26; j++) {
				s[i][j] = sc.nextInt();
			}
		}

		sc.close();

		ans = new int[D];


		for(int d=0;d<D;d++) {
			long max = score(ans, d+1);
			
			for(int i=0;i<26;i++) {
				int t = ans[d];
				ans[d] = i;
				long s = score(ans, d+1);
				
				if(s > max) {
					max = s;
				}else {
					ans[d] = t;
				}
			}
		}
		
//		System.err.println(score(ans,D));
//		System.err.println(score2(ans));
		
		Random random = new Random();
		long max = score(ans, D);
		while (System.currentTimeMillis() - st < 1900) {
			int d = random.nextInt(D);
			int i = random.nextInt(26);
			
			int t = ans[d];
			if(t==i) continue;
			
			long s = 0;
			s -= scores(i,ans);
			s -= scores(t,ans);
			
			ans[d] = i;
			
			s += scores(i, ans);
			s += scores(t, ans);
			
			if(s > 0) {
				max += s;
			}else {
				ans[d] = t;
			}
		}

//		System.err.println(max);

		StringBuilder sb = new StringBuilder();
		for (int x : ans) {
			sb.append(x+1);
			sb.append("\n");
		}
		out.print(sb.toString());

	}

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


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

int main() {
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}

Measured memory_bytes: 3200