akhauriyash/Code-Regression huggingface dataset:
(function(stdin) {
  var lines = stdin.trim().split('\n');
  var numbers = lines.shift().split(' ').map(Number);
  var n = numbers.shift();
  var m = numbers.shift();
  var nodes = [];
  var color = [];
  for (var i = 0; i < n; i++) {
    nodes.push([]);
    color.push(null);
  }
  for (var i = 0; i < m; i++) {
    var node = lines.shift().split(' ').map(Number);
    nodes[node[0]].push(node[1]);
    nodes[node[1]].push(node[0]);
  }
  function dfs(n, id) {
    var stack = [];
    color[n] = id;
    stack.push(n);
    while (stack.length > 0) {
      var next = stack.shift();
      for (var i = 0; i < nodes[next].length; i++) {
        if (!color[nodes[next][i]]) {
          color[nodes[next][i]] = id;
          stack.push(nodes[next][i]);
        }
      }
    }
  }
  var id = 1;
  for (var i = 0; i < n; i++) {
    if (!color[i]) {
      dfs(i, id++);
    }
  }
  var q = parseInt(lines.shift(), 10);
  lines.forEach(function(relation) {
    var edge = relation.split(' ').map(Number);
    if (color[edge[0]] == color[edge[1]]) {
      console.log('yes');
    } else {
      console.log('no');
    }
  });
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 80468
import java.util.*;
import java.util.stream.Collectors;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int D=scanner.nextInt();
        final int N=scanner.nextInt();
        int count=0;
        for(int i=1;i<Integer.MAX_VALUE;i++){
            if(i%Math.pow(100,D)==0&&i%Math.pow(100,D+1)!=0){
                count++;
            }
            if(count==N){
                System.out.println(i);
                return;
            }
        }
    }
}

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

#define INF 100001

int main()
{
  // INPUT
  int n; cin >> n;
  int arr[n];
  for(int i=0;  i<n; i++) cin >> arr[i];

  // INIT
  int dp[n]={};

  // Base case already done: dp[n-1]=0;


  for(int i=n-2;i>=0;i--)
  {
    int a = dp[i+1] + abs(arr[i]-arr[i+1]);
    int b = INF;                           // To make sure dp[i]=a when i+2>=n
    if(i+2<n) b = dp[i+2] + abs(arr[i]-arr[i+2]);
    dp[i]= min(a,b);
  }

  // OUTPUT
  cout << dp[0] << endl;
}


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

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

	rep(i,T.size())
		if(T.at(i) == '?')
			T.at(i) = 'D';
	cout << T << endl;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 100100100100;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
 int n;
 cin >> n;
 vector<ll>a(n), sum(n);
 ll sum2=0, ans = inf;
 rep(i, 0, n)cin >> a[i], sum2+=a[i], sum[i]=sum2;
 rep(i, 0, n-1){
     ans = min(ans, abs((sum2-sum[i])-sum[i]));
 }
 cout << ans << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  rrep(i,n)rrep(j,n)rrep(k,n){
    ans += gcd(i,gcd(j,k));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  if(A+B>=10)  cout << "error" << endl;
  else  cout << A+B << endl;
  
  return 0;
}


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

#define dump(a) (cerr << #a << " = " << (a) << endl)
#define REP(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) REP(i, 0, n)
#define ALL(x) begin(x), end(x)
const int INF = 1<<28;
int pow3(int n){
  return n*n*n;
}
int main() {
  int n;
  while(cin >> n && n){
	int ans = INF;
	for(int i =0 ;i < n;i++){
	  for(int j =0 ;j < n;j++){
		
		if(pow3(n) >= pow3(i) + pow3(j)){
		  ans = min(pow3(n) - (pow3(i)+pow3(j)),ans);
		}
		else{
		  break;
		}
	  }
	}
	cout << ans << endl;
  }


  return 0;
}

Measured memory_bytes: 1160
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc :: [Int] -> Int -> Int
calc xs p = foldr (\ x -> (+) ((x - p) ^ 2)) 0 xs

main = do
  n <- getInt
  xs <- getIntList
  let x_sum = sum xs
  let d = x_sum `div` n
  let m = x_sum `mod` n
  if m == 0 then
    print $ calc xs d
  else do
    let a = calc xs d
    let b = calc xs (d + 1)
    if a < b then
      print a
    else
      print b

Measured memory_bytes: 508
#include <cstdio>
    #include <cmath>
    #include <algorithm>
    using namespace std;
     
    int ask(int y1, int x1, int y2, int x2)
    {
    	printf("? %d %d %d %d\n", y1, x1, y2 - 1, x2 - 1);
    	fflush(stdout);
    	int a;
    	scanf("%d", &a);
    	return a;
    }
     
    int score(int q)
    {
    	if (q > 2500) return 0;
    	if (q >= 930) return max((int)(1e-8 + 125 - 3.2 * sqrt(q - 920)), 40);
    	if (q >= 880) return (int)(1e-8 + 288 - 22 * sqrt(q - 870));
    	return min(2860 - 3 * q, 300);
    }
     
    int H, W, N, K;
    int C[50][50];
     
    void solve(int y1, int x1, int y2, int x2, int cnt)
    {
    	if (y2 - y1 == 1 && x2 - x1 == 1) {
    		C[y1][x1] = cnt;
    		return;
    	}
    	if (cnt == 0) return;
    	if ((y2 - y1) * (x2 - x1) == cnt) {
    		for (int i = y1; i < y2; ++i) {
    			for (int j = x1; j < x2; ++j) {
    				C[i][j] = 1;
    			}
    		}
    		return;
    	}
     
    	if (y2 - y1 > 1) {
    		int ym = (y2 + y1) / 2;
			if (y1 == 0 && y2 == 50) ym = 32;
    		int a = ask(y1, x1, ym, x2);
    		solve(y1, x1, ym, x2, a);
    		solve(ym, x1, y2, x2, cnt - a);
    	} else {
    		int xm = (x2 + x1) / 2;
			if (x1 == 0 && x2 == 50) xm = 32;
    		int a = ask(y1, x1, y2, xm);
    		solve(y1, x1, y2, xm, a);
    		solve(y1, xm, y2, x2, cnt - a);
    	}
    }
     
    int main()
    {
    	scanf("%d%d%d%d", &H, &W, &N, &K);
    	solve(0, 0, H, W, N);
     
    	int ret = 0;
    	int pw = 1;
    	for (int i = 0; i < H; ++i) {
    		for (int j = 0; j < W; ++j) {
    			ret += C[i][j] * pw;
    			ret %= K;
    			pw = pw * 2 % K;
    		}
    	}
    	printf("! %d\n", ret);
    	return 0;
    }

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

int count(string s) {
	stack<bool> q;
	for (auto c : s) {
		bool f = c == '1';
		if (q.empty() || q.top() == f)q.push(f);
		else q.pop();
	}
	return s.size() - q.size();
}

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

	cout << count(s) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ld long double

using namespace std;

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

   int count = 0;

   ld x, y;

   while(n--){
   	cin >> x >> y;

   	if (sqrt((x*x)+(y*y)) <= d) count++;
   }

   cout << count << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int inc = 0, diff = 0, ans = 0;
    for(int i=0;i<n-1;i++){
        diff = a[i] - a[i+1];
        if(inc == 0){
            if(diff == 0){
                continue;
            }else if(diff>0){
                inc = -1;
            }else{
                inc = 1;
            }
        }else if(inc == 1){
            if(diff > 0){
                inc = 0;
                ans += 1;
            }
        }else if(inc == -1){
            if(diff < 0){
                inc = 0;
                ans += 1;
            }
        }

    }
    ans++;
    cout << ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
#define REP(i, n) for (int i = 0; i < n; ++i)

int main() {
  int n; cin >> n;
  VVI a(2, VI(n));
  REP(i, 2) {
    REP(j, n) cin >> a[i][j];
  }
  int mx = 0;
  REP(i, n) {
    int x = accumulate(a[0].begin(), a[0].begin() + i + 1, 0) +
      accumulate(a[1].begin() + i, a[1].end(), 0);
    mx = max(mx, x);
  }
  cout << mx << endl;
  return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9 + 10;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);

    int mx = -1;
    rep(i, N) {
        cin >> A[i];
        mx = max(A[i], mx);
    }

    int ans = -1, diff = INF;
    rep(i, N) {
        if (A[i] == mx) continue;

        int tmp = (A[i] < mx/2 ? mx/2 : (mx+1)/2);
        if (diff > abs(A[i] - tmp)) {
            diff = abs(A[i] - mx/2);
            ans = A[i];
        }
    }

    cout << max(mx, ans) << " " << min(mx, ans) << endl;
}

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

const ll INF = 10010010010;

int main()
{
    int n;
    cin >> n;
    vector<ll> sum(n, 0);
    rep(i, n) {
        int a;
        cin >> a;
        if(i == 0) sum[i] = a; 
        else sum[i] = (ll) a + sum[i - 1];
    }
    ll ans = INF;
    rep(i, n - 1) {
        ll x = sum[i];
        ll y = sum[n - 1] - sum[i];
        ans = min(ans, abs(x - y));
    }
    cout << ans << endl;
    return 0;
}


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

int N,M,i,j,R[5000],p,a,b,r2=0;
char G[5000][5000],f[5000];

void dfs(int d)
{
	int i;
	for(i=0;i<N;i++)
	{
		if(f[i])continue;
		if(G[d][i])
		{
			dfs(i);
			if(!f[i])
			{
				R[p++]=i;
				f[i]=1;
			}
		}
	}
	return;
}

int main()
{
	scanf("%d%d",&N,&M);
	for(i=0;i<M;i++)
	{
		scanf("%d%d",&a,&b);
		G[a-1][b-1]=1;
	}
	for(j=0;j<N;j++)
	{
		for(i=0;i<N;i++)
			if(G[i][j]==1)break;
		if(i==N)
		{
			dfs(j);
			R[p++]=j;
		}
	}

	for(i=N-1;i>0;i--)
		if(G[R[i]][R[i-1]]==0)
			r2=1;

	for(i=N-1;i>=0;i--)
		printf("%d\n",R[i]+1);
	printf("%d\n",r2);
	return 0;
}

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

struct node
{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x)
{
  while(x->left!=NIL)
    x =x->left;
    return x;
}

Node treeMaximum(Node x)
{
  while(x->right != NIL)
    x = x->right;
    return x;
}

Node treeSearch(Node u, int k)
{
  if(u==NIL && k==u->key) return u;

  else if(k < u->key) return treeSearch(u->left,k);

  else return treeSearch(u->right,k);
  
}

Node treeSuccessor(Node x)
{
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right)
    {
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x=y->left;
  else x = y->right;

  if(x!=NIL) x->parent = y->parent;
  if(y->parent==NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right =x;
  
  if( y!= z) z->key = y->key;
}

void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
    {
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y==NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u)
{
  if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u)
{
  if(u !=NIL)
    {
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}




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

int main(){
	char b;
	
	cin >> b;

	if (b == 'A')
		cout << "T";
	else if (b == 'T')
		cout << "A";
	else if (b == 'G')
		cout << "C";
	else
		cout << "G";

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#define N 100005
using namespace std;
vector <int> vec[N];
int color[N];
int main(){
    queue <int> que;
    int n , x , y;
    scanf("%d",&n);
    for(int i = 1 ; i < n ; i ++){
        scanf("%d%d",&x,&y);
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    color[1] = 1 , color[n] = 2;
    int cnt[3] = {0 , 0};
    que.push(1) ;
    que.push(n);
    while(!que.empty()){
        int x = que.front();
        que.pop();
        cnt[color[x]] ++;
 
        for(int i = 0 ; i < vec[x].size() ; i ++){
            int v = vec[x][i];
            if(color[v]) continue;
            color[v] = color[x];
            que.push(v);
        }
    }
    if(cnt[2] >= cnt[1]){
        printf("Snuke\n");
    }else{
        printf("Fennec\n");
    }
 
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,l;
  string s[100];
  cin>>n>>l;
  for(int i=0;i<n;i++){
      cin>>s[i];
  }
  sort(s,s+n);
  for(int i=0;i<n;i++){
      cout<<s[i];
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
    class Main {
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
    
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      
      for(int i = 1; i <= 100; i ++) {
          if(a * i % b ==c) {
            System.out.println("YES");
            return;
          }
      }
      System.out.println("NO");
  }
}

Measured memory_bytes: 23764
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(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) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 2e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
ll powm(ll x,ll pw,ll MOD){ //return x^pw % MOD
	x%=MOD;
	ll res=1;
	while(pw){
		if(pw&1LL) res=((res*x))%MOD;
		pw>>=1;
		x=((x*x))%MOD;
	}
	return res;
}
inline ll inv(ll x,ll MOD){
	return powm(x,MOD-2,MOD); 
}
ll fac[LIM],ifac[LIM];
void preprocess(){
	fac[0]=1;
	forsn(i,1,LIM) fac[i]=fac[i-1]*i%MOD;
	ifac[LIM-1]=inv(fac[LIM-1],MOD);
	rforn(i,LIM-2){
		ifac[i]= ifac[i+1]*(i+1)%MOD;
	}
}
ll h,w;
ll ncr(ll n,ll r){
	if(n<0 || r>n || r<0) return 0;
	return ifac[n-r]*(fac[n]*ifac[r]%MOD)%MOD; 
}
int main(){
	fastio;
	preprocess();
	cin>>h>>w>>n;
	p64 pts[n+1];
	forn(i,n){
		cin>>pts[i].fi>>pts[i].se;
		pts[i].fi--; pts[i].se--;
	}
	pts[n]= mp(h-1,w-1);
	sort(pts,pts+n+1);
	ll dp[n+1]={0};
	forn(i,n+1){
		auto r=ncr(pts[i].fi+pts[i].se,pts[i].fi);
		rforn(j,i-1){
			r+=MOD-dp[j]*ncr(pts[i].fi+pts[i].se-pts[j].fi-pts[j].se,pts[i].fi-pts[j].fi)%MOD;
			r%=MOD;
		}
		dp[i]=r;
	}
	cout<< dp[n] << ln;
	return 0;
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

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

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    auto v = multiset<int>();

    REP(i, n) {
        int q, x;
        cin >> q >> x;
        if (q == 0) {
            v.insert(x);
            cout << v.size() << endl;
        } else if (q == 1){
            cout << v.count(x) << endl;
        } else if (q == 2){
            v.erase(x);
        } else if (q == 3){
            int y;
            cin >> y;
            auto it = v.lower_bound(x);
            while (it != v.end() && *it <= y){
                cout << *it << endl;
                ++it;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 12376
#include <iostream>

int main(){
    long long int n;
    std::cin >> n;
    long long int sum = 0;
    for (long long int i = 1; i <= n; ++i)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 3640
def Ics(X, Y):
    m = len(X)
    n = len(Y)
    c1 = [0] * (n + 1)
    for i in range(m):
        d = X[i]
        c2 = c1[:]
        for j in range(n):
            if (d == Y[j]):
                c1[j + 1] = c2[j] + 1
            elif (c1[j + 1] < c1[j]):
                c1[j + 1] = c1[j]
    return (c1[-1])
 
q = int(input().rstrip())
t = []
for i in range(q):
    s1 = input().rstrip()
    s2 = input().rstrip()
    t.append(Ics(s1, s2))
print(*t, sep = "\n")

Measured memory_bytes: 7824
#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct Node {
  int p;
  int l;
  int r;
  
}N;
N T[MAX];

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}



int main(){
  int i,n,v,l,r,root;
  FILE *p;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }

  for(i=0;i<n;i++)
    if(T[i].p==NIL)root=i;

  printf("Preorder\n");
  preParse(root);
  printf("\nInorder\n");
  inParse(root);
  printf("\nPostorder\n");
  postParse(root);
  printf("\n");
  


  return 0;
}









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

int main(void) {
	int n, a[100], maxa = 0, mina = 1000000000;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cout << endl;
	for (int i = 0; i < n; i++) {
		maxa = max(maxa, a[i]);
		mina = min(mina, a[i]);
	}
	cout << maxa - mina << endl;
	return 0;
}

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

int main() {
  ll N;
  string ans="No";
  cin >> N;
  if(N%10==7) ans = "Yes";
  else if((N/10)%10==7) ans = "Yes";
  else if((N/100)%10==7) ans = "Yes";

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

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    string s;
    cin>>s;
    ll k = s.length()-1;
    if(s[k] == 's')
    s+="es";
    else 
    s+='s';
    cout<<s<<"\n";
}

Measured memory_bytes: 3620
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e18

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin>>s;
    ll ans = 0;
    
    if(s[0] == 'R')
    {
        ans++;
        if(s[1] == 'R')
        {
            ans++;
            if(s[2] == 'R')
                ans++;
        }
    }
    else if(s[1] == 'R')
    {
        ans++;
        if(s[2] == 'R')
            ans++;
    }
    else if(s[2] == 'R')
        ans++;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
bool comp(const Pl &a, const Pl &b){
  return a.second > b.second;
}

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  vector<int> t(n);
  vector<bool> used = vector<bool>(n, false);
  vector<ll> d(n);
  rep(i, n)cin >> t[i] >> d[i];
  vector<Pl> vec(n);
  rep(i, n)vec[i] = mk(t[i]-1, d[i]);
  sort(vec.begin(), vec.end(), comp);
  ll res = 0;
  ll cnt = 0;
  priority_queue<ll, vector<ll>, function<bool(ll, ll)> >pq(
      [](ll a, ll b){return a > b;}
      );
  for(int i = 0; i < k; i++){
    res += vec[i].second;
    if(used[vec[i].first]){
      pq.push(vec[i].second);
    }
    if(!used[vec[i].first])cnt++;
    used[vec[i].first] = true;
  }
  ll tmp = res;
  res += cnt * cnt;
  if(pq.size() == 0){
    cout << res << endl;
    return 0;
  }
  for(int i = k; i < n && cnt <= k && !pq.empty(); i++){
    if(used[vec[i].first])continue;
    cnt++;
    used[vec[i].first] = true;
    ll p = pq.top(); pq.pop();
    tmp = tmp - p + vec[i].second;
    res = max(res, tmp + cnt * cnt);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 3584
n=int(input())
arr=[]
res=[]
for i in range(n):
    inp = list(map(int,input().split()))
    arr.append(inp)
res.append(arr[0][0])
res.append(arr[0][1])
res.append(arr[0][2])
for i in range(1,len(arr)):
    x=[-1,-1,-1]
    x[0]=max(res[1],res[2])+arr[i][0]
    x[1]=max(res[0],res[2])+arr[i][1]
    x[2]=max(res[0],res[1])+arr[i][2]
    res=x
print (max(res))

Measured memory_bytes: 29972
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    a += b;
    int n = stoi(a);
    for (int i = 1; i <= 1000; i++) {
        int c = i * i;
        if (c == n) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

int vtoi(int a, int b, int c, int d){
    return a + 1000 * b + 1000000 * c + 1000000000 * d;
}
int vtoi(vec v){
    return vtoi(v[0], v[1], v[2], v[3]);
}

signed main(){

    int N; cin >> N;
    mat C(N, vec(4));
    vector<mat> C2(N, mat(4, vec(4)));
    map<int, int> m;
    REP(i, N){
        readv(C[i]);
        REP(r, 4){
            REP(j, 4) C2[i][r][j] = C[i][(j + r) % 4];
            m[vtoi(C2[i][r])] += 1;
        }
    }

    int ans = 0;
    mat side(4, vec(4));
    REP(i, N){
        REP(r, 4) m[vtoi(C2[i][r])] -= 1;
        FOR(j, i + 1, N){
            REP(r, 4) m[vtoi(C2[j][r])] -= 1;

            REP(r, 4){
                int tmp = 1;
                REP(s, 4){
                    side[s][0] = C2[i][0][(4 - s) % 4];
                    side[s][1] = C2[i][0][3 - s];
                    side[s][2] = C2[j][r][(1 + s) % 4];
                    side[s][3] = C2[j][r][s];
                }
                int s0 = 0;
                REP(s, 4){
                    if(m[vtoi(side[s])] > 0){
                        tmp *= m[vtoi(side[s])];
                        REP(r2, 4) m[vtoi(side[s][(0 + r2) % 4], side[s][(1 + r2) % 4], side[s][(2 + r2) % 4], side[s][(3 + r2) % 4])] -= 1;
                        s0++;
                    }else break;
                }
                REP(s, s0) REP(r2, 4) m[vtoi(side[s][(0 + r2) % 4], side[s][(1 + r2) % 4], side[s][(2 + r2) % 4], side[s][(3 + r2) % 4])] += 1;
                if(s0 == 4) ans += tmp;
            }

            //cout << i << "," << j << "," << ans << endl;

            REP(r, 4) m[vtoi(C2[j][r])] += 1;
        }
        REP(r, 4) m[vtoi(C2[i][r])] += 1;
    }
    cout << ans / 3;
    
    return 0;
}


Measured memory_bytes: 20480
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<deque>
#include<map>
using namespace std;
#define ll long long
int main(){
      ll N,K;
      cin >> N >>K;
      vector<pair<int,int> > sushi(N);
      ll i;
      ll pre_eaten[N];
      for(i=0;i<N;i++){
        cin >> sushi[i].second >> sushi[i].first;
        pre_eaten[i]=0;
      }
      sort(sushi.begin(),sushi.end());
      ll type=0;
      ll sum=0;
      deque<ll> sushideque;
      for(i=N-1;i>=N-K;i--){
        if(pre_eaten[sushi[i].second-1]==0){
          pre_eaten[sushi[i].second-1]=1;
          type++;
        }else{
          sushideque.push_back(sushi[i].first);
        }
        sum+=sushi[i].first;
      }
      ll ans = sum + type*type;
      while(sushideque.size()!=0&&i>=0){
        if(pre_eaten[sushi[i].second-1]==0){
          pre_eaten[sushi[i].second-1]=1;
          sum+=sushi[i].first-sushideque.back();
          sushideque.pop_back();
          type++;
          ans=max(ans,sum+type*type);
        }
        i--;
      }
      cout << ans;
      return 0;
}


Measured memory_bytes: 2176
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

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

ll pow2(ll m) {
    if (m == 0) return 1LL;
    ll tmp = pow2(m / 2);
    if (m & 1) return (tmp * tmp % MOD) * 2 % MOD;
    else return tmp * tmp % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n); REP(i, n) cin >> a[i];
    sort(ALL(a));
    vll dig(62, 0);  // i ビット目にいくつ 1 がたっているものがあるか
    REP(i, n) {
        REP(j, 62) {
            if ((a[i] >> j) & 1) dig[j]++;
        }
    }

    vll aaa(62, 0);
    vvll bit0(n + 1, vll(62, 0)), bit1(n + 1, vll(62, 0));
    REP(i, n) {
        REP(j, 62) {
            if ((a[i] >> j) & 1) {
                aaa[j] += n - dig[j] - bit0[i][j];
                bit1[i + 1][j] = bit1[i][j] + 1;
                bit0[i + 1][j] = bit0[i][j];
            } else {
                aaa[j] += dig[j] - bit1[i][j];
                bit0[i + 1][j] = bit0[i][j] + 1;
                bit1[i + 1][j] = bit1[i][j];
            }
            aaa[j] %= MOD;
        }
    }

    ll ans = 0;
    REP(i, 62) ans = (ans + pow2(i) * aaa[i] % MOD) % MOD;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 316672
K = int(input())
a = 7
cnt = 1
while a % K != 0:
    a = a * 10 + 7
    a = a % K
    cnt += 1
    if cnt == 10**6 + 10:
        break

if cnt == 10**6 + 10:
    print(-1)
else:
    print(cnt)

Measured memory_bytes: 9172
q = int(input())
l, r = [0]*q, [0]*q
for i in range(q):
    l[i], r[i] = map(int, input().split())

MAX = 101010
is_prime = [1]*MAX
is_prime[0] = 0
is_prime[1] = 0
for i in range(2,MAX):
    if not is_prime[i]: 
        continue
    for j in range(i*2, MAX, i):
        is_prime[j] = 0

a = [0]*MAX
for i in range(MAX):  # ,,2
    if i%2 == 0: 
        continue
    if is_prime[i] and is_prime[(i+1)//2]: 
        a[i] = 1

s = [0]*(MAX+1)
for i in range(MAX): 
    s[i+1] = s[i] + a[i]

for i in range(q):
    print(s[r[i]+1]-s[l[i]])

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int H,W;
  cin >> H >> W;
  vector<vector<int>> A(H,vector<int>(W));
  rep(i,H){
    rep(j,W)  cin >> A.at(i).at(j);
  }
  vector<vector<int>> B(H,vector<int>(W));
  rep(i,H){
    rep(j,W)  cin >> B.at(i).at(j);
  }

  int base=100*(H+W);
  vector<vector<vector<bool>>> dp(H,vector<vector<bool>>(W,vector<bool>(2*base,false)));
  dp.at(0).at(0).at(base+A.at(0).at(0)-B.at(0).at(0))=true;
  dp.at(0).at(0).at(base-A.at(0).at(0)+B.at(0).at(0))=true;
  rep(i,H){
    rep(j,W){
      int tmp=A.at(i).at(j)-B.at(i).at(j);
      rep(k,2*base){
        if(i-1>=0 && dp.at(i-1).at(j).at(k)){
          if(k+tmp <2*base) dp.at(i).at(j).at(k+tmp)=true;
          if(k-tmp >=0) dp.at(i).at(j).at(k-tmp)=true;
        }
        if(j-1>=0 && dp.at(i).at(j-1).at(k)){
          if(k+tmp <2*base) dp.at(i).at(j).at(k+tmp)=true;
          if(k-tmp >=0) dp.at(i).at(j).at(k-tmp)=true;
        }
      }
    }
  }
  int ans=1e9;
  rep(i,2*base){
    if(!dp.at(H-1).at(W-1).at(i))  continue;
    chmin(ans,abs(i-base));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 29080
#include"bits/stdc++.h"
using namespace std;
namespace whatever{
    int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}

	void run(){
	//	freopen(".in","r",stdin);
	//	freopen(".out","w",stdout);
        int n=readu();
        int k=readu();
        if(n%k)
            puts("1");
        else
            puts("0");
	}
}
int main(){
	whatever::run();
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 15;

ll n , m ,  x , c[N] , a[N][N] , ans=1e18;
vector<int> v;

void solve(int i)
{
    if (i > n)
    {
        ll cst=0 , aa[15]={};
        for(int j=0; j<v.size(); j++)
        {
            cst += c[v[j]];
            for(int jj=1; jj<=m; jj++)
                aa[jj] += a[v[j]][jj];
        }
        for(int j=1; j<=m; j++)
            if (aa[j] < x) return;

        ans = min(ans , cst);
        return;
    }

    v.push_back(i);
    solve(i+1);
    v.pop_back();
    solve(i+1);
}

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

    cin >> n >> m >> x;
    for(int i=1; i<=n; i++)
    {
        cin >> c[i];
        for(int j=1; j<=m; j++)
            cin >> a[i][j];
    }

    solve(1);

    if (ans == 1e18) cout << "-1\n";
    else cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3656
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	string s;
	cin >> s;
	int l = 0, r = s.length() - 1;
	int ret = 0;
	while (l < r) {
		if (s[l] != s[r]) {
			ret++;
		}
		l++;
		r--;
	}
	cout << ret << endl;
	return 0;
}


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;

		while((str = br.readLine()) != null) {
			String num[] = str.split(" ", 0);
			int x = Integer.parseInt(num[0]);
			int y = Integer.parseInt(num[1]);

			if(x <= 1000000 && y <= 1000000 ) {
				System.out.println(String.valueOf(x+y).length());
			}
		}

		br.close();
	}
}

Measured memory_bytes: 24292
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}


int main(){
    ll a,b,c,x,y,ans=INF;cin>>a>>b>>c>>x>>y;
    rep(i,max(2*x+1,2*y+1)){
        chmin(ans,i*c+max((x-i/2),0ll)*a+max((y-i/2),0ll)*b);
    }

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

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

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

int main(){
int K, X;
cin >> K >> X;

int left, right;
left = X - (K - 1);
right = X + (K - 1);

for(int i = left; i <= right; i++){ 
   print(i);
   print(' ');
}


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,K,S;
int main(){
    cin>>N>>K>>S;
    ll A[N];
    if(S>=3){
        for(int i=0;i<K;i++)A[i]=S;
        for(int i=K;i<N;i++)A[i]=S-1;
    }
    else{
        for(int i=0;i<K;i++)A[i]=S;
        for(int i=K;i<N;i++)A[i]=S+1;
    }
    for(int i=0;i<N;i++)cout<<A[i]<<" ";
    cout<<endl;
    
    
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

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

	ll n, p;
	while(cin>>n>>p, n!=0){
		vll pos(n, 0);
		ll m = p;
		for(ll i=0; ;i++){
			int j = i % n;
			if (p>0){
				p--;
				pos[j]++;
				if (pos[j] == m){
					cout << j << "\n";
					break;
				}
			}else{
				p += pos[j];
				pos[j] = 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3136
// luogu-judger-enable-o2
#include<bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
bool s[1005][1005],cnt[1005];
int n,m,a[1000005],b[1000005],ans;
int main()
{
    scanf("%d%d",&n,&m);
    for(reg int i=1;i<=m;i++)scanf("%d%d",&a[i],&b[i]);
    for(reg int i=1;i<=n;i++)
    {
        s[i][i]=1;
        for(reg int j=m;j>=1;j--)
        {
            reg bool x=s[i][a[j]],y=s[i][b[j]];
            if(x&y)
			{
				cnt[i]=1;
				break;
			}
            else if(x)s[i][b[j]]=1;
            else if(y)s[i][a[j]]=1;
        }
    }
    for(reg int i=1;i<n;i++)
    {
        if(cnt[i])continue;
        for(reg int j=i+1;j<=n;j++)
        {
            if(cnt[j])continue;
            reg int tmp=1;
            for(reg int k=1;k<=n;k++)if(s[i][k]&&s[j][k])tmp=0;
            ans+=tmp;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
 
typedef long long ll;

#define rep(i,n) for(ll i = 0; i < n; i++)
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

vector<vector<int> > G(105);
vector<int> D(105,-1);

int main(){
  int n;
  cin >> n;
  rep(i,n){
    int u,k;
    cin >> u >> k;
    rep(j,k){
      int v;
      cin >> v;
      G[u].push_back(v);
    }
  }

  queue<int> q;
  q.push(1);
  D[1] = 0;  
  while( !q.empty() ){
    int v = q.front();
    q.pop();
    
    rep(i,G[v].size()){      
      if(D[G[v][i]] != -1) continue;
      D[G[v][i]] = D[v] + 1;
      q.push(G[v][i]);
    }
  }

  rep(i,n){
    cout << i+1 << " " << D[i+1] << endl;
  }
}



Measured memory_bytes: 3152
N, X = [int(elem) for elem in input().split()]
L_list = [int(elem) for elem in input().split()]

cur_pos = 0
num_jumps_under_X = 1
for L in L_list:
    cur_pos += L
    if cur_pos <= X:
        num_jumps_under_X += 1
print(num_jumps_under_X)


Measured memory_bytes: 38256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

int main(){
    string S,A;
    cin>>S;
    A="2019/04/30";
    if(S<=A){
        cout<<"Heisei";
    }else{
        cout<<"TBD";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,j,tmp;
	int mts[11] = {0};

	for(i = 0; i < 10; i++)
	{
		scanf("%d",&mts[i]);
	}

	for(j = 0; j < 10; j++)
	{
		for(i = 0; i < 10 - j; i++)
		{
			if(mts[i] < mts[i+1])
			{
				tmp = mts[i];
				mts[i] = mts[i+1];
				mts[i+1] = tmp;
			}
		}
	}

	printf("%d\n%d\n%d\n",mts[0],mts[1],mts[2]);

	return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main(){
    int s[7],ans;
    string a;
    for (int i=1;i<=6;i++){
        cin>>s[i];
    }
    cin>>a;
    for(int i=0;i<a.size();i++){
        ans=s[1];
        if(a[i]=='E'){
            s[1]=s[4];
            s[4]=s[6];
            s[6]=s[3];
            s[3]=ans;
            
        }
        else if(a[i]=='S'){
            s[1]=s[5];
            s[5]=s[6];
            s[6]=s[2];
            s[2]=ans;
        }
        else if(a[i]=='N'){
            s[1]=s[2];
            s[2]=s[6];
            s[6]=s[5];
            s[5]=ans;
        }
        else if(a[i]=='W'){
            s[1]=s[3];
            s[3]=s[6];
            s[6]=s[4];
            s[4]=ans;
        }
    }cout<<s[1]<<endl;
    return 0;
    
}


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

struct Duration
{
  uint64_t s, t;
  Duration(uint64_t s = 0, uint64_t t = 0) : s(s), t(t) {}
  
  bool operator==(const Duration &rhs) const
  {
    return s == rhs.s && t == rhs.t;
  }
  
  bool operator<(const Duration &rhs) const
  {
    return (s == rhs.s) ? t < rhs.t : s < rhs.s;
  }
};

std::istream& operator>>(std::istream &is, Duration &duration)
{
  is >> duration.s >> duration.t;
  return is;
}

int slim_programs(std::vector< std::set<Duration> > &programs)
{
  uint64_t C = programs.size();
  
  for (uint64_t c = 0; c < C; ++c) {
    if (programs[c].size() <= 1) { continue; }
    
    std::set<Duration> set;
    set.insert(*programs[c].begin());
    for (auto itr = ++programs[c].begin(); itr != programs[c].end(); ++itr) {
      auto prev = --set.end();
      if (prev->t == itr->s) {
        set.emplace(prev->s, itr->t);
        set.erase(prev);
      } else {
        set.insert(*itr);
      }
    }
    programs[c] = set;
  }
  
  return 0;
}

int main()
{
  uint64_t N, C;
  std::cin >> N >> C;
  
  std::vector< std::set<Duration> > programs(C, std::set<Duration>());
  for (uint64_t n = 0; n < N; ++n) {
    Duration duration;
    uint64_t channel;
    std::cin >> duration >> channel;
    
    programs[channel - 1].insert(duration);
  }
  
  slim_programs(programs);
  
  std::vector<int64_t> sum(1e+5 + 2, 0);
  for (uint64_t c = 0; c < C; ++c) {
    for (const Duration &duration : programs[c]) {
      ++sum[duration.s];
      --sum[duration.t + 1];
    }
  }
  
  uint64_t total = 0, max = 0;
  for (uint64_t t = 0; t <= 1e+5; ++t) {
    total += sum[t];
    max = std::max(max, total);
  }
  std::cout << max << std::endl;
  
  return 0;
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

vector<ll>v;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    ll lcm=v[0];
    ll gg=0;
    for(int i=0;i<n;i++){
        gg=gcd(lcm,v[i]);
        lcm=(v[i]*lcm)/gg;
    }
    lcm/=2;
    for(int i=0;i<n;i++){
        if(lcm%v[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<m/lcm-m/(2*lcm)<<endl;
    return 0;

}


Measured memory_bytes: 1024
#include<stdio.h>
long n;
int k;

//整数nがk進数のときの10進値を返す
long trimingDigit(){
  long val;
  int i=1,digit;
  while(n>0){
    val += n%k * i;
    n /= k;
    i *= 10;
    digit++;
  }
  return digit;
}

int main(){
  int digit;
  scanf("%ld %d",&n,&k);
  digit = trimingDigit();
  printf("%d",digit);
}

Measured memory_bytes: 128