akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;
int main(){
    string s;
    cin >> s;
    bool hantei=0;
    for(int i=1;i<s.size();i++){
        if(s[i]==s[i-1]){
            hantei=1;
        }
    }
    if(hantei){
        cout <<"Bad"<<endl;
    }else{
        cout <<"Good"<<endl;
    }
}

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

int main() {
	int N , M;
    string S;
  	int SUM;
  	int MAX = 0;
    cin >> N;
  	vector<string> blue(N);
  	//青いカードの文字列 N 個を全て読み込む
  	for(int i = 0; i < N; i++){
      	cin >> 	S;
    	blue.at(i) = S;
    }
    cin >> M;
  	vector<string> red(M);
	//赤いカードの文字列 M 個を全て読み込む
  	for(int j = 0; j < M; j++){
    	cin >> S;
      	red.at(j) = S;
    }

  	string temp;
  	for(int i = 0; i< N; i++){
      	SUM = 0;
       	//青いカードのi番目の文字列をいったん temp に入れる
    	temp = blue.at(i);
        //tempと同じ文字列が青いカードの中に何個あるか数えて、見つかるごとにSUMを1増やす
      	for(int i = 0; i < N; i++){
        	if(blue.at(i) == temp){
            	SUM += 1;
            }
        }
        //tempと同じ文字列が赤いカードの中に何個あるか数えて、見つかるごとにSUMを1減らす
      	for(int j = 0; j < M; j++){
        	if(red.at(j) == temp){
            	SUM -= 1;
            }
        }
        //SUMの数字とMAXを比較し、SUMの方が大きかったらMAXの値を更新する
      	if(SUM > MAX){
        	MAX = SUM;
        }
    }
	cout << MAX << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	int n, a[10000], i, result;
	result = 0;

	scanf("%d", &n);

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

	for (i = 0; i < n; ++i)
	{
		while (a[i] % 2 == 0)
		{
			result++;
			a[i] /= 2;
		}
	}
	printf("%d\n", result);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define int long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
#define N 105
char s[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int k;
	cin>>s>>k;
	int n=strlen(s);
	bool all=true;
	for(int i=0;i<n-1;i++)
	{
		if(s[i]!=s[i+1]) all=0;
	}
	if(all)
	{
		cout<<(n*k/2)<<endl;
		return 0;
	}
	int fir=0,las=n-1;
	for(int i=0;i<n-1;i++)
	{
		if(s[i]!=s[i+1])
		{
			fir=i+1;break;
		}
	}
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]!=s[i-1])
		{
			las=i-1;break;
		}
	}
	int ans=0,suf=0;
	for(int i=fir;i<=las;i++)
	{
		if(s[i]==s[i+1])
		{
			suf++;continue;
		}
		suf++;
		ans+=suf/2;
		suf=0;
	}
	if(suf) ans+=suf/2;
	ans*=k;
	int ne=n-las-1+fir;
	if(s[0]==s[n-1])
	{
		ans+=(ne/2*(k-1));
		ans+=(n-las-1)/2;
		ans+=(fir/2);
	}
	else
	{
		ans+=(n-las-1)/2*k;
		ans+=(fir/2*k);
	}
	cout<<ans<<endl;
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

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

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N, M;
    cin >> N >> M;
    VEC(bool) From(N + 1, false), To(N + 1, false);
    FOR(i, 0, M) {
        int a, b;
        cin >> a >> b;
        if (a == 1)
            To[b] = true;
        if (b == N)
            From[a] = true;
    }

    FOR(i, 2, N)
        if (From[i] && To[i]) {
            cout << "POSSIBLE" << endl;
            return;
        }
    
    cout << "IMPOSSIBLE" << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define DBG(X) cout<<" "<<#X<<" : "<<X<<endl
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;

struct Input
{
	int n;char c;char str[10010];string s;ll l;double d;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	double nextDouble(){scanf("%lf", &d);return d;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

int d[6][6];
int s[6][6];

int main(){
	int n = in.nextInt();
	while(n--){
		for(int i = 1; i<= 5; i++) for(int j = 1; j <= 5; j++) d[i][j] = in.nextInt();
		for(int i = 1; i <=5; i++){
			for(int j = 1; j <= 5; j++){
				s[i][j] = 0;
				if(d[i][j])
				s[i][j] = s[i-1][j] +d[i][j];
			}
		}
		int ans = 0;
		for(int y = 1; y <= 5; y++){
			for(int x = 1; x <= 5; x++){
				int e = INF;
				for(int m = 0; x+m <= 5; m++){
					e = min(e, s[y][x+m]);
					ans = max(ans, e * (m+1));
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

int main(){
  int a[26];
  for(int i = 0; i < 26; i++)
    a[i] = 0;
  string w;
  cin >> w;

  for(int i = 0; i < w.length(); i++)
    a[w[i] - 'a']++;

  for(int i = 0; i < 26; i++){
    if(a[i] % 2 == 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
a = [int(i) for i in input().split()]

dic = {}
dic[1] = 2
dic[2] = 5
dic[3] = 5
dic[4] = 4
dic[5] = 5
dic[6] = 6
dic[7] = 3
dic[8] = 7
dic[9] = 6

ls = [-1]*8
dp = [-1]*(N+1)
dp[0] = 0
for i in a:
  j = dic[i]
  if ls[j]<i:
    ls[j] = i

tag = []
for i in range(len(ls)):
  if ls[i]!=-1:
    tag += [i]
for i in range(N+1):
  for j in tag:
    if i+j<=N:
      dp[i+j] = max(dp[i]*10+ls[j], dp[i+j])

print(dp[N])


Measured memory_bytes: 14708
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>

int dcmp(double x) {
    static double eps = 1e-8;
    return (x > eps) - (x < -eps);
}

struct vec{
    double x, y;

    vec(double _x=0, double _y=0)
        :x(_x), y(_y) {}

    vec operator- () const{ return vec(-x, -y); }
    
    vec operator+ (const vec& v) const{ return vec(x+v.x, y+v.y); }
    vec operator- (const vec& v) const{ return vec(x-v.x, y-v.y); }
    vec operator* (double c) const{ return vec(x*c, y*c); }
    vec operator/ (double c) const{ return vec(x/c, y/c); }

    double dot(const vec& v) const{ return x*v.x + y*v.y; }
    double cross(const vec& v) const{ return x*v.y - y*v.x; }

    double len2() const{ return x*x + y*y; }
    double len() const{ return sqrt(len2()); }
    
    vec& norm() { return *this = *this / len(); }
    vec& rot(double rad) {
        return  *this = vec(x*cos(rad) - y*sin(rad), x*sin(rad) + y*cos(rad));
    }

    bool operator< (const vec& v) const{
        return dcmp(x-v.x) < 0 || (dcmp(x-v.x)==0 && dcmp(y-v.y) < 0);
    }
};

struct line{
    vec u, v; // u + x*v

    line() {}
    line(vec _u, vec _v)
        :u(_u), v(_v) {}

    vec get(double x) {
        return u + v * x;
    }
};

line makeline(vec a, vec b) {
    return line(a, b - a);
}

bool on_left(line l, vec u) {
    return dcmp(l.v.cross(u - l.u)) > 0;
}

vec line_intersection(line a, line b) {
    return b.u + b.v * b.v.cross(b.u-a.u) / a.v.cross(b.v);
}

bool segment_intersection(vec a, vec b, vec c, vec d) {
    line x = line(a, b-a), y = line(c, d-c);
    return on_left(x, c) != on_left(x, d) && on_left(y, a) != on_left(y, b);
}

std::vector<vec> convex_hull(std::vector<vec> p) {
    std::sort(p.begin(), p.end());
    std::vector<vec> ch;
    for (size_t i = 0; i < p.size(); ++i) {
        while (ch.size() > 1 && on_left(makeline(ch[ch.size()-2], p[i]), ch[ch.size()-1]))
            ch.pop_back();
        ch.push_back(p[i]);
    }
    size_t k = ch.size();
    for (int i = p.size() - 2; i >= 0; --i) {
        while (ch.size() > k && on_left(makeline(ch[ch.size()-2], p[i]), ch[ch.size()-1]))
            ch.pop_back();
        ch.push_back(p[i]);
    }
    ch.pop_back();
    return ch;
}

double convex_diameter(const std::vector<vec> &p) {
  int is = 0, js = 0;
  for (size_t i = 1; i < p.size(); ++i) {
    if (p[i].x > p[is].x) is = i;
    if (p[i].x < p[js].x) js = i;
  }
  double maxd = (p[is]-p[js]).len2();
  
  int i, maxi, j, maxj;
  i = maxi = is;
  j = maxj = js;
  do {
      if ((p[i] - p[(i + 1)%p.size()]).cross(p[j] - p[(j + 1)%p.size()]) >= 0) j = (j+1) % p.size();
      else i = (i+1) % p.size();
      if ((p[i]-p[j]).len2() > maxd) {
          maxd = (p[i]-p[j]).len2();
          maxi = i; maxj = j;
      }
  } while (i != is || j != js);
  return sqrt(maxd);
}

// end template

int main() {
    std::vector<vec> p;
    int n;
    double x,y;
    for(scanf("%d",&n);n--;p.push_back(vec(x, y)))
        scanf("%lf%lf",&x,&y);
    printf("%f\n",convex_diameter(p));
    return 0;
}



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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    ll n, k;
    cin >> n >> k;

    double ans = 0.0;

    rep(i, n){
        ll x = i+1;
        double tmp = 1.0 / n;
        rep(j, 20){
            if(x >= k){
                break;
            }
            x *= 2;
            tmp /= 2.0;
        }
        ans += tmp;
    }

    cout << fixed;
    cout << setprecision(15) << ans  << endl;

    return 0;
}



Measured memory_bytes: 256
/*...Part - 01...*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/

int n, m;
vvi g ;

int dp[N] ;

int dfs(int s){
	//error(dp[s], s)
	if(dp[s] != -1)return dp[s] ;
	dp[s] = 0 ;
	int res = 0 ;
	for(int i : g[s]){
		res = max(res , dfs(i) + 1) ;
	}
	//error(res, s)
	return dp[s] = res ;
}

int main(){
    int test = 1 , tc = 0 ;
    while(test--){
        n = Int, m = Int ;
        g.resize(n + 1) ;
        for(int i = 1 ; i <= m ; ++i){
        	int x = Int, y = Int ;
        	g[x].pb(y) ;
        }
        memn(dp) ;
        int res = 0 ;
        for(int i = 1 ; i <= n ; ++i){
        	res = max(res , dfs(i)) ;
        }
        //for(int i = 1 ; i <= n ; ++i)cout << dp[i] << '\n' ;
        cout << res << '\n' ;
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/




Measured memory_bytes: 8576
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  long long int N, M;
  cin >> N >> M;
  
  vector<pair<long long int, long long int> > ab(N);
  long long int a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    ab[i] = make_pair(a, b);
  }
  
  sort(ab.begin(), ab.end());
  
  long long int cost = 0;
  for (int i = 0; i < N; i++) {
    long long int limit = min(M, ab[i].second);
    cost += limit * ab[i].first;
    M -= limit;
  }
  
  cout << cost << endl;

  return 0;
}



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

using ll = long long; 
/*
dp[i][j] - minimum cost from i to j
*/

int main() {
    const int INF = 1e9+7;
    
    int n;
    
    scanf("%d", &n);
    
    vector<int> arr(n);
    
    vector<vector<ll>> dp(n, vector<ll>(n, -1));
    
    vector<vector<int>> mids(n, vector<int>(n));
    
    vector<ll> pref_sums(n+1);
    
    ll pref_sum = 0;
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        dp[i][i] = 0;
    }
    
    for (int i = 0; i <= n; i++) {
        pref_sum += arr[i];
        pref_sums[i] = pref_sum;
    }
    
    for (int length = 1; length < n; length++) {
        for (int left = 0; left+length < n; left++) {
            int right = left + length;
            //cout << left << " " << right << endl;
            for (int mid = left; mid < right; mid++) {
                ll left_cost = dp[left][mid];
                ll right_cost = dp[mid+1][right];
                ll range_sum = pref_sums[right] - (left-1 < 0 ? 0 : pref_sums[left-1]);
                ll my_cost = left_cost + right_cost + range_sum;
                //cout << total << endl;
                /*
                if (total < dp[left][right]) {
                    // update chosen mid & min value
                    dp[left][right] = my_cost;//total;
                    //mids[left][right] = mid;
                }
                */
                if (dp[left][right] == -1) {
                    dp[left][right] = my_cost;
                }
                else {
                    dp[left][right] = min(dp[left][right], my_cost);                
                }
            }
        }
    }
    /*
    vector<pair<int, int>> v; // (start, end)
    
    v.push_back({0, n-1});
    
    ll ans = 0; //-dp[0][n-1]; // the last one 
    
    while (!v.empty()) {
        pair<int, int> cur = v.back();
        v.pop_back();
        if (cur.second - cur.first + 1 >= 2) { // interval at least two
            ans += dp[cur.first][cur.second];
            int mid = mids[cur.first][cur.second];
            cout << "L: " << cur.first << " R: " << cur.second << " Total: " << dp[cur.first][cur.second] << " mid: " << mid << endl;
            v.push_back({cur.first, mid});
            v.push_back({mid+1, cur.second});    
        }
    }
    */
    
    
	/*
	for (int i = 0; i < n; i++) {
	    for (int j = 0; j < n; j++) {
	        for (int mid = i; mid <= j; mid++) {
	            ll cur = dp[i][mid];
	            if (mid+1 <= j) {
	                cur += dp[mid+1][j];
	            }
	            dp[i][j] = min(dp[i][j], cur);
	        }
	    }
	}
	*/
	
	//printf("%lld", ans);
	
	printf("%lld", dp[0][n-1]);
	
	return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

// 13
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();
		
		int count = 0;
		int[] check = {a, b, c};
		while(true) {
			if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) break;
			if(a == b && b == c && c == a) {
				count = -1;
				break;
			}
			int at = a;
			int bt = b;
			a = b / 2 + c / 2;
			b = at / 2 + c / 2;
			c = at / 2 + bt / 2;
			++count;
			
			if(a % 2 != 0 || b % 2 != 0 || c % 2 != 0) break;
			if(a == b && b == c && c == a) {
				count = -1;
				break;
			}
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 35720
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    token = lines[0].split()
    n = int(token[0])
    k = int(token[1])
    s = lines[1]

    return (n, k, s)


def solve(n, k, s):

    
    return s[0:k-1] + s[k-1].lower() + s[k:]




def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(S_A: str, S_B: str, S_C: str):
    t = 'a'
    A = list(S_A)
    B = list(S_B)
    C = list(S_C)
    a, b ,c = 0, 0, 0
    while(True):
        if t == 'a':
            if len(A) == a:
                w = 'A'
                break
            t = A[a]
            a += 1
        elif t == 'b':
            if len(B) == b:
                w = 'B'
                break
            t = B[b]
            b += 1
        else:
            if len(C) == c:
                w = 'C'
                break
            t = C[c]
            c += 1
    print(w)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S_A = next(tokens)  # type: str
    S_B = next(tokens)  # type: str
    S_C = next(tokens)  # type: str
    solve(S_A, S_B, S_C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5300
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		new Main().solve();
	}
	int W,H,N;
	long[]p;
	long[]q;
	long INF=Long.MAX_VALUE/2;
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		W=sc.nextInt();
		H=sc.nextInt();
		N=(W+1)*(H+1);
		p=new long[W];
		q=new long[H];
		for(int i=0;i<W;i++) {
			p[i]=sc.nextLong();
		}
		for(int i=0;i<H;i++) {
			q[i]=sc.nextLong();
		}
		Arrays.sort(p);
		Arrays.sort(q);
		
		int a=W, b=H;
		int i=0,j=0;
		long ans=0;
		while(a>0 || b>0) {
			if(i==W) {
				ans+=q[j]*(a+1);
				j++;
				b--;
			}else if(j==H) {
				ans+=p[i]*(b+1);
				i++;
				a--;
			}else if(p[i]<q[j]) {
				ans+=p[i]*(b+1);
				i++;
				a--;
			}else {
				ans+=q[j]*(a+1);
				j++;
				b--;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 86812
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back

LL n,ans;
vector<LL> v;

int main()
{
	
	cin>>n;
	for(LL i=1;i*(i+1)<n;i++)
		if(n%i==0) v.pb(n/i);
	for(int i=0;i<v.size();i++)
		ans+=v[i]-1;
	cout<<ans<<'\n';
	
	return 0;
}

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

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

  for (int i = 0; i < 3; i++){
    if (S[i] == '1')
      S[i] = '9';
    else
      S[i] = '1';
  }

  cout << S;
}

Measured memory_bytes: 256
s = input()
n = len(s)
res = [0]*n
prev = "R"
now_R = 1
cnt = 1
prev_point = 0
for i in range(1,n):
    cur = s[i]
    if now_R:
        if cur =='L' and prev=='R':
            if cnt%2 == 0:
                res[i-1] += cnt//2
                res[i] += cnt//2
            else:
                res[i-1] += cnt//2+1
                res[i] += cnt//2
            prev_point = i
            cnt = 1
            now_R = 0
        else:
            cnt += 1
    else:
        if cur == 'R':
            if cnt%2 == 0:
                res[prev_point-1] += cnt//2
                res[prev_point] += cnt//2
            else:
                res[prev_point-1] += cnt//2
                res[prev_point] += cnt//2+1
            cnt = 1
            now_R = 1
        else:
            cnt += 1
    prev = s[i]
if cnt % 2 == 0:
    res[prev_point - 1] += cnt // 2
    res[prev_point] += cnt // 2
else:
    res[prev_point - 1] += cnt // 2
    res[prev_point] += cnt // 2 + 1
print(*res)

Measured memory_bytes: 10804
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int H, W;
	char C[300][300];
	char ans[300][300];

	scanf("%d%d", &H, &W);
	for (int i = 1; i <= H; i++) {
		scanf("%s", C[i]);
	}

	for (int i = 1; i <= 2 * H; i++) {
		for (int j = 0; j < W; j++) {
			ans[i][j] = C[(i+1) / 2][j];
		}
	}

	for (int i = 1; i <= 2 * H; i++) {
		for (int j = 0; j < W; j++) {
			printf("%c", ans[i][j]);
		}
		printf("\n");
	}

}


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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

bool paircomp(pair<int,int> p1,pair<int,int> p2){
    return p1.second<p2.second;
}

int main(){
    int N,K,memo,num,res=0;

    scanf("%d%d",&N,&K);
    vector<int> v(N);
    for(int i=0;i<N;i++)
        scanf("%d",&v[i]);
    
    sort(v.begin(),v.end());
    vector<pair<int, int> > vp;
    memo=v[0];
    num=1;
    for(int i=0;i<N-1;i++){
        if(v[i]!=v[i+1]){
            vp.push_back(make_pair(memo,num));
            memo=v[i+1];
            num=1;
        }else{
            num++;
        }
        if(i==N-2)
            vp.push_back(make_pair(memo,num));
    }

    if(vp.size()<=K){
        printf("0\n");
        return 0;
    }

    sort(vp.begin(),vp.end(),paircomp);
    for(int i=0;i<vp.size()-K;i++)
        res+=vp[i].second;
    
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 3188
n,m,Q = map(int,input().split())
D = [[0]*(n+1) for _ in range(n+1)]

for i in range(m):
    l,r = map(int,input().split())
    D[l][r] += 1

for i in range(n+1):
    for j in range(1, n+1):
        D[i][j] += D[i][j-1]

for i in range(n-1, -1,-1):
    for j in range(n+1):
        D[i][j] += D[i+1][j]

for i in range(Q):
    p,q = map(int,input().split())
    print(D[p][q])

Measured memory_bytes: 9332
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 305
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
double dp[N][N][N];
string s,s1;
//Variables End

double compute(ll one,ll two,ll three)
{
	
	if(three==0 && one==0 && two==0)return 0; 
	if(dp[one][two][three]>-0.5)
		return dp[one][two][three];

	double ans=n;

	if(three>0)ans+=three*compute(one,two+1,three-1);
	//cout<<one<<" "<<two<<" "<<three<<" "<<ans<<" 11 "<<endl;
	if(two>0)ans+=two*compute(one+1,two-1,three);
	//cout<<one<<" "<<two<<" "<<three<<" "<<ans<<" 12 "<<endl;
	if(one>0)ans+=one*compute(one-1,two,three);
	//cout<<one<<" "<<two<<" "<<three<<" "<<ans<<" 13 "<<endl;

	ans=(double)ans/(one+two+three);
	//cout<<one<<" "<<two<<" "<<three<<" "<<ans<<" hurray "<<endl;
	return dp[one][two][three]=ans;
}

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;
		ll a=0,b=0,c=0;
		rep(i,0,n)
		{
			ll x;cin>>x;
			if(x==1)a++;
			else if(x==2)b++;
			else c++;
		}       

		rep(i,0,n+1)rep(j,0,n+1)rep(k,0,n+1)dp[i][j][k]=-1.0;
		cout<<fixed<<setprecision(12)<<compute(a,b,c)<<endl;
    }
    return 0;
        
}

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

int main(){
	int N,K; cin>>N>>K;
	vector<int64_t> A(N);
	vector<double> B(N+1);
	vector<double> M(N+1);
	rep(i, N) cin>>A[i];
	rep(i, N) B[i+1] = B[i] + log10(A[i]);
	rep(i, N+1-K) M[i + K] = B[i + K] - B[i];
	for(int i=K+1; i<=N; ++i)
		puts( M[i] - M[i-1] > 1e-10? "Yes":"No");
}


Measured memory_bytes: 8024
import collections


def main():
    n = int(input())
    word_list = []

    for _ in range(n):
        word_list.append(input())

    c = collections.Counter(word_list)
    max_freq = max(c.values())
    most_freq_word = sorted([i for i in c if c[i] == max_freq])
    print('\n'.join(most_freq_word))


if __name__ == '__main__':
    main()

Measured memory_bytes: 116304
N = int(input())
import sys

sys.setrecursionlimit(N+10)
ab = [[] for _ in range(N)]

for i in range(N-1):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    ab[a].append(b)
    ab[b].append(a)

dF = [0] * N
dS = [0] * N
def dfs(now, d, dlist, visited):
    
    if visited[now] == False:
        dlist[now] = d
        visited[now] = True

        for next in ab[now]:
            dfs(next, d+1, dlist, visited)


vF = [False] * N
dfs(0,0,dF, vF)
vS = [False] * N
dfs(N-1, 0, dS, vS)

cnt_F = 0
cnt_S = 0
for i in range(N):
    if dF[i] <= dS[i]:
        cnt_F += 1
    else:
        cnt_S += 1

#print(dF, dS)
if cnt_F > cnt_S:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 118936
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

/*
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
Tree<int>tr;
*/

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# define LOCAL
# define sim template < class c
# define ris return * this
# define dor > debug & operator <<
# define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int gcd(int a, int b)
{
if(b) return gcd(b,a%b);
return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int n,k;

int32_t main(){_
	//freopen("input","r",stdin);
	cin >> n >> k;
	string s;
	cin >> s;
	int x = 1;
	for(int i = 0;i < sz(s);i++){
		if(i && s[i] != s[i - 1]){
			x++;
		}
	}
	x = max(1,x - 2 * k);
	rc(n - x);
	return 0;
}











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

long long mod = 1e9 + 7;

long long pow(long long x,long long p)
{
    long long ans = 1;

    while (p)
    {
        if (p % 2)
            ans = (ans * x) % mod;
        x = (1LL * x * x) % mod;
        p /= 2;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio();
    cin.tie(0);
    cout.tie(0);
    long x, y;
    cin >> x >> y;
    long long w = (x + y) / 3;

    if ((x + y) % 3 || x - w < 0 || y - w < 0)
    {
        cout << 0; 
        return 0;
    }
    y=w;
    x -= w;
    long long a = 1, b = 1;
    for (int i = 1; i <= x; i++)
    {
        a =a* (y - i + 1) % mod;
        b = b*i % mod;
    }
            cout << (a * pow(b, mod - 2) % mod);


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

int main(){
    int n,m;
    scanf(" %d %d", &n, &m);

    vector<pi> p(n);
    rep(i,n){
        int s,v;
        scanf(" %d %d", &s, &v);
        p[i] = {v,s};
    }
    sort(all(p), greater<pi>());

    vector<int> c(m);
    rep(i,m) scanf(" %d", &c[i]);
    sort(all(c), greater<int>());

    int pidx = 0, cidx = 0;
    int ans = 0;
    while(pidx<n && cidx<m){
        if(p[pidx].se <= c[cidx]){
            ++pidx;
            ++cidx;
            ++ans;
        }
        else ++pidx;
    }
    printf("%d\n", ans);
    return 0;
}



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


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
const int nax = 1e5+103;
int number, k;
int dyn[nax];
int a[nax];
int op1(int i){
	if (i==number-1) return 0;
	if(dyn[i]!=-1) return dyn[i];
	int res = abs(a[i]-a[i+1])+op1(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<number) res = min(res, abs(a[i]-a[i+j])+op1(i+j));
	}
	return dyn[i]=res;
}
int main(){
	cin>>number>>k;
	for(int i=0; i<number; i++) cin>>a[i];
	memset(dyn, -1, sizeof dyn);
	cout<<op1(0)<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
int ww[4010][4010];
int wb[4010][4010];
int bb[4010][4010];
int bw[4010][4010];
int dp[4010][4010];

int main(){
  int n,a[4010];
  char c[4010];
  int wp[4010];
  int bp[4010];
  cin>>n;
  for(int i=0;i<2*n;i++){
    cin>>c[i]>>a[i];
    a[i]--;
    (c[i]=='B'?bp[a[i]]:wp[a[i]])=i;
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      ww[i][j+1]=ww[i][j]+(wp[i]<wp[j]);
      wb[i][j+1]=wb[i][j]+(wp[i]<bp[j]);
      bb[i][j+1]=bb[i][j]+(bp[i]<bp[j]);
      bw[i][j+1]=bw[i][j]+(bp[i]<wp[j]);
    }
  }
  
  for(int i=0;i<4010;i++)
    for(int j=0;j<4010;j++)
      dp[i][j]=INF;
  
  dp[0][0]=0;
  
  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      if(i<n)dp[i+1][j]=min(dp[i+1][j],dp[i][j]+ww[i][i]+wb[i][j]);
      if(j<n)dp[i][j+1]=min(dp[i][j+1],dp[i][j]+bb[j][j]+bw[j][i]);
    }
  }
  cout<<dp[n][n]<<endl;
  return 0;
}


Measured memory_bytes: 192768
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> prime = new ArrayList<Integer>();
		prime.add(2);
		for(int i=3; i<246912; i=i+2){
			boolean check = true;
			int k=0;
			while(i>=prime.get(k)*prime.get(k)){
				if(i%prime.get(k)==0){
					check = false;
					break;
				}
				k++;
			}
			if(check) prime.add(i);
		}
		while(true){
			int s = 0;
			int e = 0;
			int n = in.nextInt();
			if(n==0) break;
			for(int i=0; prime.get(i)<=n; i++){
				s++;
			}
			e=s;
			for(int i=s; prime.get(i)<=2*n; i++){
				e++;
				if(i==prime.size()-1) break;
			}
			System.out.println(e-s);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
string s[400];
int x[400][400],a,b,vx[160000],vy[160000];
void mutu(int y,int z){
	if(y&&s[y-1][z]!=s[y][z]&&!x[y-1][z]){
		x[y-1][z]=x[y][z];
		mutu(y-1,z);
	}
	if(z&&s[y][z-1]!=s[y][z]&&!x[y][z-1]){
		x[y][z-1]=x[y][z];
		mutu(y,z-1);
	}
	if(y<a-1&&s[y+1][z]!=s[y][z]&&!x[y+1][z]){
		x[y+1][z]=x[y][z];
		mutu(y+1,z);
	}
	if(z<b-1&&s[y][z+1]!=s[y][z]&&!x[y][z+1]){
		x[y][z+1]=x[y][z];
		mutu(y,z+1);
	}
	return ;
}
signed main(){
	int z=1,ans=0;
	cin>>a>>b;
	f(i,a){
		cin>>s[i];
	}
	f(i,a){
		f(j,b){
			if(!x[i][j]){
				x[i][j]=z;
				mutu(i,j);
				z++;
			}
			if(s[i][j]=='.') vx[x[i][j]]++;
			else vy[x[i][j]]++;
		}
	}
	f(i,z){
		ans+=vx[i]*vy[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 16640
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

K = iin()

A = deque(list(range(1,10)))

cnt = 0
D = [-1,0,1]
while True:
    cnt += 1
    a = A.popleft()
    if cnt == K: 
        print(a)
        break
    t = (a % 10)
    for d in D:
        n = t+d
        if 0 <= n <= 9:
            A.append(a*10+n)





Measured memory_bytes: 14124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,a,b) \
for(ll i=ll(a);i<=ll(b);i++)
#define DEP(i,a,b) \
for(ll i=ll(a);i>=ll(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int T;
  T=1;
  while(T--)
  {
      ll n,i,j,k,l,m,a,b,c,d,e;
      cin>>a>>b>>c>>d>>e;
      if(a==0)cout<<"1";
      else if(b==0)cout<<"2";
      else if(c==0)cout<<"3";
      else if(d==0)cout<<"4";
      else cout<<"5";
  }
  return 0;
}

Measured memory_bytes: 3608
n_ = input()
n = int(n_)

levels = [9, 0, 900, 0, 90000, 0]

if n == 10**5:
    print(sum(levels))
if len(n_) == 5:
    print(sum(levels[:4]) + n - 10000 + 1)
if len(n_) == 4:
    print(sum(levels[:3]))
if len(n_) == 3:
    print(sum(levels[:2]) + n - 100 + 1)
if len(n_) == 2:
    print(sum(levels[:1]))
if len(n_) == 1:
    print(n)


Measured memory_bytes: 3064
a = int(input())
b = []

for i in range(a+1):
    if i % 3 == 0 and i % 5 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      b.append(i)
print(sum(b))



Measured memory_bytes: 104388
a, b, c, x, y = map(int, input().split())

# 単体で買うより安い
if (a + b) > 2 * c:
    # 共通部分をABで買う方
    ans1 = c * min(x, y) * 2
    if x < y:
        ans1 += b * (y - x)
    else:
        ans1 += a * (x - y)
    
    # 余らせてでもABで買う方
    ans2 = c * max(x, y) * 2

    print(min(ans1, ans2))
else:
    ans = a * x + b * y 
    print(ans)

Measured memory_bytes: 3064
def location(field, wanted):
    for i, row in enumerate(field):
        for j, cell in enumerate(row):
            if cell == wanted:
                return i, j
def count(field, wanted):
    result = 0
    for row in field:
        for cell in row:
            if cell == wanted:
                result += 1
    return result
def neighborhood(center, w, h):
    i, j = center
    return filter(lambda x: 0 <= x[0] and x[0] < h and 0 <= x[1] and x[1] < w,
                  [                (i - 1, j    ),
                   (i    , j - 1),                 (i    , j + 1),
                                   (i + 1, j    )])
printed_later = []
while True:
    #入力
    w, h = map(int, input().split())
    if(w == 0 and h == 0):
        break
    field = []  # strの配列すなわちcharの配列の配列 '.':黒 '#':赤 '@':スタート (',':到達可能)
    for i in range(h):
        field.append(list(input()))
    #出力　幅優先探索
    queue = [location(field,'@')]
    field[queue[0][0]][queue[0][1]] = ','
    while len(queue) > 0:
        for cell in neighborhood(queue.pop(0), w, h):
            if field[cell[0]][cell[1]] == '.':
                queue.append(cell)
                field[cell[0]][cell[1]] = ','
    printed_later.append(count(field, ','))
for line in printed_later:
    print(line)


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

int main() {

    int N;

    cin >> N;
    vector<int> p;
    int tmp;

    for (int i = 0; i < N; i++) {
        cin >> tmp;
        p.push_back(tmp);
    }

    int count = 0;
    for (int i = 0; i < N - 2; i++) {
        if (p[i] < p[i+1] && p[i+1] < p[i+2]) {
            count++;
        }
        else if (p[i] > p[i+1] && p[i+1] > p[i+2]) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b;
  cin >> a >> b;
  cout << 6 - (a + b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()

int n, m, k, s, tmp;
vector<vector<int> > v;
vector<int> p;

bool check(string s) {
    REP(i,m) {
        int sum = 0;
        REP(j,v[i].size()) {
            if(s[v[i][j]] == '1') sum++;
        }
        if(sum % 2 != p[i]) return false;
    }
    return true;
}

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

    REP(i, m) {
        cin >> k;
        vector<int> vv;
        REP(j, k) {
            cin >> s;
            vv.push_back(s-1);
        }
        v.push_back(vv);
    }

    REP(i, m) {
        cin >> tmp;
        p.push_back(tmp);
    }

    int nn = 1;
    REP(i, n) nn *= 2;

    int ans = 0;
    REP(i,nn){
        stringstream ss;
        ss << bitset<10>(i);
        if(check(ss.str().substr(10-n, n))) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
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;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, q;
vector<int>G[222222];
int sum[222222];
bool used[222222];
void dfs(int x) {
	used[x] = 1;
	for (int i : G[x]) {
		if (!used[i]) {
			sum[i] += sum[x];
			dfs(i);
		}
	}
}
signed main() {
	cin >> n >> q;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	rep(i, q) {
		int p, x; cin >> p >> x; p--;
		sum[p] += x;
	}
	dfs(0);
	rep(i, n)cout << sum[i] << " ";
	cout << endl;
}


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

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

  int n, k;
  cin >> n >> k;

  vector<int> a(n);
  for (auto& x : a) cin >> x;

  vector<ll> b;
  b.reserve(n * (n + 1) / 2);
  for (int i = 0; i < n; ++i) {
    ll sum = 0;
    for (int j = i; j < n; ++j) {
      sum += a[j];
      b.emplace_back(sum);
    }
  }

  // bits
  for (int bit = 39; bit >= 0; --bit) {
    auto pm = stable_partition(b.begin(), b.end(),
                               [bit](ll x) { return ((x >> bit) & 1); });
    int d = distance(b.begin(), pm);
    if (d >= k) b.resize(d);
  }

  ll ans = b[0];
  for (int i = 1; i < k; ++i) ans &= b[i];
  cout << ans;
}

Measured memory_bytes: 8120
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int MAX_N = 15;
int h, w, N;
string dir = "RDLU";
char field[MAX_N][MAX_N];
char route[50];
bool range_check(int y, int x) { return (y < 0 || x < 0 || y >= h || x >= w) ? true : false; }
void dfs(int y, int x, int pos, int cnt)
{
    if(cnt == N) 
    {
        for(int i = 0; i < N; i++) cout << route[i];
        cout << endl;
        return;
    }
    for(int i = 0; i < 4; i++)
    {
        if(i == (pos + 2) % 4) continue;
        int ty = y, tx = x;
        while(!range_check(ty, tx))
        {
            if(field[ty][tx] == 'o')
            {
                //cout << ty << " " << tx << " " << cnt << endl;
                field[ty][tx] = '.';
                route[cnt] = dir[i];
                dfs(ty, tx, i, cnt + 1);
                field[ty][tx] = 'o';
                break;
            }
            ty += dy[i];
            tx += dx[i];
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    int sy, sx, spos;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            char ch;
            cin >> ch;
            field[i][j] = ch;
            if(ch == 'o') N++;
            if(ch != '.' && ch != 'o')
            {
                sy = i, sx = j;
                for(int k = 0; k < dir.size(); k++) if(dir[k] == ch) spos = k;
            }
        }
    }
    dfs(sy, sx, spos, 0);
    return 0;
}


Measured memory_bytes: 3228