akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll ans = 0;
    reps(i, 1, n + 1) {
        string s = to_string(i);
        if (len(s) % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

static const auto MAX = 2000000;
static const auto INF = 2000000;

class BinaryHeap {
private:
    int heap[MAX + 1];
    int size = 0;

public:
    static int parent(int index)
    {
        return index / 2;
    }

    static int left(int index)
    {
        return 2 * index;
    }

    static int right(int index)
    {
        return 2 * index + 1;
    }

    void maxHeapify(int root)
    {
        int left_id = left(root);
        int right_id = right(root);

        int largest;
        if (left_id <= size && heap[left_id] > heap[root])
            largest = left_id;
        else
            largest = root;
        if (right_id <= size && heap[right_id] > heap[largest])
            largest = right_id;

        if (largest != root)
        {
            swap(heap[largest], heap[root]);
            maxHeapify(largest);
        }
    }

    void insert(int key)
    {
        size++;
        heap[size] = -INF;
        heapIncreaseKey(size, key);
    }

    void heapIncreaseKey(int index, int key)
    {
        if (key < heap[index])
            return;
        heap[index] = key;
        while (index > 1 && heap[parent(index)] < heap[index])
        {
            swap(heap[index], heap[parent(index)]);
            index = parent(index);
        }
    }

    int extractMax()
    {
        if (size < 1)
            return -1;
        int max = heap[1];
        heap[1] = heap[size--];
        maxHeapify(1);
        return max;
    }
};

int main()
{
    BinaryHeap heap;
    while(true)
    {
        string command;
        int key;
        cin >> command;
        if(command == "insert")
        {
            cin >> key;
            heap.insert(key);
        }
        else if(command == "extract")
            cout << heap.extractMax() << endl;
        else
            break;
    }
}


Measured memory_bytes: 7012
H, W, A, B = map(int, input().split())

L = ''.join(['1'] * A + ['0'] * (W - A))
R = ''.join(['0'] * A + ['1'] * (W - A))

ans = []
for h in range(H):
    if h < B:
        ans.append(L)
    else:
        ans.append(R)

print(*ans, sep='\n')

Measured memory_bytes: 3956
#C
import math
n, k = map(int, input().split())#n面ダイス 点数k以上
ans = 0
for i in range(1, n + 1):  #出目がi
    if i < k: #出目がk以下
        m = math.ceil(math.log2(k / i))
        ans += 1 / (2 ** m) / n
    else: #出目がk以上
        ans += 1 / n
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;

int h[100005];
int main() {
    int n, k;

    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", &h[i]);

    sort(h, h + n);

    int ans = h[n-1] - h[0];
    for (int i = 0; i < n-k+1; i++) {
        ans = min(ans, h[i+k-1] - h[i]);
    }

    printf("%d\n", ans);

    return 0;
}


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

int a[3][3];
int b[3][3];


int main(){
    rep(i,3) rep(j,3) cin>>a[i][j];
    int n;
    cin>>n;
    rep(ni,n){
        int x;
        cin>>x;
        rep(i,3) rep(j,3) if(a[i][j]==x) b[i][j]=1;
    }
    bool ans=false;
    rep(i,3){
        int cnt=0;
        rep(j,3)cnt+=b[i][j];
        if(cnt==3)ans=true;
    }
    rep(i,3){
        int cnt=0;
        rep(j,3)cnt+=b[j][i];
        if(cnt==3)ans=true;
    }
    {
        int cnt=0;
        rep(j,3)cnt+=b[j][j];
        if(cnt==3)ans=true;
    }
    {
        int cnt=0;
        rep(j,3)cnt+=b[j][2-j];
        if(cnt==3)ans=true;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int k, a[100000];
int dp[100010][2];

signed main() {
	cin >> k;
	for (int i = 0; i < k; i++)cin >> a[i];
	dp[0][0] = 2;
	dp[0][1] = 2;
	for (int i = k - 1; i >= 0; i--) {
		int j = k - i;
		if (dp[j - 1][0] * 2 <= a[i]) {
			cout << -1 << endl;
			return 0;
		}
		int x = 0;
		if (dp[j - 1][0] % a[i]) x = a[i] * (dp[j - 1][0] / a[i] + 1);
		else x = dp[j - 1][0];
		if (x < dp[j - 1][0] || dp[j - 1][1] < x) {
			cout << -1 << endl;
			return 0;
		}
		dp[j][0] = x;
		dp[j][1] = dp[j - 1][1] / a[i] * a[i] + a[i] - 1;
	}
	cout << dp[k][0] << " " << dp[k][1] << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int MOD = 1e9+7;
const int INF = 1e9;
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}
// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
  void debug() {cerr << "\n";}
  template<class First> void debug(const First& first) {cerr<<first<<"\n";}
  template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
  #define debug(...) 42
#endif


int N, M, P;

struct Edge {
  int from, to, cost;
};

int main() {
  cin >> N >> M >> P;

  vector<Edge> edges(M);
  vvi edge(N, vi()), redge(N, vi());
  rep(i, M) {
    cin >> edges[i].from >> edges[i].to >> edges[i].cost;
    --edges[i].from;
    --edges[i].to;
    edges[i].cost = -(edges[i].cost - P);
    edge[edges[i].from].push_back(edges[i].to);
    redge[edges[i].to].push_back(edges[i].from);
  }

  queue<int> q;
  vector<bool> can_visit_from_1(N, false),
    can_visit_from_N(N, false);
  q.push(0);
  while (!q.empty()) {
    int p = q.front(); q.pop();
    if (can_visit_from_1[p])
      continue;
    can_visit_from_1[p] = true;
    for (const auto& to : edge[p]) {
      if (!can_visit_from_1[to])
        q.push(to);
    }
  }
  q.push(N-1);
  while (!q.empty()) {
    int p = q.front(); q.pop();
    if (can_visit_from_N[p])
      continue;
    can_visit_from_N[p] = true;
    for (const auto& to : redge[p]) {
      if (!can_visit_from_N[to])
        q.push(to);
    }
  }


  int d[N];
  fill(d, d+N, INF);
  d[0] = 0;
  rep(i, N) {
    rep(j, M) {
      if (chmin(d[edges[j].to], d[edges[j].from] + edges[j].cost)) {
        if (i == N-1) {
          int from = edges[j].from, to = edges[j].to;
          if (can_visit_from_1[from] && can_visit_from_N[from] ||
              can_visit_from_1[to] && can_visit_from_N[to]) {
            cout << "-1\n";
            return 0;
          }
        }
      }
    }
  }
  cout << max(0, -d[N-1]) << endl;

  return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 6)

# 末端の頂点は白1通り、黒1通り
# それ以外の頂点は、各子どもの頂点を元に、白:子の全ての場合分けの積、黒:子が全て白の場合分けの積
# で更新していく

N = int(input())
G = [[] for i in range(N)]
MOD = 10 ** 9 + 7

for i in range(N - 1):
  x,y = map(int,input().split())
  G[x - 1].append(y - 1)
  G[y - 1].append(x - 1)
  
dp_black = [-1] * N
dp_white = [-1] * N

# 頂点vの(黒,白)の場合の数を求める
def search(v,parent):
  if dp_black[v] != -1:
    return (dp_black[v],dp_white[v])
  black = 1
  white = 1
  for child in G[v]:
    if child == parent:
      continue
    b,w = search(child, v)
    black *= w
    black %= MOD
    white *= (b + w)
    white %= MOD
  dp_black[v] = black
  dp_white[v] = white
  return (black, white)

print(sum(search(0, -1)) % MOD)


Measured memory_bytes: 106596
N = int(input())

def get_soinsu(n):
    if n ==1:
        return
    for p in soinsu.keys():
        if n%p == 0:
            soinsu[p] += 1
            get_soinsu(n//p)
            break
    else:
        soinsu[n] = 1

soinsu = {}
for i in range(2,N+1):
    get_soinsu(i)

tmp3 = soinsu.values()
    
#素因数が(74)個の数の選び方
num_74 = len([tmp for tmp in tmp3 if tmp >= 74])

#素因数が(2,24)個の数の選び方
num_24_2 = len([tmp for tmp in tmp3 if tmp >= 24]) * (len([tmp for tmp in tmp3 if tmp >= 2])-1)

#素因数が(4,14)個の数の選び方
num_14_4 = len([tmp for tmp in tmp3 if tmp >= 14]) * (len([tmp for tmp in tmp3 if tmp >= 4])-1)

#素因数が(2,4,4)個の数の選び方
tmp2 = len([tmp for tmp in tmp3 if tmp >= 4])
num_4_4_2 = max(0,tmp2*(tmp2-1)*(len([tmp for tmp in tmp3 if tmp >= 2])-2)//2)

print(num_74 + num_24_2 + num_14_4 + num_4_4_2)

Measured memory_bytes: 3064
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , x , t;
int main(){
fcin;
    cin >> n >> x >> t;
    int a = 0 , ans = 0;
    while(a<n){
        a+=x;
        ans+=t;
    }
    cout << ans << '\n';


}

Measured memory_bytes: 3200
#include<cstdio>
#include<algorithm>
using std::max;
const int N=2333;
int pre[N][N],L[N],R[N];
int n,m,h,t,top;
char mp[N][N];
int sta[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",mp[i]+1);
	for(int i=1;i<n;++i){
		for(int j=1;j<m;++j){
			int x=(mp[i][j]=='.')+(mp[i][j+1]=='.')+(mp[i+1][j]=='.')+(mp[i+1][j+1]=='.');
			if(x%2==0)pre[j][i]=pre[j-1][i]+1;else pre[j][i]=0;
		}
	}
	int ans=n;
	if(ans<m)ans=m;
	for(int j=1;j<m;++j){
		int*P=pre[j];
		sta[top=1]=L[1]=1;
		*sta=0;
		for(int i=2;i<n;++i){
			while(top&&P[i]<=P[sta[top]])--top;
			L[i]=sta[top]+1;
			sta[++top]=i;
		}
		sta[top=1]=R[n-1]=n-1;
		*sta=n;
		for(int i=n-2;i;--i){
			while(top&&P[i]<=P[sta[top]])--top;
			R[i]=sta[top]-1;
			sta[++top]=i;
		}
		for(int i=1;i<n;++i)ans=max(ans,(R[i]-L[i]+2)*(P[i]+1));
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
	string s;
	while( cin >> s ){
		string ans = "";
		for( int i = 0; i < s.size(); i++ ){
			if( s[i] == '@' ){
				for( int j = 0; j < (int)(s[i+1]-'0'); j++ ){
					ans += s[i+2];
				}
				i += 2;
			}else{
				ans += s[i];
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1192
#include <stdio.h>

int main()
{
    int A,B,count=0;
    int C,D,i;

    scanf("%d %d",&A,&B);

    for(i=A;i<B+1;i++){
        C = (i/10000)+(i%10000/1000)*10+(i%1000/100)*100+(i%100/10)*1000+(i%10)*10000;
        if(i==C){
            count++;
        }
    }
    printf("%d\n",count);

    return 0;

}

Measured memory_bytes: 128
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  int e,f;
  if(c%b!=0){
    e=c/b+1;
  }else
  {
    e=c/b;
  }
   if(a%d!=0){
    f=a/d+1;
  }else
  {
    f=a/d;
  }
  if(e<=f){
    cout <<"Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }
}

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

int n, ans, minSuffix[100100], minPrefix[100100];
pair<int, int> a[100100];

int getAns(int minL, int maxL, int minR, int maxR)
{
  return max(0, maxL - minL + 1) + max(0, maxR - minR + 1);
}

bool cmp(pair<int, int> u, pair<int, int> v)
{
  if (u.first != v.first)
    return u.first < v.first;
  return u.second > v.second;
}

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

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i].first >> a[i].second;

  sort(a, a + n, cmp);
  minPrefix[0] = a[0].second;
  for (int i = 1; i < n; i++)
    minPrefix[i] = min(minPrefix[i - 1], a[i].second);
  minSuffix[n - 1] = a[n - 1].second;
  for (int i = n - 2; i >= 0; i--)
    minSuffix[i] = min(minSuffix[i + 1], a[i].second);

  // 1 and n - 1
  ans = max(ans, getAns(a[0].first, a[0].second, a[n - 1].first, minSuffix[1]));
  ans = max(ans, getAns(a[n - 1].first, a[n - 1].second, a[n - 2].first, minPrefix[n - 2]));
  for (int i = 0; i < n; i++)
    ans = max(ans, getAns(a[i].first, a[i].second, a[n - 1].first, min(minSuffix[i + 1], minPrefix[i - 1])));

  int minRId = 0;
  for (int i = 1; i < n; i++)
    if (a[i].second < a[minRId].second)
      minRId = i;

  if (minRId != n - 1)
  {
    int minL = a[n - 1].first, maxL = a[n - 1].second;
    int minR = a[minRId].first, maxR = a[minRId].second;
    ans = max(ans, getAns(minL, min(maxL, minPrefix[n - 1]), minR, maxR));
    ans = max(ans, getAns(minL, maxL, max(minR, a[n - 2].first), maxR));
    for (int i = 0; i < n - 1; i++)
      ans = max(ans, getAns(minL, min(maxL, minSuffix[i + 1]), max(minR, a[i].first), maxR));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
#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>;

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;
}

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.length() <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) << "..." << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define max 10001
#define INF 2000000000
int color[max];
int d[max];
int n;
vector<pair<int ,int> > vc[max];
void dijksra(){
  int i,t;
  pair<int,int> u;
  priority_queue< pair<int, int> > pq;
  for(i=1;i<n;i++)d[i]=INF;
  pq.push(make_pair(0,0));
  while(!pq.empty()){
    u=pq.top();
    pq.pop();
    t=u.second;
    color[t]=1;
    if(d[t]<u.first*(-1))continue;
    for(i=0;i<(int)vc[t].size();i++){
      int v=vc[t][i].first;
      if(color[v]==1)continue;
      if(d[t]+vc[t][i].second<d[v]){
	d[v]=d[t]+vc[t][i].second;
	color[v]=-1;
	pq.push(make_pair(d[v]*(-1),v));
      }
    }
  }
  for(i=0;i<n;i++){
    cout<<i<<" "<<d[i]<<endl;
  }
}
int main(){
  int u,k,v,c;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      vc[u].push_back(make_pair(v,c));
    }
  }
  dijksra();

  return 0;
}



Measured memory_bytes: 8048
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <ld, int> P;

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

    int n;
    cin >> n;

    vector <ld> x(n), y(n);
    vector <P> angle(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        angle[i] = {atan2(y[i], x[i]), i};
    }

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

    ld ans = 0.0;
    for (int i = 0; i < n; i++) {
        ld curX = 0.0, curY = 0.0;
        for (int j = i; j < i + n; j++) {
            curX += x[angle[j % n].second];
            curY += y[angle[j % n].second];
            ans = max(ans, sqrtl(curX * curX + curY * curY));
        }
    }

    cout << fixed << setprecision(12) << ans << "\n";
    return 0;
}

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

using namespace std;

struct dice{
	int q1,q2,q3,q4,q5,q6;
};

void mN(dice &d){
	int tmp=d.q1;
	d.q1=d.q2;
	d.q2=d.q6;
	d.q6=d.q5;
	d.q5=tmp;
}

void mE(dice &d){
	int tmp=d.q1;
	d.q1=d.q4;
	d.q4=d.q6;
	d.q6=d.q3;
	d.q3=tmp;
}

void spin(dice &d){
	int tmp=d.q2;
	d.q2=d.q3;
	d.q3=d.q5;
	d.q5=d.q4;
	d.q4=tmp;
}

bool isSame(dice y, dice z){
	bool flag = false;

	for(int i=0; i<4; ++i){
		for(int j=0; j<4; ++j){
			if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
				flag = true;
				break;
			}
			spin(y);	
		}
		if(flag) break;
		mN(y);
	}
	
	mE(y);
	
	for(int i=0; i<4; ++i){
		for(int j=0; j<4; ++j){		
			if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
				flag = true;
				break;
			}
			spin(y);	
		}
		if(flag) break;
		mN(y);
	}	
			
	return flag;
}

int main(){
	dice a[100];
	int n;
	bool ans=false;
	
	scanf(" %d", &n);
	
	for(int i=0; i<n; ++i)
		scanf(" %d %d %d %d %d %d", &a[i].q1, &a[i].q2, &a[i].q3, &a[i].q4, &a[i].q5, &a[i].q6);
		
	for(int i=0; i<n-1; ++i){
		for(int j=i+1; j<n; ++j){
			ans=isSame(a[i], a[j]);
			if(ans) break;
		}
		if(ans) break;
	}
	
	if(ans) printf("No\n");
	else printf("Yes\n");
		
	return 0;
}



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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
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;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    struct Edge {
        Edge(int a, int b, int c) : a(a), b(b), c(c) {}
        int a, b, c;
    };
    int n, m; std::cin >> n >> m;
    vvi to(n, vi(n, inf)), cost;
    vector<Edge> edges;
    rep(i, n) to[i][i] = 0;
    rep(i, m) {
        int a, b, c; std::cin >> a >> b >> c;
        --a, --b;
        to[a][b] = to[b][a] = c;
        edges.pb(Edge(a, b, c));
    }
    cost = to;
    rep(k, n) rep(i, n) rep(j, n) chmin(cost[i][j], cost[i][k] + cost[k][j]);
    int ans = m;
    rep(i, m) {
        int a = edges[i].a, b = edges[i].b;
        bool used = false;
        rep(j, n) {
            if (cost[j][a]+to[a][b] == cost[j][b]) used = true;
        }
        if (used) ans--;
    }
    std::cout << ans << "\n";
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> item(n);
	int total = 0;
	for (int i = 0; i < n; i++) {
		cin >> item.at(i);
		total += item.at(i);
	}

    sort(item.begin(), item.end());
    reverse(item.begin(), item.end());
	for (int i = 0; i < m; i++) {
		if (item.at(i) < total * (1.0 / (4.0 * m))) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#Print a Frame
def paints(arr)
	arr.each{|i|
		a = []
		i.each{|j|
			a << j
		}
		a[0].times{|k|
			if (k != 0 && k != (a[0] - 1))
				w_dotto_line = ''
				a[1].times{|l|
					if (l != 0 && l != (a[1] - 1))
						w_dotto_line << "."
					else
						w_dotto_line << '#'
					end
				}
				puts w_dotto_line
			else
				w_line = ''
				a[1].times{|l|
					w_line << '#'
				}
				puts w_line
			end
		}
		puts ''
	}
end

input_arr = []
while input = gets
	h, w = input.split(' ').map(&:to_i)
	break if (h == 0 && w == 0)
	input_arr << [h, w]
end

paints(input_arr)

Measured memory_bytes: 8788
import statistics

n = int(input())
d = list(map(lambda x: int(x), input().split()))
m = statistics.median(d)
s = [i for i in d if i < m]
b = [i for i in d if i >= m]

if len(s) == len(b):
    ans = min(b) - max(s)
else:
    ans = 0
print(ans)

Measured memory_bytes: 16020
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

#define N_MAX 100001

vector<int> edge[N_MAX], revedge[N_MAX];
int visited[N_MAX];
int order[N_MAX],tail;

void dfs(int cur)
{
	if (0 != visited[cur]){
		return;
	}

	visited[cur] = 1;
	for (int i = 0; i < edge[cur].size(); i++)
	{
		dfs(edge[cur][i]);
	}

	order[cur] = tail;
	tail--;

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int N, M; scanf("%d%d", &N, &M);

	for (int i = 0; i < N + M - 1; i++){
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;
		edge[a].push_back(b);
		revedge[b].push_back(a);
	}

	fill(visited, visited + N, 0);
	tail = N-1;
	for (int i = 0; i < N; i++){
		dfs(i);
	}

	for (int i = 0; i < N; i++){
		int index = -1, val = -1;
		for (int j = 0; j < revedge[i].size(); j++){
			if (order[revedge[i][j]] > val){
				val = order[revedge[i][j]];
				index = revedge[i][j];
			}
		}
		printf("%d\n", index + 1);
	}

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 15744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>

#define rep(i,a,n)   for(int i=a;i<n;i++)
#define repe(i,a,n)  for(int i=a;i<=n;i++)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vc>  vcc;
#define fast   ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)


#define mod 1000000007
#define nl "\n"


int main()
{  fast;
   string s;
   cin>>s;
   if(s[s.size()-1]=='s')
     cout<<s+"es";
   else
      cout<<s+"s";
      cout<<endl;
}


Measured memory_bytes: 3660
N = int(input())
S = input()
ma=0
for i in range(1,N):
    leftS = S[0:i]
    rightS = S[i:]
    setLeftS = set(leftS)
    setRightS = set(rightS)
    m = 0
    for r in setRightS:
        if r in setLeftS:
            m+=1
    ma = max(ma,m)
print(ma)

Measured memory_bytes: 65996
#include <bits/stdc++.h>
const int INF = 1e9;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;

#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
#define s second
#define f first

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
/* 0 そのまま
 * 1 1
 * 2 N+1
 * 3 0
 */
LL Xor(LL i){
   if(i%4 == 0)return i;
   if(i%4 == 1)return 1;
   if(i%4 == 2)return i+1;
   if(i%4 == 3)return 0;
}
const int MOD = 1e9+7;
int main(){
    LL A,B;cin >> A >> B;
   // cout<<Xor(A)<<" "<<Xor(B)<<endl;
    cout<<(Xor(B) ^ Xor(A-1))<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int d[9][101]={0};//前日/3 一昨日%3
  int f[101]={0};
  int i,j,k,n,m,a,b;
  scanf("%d %d",&n,&m);
  while(m--){
    scanf("%d %d",&a,&b);
    f[a]=b;
  }
  for(i=0;i<9;i++){
    d[i][2]=1;
    if(f[1]&&f[1]-i%3-1)d[i][2]=0;
    if(f[2]&&f[2]-i/3-1)d[i][2]=0;
  }
  for(i=3;i<=n;i++){
    for(j=0;j<9;j++){//入れるとこ
      if(f[i]&&f[i]-1-j/3)continue;
      for(k=0;k<3;k++){
	if(k==j%3&&j%3==j/3)continue;
	d[j][i]+=d[k+(j%3)*3][i-1];
	d[j][i]%=10000;
      }
    }
  }
  /*for(i=0;i<9;i++){
    for(j=2;j<=n;j++)printf("%4d ",d[i][j]);printf("\n");
    }//*/
  for(i=a=0;i<9;i++)a+=d[i][n];
  printf("%d\n",a%10000);
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    
    vector<tuple<string, int, int>> restaurants(N);
    for (int i = 0; i < N; i++) {
        string S;
        int P;
        cin >> S >> P;
        restaurants.at(i) = make_tuple(S, -P, i + 1);
    }
    
    sort(restaurants.begin(), restaurants.end());
    for (int i = 0; i < N; i++) {
        cout << get<2>(restaurants.at(i)) << endl;
    }
    
}

Measured memory_bytes: 256
one = input()
two = input().split()
three = input().split()

N = int(one)
T = int(two[0])
A = int(two[1])
H = list(map(int,three))

for i in range(1,N):
    tem = list(map(lambda x: T-0.006*x,H))

tem_dif = list(map(lambda x: abs(x-A),tem))

print(tem_dif.index(min(tem_dif))+1)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5 + 5;

int fa[MAXN];
inline void init(int n){ for(int i=1; i<=n; ++i) fa[i] = i;}
int find(int u){ return fa[u] == u? u: fa[u] = find(fa[u]);}
inline void connect(int u,int v){ fa[find(u)] = find(v);}

int main(void)
{
	int n,m;
	scanf("%d%d",&n,&m);
	init(n);
	for(int i=1; i<=m; ++i)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		connect(u,v);
	}
	
	int cnt = 0;
	for(int i=1; i<=n; ++i)
		if(find(i) == i) ++cnt;
	
	printf("%d",cnt-1);
	return 0;
}

Measured memory_bytes: 4144
from itertools import product
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
ans = 1001001001
for x in product(range(4), repeat=n):
    s = [0] * 4
    t = -3
    for i in range(n):
        t += x[i] < 3
        s[x[i]] += l[i]
    s.pop()
    if 0 in s:
        continue
    ans = min(ans, t * 10 + abs(s[0] - a) + abs(s[1] - b) + abs(s[2] - c))
print(ans)


Measured memory_bytes: 3064
//最大と最小と和を求めるプログラム
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	long long sum = 0;
	int max = -1000000;
	int min = 1000000;
	int i;
	for (i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		if (a >max) {
			max = a;
		}
		if (a < min) {
			min = a;
		}
		sum += a;
	}
	printf("%d %d %lld\n",min,max,sum);
	return 0;
}



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

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

    bool b = false;
    int ans = 0;
    int count = 0;
    for(ll i = 0; i < S.length(); i++){
        char s = S[i];
        if (b == true && s == 'R'){
            count++;
            ans = max(ans, count);
        } else if (s == 'R') {
            b = true;
            count = 1;
            ans = max(ans, count);
        } else {
            b = false;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = Console.ReadLine().Split(' ');
            List<int> lstA = new List<int>();
            for (int i = 0; i < sS.Length; i++) { lstA.Add(int.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstA.Sort();                                                                                // 一応昇順
            int iMax = lstA[lstA.Count - 1];                                                            // nCrのnはすぐ判明
            int iMid = iMax / 2;                                                                        // nCrのrはこの値が最大だか数列内存在するかは不明
            if (lstA.Count == 2) { iMid = lstA[0]; iMax = lstA[1]; }                                    // 2つしかない場合 固定
            else                                                                                        // 3つ以上  数列内でrに近い値をどうにか取得
            {
                List<ClsPot> lstPot = new List<ClsPot>();
                for (int i = 0; i < lstA.Count - 1; i++)                                                // lstA.Count - 1 まで。最後のはiMaxで確定済み
                {
                    lstPot.Add(new ClsPot() { iX = lstA[i], iD = Math.Abs(iMid - lstA[i]) });           // 値とrまでの差
                }
                lstPot.Sort(delegate (ClsPot mca1, ClsPot mca2) { return (int)(mca1.iD - mca2.iD); });  // iDの昇順
                iMid = lstPot[0].iX;                                                                    // rまでの差が一番小さいの
                if (lstPot[0].iD == lstPot[1].iD) { iMid = lstPot[0].iX > lstPot[1].iX ? lstPot[0].iX : lstPot[1].iX; } // 2番目に小さいのも同じ差ならXの大きいの
            }

            // 出力
            Console.WriteLine("{0} {1}", iMax.ToString().Trim(), iMid.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // 点位置情報
        private class ClsPot
        {
            public int iX { get; set; } = -1;                        // 値
            public int iD { get; set; } = -1;                        // rとの差
        }

}


Measured memory_bytes: 31324
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
    cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string S;
    bool M = 0;
    cin >> S;
    int N = S.size();
    for (int i = 0; i < N/2; i++){
        if(S.at(i) != S.at(i+(N/2)+1)){
        M =1;
        break;
        }
    }
    if(M)cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

#define rep(i,n)        for (i = 0; i < n; ++i) 
#define REP(i,k,n)      for (i = k; i <= n; ++i) 
#define REPR(i,k,n)     for (i = k; i >= n; --i) 
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

const int SIZE = 1e5;
int arr[SIZE];

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
	    freopen("in.txt", "r", stdin);
	    freopen("out.txt", "w", stdout);
	#endif
}


int main() { 

	c_p_c();
	
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	bool flag = false;
	while(1){
		//cout << A << " "<< B << " "<< C <<" "<< D << endl;
		C -= B;
		A -= D;
		//cout << A << " "<< C << endl;
		if(C <= 0){
			flag = true;
			break;
		}
		else if(A <= 0){
			break;
		}
	}
	if(flag){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0; 
} 


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int main(){
        int d;
        scanf("%d",&d);
        if(d == 25){
                printf("Christmas\n");
        }
        else if(d == 24){
                printf("Christmas Eve\n");
        }
        else if(d == 23){
                printf("Christmas Eve Eve\n");
        }
        else if(d == 22){
                printf("Christmas Eve Eve Eve\n");
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

map<int,set<ii> > R;
map<int,set<ii> > C;
map<int,vector<int> > rows;
map<int,vector<int> > cols;
ii pt[111111];
ll ans;

int calcrow(int x, int l, int r)
{
	if(rows.find(x)==rows.end()) return 0;
	int lb = lower_bound(rows[x].begin(),rows[x].end(),l)-rows[x].begin();
	int rb = lower_bound(rows[x].begin(),rows[x].end(),r+1)-rows[x].begin();
	return rb-lb;
}

int calccol(int x, int l, int r)
{
	if(cols.find(x)==cols.end()) return 0;
	int lb = lower_bound(cols[x].begin(),cols[x].end(),l)-cols[x].begin();
	int rb = lower_bound(cols[x].begin(),cols[x].end(),r+1)-cols[x].begin();
	return rb-lb;
}

int d=0;
bool vis[111111];

void process(int u)
{
	vis[u]=1;
	int x=pt[u].fi; int y=pt[u].se;
	ans+=calcrow(x-d,y-d,y+d);
	ans+=calcrow(x+d,y-d,y+d);
	ans+=calccol(y-d,x-d+1,x+d-1);
	ans+=calccol(y+d,x-d+1,x+d-1);
	vi Q;
	if(!R[x-d].empty())
	{
		auto it = R[x-d].lower_bound(mp(y-d,-1));
		while(it!=R[x-d].end())
		{
			if((*it).fi<=y+d)
			{
				Q.pb((*it).se);
				C[(*it).se].erase(mp(x-d,(*it).se));
				it=R[x-d].erase(it);				
			}
			else break;
		}
	}
	if(!R[x+d].empty())
	{
		auto it = R[x+d].lower_bound(mp(y-d,-1));
		while(it!=R[x+d].end())
		{
			if((*it).fi<=y+d)
			{
				Q.pb((*it).se);
				C[(*it).se].erase(mp(x+d,(*it).se));
				it=R[x+d].erase(it);				
			}
			else break;
		}
	}
	if(!C[y+d].empty())
	{
		auto it = C[y+d].lower_bound(mp(x-d+1,-1));
		while(it!=C[y+d].end())
		{
			if((*it).fi<=x+d-1)
			{
				Q.pb((*it).se);
				R[(*it).se].erase(mp(y+d,(*it).se));
				it=C[y+d].erase(it);				
			}
			else break;
		}
	}
	if(!C[y-d].empty())
	{
		auto it = C[y-d].lower_bound(mp(x-d+1,-1));
		while(it!=C[y-d].end())
		{
			if((*it).fi<=x+d-1)
			{
				Q.pb((*it).se);
				R[(*it).se].erase(mp(y-d,(*it).se));
				it=C[y-d].erase(it);				
			}
			else break;
		}
	}
	for(int i=0;i<Q.size();i++) 
	{
		if(!vis[Q[i]]) process(Q[i]);
	}
}
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,s1,s2; cin>>n>>s1>>s2; s1--; s2--;
	for(int i=0;i<n;i++)
	{
		int x,y; cin>>x>>y;
		int px,py; px=x-y; py=x+y;
		pt[i].fi=px; pt[i].se=py;
		rows[px].pb(py); cols[py].pb(px);
		if(i!=s1) 
		{
			R[px].insert(mp(py,i)); C[py].insert(mp(px,i));
		}
	}
	for(auto it = rows.begin(); it != rows.end(); it++)
	{
		sort(it->se.begin(), it->se.end());
	}
	for(auto it = cols.begin(); it != cols.end(); it++)
	{
		sort(it->se.begin(), it->se.end());
	}
	d=max(abs(pt[s1].fi-pt[s2].fi),abs(pt[s1].se-pt[s2].se));
	process(s1);
	ans>>=1;
	cout<<ans<<'\n';
}


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


int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n+1];
	int dp[n+1];
	for(int i=1;i<n+1;i++){
	    cin>>arr[i];
	}
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	for(int i=3;i<n+1;i++){
	    int a=abs(arr[i]-arr[i-1])+dp[i-1];
	    int b=abs(arr[i]-arr[i-2])+dp[i-2];
	    dp[i]=min(a,b);
	}
cout<<dp[n]<<endl;
	return 0;
}


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

int main(){
	int n;
	cin>>n;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	string s="";
	for(int i=0;n!=0;i++){
		if(n%2!=0){
			s='1'+s;
			if(i%2==0){
				n--;
			}
			else{
				n++;
			}
		}
		else if(n%2==0){
			s='0'+s;
		}
		n=n/2;
	}
	cout<<s<<endl;
	return 0;
}

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

int main(){
  // std::ifstream in("input.txt");
  // std::cin.rdbuf(in.rdbuf());

  int64_t A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int64_t min_cost = 1LL << 60;
  for(int i=0; i<=max(X, Y); i++){
    int64_t addA = max((int64_t)0, X-i);
    int64_t addB = max((int64_t)0, Y-i);

    int64_t cost = addA * A + addB * B + i * 2 * C;
    min_cost = min(min_cost, cost);
  }

  cout << min_cost << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char str[1024],tmp[16],tmp2,tmp3[1024];
	int n,a,b,i,j;
	scanf("%s %d",str,&n);
	for(i=0;i<n;i++){
		scanf("%s",tmp);
		if(!strcmp(tmp,"print")){
			scanf("%d%d",&a,&b);
			for(j=a;j<=b;j++)printf("%c",str[j]);
			printf("\n");
		}else if(!strcmp(tmp,"reverse")){
			scanf("%d%d",&a,&b);
			for(j=b;j>(b+a)/2;j--){
				tmp2=str[j];str[j]=str[a+(b-j)];str[a+(b-j)]=tmp2;
			}
		
		}else{
			scanf("%d%d %s",&a,&b,tmp3);
			for(j=0;j<=b-a;j++)str[a+j]=tmp3[j];
		}
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int mmin(int &a, int b) {
	a = min(a, b);
	return a;
}
int main() {
	int m, n;
	cin >> m >> n;
	vector<vector<int> >dp(n + 1, vector<int>(m+1,10000*10000+1));
	dp[0][0] = 0;
	vector<int> p(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());
	vector<int> sp(m+1);
	sp[0] = 0;
	for (int i = 1; i <= m; i++) {
		sp[i] = sp[i-1] + p[i - 1];
	}
	for (int i = 1; i <= n; i++) {
		int c, e;
		cin >> c >> e;
		dp[i] = dp[i - 1];
		for (int j = 0; j <= m; j++) {
			mmin(dp[i][min(j + c, m)], dp[i-1][j] + e);
		}
	}
	vector<int> ym = dp[n];
	int ans =0;
	int mi = ym[m];
	for (int i = m; i >= 0; i--) {
		mmin(mi, ym[i]);
		ans = max(ans, sp[i] - mi);
	}
	cout << ans << endl;
}


Measured memory_bytes: 22748
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split(' ').Select(x => int.Parse(x));
        var sorted = array.OrderBy(x=>x).ToArray();
        Console.WriteLine(sorted[N - 1] - sorted[0]);
    }
}

Measured memory_bytes: 13396
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);		
		String s = sc.next();
        if(s.charAt(s.length()-1)=='s'){s+="es";}
        else{s+="s";}
		System.out.println(s);
	}
}


Measured memory_bytes: 38660
int main() {

	int a, b, c;
	int t;

	scanf("%d %d %d",&a,&b,&c);

	if (a > b) {
		t = a;
		a = b;
		b = t;
	}

	if (b > c) {
		t = b;
		b = c;
		c = t;
	}

	if (a > b) {
		t = a;
		a = b;
		b = t;
	}

	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2036
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

ans = 0
amin = min(a)
amax = max(a)
for x in range(amin, amax+1):
   ans = max(ans, c[x-1]+c[x]+c[x+1])

print(ans)


Measured memory_bytes: 20788
#include<bits/stdc++.h>
using namespace std;
int n,k,a[101],sum;
bool cmp(int c,int d)
{
	if(c>d)
	return true;
	else return false;
}
int main()
{
    int i;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1,cmp);
    for(i=1;i<=k;i++)
    sum+=a[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
open System

let x = Console.ReadLine() |> int

let f a b =
    let pow5 x =
        x * x * x * x * x
    pow5 a - pow5 b

let a, b =
    let mutable a, b = 0, 0
    let mutable d = 1
    let mutable found = f a b = x

    while not found do
        if d % 2 = 1 then
            for i in 1 .. d do
                if not found then
                    a <- a + 1
                    found <- f a b = x
            for i in 1 .. d do
                if not found then
                    b <- b - 1
                    found <- f a b = x
        else
            for i in 1 .. d do
                if not found then
                    a <- a - 1
                    found <- f a b = x
            for i in 1 .. d do
                if not found then
                    b <- b + 1
                    found <- f a b = x
        d <- d + 1
    a, b

printf "%d %d" a b


Measured memory_bytes: 29988
#include <iostream>

using namespace std;

int main()
{
    int N, M, C, B[32], A[32][32];
    int fx, count;

    cin >> N >> M >> C;
    for (int i = 0; i < M; i++)
        cin >> B[i];
    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++)
            cin >> A[i][j];
    count = 0;

    for (int i = 0; i < N; i++) {
        fx = C;
        for (int j = 0; j < M; j++) {
            fx += A[i][j] * B[j];
        }
        if (fx > 0)
            count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    for (ll i = 0; i < N; i++) {
        cin >> V[i];
    }
    ll ans = 0;
    ll tmp;
    ll cnt;
    vector<ll> t;
    for (ll a = 0; a <= N; a++) {
        for (ll b = 0; b <= N; b++) {
            if(a + b > K) continue;
            if(a + b > N) continue;
            t.clear();
            for (ll i = 0; i < a; i++) {
                t.push_back(V[i]);
            }
            for (ll i = N-1; i >= N-b; i--) {
                t.push_back(V[i]);
            }
            sort(ALL(t));
            cnt = K - a - b;
            tmp = 0;
            for (ll i = 0; i < a+b; i++) {
                if(t[i] < 0){
                    if(cnt > 0){
                        cnt--;
                    }
                    else{
                        tmp += t[i];
                    }
                }
                else{
                    tmp += t[i];
                }
            }

            // printf("%lld %lld %lld ", a, b, tmp);
            // for (int i = 0; i < a+b; i++) {
            //     printf("%lld ", t[i]);
            // }
            // cout << endl;
            ans = max(tmp, ans);


        }
    }

    printf("%lld\n", ans);

}

Measured memory_bytes: 3656
import java.io.IOException;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] num = sc.nextLine().split(" ");
			int n = Integer.parseInt(num[0]);
			int x = Integer.parseInt(num[1]);
			// ????????????
			if (n == 0 && x == 0)
				break;
			int cnt = 0;
			// 5 9
			for (int i = 1; i <= n - 2; i++) {
                for (int j = i + 1; j <= n - 1; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if ((i + j + k) == x)
                            cnt++;
                    }
				}
			}
			System.out.println(cnt);

		}

	}
}

Measured memory_bytes: 26536
S = input()
T = input()
lenS=len(S)
lenT=len(T)
ans=["a"]*lenS
for i in range (lenS):
    if(S[i]!="?"):
        ans[i]=S[i]
flag=0
for j in range(lenS-lenT+1):
    flag=1
    for i in range (lenS):
        if(S[i]=="?"):
            ans[i]="a"

    for i in range(1,lenT+1):
        if((S[lenS-i-j]!="?")&(S[lenS-i-j]!=T[lenT-i])):
            flag=0
            break
        else:
            ans[lenS-i-j]=T[lenT-i]
    
    if(flag==1):
        break

if(flag==1):
    print("".join(ans))
else:
    print("UNRESTORABLE")

    

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
main()
{
	int l[10],v1,v2;
	while(1){
		for(int i=0;i<10;i++)if(!~scanf("%d,",l+i))break;
		if(!~scanf("%d,%d",&v1,&v2))break;
		int s=0;
		for(int i=0;i<10;i++)s+=l[i];
		double p=v1*1.0/(v1+v2);
		double u=s*p,t=0;
		for(int i=0;i<10;i++)
		{
			t+=l[i];
			if(u<=t)
			{
				cout<<i+1<<endl;
				break;
			}
		}
	}
}


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

int main(){

  int n, m, num, w[100], len;
  string str, word[100];
  vector<int> vc[100];

  num = 0;
  while(cin >> str >> n){
    for(int i=0; i<=num; i++){
      if(i == num){
        word[i] = str;
        vc[i].push_back(n);
        num++;
        break;
      }
      else if(word[i] == str){
        vc[i].push_back(n);
        break;
      }
    }
  }

  fill(w, w+100, 0);
  for(int i=0; i<num; i++){
    for(int j=0; j<num; j++){
      if(w[j] == 0){
        str = word[j];
        break;
      }
    }

    for(int j=0; j<num; j++){
      if(w[j] == 0 && word[j].compare(str) <= 0){
        str = word[j];
        m = j;
      }
    }

    len = vc[m].size();
    sort(&vc[m][0], &vc[m][0+len]);
    cout << word[m] << endl << vc[m][0];
    for(int j=1; j<len; j++){
      cout << " " << vc[m][j];
    }
    cout << endl;
    w[m] = 1;
  }

  return 0;

}

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

#define L long
#define LL long long
#define UL unsigned long
#define ULL unsigned long long
#define PB push_back

using namespace std;

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int m=max(a,b)-min(a,b),n=max(b,c)-min(b,c);
    if((m<=d and n<=d) or (max(a,c)-min(a,c)<=d)) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256