akhauriyash/Code-Regression huggingface dataset:
MyString=Union{String,SubString{String},Char}
MyStringArray=Union{Array{String,1},Array{SubString{String},1},Array{Char,1}}
parseInt(x::MyString) = parse(Int, x)
parseInt(x::Real) = trunc(Int, x)
parseBigInt(x::MyString) = parse(BigInt, x)
parseBigInt(x::Real) = trunc(BigInt, x)
parseFloat(x::MyString) = parse(Float64, x)
parseFloat(x::Real) = trunc(Float64, x)
parseBigFloat(x::MyString) = parse(BigFloat, x)
parseBigFloat(x::Real) = trunc(BigFloat, x)
parseMap(x::MyStringArray) = map(parseInt, x)
parseMapBig(x::MyStringArray) = map(parseBigInt, x)

function main()
    n=parseInt(readline())
    a=sort(parseMap(split(readline())))
    ans=10^9
    for i in a[1]:a[end]
        res=0
        for j in a
            res+=(i-j)^2
        end
        ans=min(res,ans)
    end
    println(ans)
end
main()

Measured memory_bytes: 116332
H, N = map(int, input().split())
inf = 1 << 32
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    a,b = map(int, input().split())
    for j in range(H+1):
        dp[min(H,j + a)] = min(dp[min(H,j + a)], dp[j] + b)
print(dp[H])

Measured memory_bytes: 44648
#include <bits/stdc++.h>
#define F(i, s, t) for (int i = (s), _ = (t); i <= _; i ++)
#define LL long long
int rd() {
	int x = 0, f = 1; char c;
	do { c = getchar(); } while (!isdigit(c));
	do { x = x*10+c-'0', c = getchar(); } while (isdigit(c));
	return x*f;
}
const int N = 10005;
int n, a[N], b[N];
LL A, B;
int main() {
	n = rd();
	F(i, 1, n) a[i] = rd();
	F(i, 1, n) b[i] = rd();
	F(i, 1, n)
		if (a[i] > b[i])
			A += a[i] - b[i];
		else B += b[i] - a[i] >> 1;
	puts(A <= B ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define DEBUG(x) cout << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)          \
  cerr << #v << ": ";         \
  REP(__i, (v).size())        \
  cerr << ((v)[__i]) << ", "; \
  cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;

  char c = 'X';
  bool is_bad = false;
  REP(i, s.size()) {
    if (c == s[i]) {
      is_bad = true;
      break;
    }
    c = s[i];
  }
  if (is_bad)
    cout << "Bad" << endl;
  else
    cout << "Good" << endl;

  return 0;
}


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

Measured memory_bytes: 1032
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>

#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
map<string, ll>a;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}
string num[10] = { "pon","pon","hon","bon","hon","hon","pon","hon","pon","hon" };

int main() {
	string S;
	ll K;
	cin >> K >> S;
	if (S.size() > K) {
		cout << S.substr(0,K) << "...";

	}
	else {
		cout << S;
	}
}


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

using namespace std;

vector<string> str;
vector<pair<int, int>> opclo;

bool cmp1(const int &a, const int &b)
{
    return (opclo[a].first < opclo[b].first);
}
bool cmp2(const int &a, const int &b)
{
    return (opclo[a].second < opclo[b].second);
}
vector<int> ind;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    str.assign(n, string());
    opclo.assign(n, pair<int, int>{0, 0});
    ind.assign(n, 0);
    for (int i = 0; i < n; ind[i] = i, i++)
        cin >> str[i];
    vector<int> pos, neg, zero;
    for (int i = 0; i < n; i++)
    {
        pair<int, int> tmp{0, 0};
        stack<int> ss;
        for (int j = 0; j < str[i].size(); j++)
        {
            if (str[i][j] == '(')
                ss.push(j);
            else if (!ss.empty())
                ss.pop();
            else
                tmp.first++;
        }
        while (!ss.empty())
        {
            ss.pop();
            tmp.second++;
        }
        opclo[i] = tmp;
        if (tmp.first == 0 && tmp.second == 0)
            zero.push_back(i);
        else if (tmp.second - tmp.first >= 0)
            pos.push_back(i);
        else
            neg.push_back(i);
    }
    // cout << "beore sort" << endl;
    sort(pos.begin(), pos.end(), cmp1);
    sort(neg.rbegin(), neg.rend(), cmp2);
    // cout << "after sort" << endl;
    string thestr = "";
    for (int i = 0; i < pos.size(); i++)
        thestr += str[pos[i]];
    for (int i = 0; i < zero.size(); i++)
        thestr += str[zero[i]];
    for (int i = 0; i < neg.size(); i++)
        thestr += str[neg[i]];
    stack<int> ss;
    bool fg = true;
    for (int i = 0; i < thestr.size(); i++)
    {
        if (thestr[i] == '(')
            ss.push(i);
        else
        {
            if (!ss.empty())
                ss.pop();
            else
            {
                fg = false;
                break;
            }
        }
    }
    if (ss.empty() && fg)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 53220
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N, a1 = 0, b1 = 0, a2 = 0, b2 = 0;cin >> N;
map<ll, ll> A;
map<ll, ll> B;

rep(i, 0, N/2){

    ll a, b;cin >> a >> b;

    A[a]++;B[b]++;

}
  
ll x, y;
  
//for(auto a : A )cout << a.first << " " << a.second << endl;
//  cout << endl;
//for(auto b : B )cout << b.first << " " << b.second << endl;

for(auto a : A )a1 = max(a1, a.second);
  
for(auto a : A ){
  if(a.second == a1)x = a.first;
}

for(auto b : B )b1 = max(b1, b.second);
  
for(auto b : B ){
  if(b.second == b1)y = b.first;
}

//cout << x << " " << y << endl;
  
A[x] = -1;
B[y] = -1;

for(auto a : A )a2 = max(a2, a.second);

for(auto b : B )b2 = max(b2, b.second);
  
//cout << a1 << " " << b1 << endl;
//cout << a2 << " " << b2 << endl;
//cout << x << " " << y << endl;

if(x == y)cout << min(N - a1 - b2, N - b1 - a2);

else cout << N - a1 - b1;

}

Measured memory_bytes: 9716
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int64_t i,j,r=0,g=0,b=0;
    for(i=0; i<N; i++){
        if(S.at(i) == 'R') r++;
        else if (S.at(i) == 'G') g++;
        else b++;
    }
    int maxdist = (N+1)/3;
    int count = 0;
    for(i=0; i<N-2; i++){
        for(j=1; j<=(N-i-1)/2; j++){
            if( S.at(i) == S.at(i+j) ) continue;
            if( S.at(i) == S.at(i+2*j) ) continue;
            if( S.at(i+j) == S.at(i+2*j) ) continue;
            count++;
        }
    }
    int64_t ans;
    ans = r*g*b - count;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3644
def main():
    N = int(input())
    P = tuple([int(i) for i in input().split()])
    Q = tuple([int(i) for i in input().split()])
    a, b = -1, -1
    from itertools import permutations
    for i, per in enumerate(permutations(range(1, N+1), N)):
        if per == P:
            a = i+1
        if per == Q:
            b = i+1
    print(abs(a-b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
import java.util.Scanner;

//AtCoder Beginner Contest 127
//B	Algae
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int D = sc.nextInt();
		int x2000 = sc.nextInt();

		sc.close();

		int pre = x2000;
		for (int i = 0; i < 10; i++) {
			int ans = pre * r - D;
			System.out.println(ans);
			pre = ans;
		}

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
int s[100];

int main() {
	cin >> N;
	REP(i, N) cin >> s[i];
	
	int sum = accumulate(s, s + N, 0);
	int ans = 0;
	if (sum % 10 != 0) ans = sum;
	else {
		int mn = INF;
		REP(i, N) if (s[i] % 10 != 0) chmin(mn, s[i]);
		if (mn != INF) ans = sum - mn;
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll a, b; cin >> a >> b;

    if(abs(a-b)%2 == 1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (a<b?a+(b-a)/2:b+(a-b)/2) << endl;

    return 0;
}

Measured memory_bytes: 3628
S = input()

def itoc(i): return chr(ord('a') + i)
def ctoi(c): return ord(c) - ord('a')

if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit()
if len(S) == 26:
    i = 25
    while i > 0:
        if S[i-1] > S[i]:
            i -= 1
        else:
            ans = S[:i-1]
            for ci in range(ctoi(S[i-1])+1, 27):
                if itoc(ci) in ans: continue
                ans += itoc(ci)
                print(ans)
                exit()
else:
    for i in range(26):
        c = itoc(i)
        if c in S: continue
        print(S + c)
        break


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    string S;
    int N,count=0;
    cin >> N >> S;
    rep(i,N-2){
        if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
            count++;
        }
    }

    cout << count << endl;
}

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

const int INF = (1<<29);

class State{
public:
  int d,n,s;
  State(int d = 0,int n = 0,int s = 0):d(d),n(n),s(s){}
  bool operator < (const State &st) const { return d > st.d;}
};

class State2{
public:
  int d;
  bool f;
  State2(int d = INF,bool f = false):d(d),f(f){}
};

int main(){
  int n,m;
  while(cin >> n >> m && n && m){
    vector<vector<int> > L(n,vector<int>(n,INF)), S(n,vector<int>(n,INF));
    for(int i=0;i<m;i++){
      int a,b;
      int c;
      char d;
      cin >> a >> b >> c >> d;
      a--;
      b--;
      if(d == 'L') L[a][b] = L[b][a] = c;
      else S[a][b] = S[b][a] = c;
    }

    
    for(int k=0;k<n;k++){
      L[k][k] = S[k][k] = 0;
      for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
	  for(int l=0;l<2;l++){
	    if(l == 0){
	      if(L[i][k] >= INF || L[k][j] >= INF) continue;
	      L[i][j] = min(L[i][j],L[i][k]+L[k][j]);
	    }
	    else{
	      if(S[i][k] >= INF || S[k][j] >= INF) continue;
	      S[i][j] = min(S[i][j],S[i][k]+S[k][j]);
	    }
	  }
	}
      }
    }

    int n2;
    cin >> n2;
    vector<int> dest(n2);
    for(int i=0;i<n2;i++){
      cin >> dest[i];
      dest[i]--;
    }

    vector<vector<int> > dp(2,vector<int>(n,INF));
    dp[0][dest[0]] = 0;

    for(int i=1;i<n2;i++){
      for(int j=0;j<n;j++){
	if(dp[0][j] >= INF || L[dest[i-1]][j] >= INF) continue;
	for(int k=0;k<n;k++){
	  if(S[j][k] >= INF || L[k][dest[i]] >= INF) continue;
	  dp[1][k] = min(dp[1][k], dp[0][j] + L[dest[i-1]][j] + S[j][k] + L[k][dest[i]]);
	  if(j == k) dp[1][k] = min(dp[1][k], dp[0][j] + L[dest[i-1]][dest[i]]);
	}
      }
      dp[0].assign(dp[1].begin(),dp[1].end());
      dp[1].assign(n,INF);
    }

    int ans = INF;
    for(int i=0;i<n;i++) ans = min(ans,dp[0][i]);

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
using namespace std;
 
long long f(long long n, long long c, long long d) {
  long long n1 = c; 
  long long m = d;
  long long lcm = 0;
  while (m % n1 != 0) {
    long long temp = n1;
    n1 = m % n1;
    m = temp;
  }
  lcm = c * d / n1;
  n -= n / c + n / d - n / lcm;
  
  return n;
}
 
int main()
{
  long long a, b, c, d, ans1, ans2;
  cin >> a >> b >> c >> d;
  ans1 = f(b, c, d);
  ans2 = f(a - 1, c, d);
  
  cout << ans1 - ans2 << endl;
  
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll dp[51][51][101];
ll mo=1000000007;

static const int N_=1020;
static ll C_[N_][N_];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,N_) C_[i][0]=C_[i][i]=1;
	for(i=1;i<N_;i++) for(j=1;j<i;j++) C_[i][j]=(C_[i-1][j-1]+C_[i-1][j])%mo;
	
	cin>>N;
	dp[1][1][50]=dp[1][1][49]=N;
	ll ret=0;
	for(i=1;i<N;i++) {
		ret+=dp[i][N][50];
		for(j=1;j<N;j++) {
			for(k=0;k<=100;k++) if(dp[i][j][k]) {
				FOR(x,N) FOR(y,N) if(j+x+y<=N) {
					if(x+y<max(1,abs(k-50))) continue;
					int nex=((k-50)+x-y);
					if(nex%2) continue;
					nex=nex/2+50;
					if(nex<0||nex>100) continue;
					(dp[i+1][j+x+y][nex] += dp[i][j][k]*C_[x+y][x]%mo*C_[N-j][x+y])%=mo;
				}
			}
		}
	}
	ret+=dp[N][N][50];
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 9472
#include <stdio.h>
 
int main(){
  int n,m,l;
  int a[100][100],b[100][100],i,j,k;
 unsigned long int c[100][100];
  scanf("%d %d %d",&n,&m,&l);
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0; i<m; i++){
    for(j=0; j<l; j++){
      scanf("%d",&b[i][j]);
    }
  }
  for(i=0; i<n; i++){
    for(j=0; j<l; j++){
      c[i][j]=0;
    }
  }//----       
 for(i=0; i<n; i++){//                                                         
    for(j=0; j<l; j++){
      for(k=0; k<m; k++){
        c[i][j]+=(a[i][k]*b[k][j]);
      }
    }
  }
  for(i=0; i<n; i++){
    for(j=0; j<l; j++){
      if(j==l-1)printf("%ld\n",c[i][j]);
      else printf("%ld ",c[i][j]);
    }
  }
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

 

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m,k; cin>>n>>m>>k;
  ll nm=n*m;
  
  rep(i,n+1){
    rep(j,m+1){
      ll tmp=i*m;
      tmp+=j*n-(i*j*2);
      if(tmp==k || nm-tmp==k){
        // cout<<i<<' '<<j<<' '<<tmp<<endl;
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main{
	int x;
	
	public void solve(){
		Scanner sc=new Scanner(System.in);
		x=sc.nextInt();
		System.out.println(x*x*x);
		
		
	}
	
	public static void main(String[] args){
		 Main obj = new Main();
		 obj.solve();
		 
	}
}
	

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

int gcd(int a, int b){
  if (a % b)
    return gcd(b, a % b);
  else
    return b;
}

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

int main(){
  int d;
  int a = 360;
  int g;
  
  cin >> d;
  g = lcm(d,a);
  
  cout << g / d << endl;
  
  return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 100005
using namespace std;
int n,k,a[maxn],ans;
struct node
{
	int v,nxt;
}G[maxn];
int adj[maxn],num_Edge=0;
void add(int x,int y)
{
	G[++num_Edge].v=y;
	G[num_Edge].nxt=adj[x];
	adj[x]=num_Edge;
}
int f[maxn],g[maxn];
void dfs(int x)
{
	//printf("%d",x);
	f[x]=g[x]=0;
	for(int i=adj[x];i!=-1;i=G[i].nxt)
	{
		int V=G[i].v;
		dfs(V);
		f[x]+=f[V];
		if(g[V]+1>=k) f[x]++;
		else g[x]=max(g[x],g[V]+1);
	}
}
int main()
{
	memset(adj,-1,sizeof(adj));
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i>1) add(a[i],i); 
	}
	for(int i=adj[1];i!=-1;i=G[i].nxt)
	{
		dfs(G[i].v);
		ans+=f[G[i].v];
	}
	if(a[1]!=1) ans++;
	printf("%d",ans);
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

void solve() {
  int n,k;cin >> n >> k;

  vector<int> a(n);

  for(auto &i: a){
    cin >> i;
  }

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

  assert(n >= k);

  print(accumulate(a.begin(),a.begin() + k ,0));
}

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  solve();

  return 0;
}


Measured memory_bytes: 3652
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
	
    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        char c[]=sc.getCharSet();
        int r=0;
        for (int i = 0; i < c.length/2; i++) {
			if(c[i]!=c[c.length-i-1])r++;
		}

        out.println(r);
     	out.flush();
    }


    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//
//class P {
//	int x, y, d;
//	P(int  x, int y, int d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return -p.a+a;//as
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  if (s == "ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		String S = in.next();
		int preCount = 0;
		int suffCount = 0;
		StringBuilder ans = new StringBuilder(S);
		for (int i = 0; i < N; i++) {
			if (S.charAt(i) == '(') {
				preCount++;
			}
			if (S.charAt(i) == ')') {
				suffCount++;
			}
			if (preCount > 0 && S.charAt(i) == ')') {
				preCount--;
				suffCount--;
			}
		}
		for (int i = 0; i < suffCount; i++) {
			ans.insert(0, '(');
		}
		for (int i = 0; i < preCount; i++) {
			ans.append(")");
		}
		System.out.println(ans.toString());
		in.close();
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n,m;cin>>n>>m;
    int a[m];REP(i,m)cin>>a[i];
    vector<int>dp(n+1,(int)1<<29);
    dp[0]=0;
    REP(i,n+1)REP(j,m){
        if(i-a[j]>=0)
            dp[i]=min(dp[i-a[j]]+1,dp[i]);
    }
    cout<<dp[n]<<endl;
}



Measured memory_bytes: 3196
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

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

/*
int N;
ll h[100010];

// DP テーブル
ll dp[100010];
*/

int main()
{
	int ans = 0;
	string S; cin >> S;

	for (int i = 1; i < S.size(); i++)
	{
		if (S[i] == S[i - 1])
		{
			(S[i - 1] == '0') ? S[i] = '1' : S[i] = '0';
			ans++;
		}
	}
	//cout << S << endl;
	cout << ans << endl;
}


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

using namespace std;

int main()
{
    long long int n,k,x,y,sum;

    while(scanf("%lld %lld %lld %lld",&n,&k,&x,&y)==4)
    {
        sum=0;

        if(n<=k)
        {
            for(int i=1; i<=n; i++)
            {
                sum+=x;
            }

            printf("%lld\n",sum);
        }

        else
        {
            for(int i=1; i<=k; i++)
            {
                sum+=x;
            }

            for(int i=k+1; i<=n; i++)
            {
                sum+=y;
            }

            printf("%lld\n",sum);
        }
    }

    return (0);
}


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

using namespace std;

int main(){
	string s;
	int n;
	
	cin >> s;
	n=s.size();
	
	if(n>=4 && s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
from collections import deque
from collections import defaultdict


class Graph(object):
    """
    隣接リストによる無向グラフ
    重み無しで距離は１
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst):
        self.graph[src].append(dst)
        self.graph[dst].append(src)

    def get_nodes(self):
        return self.graph.keys()


if __name__ == "__main__":
    n, x, y = map(int, input().split())
    x -= 1
    y -= 1

    g = Graph()
    for i in range(n-1):
        g.add_edge(i, i+1)
    g.add_edge(x, y)

    ans = [0] * (n-1)

    # BFSによる解法
    for i in range(n-1):
        # 始点からの距離
        # -1を未訪問とする
        dist = [-1] * n

        # 初期条件
        # 今回は頂点iから探索を行う
        dist[i] = 0
        que = deque([i])

        while len(que) != 0:
            vertex = que.popleft()
            for v in g.graph[vertex]:
                if dist[v] != -1:
                    pass
                else:
                    tmp = dist[vertex] + 1
                    dist[v] = tmp
                    if v > i:
                        ans[tmp-1] += 1
                    que.extend(g.graph[vertex])

    for a in ans:
        print(a)


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

#define for1(i, n) for (ll i = 1; i <= n; ++i)
#define for0(i, n) for (ll i = 0; i < n; ++i)
#define vll vector<ll>
#define fast std::ios_base::sync_with_stdio(false);
#define ll long long int
#define etc \
  ll t;     \
  cin >> t; \
  while (t--) solve();
#define ntc solve();
#define pb push_back
#define mp make_pair

void solve() {
  ll n;
  cin >> n;

  ll arr[n];

  for0(i, n) cin >> arr[i];

  if (n == 1)
    cout << 0, exit(0);
  else if (n == 2)
    cout << abs(arr[0] - arr[1]), exit(0);

  ll dp[n] = {0};
  dp[0] = 0;
  dp[1] = abs(arr[1] - arr[0]);

  for (int i = 2; i < n; i++)
    dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]),
                dp[i - 2] + abs(arr[i] - arr[i - 2]));

  cout << dp[n - 1];
}

int main() { fast ntc return 0; }

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

using namespace std;

using ll = long long;

struct UnionFind {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;

    UnionFind(int sz) : data(sz, -1) {}

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }

    int find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -data[find(x)];
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        uf.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (uf.find(i) == i);
    }
    cout << ans << endl;
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int A[100];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, sum = 0, ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i], sum += A[i], A[i] *= N;
	for (int i = 0; i < N; i++) {
		if (abs(sum - A[ans]) > abs(sum - A[i])) ans = i;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;


void solve()
{
	int n;
	while (cin >> n, n)
	{
		vector<int> h(n + 1);
		for (int i = 0; i <= n; ++i)
		{
			cin >> h[i];
		}
		h.push_back(1e9);
		for (int i = 0; i <= n; ++i)
		{
			vector<int> use;
			for (int j = 0; j <= n; ++j)
			{
				if (j == i)
				{
					continue;
				}
				use.push_back(h[j]);
			}
			bool isAllSameDiff = true;
			int diff = use[1] - use[0];
			for (int j = 2; j < use.size(); ++j)
			{
				if (use[j] - use[j - 1] != diff)
				{
					isAllSameDiff = false;
					break;
				}
			}
			if (isAllSameDiff)
			{
				cout << h[i] << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1220
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

import copy

# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

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():
    s = list(input())
    k = ni()

    if len(set(s))==1:
        print((len(s)*k)//2)
        exit(0)

    def changer(sss):
        ts = sss.copy()
        cnt = 0
        for i in range(1, len(ts)):
            if ts[i] == ts[i - 1]:
                ts[i] = "@"
                cnt += 1

        return cnt

    print(changer(s) + (k - 1) * (changer(s + s) - changer(s)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5040
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i, a, b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i, a, b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main() {
    int A;
    cin >> A;

    int ans = 0;
    for(int i = 1; i <= A; i++) {
        if (to_string(i).size() % 2 != 0) {
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1e9+7;

ll gcd(ll x, ll y) {
    if(x < y) swap(x, y);
    while(y > 0) {
        int tmp = x;
        x = y;
        y = tmp % y;
    }
    return x;
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    ll ans = a[0];
    rep(i,n-1) ans = gcd(ans, a[i+1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b) {
        cout << c << "\n";
    }
    else if (a == c) {
        cout << b << "\n";
    }
    else {
        cout << a << "\n";
    }

    /*int a;
    cin >> a;*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll ans;
int main(void){
    ll n; cin>>n;
    for(int i=1;i<=n;i++){
        ans+=(i*(n/i)*(n/i+1)/2);
    }
    cout<<ans<<endl;

}



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

int main(void){

  long long n,i,j;
  long long c = 0;
  cin >> n;
  vector<int> a(n);
  for(i = 0;i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  j = n/2;
 while(1){
    if(a[j-1] < a[j]){
      c ++ ;
      a[j-1] = a[j-1] + 1;
    }
    else{
      break;
    }
    
  }

  cout << c << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	int a, b, c, d, e, f;
	int i, j, k;
	int v, u;
	float n;
	vector<int>x, y;

	cin >> a >> b >> c >> d >> e >> f;

	for (i = 0; a * 100 * i <= f; i++) {
		for (j = 0; b * 100 * j <= f; j++) {
			v = a * i * 100 + b * j * 100;
			if (v <= f && v != 0) {
				x.push_back(v);
			}
		}
	}
	for (i = 0; c*i <= f; i++) {
		for (j = 0; d*j <= f; j++) {
			v = c * i + d * j;
			if (v <= f && v != 0) {
				y.push_back(v);
			}
		}
	}

	n = 0;
	v = -1;
	u = -1;
	for (i = 0; i < x.size(); i++) {
		for (j = 0; j < y.size(); j++) {
			if (x[i] + y[j] <= f) {
				if (x[i] / 100 * e >= y[j]) {
					if (100.0 * y[j] / (float)(x[i] + y[j]) > n) {
						n = 100.0 * y[j] / (float)(x[i] + y[j]);
						v = i;
						u = j;
					}
				}
			}
		}
	}
	if (v == -1 && u == -1) {
		cout << a * 100 << " " << 0;
	}
	else {
		cout << x[v] + y[u] << " " << y[u];
	}
	return 0;
}

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;
static const ll MOD = 1000000007;
 #define LOOP 10000000


int main() {

  int N;
  string S;
  int cnt = 0;

  cin >> N >> S;

  REP(i, 1000){
    int num[3] = { i/100, (i/10)%10, i%10 };
    int f = 0;
    REP(j, N){
      if(S[j] == ('0' + num[f]))f++;
      if(f == 3)break;
    }
    if(f==3)cnt++;
  }

  cout << cnt << endl;

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
ll A,B,C;
int X,Y;
ll dp[5010];  //Bがi枚のとき, 条件を満たす価格の最低

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>A>>B>>C>>X>>Y;

    ll ans = LLINF;
    REP(i,0,X+1){
        int minc = (ll)(X - i)*2LL;    //最低買うCのピザの枚数
        ll t1 = (ll)(i)*A + (ll)(max(0, Y - minc/2))*B + (ll)minc*C;
        ll t2 = (ll)(i)*A + (ll)(max(minc, Y*2))*C;
        ans = min({ans, t1, t2});
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long a,b,N,X,sol=0;
    cin>>N>>X;

    a=N-X;
    b=X;

    sol=a+b;
    while(a%b!=0)
    {
        sol+=2*(a/b)*b;
        a=a%b;
        swap(a,b);
    }

    sol+=2*(a/b)*b-b;
    cout << sol << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner scanner = new Scanner(System.in);
	
      	int N = scanner.nextInt();
      
      	if(N % 2 > 0) {
        	System.out.println("No");
          	return;
        }
      	
      	String all = scanner.next();
      	String first = all.substring(0, N / 2);
      	String second = all.substring(N / 2, N);
      
      	if(first.equals(second)) {
        	System.out.println("Yes");
          	return;
        }
      	System.out.println("No");
	}
}
 

 



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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;


lli factorial(lli n,lli mod = mod){
  static lli dp[100000];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1))%mod;
}

lli powl(lli x,lli r,lli mod = mod){
  lli ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

lli inverse(lli x,lli mod = mod){
  return powl(x,mod-2,mod);
}

lli combination(lli n,lli m,lli mod = mod){
  if(n < m) return 0;
  return (((factorial(n)*inverse(factorial(m)))%mod)*inverse(factorial(n-m)))%mod;
}


lli k,n;
lli g_ans[e3];
lli ans,p,a,b,r,mem,q,u;

int main(){

  cin >> k >> n;
  for(lli i = 2;i <= 2*k;i++){
    if(i%2 == 0){
      ans = 0;
      if(i-1 <= k) a = 1, b = i-1;
      else a = i-k, b = k;

      p = abs(b-a)/2;
      // cerr << p << endl;

      r = k-p*2-1;
      u = min(n,p);
      for(q = r ? 0 : 1;q <= u;++q){
        mem = combination(p,q)*powl(2,q);
        mem %= mod;
        if(n-q-1 >= 0) mem *= (combination(n+r-1,n-q)+combination(n+r-1-1,n-q-1));
        else mem *= combination(n+r-1,n-q);
        mem %= mod;
        ans += mem;
        ans %= mod;
      }
      // n--;
      // u = min(n,p);
      // for(q = r ? 0 : 1;q <= u;++q){
      //   mem = combination(p,q)*powl(2,q);
      //   mem %= mod;
      //   mem *= combination(n+r-1,n-q);
      //   mem %= mod;
      //   ans += mem;
      //   ans %= mod;
      // }
      // n++;
      cout << ans << endl;
    }else{
      ans = 0;
      if(i-1 <= k) a = 1, b = i-1;
      else a = i-k, b = k;
      p = abs(b-a)/2+1;

      r = k-p*2;
      for(q = r ? 0 : 1;q <= n && q <= p;q++){
        mem = combination(p,q)*powl(2,q);
        mem %= mod;
        mem *= combination(n+r-1,n-q);
        mem %= mod;
        ans += mem;
        ans %= mod;
      }
      cout << ans << endl;
    }
  }

}


Measured memory_bytes: 512
import math
n, m = map(int, input().split())

if n == 1:
    print(m)
    exit()
a = []
b = []
for i in range(1, math.ceil(math.sqrt(m))):
    if m % n == 0:
        print(m // n)
        exit()
    if m % i == 0:
        b.append(i)
        b.append(m // i)
        
#print(b)

for i in range(len(b)):
    if b[i] * n <= m:
        a.append(b[i])
#print(a)

if len(b) == 2:
    print(1)
else:
    print(max(a))


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, ans;

    cin >> N;
    for (ll i = 1; i < sqrt(N) + 1; i++)
    {
        if (N % i == 0)
        {
            ans = i + N / i - 2;
        }
    }

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AC_ItoHC
{
    class Program
    {
        static int numType = 26;
        int D;

        static void Main(string[] args) => new Program().Run();

        void Run()
        {
            var st = new DateTime();
            var limit = 1800;

            D = int.Parse(Console.ReadLine());
            var c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var s = new int[D][];
            for (int i = 0; i < D; i++)
            {
                s[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }

            var ans = iniSolve(c, s);
            var score = CalcScore(c, s, ans);
            while ((DateTime.Now - st).TotalMilliseconds <= limit)
            {
                var newAns = Solve();
                var newScore = CalcScore(c, s, newAns);

                if (score > newScore)
                {
                    score = newScore;
                    ans = newAns;
                }
            }

            for (int i = 0; i < D; i++)
            {
                Console.WriteLine(ans[i] + 1);
            }
        }

        private int[] iniSolve(int[] c, int[][] s)
        {
            var ret = new int[D];
            for (int i = 0; i < D; i++)
            {
                ret[i] = Array.IndexOf(s[i], s[i].Max());
            }

            return ret;
        }

        private int[] Solve()
        {
            var ret = new int[D];
            var r = new Random();
            for (int i = 0; i < D; i++)
            {
                ret[i] = r.Next() % numType;
            }

            return ret;
        }

        private int CalcScore(int[] c, int[][] s, int[] t)
        {
            var score = 0;
            var lastD = new int[numType];

            for (int d = 0; d < D; d++)
            {
                for (int i = 0; i < numType; i++)
                {
                    lastD[i]++;
                    if (i == t[d]) lastD[i] = 0;
                }

                score += s[d][t[d]];

                for (int i = 0; i < numType; i++)
                {
                    score -= lastD[i] * c[i];
                }
            }

            return score;
        }
    }
}


Measured memory_bytes: 31072
x, y = input().split()
arr = list(map(int, input().split()))
t1 = sum(arr)
t2 = int(4*int(y))
ans = 0
for i in arr:
    if i >= t1/t2:
        ans += 1

if ans >= int(y):
    print('Yes')
else:
    print('No')

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


int main() {
ll A,B,K;
  cin >> A >>B>>K;
 ll s = B-A;
  if((s%2 ==0 && K >= (s/2)+1)||(s%2==1 && K >= (s+1)/2)){
 repp(i,A,B) cout << i <<endl;
  }
  else{
   repp(i,A,A+K-1) cout << i <<endl;
   repp(i,B-K+1,B) cout << i <<endl;
  }
}
  


Measured memory_bytes: 256