akhauriyash/Code-Regression huggingface dataset:
#ifdef INPUT
#include <sstream>
stringstream input(R"(
2
80 70
)");
#define cin input
#endif

#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

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

    vector<string> s(n);

    for (auto& x : s)
        cin >> x;
    
    int r = 0;

    REP(i, n)
    {
        r += [&]()
        {
            REP(j, n)
                REP(k, n)
                    if (s[(j + i) % n][k] != s[(k + i) % n][j])
                        return 0;
            return n;
        }();
    }

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

// 最大流用の辺
struct Edge{
    ll to;
    ll capacity;
    ll rev; // index
    Edge(ll t, ll c, ll r){
        to = t;
        capacity = c;
        rev = r;
    }
    Edge(){}
};
 
// 最大流
// ford fulkerson ver
struct MaxFlow{
    vector<vector<Edge> > G;
    vector<bool> used;
 
    MaxFlow(ll node_num){
        G.resize(node_num);
        used.resize(node_num);
    }
 
    void add_edge(ll from, ll to, ll capacity){
        G[from].push_back(Edge(to, capacity, G[to].size()));
        G[to].push_back(Edge(from, 0, G[from].size()-1));
    }
 
    ll dfs(ll v, ll t, ll flow){
        if(v==t) return flow;
        used[v] = true;
        for(Edge &edge : G[v]){
            if(!used[edge.to] && edge.capacity > 0){
                ll d = dfs(edge.to, t, min(flow, edge.capacity));
                if(d>0){
                    edge.capacity -= d;
                    G[edge.to][edge.rev].capacity += d;
                    return d;
                }
            }
        }
        return 0;
    }
 
    ll calc(ll start, ll end){
        ll flow_sum = 0;
        while(true){
            fill(ALL(used), false);
            ll f = dfs(start, end, inf);
            if(f==0){
                break;
            }
            flow_sum += f;
        }
        return flow_sum;
    }
};

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

    // input
    ll N; 
    cin >> N;

    VI A(N);
    rep(i, N){
        cin >> A.at(i);
    }

    MaxFlow flow(N+2);
    
    // 0 start
    // 1-N node
    // N+1 sink

    ll sum = 0;
    rep(i, N){
      ll id = i+1;
      ll a = A[i];

      if(a>=0){
        sum += a; // 無条件で貰えるお金
        flow.add_edge(0, id, a); // waru
        flow.add_edge(id, N+1, 0);
      }else{
        flow.add_edge(0, id, 0);
        flow.add_edge(id, N+1, -a);
      }
    }

    FOR(i, 1, N){
      // iの倍数へのエッジ
      FOR(m, 2, 101){
        if(i*m>N)break;
        flow.add_edge(m*i, i, inf);
      }
    }

    ll penalty = flow.calc(0, N+1);
    ll ans = sum - penalty;
    p(ans);
    
    return 0;
}

Measured memory_bytes: 256
L = list(map(int,list(input())))
L = [0] + L
N = len(L)
dp1 = [0 for _ in range(N+1)]
dp2 = [0 for _ in range(N+1)]

for i in range(N):
    dp1[i+1] = min(dp1[i] + L[i], dp2[i] + 10 - L[i])
    dp2[i+1] = min(dp2[i] + 10 - L[i] - 1, dp1[i] + L[i] + 1)

print(dp1[-1])

Measured memory_bytes: 92512
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve(int test) {

	string s; cin >> s ;
	int sm = 0 , n = sz(s) ;

	rep(i,0,n) sm += (s[i] -'0');

	if(sm%9) cout << "No";
	else cout << "Yes" ;	
}
 
int32_t main() {
 

 
    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
long long int b[200001];
int main()
{
long long int n,m=0,s=0,i;
cin>>n;
long long int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
b[a[i]]++;
}
for(i=1;i<=n;i++)
{
if(b[i]>=2)
s=s+b[i]*(b[i]-1)/2;
}
for(i=0;i<n;i++)
{
m=s;
m=m-(b[a[i]]*(b[a[i]]-1)-(b[a[i]]-1)*(b[a[i]]-2))/2;
cout<<m<<endl;

}
}


Measured memory_bytes: 4736
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    char c,k;
    int ans=0;
	scanf("%c",&c);
    printf("%c",c);
    while(c=getchar()){
    	if(c==' '||c=='\n')break;
    	ans++;
    	k=c;
	}
	printf("%d%c",ans-1,k);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    double N,K,a;
    cin >> N >> K;
    a = K;
    if (N < K) {
        cout << 1 << endl;
    }else {
        for (int i = 1;; i++){
            a *= K;
            if (N < a) {
                cout << i + 1 << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
def chmin(a,b):
    if a > b:
        return b
    else:
        return a


N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = float('inf')
dp = [INF] * N
dp[0] = 0


for i in range(N):
    for j in range(1,K+1):
        if i-j >= 0:
            dp[i] = chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]))

print(dp[N-1])

Measured memory_bytes: 55648
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long ll;

int main(void){
	ll a, result;
  	long double b;
	scanf("%lld", &a);
  	scanf("%Lf", &b);
    
	b *= 100;
  	b = round(b);
  	
	result = a*b/100;
  	printf("%lld", result);
	return 0;

}

Measured memory_bytes: 2224
#include <iostream>

using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	if ( a+a-1 > a+b )
		cout << a+a-1;
	else if ( b+b-1 > a+b )
		cout << b+b-1;
	else
		cout << a+b;
	cout << endl;




	return 0;
}


Measured memory_bytes: 256
N = int(input())
next_plan = [0, 0, 0]
for i in range(N):
    now_plan = next_plan
    next_plan = [int(i) for i in input().split()]
    time = next_plan[0] - now_plan[0]
    x = abs(next_plan[1] - now_plan[1])
    y = abs(next_plan[2] - now_plan[2])
    distance = x + y
    if not (distance <= time and (time - distance) % 2 == 0):
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 3064
import copy
n = int(input())
a = [0]*n

for i in range(n):
    a[i] = int(input())

b = copy.copy(a)
b.sort(reverse = True)

for i in range(n):
    if(a[i] == b[0]):
        print(b[1])
    else:
        print(b[0])

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

inline long long read(){    //快读
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

long long n, m;
int main(){
    n = read(), m = read();
    cout << (n * (n-1) / 2) + (m * (m-1) / 2) << endl;    //组合数学就不解释了，还不会的赶紧去百度一下
    return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};


int main(){
    IOS;
    make(ll,n);
    if(n%2) cout<<"0 \n";
    else{
        ll ans=0;
        n/=2;
        while(n/5){
            ans+=(n/5);
            n/=5;
        }
        cout<<ans<<endl;
    }



    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

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

int n, m, h, a, b, ans;
vector<vi> G(100010);
vector<int> H(100010);

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> H[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}
	for (int i = 1; i <= n; i++) {
		bool flag = true;
		for (int j = 0; j < G[i].size(); j++) {
			if (H[G[i][j]] >= H[i]) {
				flag = false;
				break;
			}
		}
		if (flag) ans++;
	}
	cout << ans;
}

Measured memory_bytes: 8748
from collections import Counter
s = input()
t = input()
convert_dict = {}
count_list = []
count = {}

for i in range(len(s)):
    if t[i] not in convert_dict.keys():
        convert_dict[t[i]] = s[i]

    else:
        if convert_dict[t[i]] != s[i]:
            print("No")
            exit()

for i in convert_dict.values():
    count_list.append(i)

count = Counter(count_list)

if max(count.values()) > 1:
    print("No")

else:
    print("Yes")


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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

signed main(){
	int n=read();
	vector<pi> pos;
	REP(i,n)
		pos.PB(pi(read()-1,i+1));
	vi ans(n*n,-1);
	int b=0,e=n*n-1;
	sort(ALL(pos));
	const auto setfront=[&](int v){
		while(b<n*n&&ans[b]!=-1)
			b++;
		if(b==n*n)
			No();
		ans[b]=v;
	};
	for(auto kv:pos){
		int x=kv.first,i=kv.second;
		if(ans[x]!=-1)
			No();
		ans[x]=i;
		FOR(j,1,i)
			setfront(i);
		if(x<b)
			No();
	}
	reverse(ALL(pos));
	const auto setback=[&](int v){
		while(e>=0&&ans[e]!=-1)
			e--;
		if(e<0)
			No();
		ans[e]=v;
	};
	for(auto kv:pos){
		int x=kv.first,i=kv.second;
		FOR(j,i+1,n+1)
			setback(i);
		if(e<x)
			No();
	}
	cout<<"Yes"<<endl;
	REP(i,n*n)
		print(ans[i],i==n*n-1?1:2);
}


Measured memory_bytes: 3072
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = __int128;
using li = long long int;

lli f(lli n){
  if(n<2)return 1;
  return n * f(n-2);
}
lli g(lli n){
  lli p = f(n);
  int cnt = 0;
  while(p % 10 == 0){
    cnt ++;
    p/=10;
  }
  return cnt;
}
lli piyo(lli n){
  lli p = 5;
  lli ans = 0;
  while(p<=n){
    ans += (n/p/2);
    p = 5 * p;
  }
  return ans;
}

void solve(long long N) {
  if(N&1){
    cout << 0 << endl;
    return;
  }
  if(N<=20){
    cout << (li)g(N) << endl;
    return;
  }
  cout << (li)piyo(N)<<endl;
  return;
}

int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val a, b, c, x = sc.nextInt()
    var ans = 0
    for (i <- 0 to a) {
      for (j <- 0 to b) {
        val cc = x - i * 500 - j * 100
        if (0 <= cc / 50 && cc / 50 <= c) ans += 1
      }
    }
    println(ans)
  }
}


Measured memory_bytes: 25540
N, M = [int(x) for x in input().split()]
K = [[0]*N]*M
for i in range(M):
  K[i] = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
total = 0
for i in range(2 ** N):
    lamp = [0] * N
    for j in range(N):
        if ((i >> j) & 1):
            lamp[j] = 1
    flag = True
    for x in range(M):
      result = 0
      for y in K[x][1:]:
        if lamp[y-1] == 1:
          result += 1
      result %= 2
      if result != P[x]:
        flag = False
    if flag:
      total += 1
print(total)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 4000
#define MOD 998244353
char s[MAXN+5];
int n,num1[MAXN+5],num2[MAXN+5];
int dp[MAXN+5][MAXN+5];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		num2[i]=s[i]-'0';
		num1[i]=2-num2[i]+num1[i-1];
		num2[i]+=num2[i-1];
	}
	dp[0][0]=1;
	for(int i=1;i<=n*2;i++)
	{
		int cnt1=num1[min(n,i)],cnt2=num2[min(n,i)];
		for(int j=0;j<=i;j++)
		if(cnt1>=j&&cnt2>=i-j)
		{
			dp[i][j]=dp[i-1][j];
			if(j>0)dp[i][j]=(dp[i][j]+dp[i-1][j-1])%MOD;
		}
	}
	printf("%d\n",dp[n*2][num1[n]]);
}

Measured memory_bytes: 60544
def solve(items, w):
    dp = [[0]*(w+1)]
    for item in items:
        curr = []
        for i in range(w+1):
            if i - item[0] >= 0:
                curr.append(max(dp[-1][i], dp[-1][i - item[0]]+item[1]))
            else:
                curr.append(dp[-1][i])
        dp.append(curr)
    return dp[-1][-1]


if __name__ == "__main__":
    n, w = map(int, input().split())
    items = [[int(x) for x in input().split()] for y in range(n)]
    print(solve(items, w))

Measured memory_bytes: 172772
x = int(input())

if x >= 400 and x <= 599:
    print(8)
elif x >= 600 and x <= 799:
    print(7)
elif x >= 800 and x <= 999:
    print(6)
elif x >= 1000 and x <= 1199:
    print(5)
elif x >= 1200 and x <= 1399:
    print(4)
elif x >= 1400 and x <= 1599:
    print(3)
elif x >= 1600 and x <= 1799:
    print(2)
elif x >= 1800 and x <= 1999:
    print(1)




Measured memory_bytes: 61624
import math
n,a,b = map(int,input().split())
H = list(int(input()) for _ in range(n))
l,r = 0, 10**9
d = a-b
while r-l>1:
    mid = (r+l)//2
    tmp = 0
    for h in H:
        if h <= mid*b:
            continue
        tmp += math.ceil((h-mid*b)/d)
    if tmp <= mid:
        r = mid
    else:
        l = mid
print(r)

Measured memory_bytes: 50520
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 01/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N,M; cin>>N>>M;
  string str(N, 0);
  for (int i = 0; i < M; i++) {
    int s,c; cin>>s>>c;
    if ((N > 1 and s == 1 and c == 0) or (str[s-1] != 0 and str[s-1] != '0'+c)) {
      cout << -1 << endl;
      return 0;
    }
    str[s-1] = '0'+c;
  }
  for (auto& c : str)
    if (c == 0) c = '0';
  if (N > 1 and str[0] == '0')
    str[0] = '1';
  cout << str << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll score(vector<ll>& v, bool k, bool o, bool n) {
    return v[0] * (k ? 1 : -1) + v[1] * (o ? 1 : -1) + v[2] * (n ? 1 : -1);
}

int main(int argc, char const* argv[]) {
    int n, m;
    cin >> n >> m;
    vector<vector<ll>> xs;
    for (int i = 0; i < n; ++i) {
        xs.push_back(vector<ll>());
        for (int j = 0; j < 3; ++j) {
            ll temp;
            cin >> temp;
            xs[i].push_back(temp);
        }
    }
    vector<vector<bool>> comb({{true, true, true},
                               {true, true, false},
                               {true, false, true},
                               {true, false, false},
                               {false, true, true},
                               {false, true, false},
                               {false, false, true},
                               {false, false, false}});
    vector<vector<ll>> scores;
    for (auto&& c : comb) {
        scores.push_back(vector<ll>());
        for (auto&& x : xs) {
            scores.back().push_back(score(x, c[0], c[1], c[2]));
        }
    }
    ll maxScore = -1;
    for (auto&& s : scores) {
        sort(s.begin(), s.end(), greater<ll>());
        ll temp = 0;
        for (int i = 0; i < m; ++i) {
            temp += s[i];
        }
        if (temp > maxScore) {
            maxScore = temp;
        }
    }
    cout << maxScore << endl;
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;
int par[MAXN];

inline int qry(int x) { return x == par[x] ? x : par[x] = qry(par[x]); }
inline void join(int u, int v) { par[qry(u)] = qry(v); }

int main() {
	int n, q; ll m;
	scanf("%d %lld %d", &n, &m, &q);
	for (int i = 0; i < n; i++) par[i] = i;
	vii edg;
	int cnt = 0;
	for (int i = 0; i < q; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if (c == 0) {
			if (qry(a) != qry(b))
				cnt++;
			join(a, b);
		} else {
			if (m == n-1)
				return !printf("No\n");
			edg.pb(make_pair(a,b));
		}
	}
	if (m == n-1)
		return !printf("Yes\n");
	for (auto it: edg)
		if (qry(it.fi) == qry(it.se))
			return !printf("No\n");
	ll tmp = 0;
	for (int i = 0; i < n; i++)
		if (qry(i) == i)
			cnt++, tmp++;
	if (cnt <= m && m <= cnt + (tmp*(tmp-3)) / 2 && tmp > 2)
		return !printf("Yes\n");
	printf("No\n");
	return 0;
}


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

int main(){
  long long A, B, K;cin >> A >> B >> K;
  A -= K;
  if(A >= 0){
    cout << A << " " << B;
  }else{
    B += A;
    if(B >= 0)
      cout << 0 << " " << B;
    else
      cout << 0 << " " << 0;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

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

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

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

    int r = arr[n / 2];
    int l = arr[n / 2 - 1];

    cout << r - l << '\n';

    return 0;
}

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

main()
{
   int i,j,k,sum=0,a[3][3],sum1=0;
   for(i=0;i<3;i++)
   {
       for(j=0;j<3;j++)
       {
           cin>>a[i][j];
           sum+=a[i][j];
           if(i==j)
           {
               sum1+=a[i][j];
           }
       }
   }
   if(sum%3==0)
   {
       if(sum1==(sum/3))
       {
           cout<<"Yes"<<endl;
       }
       else
       {
           cout<<"No"<<endl;
       }
   }
   else
   {
       cout<<"No"<<endl;
   }
}

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

#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));


const int N = 1e5 + 10; 
const int MAXVALUE = 16;  
struct TEdge { 
	int foo, bar, value; 
	TEdge (int foo = 0, int bar = 0, int value = 0) : foo(foo), bar(bar), value(value) {}
	int findOther (int u) { return (foo == u) ? bar : foo; }
} e[N]; 

int n; 
vector<int> g[N]; 
int a[N]; 
int countOccur[MAXVALUE]; 
int dp[(1 << MAXVALUE)]; 
bool isZero[(1 << MAXVALUE)]; 
int main() {
    #define file "F"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);

    ios :: sync_with_stdio(false); 
    cin >> n; 
    for (int iE = 1; iE < n; iE++) { 
    	int foo, bar, value; 
    	cin >> foo >> bar >> value;
    	foo++; bar++;  
    	e[iE] = TEdge(foo, bar, value); 
    	g[foo].push_back(iE); 
    	g[bar].push_back(iE); 
    }
    for (int foo = 1; foo <= n; foo++) { 
    	for (int iE : g[foo]) { 
    		a[foo] ^= e[iE].value; 
    	}
    	countOccur[a[foo]]++; 
    }
    for (int mask = 0; mask < (1 << MAXVALUE); mask++) { 
    	int xorValue = 0; 
    	for (int i = 0; i < MAXVALUE; i++) { 
    		if ((mask >> i) & 1) { 
    			xorValue ^= i; 
    		}
    		isZero[mask] = (xorValue == 0); 
    	}
    }
    for (int mask = 0; mask < (1 << MAXVALUE); mask++) { 
    	for (int subMask = mask; subMask; subMask = (subMask - 1) & mask) if (isZero[subMask]) {
    		dp[mask] = max(dp[mask], dp[mask ^ subMask] + 1);  
    	}
    }
    int ret = 0; 
    int remainMask = 0;
    ret += countOccur[0];  
    for (int value = 1; value < MAXVALUE; value++) { 
    	if (countOccur[value] & 1) remainMask ^= (1 << value);
    	ret += countOccur[value] / 2; 
    }
    ret += dp[remainMask];
    ret = n - ret; 
    cout << ret;  
    return 0;
}



Measured memory_bytes: 8056
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: u64 = sc.cin();
    let m: u64 = sc.cin();
    put!((n+m-1)/m);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
n=int(input())
rate=380000.0
ans=0.0

for i in range(n):
  x,u = input().split()
  x = float(x)
  ans += x * rate if u == "BTC" else x

#format関数 .桁数fで小数点以下が指定できる
print("{:.11f}".format(ans))
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define Bye return 0
#define ll long long

using namespace std;

void solve(){
    char c; cin>>c;
    if(c>='a' && c<='z')
        cout<<"a"<<endl;
    else cout<<"A"<<endl;
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3548
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll mod = 1000000007;
    ll N;
    cin >> N;
    vector<ll> v;
    map<ll,ll> mp;
    rep(i,N){
        ll A;
        cin >> A;
        if(mp.count(A)) mp[A]++;
        else{
            mp.emplace(A,1);
            v.push_back(A);
        }
    }
    ll out = 0;
    bool isExist = true;
    sort(v.begin(),v.end());
    rep(i,v.size()){
        if(i==0){
            if(N%2==1){
                if(v[i]==0&&mp[v[i]]==1) ;
                else{
                    isExist = false;
                    break;
                }
            }else{
                if(v[i]==1&&mp[v[i]]==2) ;
                else{
                    isExist = false;
                    break;
                }
            }
        }else{
            if(v[i]==v[i-1]+2&&mp[v[i]]==2) ;
            else{
                isExist = false;
                break;
            }
        }
    }
    if(isExist){
        out = 1;
        rep(i,N/2){
            out = (out*2)%mod;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 7640
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

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

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

int main(){
    ll n, k; cin>>n>>k;
    vector<ll> a(n), b(n);
    vector<ll> cnt(100010, 0);
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i];
        cnt[a[i]]+=b[i];
    } 

    for(int i=1; i<=100000; i++){
        k-=cnt[i];
        if(k<=0){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
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;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    if((B-A)%2==0){
        cout<<(B-A)/2<<endl;
    }else{
        cout<<min(A-1,N-B)+(B-A-1)/2+1<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int m[4]={10,50,100,500};
	for(int x=0;;x++){
		int n;
		cin>>n;
		//o(n);
		if(n==0) break;
		if(x) cout<<endl;
		int y[4]={},min=80,ans[4]={},ysum=0;
		rep(i,0,4) cin>>y[i];
		rep(z,0,4) ysum+=y[z];
		rep(i,0,y[0]+1) rep(j,0,y[1]+1) rep(k,0,y[2]+1) rep(l,0,y[3]+1){
			int sum=10*i+50*j+100*k+500*l;
			int many=i+j+k+l;
			if(sum<n) continue;
			int a=sum-n,res[4]={};
			while(1){
				if(a==0) break;
				int mm[4]={500,100,50,10};
				rep(z,0,4){
					if(a>=mm[z]){
						a-=mm[z]; res[3-z]++; break;
					}
				}
			}
			int rsum=0;
			rep(z,0,4) rsum+=res[z];
			if((res[0]>0 && i>0)||(res[1]>0 && j>0)||(res[2]>0 && k>0)||(res[3]>0 && l>0)) continue;
			if(min>ysum-many+rsum){
				min=ysum-many+rsum;
				ans[0]=i; ans[1]=j; ans[2]=k; ans[3]=l;
			}
		}
		rep(i,0,4){
			if(ans[i]) cout<<m[i]<<" "<<ans[i]<<endl;
		}
	}
}

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

int main() {
int64_t a,b,c,ans,cou;
cin>>a>>b>>c;
  cou=0;
vector<vector<char>> data(a, vector<char>(b));
for(int64_t i=0;i<a;i++){
  for(int64_t j=0;j<b;j++){
    cin>>data.at(i).at(j);
  }
}  
for(int64_t i=0;i<pow(2,a);i++){
  for(int64_t j=0;j<pow(2,b);j++){
    int64_t p,q;
    p=i;
    q=j;
    ans=0;
    vector<int64_t> va(a);
    vector<int64_t> vb(b); 
    for(int64_t k=0;k<a;k++){
      if(p%2==1){va.at(k)=1;}
      p=p/2;
    }
    for(int64_t k=0;k<b;k++){
      if(q%2==1){vb.at(k)=1;}
      q=q/2;
    }
    for(int64_t k=0;k<a;k++){
      for(int64_t l=0;l<b;l++){
       if(data.at(k).at(l)=='#'&&va.at(k)==0&&vb.at(l)==0){ans++;}
      }
    }
    if(ans==c){cou++;}
  }
} 
cout<<cou<<endl;
} 

Measured memory_bytes: 4016
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;

const int Inf = 10000*100000+100;
int V,E,R,S,T[500000+10],D[500000+10],H[500000+10],N[500000+10];
int C[100000+10],P[100000+10];

int main() {
	queue<int> Q;
	cin >> V >> E >> R;
	for (int i=1; i<=E; i++){
		cin >> S >> T[i] >> D[i];
		N[i] = H[S];
		H[S] = i;
	}
	fill(C,C+100010,Inf);
	C[R] = 0;
	Q.push(R);
	P[R] = 1;
	while(!Q.empty()){
		int u = Q.front();
		Q.pop();
		P[u] = 0;
		for (int i=H[u]; i; i=N[i]){
			int t = T[i];
			if (C[t] > C[u] + D[i]){
				C[t] = C[u]+D[i];
				if (!P[t]){
					Q.push(t);
					P[t] = 1;
				}	
			}
		}
	}
	
	for (int i=0; i<V; i++){
		if (C[i] < Inf){
			cout << C[i] << endl;
		}else{
			cout << "INF" << endl;
		}
	}	
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;
bool from1[200100];
bool ton[200100];

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--; b--;
        if(a==0){
            from1[b]=true;
        }
        if(b==0){
            from1[a]=true;
        }
        if(a==n-1){
            ton[b]=true;
        }
        if(b==n-1){
            ton[a]=true;
        }
    }
    for(int i=1;i<n-1;i++){
        if(from1[i] && ton[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;

}

Measured memory_bytes: 3920
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var [n,m]=arr.shift().split(" ").map(Number);
   if(n==0 && m==0)break;
   var h=[];
   for(var i=0;i<n;i++)h[i]=0;
   for(var i=0;i<m;i++){
      var p=arr.shift().split(" ").map(Number);
      h=p.map((v,i)=>h[i]+v);
   }
   console.log(Math.max(...h));
}


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

int main () {
  int num = 1;
  int N, K;
  cin >> N >> K;
  
  
  for (int i = 0 ; i < N ; i++) {
    if ( num > K) {
      num += K;
    } else {
      num *= 2;
    }
  }
  
  cout << num << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int ch;
while((ch=getchar())!=EOF){
if(ch!='\b'||ch!='.'){
switch(ch){
case 'a':ch='A';break;
case 'b':ch='B';break;
case 'c':ch='C';break;
case 'd':ch='D';break;
case 'e':ch='E';break;
case 'f':ch='F';break;
case 'g':ch='G';break;
case 'h':ch='H';break;
case 'i':ch='I';break;
case 'j':ch='J';break;
case 'k':ch='K';break;
case 'l':ch='L';break;
case 'm':ch='M';break;
case 'n':ch='N';break;
case 'o':ch='O';break;
case 'p':ch='P';break;
case 'q':ch='Q';break;
case 'r':ch='R';break;
case 's':ch='S';break;
case 't':ch='T';break;
case 'u':ch='U';break;
case 'v':ch='V';break;
case 'w':ch='W';break;
case 'x':ch='X';break;
case 'y':ch='Y';break;
case 'z':ch='Z';break;
}}
putchar(ch);
}
return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> b(n-1);
    for (auto& e : b) cin >> e;

    vector<int> a(n);
    a[0] = a[1] = b[0];
    
    for (int i = 1; i < n-1; i++) {
        if (a[i] < b[i]) a[i+1] = b[i];
        else a[i+1] = a[i] = b[i];
    }

    cout << accumulate(begin(a), end(a), 0) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner stdin = new Scanner(System.in)) {
			int n = Integer.parseInt(stdin.next());
			if (n < 3 || n > 10000) {
				throw new RuntimeException("Input Range:between 3 and 10000");
			}
			System.out.println(checkNum(n));

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static String checkNum(int n) {
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0) {
				sb.append(' ').append(String.valueOf(i));
			} else if (String.valueOf(i).contains("3")) {
				sb.append(' ').append(String.valueOf(i));
			}
		}
		return sb.toString();
	}
}

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

using namespace std;

const int MAX = 111;
int n;
unsigned long long t[MAX];

unsigned long long gcd(unsigned long long a, unsigned long long b) {
    if(a < b) swap(a, b);
    unsigned long long ret = 1;
    while(b) {ret = b; b = a % b; a = ret;}
    return ret;
}

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

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", t + i);
  }
  long long ans = t[0];
  for (int i = 1; i < n; i++) {
    ans = lcm(ans, t[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
price1 = 0
price2 = 0
price = 0
if (a+b) >= c*2:
    price1 += min(x,y) * 2 * c
    if min(x,y)==x:
        price1 += (y-x)*b
    else:
        price1 += (x-y)*a
        
    price2 += c * max(x,y) *2
    price = min(price1,price2)
else:
    price += (a*x + b*y)
print(price)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

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

    int n;
    cin >> n;
    rep(i,1,9) rep(j,1,9) if(i*j==n) n=-1;
    if (n==-1) cout << "Yes" << endl;
    else       cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;

inline int read(){
	int x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar());
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x;
}

int gcd(int x,int y){ return y?gcd(y,x%y):x;}

int n,mx,g,k;

int main(){
	n=read(),k=read();
	for(int i=1,now;i<=n;i++){
		now=read();
		mx=max(mx,now);
		g=gcd(g,now);
	}

	if(k<=mx&&!((mx-k)%g)) puts("POSSIBLE");
	else puts("IMPOSSIBLE");

	return 0;
}

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

using namespace std;

int main()
{
    int n, m, l;
    cin >> n >> m >> l;

    vector<vector<long>> m1(n, vector<long>(m));
    vector<vector<long>> m2(m, vector<long>(l));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            int x;
            cin >> x;
            m1[i][j] = x;
        }
    }
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < l; ++j) {
            int x;
            cin >> x;
            m2[i][j] = x;
        }
    }

    vector<vector<long>> r(n, vector<long>(l, 0));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < l; ++j) {
            for (int k = 0; k < m; ++k) {
                r[i][j] += m1[i][k] * m2[k][j];
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < l; ++j) {
            if (j != 0) {
                cout << ' ';
            }
            cout << r[i][j];
        }
        cout << endl;
    }
}

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

long long A,B;
vector<long long> val;
long long memo[100005][2];
long long diffarr[100005];
const long long MOD = 1000000007LL;
const long long INF = 1000000000000000005LL;

///range min because im lazy to code sparse table
struct node{
int s,e;
long long v;
node *l,*r;
node(int _s, int _e){
    s = _s;e = _e;
    if (s==e){
        v = diffarr[s];
    }
    else{
        l = new node(s, (s+e)/2);
        r = new node((s+e)/2+1,e);
        v = min(l->v,r->v);
    }
}
long long query(int a, int b){
    if (b<a) return INF;
    if (a<=s && e<=b){
        return v;
    }
    if (b<=(s+e)/2){
        return l->query(a,b);
    }
    if (a>(s+e)/2){
        return r->query(a,b);
    }
    return min(l->query(a,b),r->query(a,b));
}
}*root;

bool possible(int l, int r, bool side){
    if (l>=r) return true;
    long long diffreq = side?B:A;
    long long mind = root->query(l+1,r);
    return mind>=diffreq;
}

long long ways(int id, bool r){
    if (memo[id][r]!=-1) return memo[id][r];
    long long diff = r?B:A;
    int maxprev = upper_bound(val.begin(),val.end(),val[id]-diff) - val.begin();
    if (maxprev==0){
        if (possible(0,id-1,!r)){
            return memo[id][r] = 1;
        }
        else return memo[id][r] = 0;
    }
    maxprev--;
    if (maxprev==id-1){
        return memo[id][r] = (ways(id-1,r)+ways(id-1,!r))%MOD;
    }
    if (!possible(maxprev+1,id-1,!r)){
        return memo[id][r] = 0;
    }

    return memo[id][r] = (ways(maxprev+1,!r))%MOD;

}



int main(){
int n;
scanf("%d%lld%lld",&n,&A,&B);
for (int x = 0; x<n; x++){
    long long a;
    scanf("%lld",&a);
    val.push_back(a);
}
for (int x = 1; x<n; x++){
    diffarr[x] = val[x]-val[x-1];
}
diffarr[0] = INF;
memset(memo,-1,sizeof(memo));
root = new node(0,n-1);

printf("%lld",(ways(n-1,true)+ways(n-1,false))%MOD);
}


Measured memory_bytes: 17396
#include <stdio.h>

int main() {
    // Constraints: 100 <= N <= 999
    // s <- '100\0' ~ '999\0'
    char s[4];
    scanf("%s", s);

    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        puts("Yes");
    }
    else {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;

int main() {
	int N;
	cin >>N;
	string S;
	cin >> S;
	int K;
	cin >> K;

	for (size_t i = 0; i < S.length(); i++) {
		if (S[i] != S[K - 1]) {
			S[i] = '*';
		}
	}

	std::cout << S << endl;

	return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;
int n, s, ans;

void solve(int cnt, int num, int sum){
    if(n==cnt&&s==sum){
        ans++;
        return;
    }else if(cnt>n||num>9||sum>s){
        return;
    }

    solve(cnt+1, num+1, sum+num);
    solve(cnt, num+1, sum);
}

int main(){

    while(1){
        cin>> n>> s;
        if(n==0&&s==0) break;

        ans=0;
        solve(0, 0, 0);

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

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define INF 1000000001
#define MOD 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const ull B=100000007;
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
struct A{int x,y,cost;};
int main(){
      int h,w,n,fin=-1;
      int x[11],y[11];
      memset(x,-1,sizeof(x));
      memset(y,-1,sizeof(y));
      cin>>h>>w>>n;
      char c;
      bool fld[1000][1000];
      REP(i,h)REP(j,w){
            cin>>c;
            if(c=='.')fld[j][i]=true;
            else if(c=='X')fld[j][i]=false;
            else if(c=='S'){
                  fld[j][i]=true;
                  x[0]=j;y[0]=i;
            }else{
                  fld[j][i]=true;
                  x[c-'0']=j;
                  y[c-'0']=i;
                  fin=max(fin,c-'0');
            }
      }
      int ans=0;
      REP(i,fin){
            int d[1000][1000];
            memset(d,-1,sizeof(d));
            queue<A> Q;
            Q.push((A){x[i],y[i],0});
            while(!Q.empty()){
                  A a=Q.front();Q.pop();
                  int xx=a.x,yy=a.y,cost=a.cost;
//                  cout<<xx<<" "<<yy<<endl;
                  if(d[xx][yy]!=-1)continue;
                  d[xx][yy]=cost;
//                  cout<<xx<<" "<<yy<<" "<<cost<<endl;
                  if(xx==x[i+1]&&yy==y[i+1]){
                        ans+=cost;
                        break;
                  }
                  REP(j,4){
                        int nx=xx+dx[j],ny=yy+dy[j];
                        if(nx<0||nx>=w||ny<0||ny>=h||!fld[nx][ny])continue;
                        Q.push((A){nx,ny,cost+1});
                  }
            }
      }
      cout<<ans<<endl;
}

Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
ll mod = 1e9+7;
double PI = 3.14159265359;

int main(){
    double a,b,h,m;
    cin >>a >> b >> h >>m;
    double t_h, t_m;
    t_h = h/12.0 * 2*PI + m/60.0 * PI/6;
    t_m = m/60.0 * 2*PI;
    double ans;
    ans = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(t_h-t_m));
    cout << fixed;
    cout << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 4216
#include<cstdio>
#include<algorithm>
const int N=1e5+6;
int n,m,deg[N],u,v,head[N],cnt=1;
bool vis[N];
struct edge{
	int to,nxt;
}e[N<<1];
void dfs(int u,int pre){
	vis[u]=1;
	for(int i=head[u];i;i=e[i].nxt)
	if(i!=pre&&e[i].to!=v){
		if(!vis[e[i].to])dfs(e[i].to,i^1);else{puts("Yes");exit(0);}
	}
	vis[u]=0;
}
int main(){
	scanf("%d%d",&n,&m);
	while(m--){
		scanf("%d%d",&u,&v);
		e[++cnt]=(edge){v,head[u]},head[u]=cnt;
		e[++cnt]=(edge){u,head[v]},head[v]=cnt;
		++deg[u],++deg[v];
	}
	for(int i=1;i<=n;++i)if(deg[i]&1)return puts("No"),0;
	if(*std::max_element(deg+1,deg+n+1)>4)return puts("Yes"),0;
	u=v=0;
	for(int i=1;i<=n;++i)
	if(deg[i]==4){if(!u)u=i;else if(!v)v=i;else return puts("Yes"),0;}
	if(v)dfs(u,0);
	return puts("No"),0;
}

Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		long k = scan.nextLong();

		long re = 0L;

		if(k <= a) {
			re = k;
			}else if(k <= (a+b)) {
	re = a;
			}else {
	re = a-(k-a-b);
			}
		System.out.println(re);
		scan.close();
	}

}


Measured memory_bytes: 26984