akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w; cin >> h >> w;
    V< V<char> > a(h, V<char>(w));
    REP(i, h) REP(j, w) cin >> a[i][j];
    vvll dp(h+1, vll(w+1, 0));
    dp[1][1] = 1;
    rep(i, 1, h+1) {
        rep(j, 1, w+1) {
            if (i==1 && j==1) continue;
            if (a[i-1][j-1] == '#') dp[i][j] = 0;
            else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
        }
    }
    cout << dp[h][w] << '\n';
    return 0;
}


Measured memory_bytes: 9088
#include<cstdio>
 
int main(){
   int n,i,a,b,min,max;
   long long sum;
   scanf("%d %d",&n,&a);
   min = a;
   max = a;
   sum = a;
   for(int i = 2;n >= i;i++){
       scanf("%d",&b);
       if(min >= b){
           min = b;
       }
       else{
           min = min;
       }
       if(max <= b){
           max = b;
       }
       else{
           max = max;
       }
       sum = sum + b;
       }
       printf("%d %d %lld\n",min,max,sum);
       return 0;
        
}


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

int n, k, idx;
ll a[1001], sum[500500], ans;

int main() {
    cin >> n >> k;
    rep(i, n) cin >> a[i+1]; // 1 origin
    REP(i, 1, n) a[i+1] += a[i]; // cumulative sum
    REP(l, 1, n+1) REP(r, l, n+1) {
        sum[idx++] = a[r] - a[l-1]; // N(N+1)/2
    }
    
    for(int i = 39; i >= 0; --i) {
        ll x = ans | (1L << i);
        int cnt = 0;
        rep(j, idx) if ((sum[j] & x) == x) cnt++;
        if (cnt >= k) ans = x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>

int main(void){
  int n,x,i,j,k;
  int comb;

  while(1){
    comb=0;
    scanf("%d %d",&n,&x);
    if(n==0 && x==0){
      break;
    }

    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	for(k=1;k<=n;k++){
	  if(i==j || i==k || j==k){
	    ;
	  }else if(i+j+k==x){
	      comb++;
	  }
	}
      }
    }
    printf("%d\n",comb/6);
  }

  return 0;
}

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

int main(){
long long a=1000000000+7;
int n;
  cin >> n;
  long long s;
  long long t=1;
for(int i=1;i<=n;i++){
t*=i;
s=t%a;
t=s;  
} 
cout << t << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0) return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int a, b; cin >> a >> b;
	cout << a * b << endl;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main()
{
    int i,j,k,n,t,count=0;
    scanf("%d",&n);
    long long array[n];
    for(i=0;i<n;i++){
        scanf("%lld",&array[i]);
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            for(k=j+1;k<n;k++){
                if((array[i]!=array[j])&&(array[i]!=array[k])&&(array[k]!=array[j])){
                    if((array[i]+array[j]>array[k])&&(array[i]+array[k]>array[j])&&(array[k]+array[j]>array[i]))
                        count++;
                }
            }
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define INF 1e9
typedef long long int ll;
using namespace std;
 
int main()
{
    int n, k;
    cin >> n >> k;
    int h[n+5];
    int a[n+5];
    for (int i = 1; i <= n; i++)
    {
         cin >> h[i];
         a[i] = INF;
    }
 
    a[1] = 0;
    for (int i = 1; i <= k && i+1 <= n; i++)
    {
        a[i+1] = abs(h[i+1] - h[1]);
    }
 
    for (int i = k+1; i <= n; i++)
        for (int j = 1; j <= k; j++)
            a[i] = min(a[i], a[i-j] + abs(h[i-j] - h[i]));
            
    cout << a[n] << endl;       
 
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if (A>=B&&A>=C){
        cout<<A*10+B+C<<endl;
    }else if(B>=A&&B>=C){
        cout<<B*10+A+C<<endl;
    }else if(C>=A&&C>=B){
        cout<<C*10+A+B<<endl;
    }
return 0;
}
    




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10005
#define mp make_pair
#define pb push_back
#define int long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define len(x) (x.size())
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define T int tc;cin>>tc;for(int t=1;t<=tc;t++)
#define set_arr(arr,i) memset(arr,i,sizeof(arr))
#define trace1(x)							cerr << #x << ": " << x << endl;
#define trace2(x, y)						cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)						cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) 			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << :  << f << endl;
using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);	
	cin.tie(0);
	cout.tie(0);
	
 	string s,t;
 	cin>>s>>t;
 	int c = 0;
 	rep(i,0,3){
 		if(s[i]==t[i])c++;
 	}
 	cout<<c;

	return 0;
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define REP(i, n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a, b) a = min((a),(b))
#define CHMAX(a, b) a = max((a),(b))
#define ZP(a, len) cout << setfill('0') << setw(len) << right << a << endl;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

signed main() {
    string s;
    cin >> s;
    map<char, char> m = {
            {'A', 'T'},
            {'T', 'A'},
            {'C', 'G'},
            {'G', 'C'}
    };
    string ans = "";
    for (auto c : s) {
        ans += m[c];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  ll N;
  cin>>N;
  if(N%2==0){
    ll ans=0;
    for(ll i=5;i<=N;i*=5){
      ans+=N/i/2;
    }
    cout<<ans<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    string s;
    int i;
    cin >> s;
    int sum = 0;
    int len = s.size();
    for(i = 0;i<len;i++){
        sum += (s[i] - '0');
    }
    if(sum % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3660
/*
    oj d https://atcoder.jp/contests/abc166/tasks/abc166_d
    g++ D.cpp
    oj t
    oj s https://atcoder.jp/contests/abc166/tasks/abc166_d D.cpp
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

vector<long long> divisor(long long n){
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

int main(){
    ll X;
    cin >> X;

    vector<ll> vec;
    vec = divisor(X);
    int l = vec.size();
    /*
    for(int i=0;i<l;i++)
        cout << vec[i] << endl;
    */
    for(int i=0;i<l;i++){
        ll A, B, c;
        // A - B = f
        A = vec[i];
        B = 0;
        c = LLONG_MAX;
        for(;;){
            ll num = pow(A,5) - pow(B,5);
            //cout << num << endl;
            if(num == X){
                cout << A << ' ' << B << endl;
                return 0;
            }else if(abs(X - num) > c){
                break;
            } 
            A++;
            B++;    
            c = abs(X - num);   
        }
        A = vec[i];
        B = 0;
        c = LLONG_MAX;
        for(;;){
            ll num = pow(A,5) - pow(B,5);
            //cout << num << endl;
            if(num == X){
                cout << A << ' ' << B << endl;
                return 0;
            }else if(abs(X - num) > c){
                break;
            } 
            A--;
            B--;    
            c = abs(X - num);   
        }
        // A - B = -f
        A = 0;
        B = vec[i]*-1;
        c = LLONG_MAX;
        for(;;){
            ll num = pow(A,5) - pow(B,5);
            //cout << num << endl;
            if(num == X){
                cout << A << ' ' << B << endl;
                return 0;
            }else if(abs(X- num) > c){
                break;
            } 
            A--;
            B--;
            c = abs(X - num); 
        }
        A = 0;
        B = vec[i]*-1;
        c = LLONG_MAX;
        for(;;){
            ll num = pow(A,5) - pow(B,5);
            //cout << num << endl;
            if(num == X){
                cout << A << ' ' << B << endl;
                return 0;
            }else if(abs(X- num) > c){
                break;
            } 
            A++;
            B++;
            c = abs(X - num); 
        }
    }

}

Measured memory_bytes: 3960
#include <iostream>
using namespace std;
int main() {
	int x,y,u,i,o;
	cin>>x>>y>>u>>i>>o;
	if(x!=1)
	cout<<1;
	if(y!=2)
	cout<<2;
	if(u!=3)
	cout<<3;
	if(i!=4)
	cout<<4;
	if(o!=5)
	cout<<5;
	
	return 0;
}

Measured memory_bytes: 3628
def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = []
    if max(A) + min(A) >= 0:
        x = A.index(max(A))
        for i in range(N):
            C.append((x+1, i+1))
        for i in range(1, N):
            C.append((i, i+1))
    else:
        x = A.index(min(A))
        for i in range(N):
            C.append((x+1, i+1))
        for i in range(N, 1, -1):
            C.append((i, i-1))
    print(len(C))
    for x, y in C:
        print(x, y)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (long long int i = (a); i < (b); i++)
#define FORD(i, a, b) for(long long int = (a); i >=(b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod1=1000000007;
ll mod2=67280421310721;
ll mod3=998244353;
ll INF=1e18;

ll binpow1(ll a,ll b){
    ll res=1;
    while (b>0){
        if (b&1)
        res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}

ll binpow2(ll a,ll b,ll m){
    a%=m;
    ll res=1;
    while (b>0){
        if (b & 1)
        res=res*a%m;
        a=a*a%m;
        b>>=1;
    }
    return res;
}

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

map<ll,ll> fact(ll n) {
    map<ll,ll> factorization;ll c=0;
    while (n % 2 == 0) {
        c++;
        n /= 2;
    }
    if(c>0)
    {
        factorization.insert({2,c});
    }c=0;
    for (ll d = 3; d * d <= n; d += 2) {
        while (n % d == 0) {
            c++;
            n /= d;
        }
        if(c>0)
    {
        factorization.insert({d,c});
    }c=0;
    }
    if (n > 1)
       {
           factorization.insert({n,1});
       }
    return factorization;
}

ll dp[101][100001];
pair<ll,ll> a[101];

int main()
{ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    ll n,w;
    cin>>n>>w;ll ans1=0;ll sum=0;
    FOR(i,0,n)
    {
        cin>>a[i].first>>a[i].second;sum=sum+a[i].second;
    }
    FOR(i,0,n+1)
    {
        FOR(j,0,sum+1)
        {
            if(j!=0 && i==0)
            {
                dp[i][j]=-1;
            }
            else if(j==0)
            {
                dp[i][j]=0;
            }
            else
            {
                if(a[i-1].second<=j)
                {
                    if(dp[i-1][j]!=-1 && dp[i-1][j-a[i-1].second]!=-1)
                    {
                        dp[i][j]=min(a[i-1].first+dp[i-1][j-a[i-1].second],dp[i-1][j]);
                    }
                    else if(dp[i-1][j-a[i-1].second]!=-1)
                    {
                        dp[i][j]=a[i-1].first+dp[i-1][j-a[i-1].second];
                    }
                    else if(dp[i-1][j]!=-1)
                    {
                        dp[i][j]=dp[i-1][j];
                    }
                    else
                    {
                        dp[i][j]=-1;
                    }
                }
                else
                {
                    if(dp[i-1][j]!=-1)
                    {
                        dp[i][j]=dp[i-1][j];
                    }
                    else
                    {
                        dp[i][j]=-1;
                    }
                }
            }
            if(dp[i][j]<=w && dp[i][j]>=0)
            {
                ans1=max(ans1,j);
            }
        }
    }
    cout<<ans1<<'\n';

	return 0;
}













Measured memory_bytes: 82472
A,B,C,X,Y = [int(x) for x in input().split()]

def calc_cost(max_a,max_b):
    need_ab = max(X-max_a, Y-max_b)
    a = max(X - need_ab, 0)
    b = max(Y - need_ab, 0)
    return A*a + B*b + C*(2*need_ab)

print(min([calc_cost(x,y) for x in [0,X] for y in [0,Y]]))

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

using namespace std;

int main()
{
  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 dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
	int diff = (t[i] - t[i - 1]) - dist;
    if (diff < 0 || diff % 2 == 1) {
   		cout << "No" << endl;
      	return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}

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

typedef long long LL;
const LL B = 1000000007LL;


LL f(LL N, LL M) {
	return (M * (N - M + 1) + 1) % B;
}


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

	LL cnt = 0;
	for (LL M = K; M <= N + 1; ++M) {
		cnt += f(N, M);
		cnt = cnt % B;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#define MAX 100005
#define NIL -1
  
struct Node
{
  int parent,left,right;
};
   
struct Node T[MAX];
int n,D[MAX],H[MAX];
   
void setDepth(int u,int d)
{
  if(u == NIL)  return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}
   
int setHeight(int u)
{
  int h1=0,h2=0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left)+1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right)+1;
  return H[u] = (h1>h2?h1:h2);
}
   
int getSibling(int u){
  if( T[u].parent == NIL )
    return NIL;
  if( T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if( T[T[u].parent].right != u &&T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}
  
   
void print(int u)
{
  int i,c;
  printf ("node %d: ",u);
  printf
    ("parent = %d, ",T[u].parent);
  printf
    ("sibling = %d, ",getSibling(u));
  int deg=0;
  if( T[u].left != NIL)
    deg++;
  if( T[u].right != NIL )
    deg++;
  printf
    ("degree = %d, ",deg);
  printf
    ("depth = %d, ",D[u]);
  printf
    ("height = %d, ",H[u]);
   
  if( T[u].parent == NIL )
    printf("root\n");
  else if( T[u].left == NIL && T[u].right == NIL )
    printf("leaf\n");
  else printf
	 ("internal node\n");
}
   
int main()
{
  int v,l,r,root=0,i;   
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].parent = NIL;
     
  for( i = 0; i < n; i++ )
    {
      scanf("%d",&v);
      scanf("%d",&l);
      scanf("%d",&r);
      T[v].left = l;
      T[v].right = r;
      if( l != NIL )
	T[l].parent = v;
      if( r != NIL )
	T[r].parent=v;
    }
  for( i = 0; i < n; i++ )
    {
      if( T[i].parent == NIL )
	root=i;
    }
   
  setDepth(root,0);
  setHeight(root);
  for( i = 0; i < n; i++ )
    print(i);
   
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int MAXN=1e9+7, curr=0;
int t[26][4*500100], a[4*500100];;
 
void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[curr][v] = (a[tl] == curr);
    } else {
        int tm = (tl + tr) / 2;
        build(v*2, tl, tm);
        build(v*2+1, tm+1, tr);
        t[curr][v] = t[curr][v*2] + t[curr][v*2+1];
    }
}
 
int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[curr][v];
    }
    int tm = (tl + tr) / 2;
    return sum(v*2, tl, tm, l, min(r, tm))
           + sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}
 
void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[curr][v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[curr][v] = t[curr][v*2] + t[curr][v*2+1];
    }
}
 
int main()
{
	int n; cin >> n;
	string str; cin >> str;
	int len=str.length();
 
	for(int i=0;i<len;++i) a[i]=str[i]-'a';
	for(int i=0;i<26;++i){
		curr=i;
		build(1, 0, len-1);
	}
 
	int q; cin >> q;
	while(q--){
		int k;
		cin >> k;
 
		if(k==1){
			int l;
			char r;
			cin >> l >> r;
			--l;
			curr = a[l];
			update(1, 0, len-1, l, 0);
			a[l]=r-'a';
			curr=a[l];
			update(1, 0, len-1, l, 1);
		}
 
		else{
			int l, r;
			cin >> l >> r;
			int ans=0;
			for(int i=0;i<26;++i){
				curr=i;
				int val=sum(1, 0, len-1, l-1, r-1);
				if(val>0) ++ans;
			}
			cout << ans << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 162564
N=int(input())
H=list(map(int,input().split()))
a=[0]*N
max_i=0
for i in range(1,N):
	if(H[i-1]>=H[i]):
		a[i]=a[i-1]+1
		if(max_i<a[i]):max_i=a[i]
print(max_i)



Measured memory_bytes: 63984
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
using namespace std;
signed main()
{
    fast;
    
    int i;
    string s;
    cin>>s;
    string days[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(i=0;i<7;i++)
    {
    	if(s.compare(days[i])==0)
    	{
    		cout<<7 - i ;
    		break;
    	}
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  int s = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    s ^= a[i];
  }

  for(int i = 0; i < n; i++){
    cout << (s ^ a[i]) << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 4684
#include<iomanip>
#include<algorithm>

// from iostream
#include<iostream>
using std::cout;
using std::cin;
using std::cerr;
using std::flush;
using std::endl;
// from vector
#include<vector>
using std::vector;
// from queue
#include<queue>
using std::deque;
using std::priority_queue;
// from tuple
using std::tuple;
using std::get;
using std::tie;
using std::make_tuple;
using std::forward_as_tuple;
// from string
#include<string>
using std::string;

typedef signed long long INT;
typedef tuple<INT,INT> TII;
typedef tuple<INT,INT,INT> TIII;
typedef tuple<double,double> TDD;
typedef tuple<double,double,double> TDDD;
typedef vector<INT>  VI;
typedef vector<TII>  VII;
typedef vector<TIII> VIII;
typedef vector<double> VD;
typedef vector<TDD>    VDD;
typedef vector<TDDD>   VDDD;

int main(){
  std::ios::sync_with_stdio(false);
  // begin main
  string yes = "YES",no="NO";
  INT r,g,b;
  cin >> r >> g >> b;
  INT sum = r*100 + g*10 + b;
  cout << ( sum%4 ? no : yes ) << endl;
  // end main
  return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
#define double ld
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template<class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template<class T0, class T1>
inline istream &operator>>(istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template<class T0, class T1, class T2>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template<class T0, class T1, class T2, class T3>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}

template<class T>
inline ostream &operator<<(ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}
const int N = 1e7;

void smain() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll s = (a + b + c);
    int i = 0;
    for (; i < N; ++i) {
        if ((a & 1) || (b & 1) || (c & 1)) {
            cout << i;
            return;
        }
        a = (s - a) / 2;
        b = (s - b) / 2;
        c = (s - c) / 2;
    }
    cout << "-1";
}

Measured memory_bytes: 256
x,n = map(int,input().split())
if n != 0:
    l = list(map(int,input().split()))
def check(x):
    flg = 0
    for i in range(n):
        if l[i] == x:
            flg = 1
    return(flg)
cnt = 0
flg2 = 0
tmp = x
if n == 0:
    flg2 = 1
while flg2 == 0:
    if check(tmp) == 0:
        flg2 = 1
        ans = tmp
    else:
        cnt += 1
        if cnt%2 == 1:
            tmp = x-(cnt+1)/2
        else:
            tmp = x+cnt/2
print(int(tmp))
        


Measured memory_bytes: 9208
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#ifdef LOCAL
#define TIMER cerr<<clock()<<"ms\n"
#else
#define TIMER
#endif
#define SZ 666666
int n,p[SZ],b[SZ];
//a[p1]+b[p1]=1
//a[p1]=0 b[p1]=1
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",p+i), b[p[i]]=i;
	int BL=20003,INF=1e8*9;
	for(int i=1;i<=n;i++)
		printf("%d ",BL*i);
	puts("");
	for(int i=1;i<=n;i++)
		printf("%d ",INF-BL*i+b[i]);
	puts("");
}


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

int main(void){
	int n,m;

	while(cin>>n>>m,n){
		int t[n];
		for(int i=0;i<n;i++){
			cin>>t[i];
		}
		sort(t,t+n);
		reverse(t,t+n);

		int ans = 0;
		for(int i=0;i<n;i+=m){
			int sum = 0;
			for(int j=i;j<n && j<i+m;j++){
				sum += t[j];
			}
			if(i+m <= n) sum -= t[i+m-1];
			ans += sum;
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		ArrayList<pair> al = new ArrayList<pair>();
		while(true){
			String str = scan.next();
			int x = Integer.parseInt(str.substring(0,str.indexOf(",")));
			str = str.substring(str.indexOf(",") + 1,str.length());
			int y = Integer.parseInt(str);
			if(x == 0 && y == 0){
				break;
			}
			pair p = new pair(x,y);
			al.add(p);
		}
		Collections.sort(al,new PairCompare());
		while(scan.hasNextInt()){
			int n = scan.nextInt();
			int rank = 1;
			for(int i = 0;i < al.size();i++){
				if(i != 0 && al.get(i - 1).second != al.get(i).second){
					rank++;
				}
				if(al.get(i).first == n){
					System.out.println("" + rank);	
				}
			}
		}
		
	}

}
class pair{
	int first;
	int second;
	pair(int x,int y){
		first = x;
		second = y;
	}
}
class PairCompare implements Comparator<pair>{

	public int compare(pair x,pair y) {
		// TODO 自動生成されたコンストラクター・スタブ
		if(x.second > y.second){
			return -1;
		}else if(x.second < y.second){
			return 1;
		}else{
			if(x.first < y.first){
				return -1;
			}else{
				return 1;
			}
		}
		
	}
}

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

int main(){
    string s;
    cin >> s;

    ll ans=0;
    rep(i, s.size()){
        char c=s[i];
        ans=(ans+atoi(&c))%9;
    }
    if(ans==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3752
#include<string>
#include<iostream>
#include<deque>
#include<cstdlib>
#include<algorithm>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define rep(i, x, n) for(i=x;(i)<(n);(i)++)

const int MOD = 1000000007;

int main() {
	int n;
	cin >> n;
	deque<lli> dp(n), nodes;
	int i;
	rep(i, 0, n) {
		lli temp;
		cin >> temp;
		nodes.push_back(temp);
	}
	rep(i, 0, n) {
		if (i == 0) {
			dp[i] = 0;
			continue;
		}
		else if (i == 1) {
			dp[i] = dp[i - 1] + abs(nodes[i] - nodes[i - 1]);
		}
		else {
			dp[i] = min(dp[i - 1] + abs(nodes[i] - nodes[i - 1]), dp[i - 2] + abs(nodes[i] - nodes[i - 2]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 5252
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < n; i++) {
	  if (a[i] == b[i] && b[i] == c[i]) {
		  continue;
		}
	  else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
		  ans++;
		} else {
		  ans += 2;
		}
	}
  cout << ans << endl;
  return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n = 3;
  vector<int> a(n); rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(),a.end()),a.end());
  cout << a.size() << endl;
    
  return 0;
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.StringTokenizer;

class Main {
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() { // reads in the next string
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        } // reads in the next int

        public long nextLong() {
            return Long.parseLong(next());
        } // reads in the next long

        public double nextDouble() {
            return Double.parseDouble(next());
        } // reads in the next double
    }

    static InputReader r = new InputReader(System.in);
    static PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        String word = r.next();
        //if char at last digit is s, append es
        //if char at last digit isnt es, append s
        if (word.endsWith("s")) {
            word += "es";
        } else {
            word += "s";
        }
        pw.println(word);
        pw.close(); // flushes the output once printing is done
    }
}


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

const int L = 128;
int Q = 850;

int ask(string s) {
	if (!Q) exit(100);
	Q--;

	cout << "? " << s << endl;
	int dist; cin >> dist;
	return dist;
}

void answer(string s) {
	cout << "! " << s << endl;
	exit(0);
}

/************************************************/

void init(vector<string> &s, char c, int &len) {
	string que(L, c);
	int ds = ask(que);
	if (ds == L) return;

	string gf(L - ds, c);
	len += gf.size();
	s.push_back(gf);
}

bool cmp(string s1, string s2) {
	if (s1.size() == s2.size()) return s1 < s2;
	return s1.size() > s2.size();
}

string merge_strings(string x, string y, int len) {
	string ans;
	while (x.size() && y.size()) {
		string tmp = ans + y[0] + x;
		if (ask(tmp) == len - tmp.size()) {
			ans += y[0];
			y.erase(y.begin());
		} else {
			ans += x[0];
			x.erase(x.begin());
		}
	}
	ans += x + y;
	return ans;
}

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

	vector<string> s; int len = 0;
	for (char c = 'a'; c <= 'z'; c++) init(s, c, len);
	for (char c = 'A'; c <= 'Z'; c++) init(s, c, len);
	for (char c = '0'; c <= '9'; c++) init(s, c, len);

	while (s.size() > 1) {
		sort(s.begin(), s.end(), cmp);

		string x = s.back(); s.pop_back();
		string y = s.back(); s.pop_back();

		s.push_back(merge_strings(x, y, len));
	}

	answer(s[0]);

	return 0;
}


Measured memory_bytes: 3748
#include<iostream>
using namespace std;
int main()
{
	int W,H,x,y,r;
	cin >> W>>H>>x>>y>>r;
	if ((x - r) >= 0 && (x + r) <= W && (y - r) >= 0 && (y + r) <= H){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	n = INT()
	s = input()
	for x in s:
		p = ord(x) % 65
		q = (p + n) % 26
		print(chr(q + 65), end = '')

if  __name__=='__main__':
    main()


Measured memory_bytes: 6496
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        for(int i = 360; i < int.MaxValue; i += 360)
        {
            if(i % n == 0)
            {
                n = i / n;
                break;
            }
        }

        WriteLine(n);
    }
}


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

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)

//main.cpp-Sample


namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);
	int npr(int n,int r);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
	int npr(int n,int r){
		for (int i = 1; i < r; ++i)
		{
			n *= n-1;
		}
		return n;
	}
}


using namespace std;
signed main (){
	int n,a,b;
	cin >> n>>a>>b;
	if((b-a)%2==0){
		cout<<(b-a)/2<<endl;
	}else{
		cout<<min(((a-1)+(b-a-1)/2),((n-b)+(b-a-1)/2))+1<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,k,s;
    cin>>n>>k>>s;
    int l=1000000000;
    if(s==l){
        l--;
    }
    rep(i,n){
        if(i<k){
            cout<<s<<endl;
        }
        else{
            cout<<l<<endl;
        }
    }
}

Measured memory_bytes: 1280
N,K = map(int,input().split())
L = list(map(str,input().split()))
flag = 0
while flag == 0 :
    counter = 0
    for c in str(N) :
        if c not in L :
            counter += 1
        else :
            break
    if counter == len(list(str(N))) :
        flag = 1
    else :
        N += 1
print(N)


Measured memory_bytes: 3060
'use strict';
function Main(input) {
    input = input.split("\n");
    let tmp = input[0].split(" ");
    //console.log(input);
    for(let i=0;i<5;i++){
        for(let j = i;j<5;j++){
            //console.log(`A:${input[i]} vs B:${input[j]} = abs:${input[i]-input[j]}`)

            if (Math.abs(input[i]-input[j])>input[5]){
                console.log(":(");
                return;
            }
        }
    }
    console.log("Yay!");
    return;
}
/*
Main(`1
2
4
8
9
15`);
*/
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>

using namespace std;

int main()
{int N; int K ; cin >> N >> K; int sum = 0;
 for(int i = 0; i < N; i++){
   int x; cin >> x; sum += 2*min(abs(x),abs(K-x));}
 
 cout << sum << endl;
 
 return 0;}


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

using namespace std;

int main(){
long long int n;
  cin >> n;
  vector<int>character;
  while(n>0){
   n--;	
   character.push_back(n%26);
   n/=26;
  }
  string ans;	
  int size = character.size();
  for(int i = 1; i <= character.size(); i++){
  ans.push_back(character[size-i]+'a');
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
A,B,C,X,Y=map(int,input().split())
ans=[]
if X>=Y:
    X,Y=Y,X
    A,B=B,A

ans.append(A*X+B*Y)
ans.append(2*C*X+B*(Y-X))
ans.append(2*C*max(X,Y))

print(min(ans))

Measured memory_bytes: 3060
from itertools import combinations_with_replacement


def euclidean(num_list: list):
    a, b = sorted(num_list)
    while b % a != 0:
        redi = b % a
        b = a
        a = redi
    return a


K = int(input())
k_range = list(range(1, K+1))

result = 0
for comb in combinations_with_replacement(k_range, 3):
    min_abc = min(comb)
    gcd = euclidean(comb[0:2])
    gcd = euclidean([gcd, comb[2]])
    if comb[0]==comb[1] and comb[1]==comb[2]:
        coef = 1
    elif (comb[0]!=comb[1] and comb[1]!=comb[2]) and comb[2]!=comb[0]:
        coef = 6
    else:
        coef = 3
    result += gcd * coef
print(result)

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			cout << "NO" << "\n";
			return 0;
		}
	}
    
    cout << "YES" << "\n";
    return 0;
}

Measured memory_bytes: 1024
n = int(input())

l = ['M', 'A', 'R', 'C', 'H']
nl = {'M': [], 'A': [], 'R': [], 'C': [], 'H': []}
for _ in range(n):
    name = input()
    if name[0] in l:
        nl[name[0]].append(name)

from itertools import combinations
ans = 0
for comb in combinations(l, 3):
    a,b,c = comb
    ans += len(nl[a]) * len(nl[b]) * len(nl[c])
print(ans)

Measured memory_bytes: 10084
S = input()
Q = int(input())
reverse_flg = False

b_str = ""
f_str = ""

for q in range(Q):
  r = input().split()
  if len(r) == 1:
    reverse_flg = not reverse_flg
  else:
    # Sは最終的に加えればいいので、それを最適化する
    if int(r[1]) == 1:
      if reverse_flg:
        f_str = f_str + r[2]
      else:
        b_str = r[2] + b_str
    else:
      if reverse_flg:
        b_str = r[2] + b_str
      else:
        f_str = f_str + r[2]

S = b_str + S + f_str

if reverse_flg:
  S = S[::-1]

print(S)

Measured memory_bytes: 4392
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M;
  cin >> N >> M;
  int64_t result = 1;
  for (int64_t d = 1; d * d <= M; ++d) {
    if (M % d == 0 && M / d >= N) {
      result = max(result, d);
    }
    if (M % d == 0 && d >= N) {
      result = max(result, M / d);
    }
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

int n;
int dpp[200005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    int a;
    for (int i = 2; i <= n; i++)
    {
        cin >> a;
        dpp[a]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << dpp[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 4428
#include<bits/stdc++.h>
#include<memory.h>
using namespace std;
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define pf printf
#define sf scanf
#define pb push_back
#define MAX 1000005
#define FOR(i,n) for(i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define mod7 1000000007
typedef long long int ll;
typedef long double lld;
const double PI=2*acos(0.0);
int CASE=1,TEST=1;
struct vpair{
    int a;
    int b;
    vpair(int a,int b){this->a=a;this->b=b;}
};
bool cmp(vpair &a,vpair &b){
    if(a.a<b.a)return true;
    else if(a.a==b.a){
        if(a.b<b.b)return true;
        else return false;
    }else{
        return false;
    }
}
int n,a,b,c=1;
string s;
int main(void){
    cin>>a>>b;
    getchar();
    getline(cin,s);
    n=s.length();
    if(a+b+1>n){
        pf("No\n");
        return 0;
    }
    for(int i=0;i<a;i++){
        if(s[i]-'0'<=9 && s[i]-'0'>=0){
            c=1;
        }else{
            pf("No\n");
            return 0;
        }
    }
    if(s[a]=='-')c=1;
    else{
        pf("No\n");
        return 0;
    }
    for(int i=a+1;i<a+b+1;i++){
        if(s[i]-'0'<=9 && s[i]-'0'>=0){
            c=1;
        }else{
            pf("No\n");
            return 0;
        }
    }
    if(c==1)pf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<algorithm>
#include<limits.h>
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(i,n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;
int main(){
    int n,k;
vector<long long int> a;
long long temp;
cin >> n >> k;
lp(i,n){
    cin >> temp;
a.push_back(temp);
}
sort(a.begin(),a.end());
//lp(i,n)cout << a[i] << " ";
//cout << endl;
long long ans = 9000000000;
for(int i=k-1;i<n;i++){
ans = min(ans,a[i] - a[i-k+1]);
}
cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>

int main()
{
	int x[3];
	std::cin >> x[0] >> x[1] >> x[2];
	for (int i = sizeof(x)/sizeof(x[0]) - 1; i > 0; i--)
	{
		for (int j = 0; j < i; j++)
		{
			if (x[j] > x[j+1])
			{
				int temp = x[j];
				x[j] = x[j+1];
				x[j+1] = temp;
			}
		}
	}
	for (int i = 0; i < sizeof(x)/sizeof(x[0]) - 1; i++)
	{
		std::cout << x[i] << " ";
	}
	std::cout << x[sizeof(x)/sizeof(x[0]) - 1] << "\n";
}

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

int main(void){
	int n;
	cin >> n;
	if(n%2==0){
		printf("%.6f\n",0.5);
	}else{
		printf("%.6f\n",(double)(n/2+1)/n);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[500006];
bool cmp(long long int e,long long int s){
return e>s;
}
int main()
{
	long long n;
	cin>>n;
	
	for(int i=1;i<=3 * n;i++)
	cin>>a[i];
	sort(a+1,a+3*n + 1,cmp);
	
	long long sum = 0;
	
	for(int i=1;i<=n;i++){
		//cout<<a[2 * i]<<" ";
	sum+=a[2 * i];
}
	cout<<sum<<endl;
}


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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N, K;
  cin >> N >> K;
  vll H(N);
  for (auto& h : H) {
    cin >> h;
  }

  Sort(H);
  ll ret = 0;
  REP(i, N-K) {
    ret += H[i];
  }

  cout << ret << endl;
  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
typedef long long ll;
#define MOD 1000000007

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 = 1LL << 60;



//大文字小文字気をつけろ


int main(){
  int a,b,c,d,e,f,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(abs(a-e)<=k){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256