akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;
ll ans[20];
int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  mem(ans, 0);
  ll H,W;
  int N;
  cin >> H >> W >> N;
  vector <pair <int,int> > blacks(N);
  rep(i,N){
    cin >> blacks[i].fir >> blacks[i].sec;
    blacks[i].fir--;
    blacks[i].sec--;
  }
  set <pair <int,int> > counted;
  sort(ALL(blacks));
  int dx[] = {0,-1,-2,0,-1,-2,0,-1,-2};
  int dy[] = {0,0,0,-1,-1,-1,-2,-2,-2};
  rep(i,N){
    int x = blacks[i].fir, y = blacks[i].sec;
    rep(k,9){
      //lu
      int cx = x + dx[k], cy = y + dy[k];
      if (0 <= cx && cx + 2 < H && 0 <= cy && cy + 2 < W && counted.find(mp(cx,cy)) == counted.end()) {
        ;
      }else{
        continue;
      }
      int cnt = 0;
      counted.insert(mp(cx,cy));
      rep(i,3){
        rep(j,3){
          cnt += binary_search(ALL(blacks), mp(cx+i, cy + j));
        }
      }
      ans[cnt] += 1;
    }
  }
  //DEBUG1(counted);
  ll z = (H - 2) * (W - 2) - sz(counted);
  cout << z << endl;
  rep2(i,1,10){
    cout << ans[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 43264
/* AOJ 0057
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0057
 *
 */

#include <stdio.h>

int main(){
    int n;
    while(scanf("%d", &n) == 1){
        printf("%d\n", (n*n + n + 2) /2);
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <functional>
#include <math.h>
#include <map>
#include <set>
#include <string>
using namespace std;
#define fio ios::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

const int INT_INF = 1e9;
const ll LL_INF = 1e18;
const int MAXN = 500003;

typedef struct GE{
	int to;
	ll w;
	GE(){};
}GE;

int n, m;
int A[MAXN];
int psum[MAXN];
int chk[MAXN];
int main() {
	scanf("%d", &n);
	
	for(int i=0;i<n;i++) {
		scanf("%d", &A[i]);
		chk[A[i]]++;
	}
	// sort(A,A+n);
	int add=0;
	for(int i=1;i<MAXN;i++){
		add += chk[i];
		psum[i] = add;
	}
	int ans=0;
	int lcnt, rcnt;
	for(int i=1;i<=100000;i++){
		rcnt = n-psum[i-1];
		lcnt = n-rcnt;

		if(lcnt==rcnt)
			ans++;
	}
	printf("%d", ans);
	
	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define N 100000
vector<int> par(N);
vector<int> ranks(N);

void init(int n)
{
  int i;
  rep(i,n)
  {
    par[i]=i;
    ranks[i]=1;
  }
}

int find(int x)
{
  if(par[x]==x)return x;
  else return par[x]=find(par[x]);
}

void unite(int x, int y)
{
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(ranks[x]<ranks[y])par[x]=y;
  else
  {
    par[y]=x;
    if(ranks[x]==ranks[y])ranks[x]++;
  }
}

bool same(int x, int y)
{
  return find(x) == find(y);
}

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> p(n);
  int i;
  rep(i,n)cin>>p[i];
  vector<int> pos(n);
  rep(i,n)pos[p[i]-1]=i;
  vector<int> x(m);
  vector<int> y(m);
  rep(i,m)cin>>x[i]>>y[i];
  init(n);
  rep(i,m)
  {
    unite(pos[x[i]-1],pos[y[i]-1]);
  }
  int ans=0;
  rep(i,n)
  {
    if(same(pos[i],i))ans++;
  }
  cout<<ans<<endl;
}


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

#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

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

#define MAX_V 100000

#define MOD 1000000007L
#define INF 100000000000

bool next_type(bool prev, bool current, bool honest) {
	return prev ^ !current ^ !honest;
}

signed main() {
	int n;
	string s;
	cin >> n >> s;
	string c[4] = { "SS", "SW", "WS", "WW" };
	string res = "";
	bool end = false;
	for (size_t i = 0; i < 4 && !end; i++) {
		// cout << i << endl;
		res = c[i];
		for (size_t j = 1; j < s.size() - 1; j++) {
			bool next = next_type(res[j - 1] == 'S', s[j] == 'o', res[j] == 'S');
			res += "WS"[next];
			// cout << res << endl;
		}
		int last = s.size() - 1;
		int ln = next_type(res[last - 1] == 'S', s[last] == 'o', res[last] == 'S');
		int fn = next_type(res[last] == 'S', s[0] == 'o', res[0] == 'S');
		// printf("ln: %c\nfn: %c\n", "WS"[ln], "WS"[fn]);
		if ("WS"[ln] == res[0] && "WS"[fn] == res[1]) {
			end = true;
			break;
		}
	}
	cout << (end ? res : "-1") << endl;
}


Measured memory_bytes: 776
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {


    public static void solve() {
        int n = in.nextInt(), w = in.nextInt();

        int[] weights = new int[n];
        int[] values = new int[n];

        for(int i = 0; i < n; i += 1) {
            weights[i] = in.nextInt();
            values[i] = in.nextInt();
        }

        long[][] store = new long[n][w+1];

        for(int j = 0; j <= w; j += 1)
            store[0][j] = weights[0] > j ? 0 : values[0];

        for(int i = 1; i < n; i += 1) {
            for(int j = 1; j <= w; j += 1) {
                store[i][j] = store[i-1][j];

                if(j-weights[i] >= 0)
                    store[i][j] = Math.max(store[i][j], values[i] + store[i-1][j-weights[i]]);
            }
        }

        out.println(store[n-1][w]);
    }


    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }


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

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}

Measured memory_bytes: 124372
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    vector<int> cnt(n+5,0);
    int ans = 0;
    int pena = 0;
    rep(i,m) {
        int a;string res;
        cin>>a>>res;
        if (cnt[a] == -1) continue;
        else if (res == "WA") cnt[a]++;
        else {
            ans++;
            pena += cnt[a];
            cnt[a] = -1;
        }
    }
    cout << ans << " "  << pena << endl;
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	deque<int>deq;
	for(int i=0; i<n; i++){
		if(i%2==0) deq.push_front(arr[i]);
		else deq.push_back(arr[i]);
	}
	if(n%2==0){
		while(deq.size()){
			cout<<deq.back()<<" ";
			deq.pop_back();
		}
	}
	else{
		while(deq.size()){
			cout<<deq.front()<<" ";
			deq.pop_front();
		}
	}
}

Measured memory_bytes: 4852
s = input()
t = input()
l = len(s)
t_l = len(t)
l_gap = l - t_l

x = 0
for i in range(l_gap + 1):
  c = 0
  for m in range(t_l):
    if t[m] == s[i+m]:
      c += 1
  if c > x:
    x = c
print(t_l -x)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> a >> b;
	cout << min(b, n * a) << "\n";
	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 110000
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair
#define LL long long

string s;

int func(int pos, int past)  {
    if(pos == s.size())    {
        return 0;
    }
    int ans = 1000000000;
    if(past == 1)    {
        ///current ta 0 boshbe
        int cc = 0;
        if((s[pos] - '0') == 1)    {
            cc = 1;
        }
        ans = min(ans, cc + func(pos + 1, 0));
    }
    else if(past == 0)    {
        ///current ta 1 boshbe
        int cc = 0;
        if((s[pos] - '0') == 0)    {
            cc = 1;
        }
        ans = min(ans, cc + func(pos + 1, 1));
    }
    else    {
        ///current ta boshiye
        ans = min(ans, func(pos + 1, s[pos] - '0'));

        ///current ta na boshiye
        ans = min(ans, 1 + func(pos + 1, !(s[pos] - '0')));
    }
    return ans;
}

int main()  {
//    freopen("in.txt", "r", stdin);

    cin >> s;
    cout << func(0, 2) << "\n";

    return 0;
}
/**
*/


Measured memory_bytes: 3584
package main

import "fmt"

var (
	x, a, b int
)

func main() {
	fmt.Scan(&x, &a, &b)

	if abs(x-a) < abs(x-b) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
const char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
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);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
  int n, input_tmp; lli res = 0, continuous = 0;
  cin >> n;
  REP(_, n){
    cin >> input_tmp;
    if(input_tmp == 0){res += continuous / 2; continuous = 0;}
    else continuous += input_tmp;
  }
  res += continuous / 2;
  cout << res << BR;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<int> A(N+1);
  for(int i = 0; i <N+1; i++) cin >> A[i];

  vector<int> B(N);
  for(int i = 0; i <N; i++) cin >> B[i];

  vector<int> defeat(N+1, 0);

  for(int i = 0; i<N; i++){
    if(A[i] <= B[i]){
      defeat[i] += A[i];
      if(A[i+1] <= B[i]-A[i]){
        defeat[i+1] += A[i+1];
        A[i+1] = 0;
      } else {
        defeat[i+1] += B[i]-A[i];
        A[i+1] -= B[i]-A[i];;
      }
    } else {
      defeat[i] += B[i];
      A[i] -= A[i]-B[i];
    }
  }

  ll sum = 0;
  for(int i = 0; i < N+1; i++){
    sum += ll(defeat[i]);
  }

  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>
int main(){
  int A,B,i,rA,sum=1,c=0;
  scanf("%d %d",&A,&B);
  rA=A-1;

  while(B>sum){
    sum += rA;
    c++;
  }
  printf("%d",c);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int i,n=700;
  char s[4];
  scanf("%s",s);
  for(i=0;i<3;i++){
  if(s[i]=='o')
  n=n+100;
}
printf("%d\n",n );
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> X(N),Y(N);
    for(int i = 0;i < N;i ++){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y.begin(),Y.end());
    int p = Y[N/2];
    for(int i = 0;i < N;i ++){
        if(X[i] < p) cout << Y[N/2] << endl;
        else cout << Y[N/2 - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstring>
#define MAXN 510
#define LL long long

int W,H,w,h;
LL a[MAXN][MAXN];

int main(){
	scanf("%d%d%d%d",&H,&W,&h,&w);
	if(w*h==1){
		puts("No");
		return 0;
	}
	LL x=999999999/(h*w-1);
	LL s=0;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++){
			if(i%h || j%w) a[i][j]=x;
			else a[i][j]=-(x*(w*h-1)+1);
			s+=a[i][j];
		}
	if(s<=0) puts("No");
	else{
		puts("Yes");
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++)
				printf("%lld ",a[i][j]);
			puts("");
		}
	}
}


Measured memory_bytes: 4864
#include <stdio.h>

int main() {
  int m, f, r;
  while(1) {
    scanf("%d%d%d", &m, &f, &r);
    if(m == -1 && f == -1 && r == -1) break;
    printf("%c\n", (
      (m < 0 || f < 0) ? 'F' :
      (m + f >= 80) ? 'A' :
      (m + f >= 65) ? 'B' :
      (m + f >= 50 || (m + f >= 30 && r >= 50)) ? 'C' :
      (m + f >= 30) ? 'D' :
      'F'
    ));
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll mul[1000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll i,j,n;
	for(i=1;i<=9;++i)
		for(j=1;j<=9;++j)
			mul[i*j] = 1;

	cin >> n;
	if(mul[n])
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//


int main(){
        ll n,m;
        cin >> n >> m;
        vector<P> x(n);
        for(ll i = 0; i < n; i++)
        {
                ll a,b;
                cin >> a >> b;
                x[i].first = a;
                x[i].second = b;
        }

        sort(all(x));

        ll ans = 0;
        ll tmp = 0;
        for(ll i = 0; i < n; i++)
        {
                tmp += x[i].second;
                if(tmp == m){
                        ans += x[i].second * x[i].first;
                        cout << ans << endl;
                        return 0;
                }
                else if(tmp > m){
                        tmp -= x[i].second;
                        for(ll j = 0; j < x[i].second; j++){
                                if(tmp == m){
                                        cout << ans << endl;
                                        return 0;
                                }
                                ans += x[i].first;
                                tmp++;
                        }
                }
                ans += x[i].second * x[i].first;
        }


}
































Measured memory_bytes: 1920
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      double[] a = new double[10];
      a[0] = sc.nextDouble();
      for(int i=1; i<10; i++) {
        if(i % 2 == 0) {
	  a[i] = a[i-1]/3;
        }
	else {
          a[i] = a[i-1]*2;
        }
      }
      double s=0;
      for(int i=0; i<10; i++) {
        s+=a[i];
      }
      System.out.println(s);
    }
  }
}

Measured memory_bytes: 28188
(defun f(n)
  (labels ((rec (m i)
                (if (> i 9)
                  nil
                  (if (zerop (mod m i))
                    (let ((a (/ m i)))
                      (if (and (< a 10)
                               (> a 0))
                        t
                        (rec m (1+ i))))
                    (rec m (1+ i))))))
    (rec n 1)))
(let* ((line (read-line nil nil)))
  (format t "~A" (if (f (parse-integer line)) "Yes" "No")))


Measured memory_bytes: 13544
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
using namespace std;
using Data = pair<long long, vector<int> >;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;
const int mod = 1e9+7;

int main() {
    int n,k;cin >> n >> k;
    k--;

    string s;cin >> s;

    REP(i,n){
        if(i==k){
            p((char)('a'+(s.at(i)-'A')))
        }
        else {
            p(s.at(i))
        }
    }
    pl("")
}

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

using namespace std;
#define int long long
#define INF 1000000000000000000
#define pb push_back

int call(int i,int j,vector<int>&A, vector<vector<int> >&dp)
{
    if(i==j)
    {
        return 0;
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    
    dp[i][j]=INF;
    int add=A[j];
    if(i>0)
    {
        add-=A[i-1];
    }
    //cout<<i<<" "<<j<<" "<<add<<" ";
    for(int k=i;k<j;k++)
    {
        dp[i][j]=min(dp[i][j],call(i,k,A,dp)+call(k+1,j,A,dp)+add);
    }
    return dp[i][j];
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin>>N;
    
    vector<int>A(N);
    
    for(int i=0; i<N ;i++)
    {
        cin>>A[i];
        if(i!=0)
        {
            A[i]+=A[i-1];
        }
    }
    vector<vector<int> >dp(N,vector<int> (N,-1));
    cout<<call(0,N-1,A,dp);
    cout<<"\n";
  /* for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    return 0;
}

Measured memory_bytes: 1536
A, B, M = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 10 ** 9
for i in range(M):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)

print(min(ans, min(a) + min(b)))



Measured memory_bytes: 18736
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int x = sc.NextInt();
        int t = sc.NextInt();

        Console.WriteLine(t * ((n + x - 1) / x));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27480
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<29;
const LL OO=1e18;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int sum[50][50];
int f[50][50][50][50];
inline int S(int lx,int ly,int rx,int ry) { return sum[rx][ry]-sum[lx-1][ry]-sum[rx][ly-1]+sum[lx-1][ly-1]; }
int main()
{
	int n=gi(),m=gi(),i,j,sx,sy,lx,ly,rx,ry,ans=oo,w;char c;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) {
			while ((c=getchar())!='+'&&c!='#'&&c!='P');
			sum[i][j]=sum[i-1][j]+sum[i][j-1]+(c=='#')-sum[i-1][j-1];
			if (c=='P') sx=i,sy=j;
		}
	memset(f,0x3f,sizeof(f));
	f[1][1][n][m]=0;
	for (lx=1;lx<=sx;lx++)
		for (rx=n;rx>=sx;rx--)
			for (ly=1;ly<=sy;ly++)
				for (ry=m;ry>=sy;ry--)
					if ((w=f[lx][ly][rx][ry])<oo) {
						upmin(ans,f[lx][ly][rx][ry]+min(min(S(lx,ly,sx,sy),S(sx,ly,rx,sy)),min(S(lx,sy,sx,ry),S(sx,sy,rx,ry))));
						for (i=lx-1;i<=rx;i++)
							for (j=ly-1;j<=ry;j++) {
								w=f[lx][ly][rx][ry]+min(S(lx,j+1,i,ry)+S(i+1,ly,rx,j),S(lx,ly,i,j)+S(i+1,j+1,rx,ry));
								if (i<sx)
									if (j<sy)
										upmin(f[i+1][j+1][rx][ry],w);
									else
										upmin(f[i+1][ly][rx][j],w);
								else
									if (j<sy)
										upmin(f[lx][j+1][i][ry],w);
									else
										upmin(f[lx][ly][i][j],w);
							}
					}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 24704
// JavaProgram.cpp
// Author : Priydarshi Singh (@dryairship)
// One cat just leads to another. One bug leads to two others.

#include <bits/stdc++.h>
using namespace std;

// I like my types defined.
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
typedef map<int, int>       mii;

// Traditional science is all about finding "hashtag define"s.
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n, c)        for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define fill1(a)            memset(a, -1, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"

// When you realize MOD > INF...
int DEBUGGING    =          0;
const int INF    =          1000000000;
const int MOD    =          1000000007;
const ll LINF    =          1e18;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

// I'D SPAM. Hehe.
ll gcdEx                    (ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;} 
ll x1,y1,gcd=gcdEx          (b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)         {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
ll modD(ll a, ll b)         {return (modI(b,MOD)*(a%MOD))%MOD;}
ll modS(ll a, ll b)         {return ((a%MOD)-(b%MOD)+MOD)%MOD;}
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;} y=y>>1; x=(x*x)%MOD;} return r;}
ll modA(ll a, ll b)         {return ((a%MOD)+(b%MOD))%MOD;}
ll modM(ll a, ll b)         {return ((a%MOD)*(b%MOD))%MOD;}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(int TEST_CASE){
    int a,b;
    cin >> a >> b;
    int mx = max(a,b);
    int mn = a+b-mx;
    if(mx==mn) cout << 2*mx;
    else cout << 2*mx-1;
}

int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<ll>> dp(n+1,vector<ll>(13,0));
    dp[0][0] = 1;
    for (int i = 0;i < n;++i) {
        if (s[i] == '?') {
            for (int j = 0;j < 13;++j) {
                for (int k = 0;k < 10;++k) {
                    (dp[i+1][(j*10+k)%13] += dp[i][j]) %= mod;
                }
            }
        } else {
            int k = s[i]-'0';
            for (int j = 0;j < 13;++j) {
                (dp[i+1][(j*10+k)%13] += dp[i][j]) %= mod;
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;


typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef vector<ii> vii; 
typedef vector<ff> vff;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    int n = min(s.length(), t.length());
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if(s[i]==t[i]){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long

LL N,M,ans,r,a,col[8];

pair<LL, LL>bc;
vector<pair<LL, LL>>BC;
int main() {
	LL H, W,Wh,Hh;
	LL A, B, C;
	cin >> H>>W;
	ans = 10000000000;


	for (int i = 1; i < H; i++) {
		A = i*W;
		if (W% 2 == 0) {
			B = (H - i)*W/2;
			C = (H - i)*W/2;
		}
		else {
			B = (H - i)*(W+1) / 2;
			C = (H - i)*(W-1) / 2;
		}
		ans = min(ans,max(A, B) - min(A, C));
	}



	for (int i = 1; i < H; i++) {
		A = i*W;
		if ((H-i) % 2 == 0) {
			B = (H - i) / 2 * W;
			C = (H - i) / 2 * W;
		}
		else {
			B = ((H - i) +1) / 2 * W;
			C = ((H - i) -1) / 2 * W;
		}
		ans = min(ans, max(A, B) - min(A, C));
	}



	for (int i = 1; i < W; i++) {
		A = i*H;
		if (H % 2 == 0) {
			B = (W - i)*H/2;
			C = (W - i)*H/2;
		}
		else {
			B = (W - i)*(H+1) / 2;
			C = (W - i)*(H-1) / 2;
		}
		ans = min(ans, max(A, B) - min(A, C));
	}
	for (int i = 1; i < W; i++) {
		A = i*H;
		if ((W - i) % 2 == 0) {
			B = (W - i) / 2 * H;
			C = (W - i) / 2 * H;
		}
		else {
			B = ((W - i) + 1) / 2 * H;
			C = ((W - i) - 1) / 2 * H;
		}
		ans = min(ans, max(A, B) - min(A, C));
	}
	cout << ans << endl;
	return 0;

}


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

const int Maxn = 300005;
int n, m, s[Maxn], rk[Maxn], pos[Maxn];
long long t, c;
int main()
{
	scanf("%d%d%lld", &n, &m, &t);
	for (int i = 0; i < n; i++)
	{
		int opt;
		long long tmp;
		scanf("%d%d", &s[i], &opt);
		if (opt == 2) tmp = s[i] - t;
		else tmp = s[i] + t;
		(c += tmp / m) %= n;
		if (tmp % m < 0) (c += n - 1) %= n;
		pos[i] = (tmp % m + m) % m;
		rk[i] = i;
	}
	sort(pos, pos + n);
	(c += n) %= n;
	for (int i = c; i < n; i++)
		printf("%d\n", pos[i]);
	for (int i = 0; i < c; i++)
		printf("%d\n", pos[i]);
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb(x) push_back(x)

typedef pair<ll,ll> pp;
int lcm(int a, int b)
{
    int lar = max(a, b);
    int small = min(a, b);
    for (int i = lar; ; i += lar) {
        if (i % small == 0)
            return i;
    }
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) {
    return (a.second < b.second);
}

ll power(ll x, unsigned ll y, ll p)
{
    ll res = 1;     // Initialize result
  
    x = x % p; // Update x if it is more than or
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
  
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
  
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

struct ArrayWrapper
{
    int a[101][101];
};

bool isPowerOfTwo (ll x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}


void solve(){
    ll n; cin >> n;
    ll a[n+1];
    map<ll,ll> m;
    ll count = 0;
    for(ll i = 1;i <= n;i++){
        cin >> a[i];
        m[a[i]+i]++;
        if(i != 1){
            ll x = i-a[i];
            count += m[x];
        }
    }
    cout << count << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //ll t; cin >> t; while(t--)
        solve();
}


Measured memory_bytes: 27880
#include<iostream>
#include<math.h>
using namespace std;

bool isPrime(int x){
 if(x==2) return true;

 if(x<2 || x%2==0) return false;

 int i = 3;
 while(i<=sqrt(x)){
  if(x%i==0) return false;
  i = i + 2;
 }

 return true;
}

int main(){
 int n;
 cin >> n;
 int N[n];
 for(int i=0; i<n; i++){
  cin >> N[i];
 }

 int count = 0;
 for(int i=0; i<n; i++){
  if(isPrime(N[i])) count++;
 }

 cout << count << endl;

 return 0;
}

Measured memory_bytes: 3068
from heapq import *
import sys
from collections import *

from itertools import *
from decimal import *
import copy
from bisect import *
import time

import math

def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
X=int(input())
dp=[0]*(X+1)
dp[0]=1
for a in [100,101,102,103,104,105]:
    for i in range(len(dp)):
        if i-a>=0:
            if dp[i-a]==1:
                dp[i]=1
print(dp[-1])


Measured memory_bytes: 61036
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "YES"
#define no "NO"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int a,b,c;
int main(){
    cin >> a >> b >> c;
    pr((b-a == c-b)?yes : no);
}

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    i64 w;
    cin >> n >> w;
    int ofs = n / 2, res = n - ofs;
    akari<i64> vs(n), ws(n);
    akari<pair<i64, i64>> xs, ys;
    for (int i = 0; i < n; i++)
    {
        cin >> vs[i] >> ws[i];
    }
    for (int i = 0; i < 1 << ofs; i++)
    {
        i64 wsum = 0, vsum = 0;
        for (int j = 0; j < ofs; j++)
        {
            if (i >> j & 1)
            {
                wsum += ws[j];
                vsum += vs[j];
            }
        }
        if (wsum <= w)
            xs.emplace_back(wsum, vsum);
    }
    for (int i = 0; i < 1 << res; i++)
    {
        i64 wsum = 0, vsum = 0;
        for (int j = 0; j < res; j++)
        {
            if (i >> j & 1)
            {
                wsum += ws[ofs + j];
                vsum += vs[ofs + j];
            }
        }
        if (wsum <= w)
            ys.emplace_back(wsum, vsum);
    }
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());
    i64 ans = 0, maxi = 0;
    for (auto &p : xs)
    {
        i64 &x = p.second;
        x = max(x, maxi);
        maxi = max(x, maxi);
    }
    maxi = 0;
    for (auto &p : ys)
    {
        i64 &y = p.second;
        y = max(y, maxi);
        maxi = max(y, maxi);
    }
    for (auto &p : xs)
    {
        auto it = upper_bound(ys.begin(), ys.end(), make_pair(w - p.first + 1, (i64)0));
        it = prev(it);
        ans = max(ans, p.second + it->second);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 43684
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,k,h,p,j,l,flg,w,f;
	char s[100][100];
	scanf("%d %d %d",&n,&m,&h);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
	}
	w=0;
	for(i=0;i<n;i++){
		for(j=0;j<m-h+1;j++){
			flg=0; f=0;
			for(l=0;l<h;l++){
				if(s[i][j+l]=='#'){
					flg=1;
				}
				f++;
			}
			if(flg==0&&f==h) w++;
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<n-h+1;j++){
			flg=0; f=0;
			for(l=0;l<h;l++){
				if(s[j+l][i]=='#'){
					flg=1;
				}
				f++;
			}
			if(flg==0&&f==h) w++;
		}
	}
	printf("%d\n",w);
	return 0;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct N001 {
   long n;
   std::vector<long> parents;
   std::vector<long> numbers;
   N001(long n_) : n(n_), parents(n+1, -1), numbers(n+1, -1) {
   }
};
long find(N001& s, long x) {
   if( s.parents[x] == -1 ) return x;
   return s.parents[x] = find(s, s.parents[x]);
}
bool same(N001& s, long x, long y) {
   return find(s, x) == find(s, y);
}
void unite(N001& s, long x, long y) {
   long x2 = find(s, x);
   long y2 = find(s, y);
   if( x2 == y2 ) return;
   if( not ( s.numbers[x2] <= s.numbers[y2] ) )
      std::swap(x2, y2);
   s.parents[x2] = y2;
   s.numbers[y2] += s.numbers[x2];
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long k, t; scan(k, t);
      LI xs(t); for(long &x : xs) scan(x);
      long res = 0;
      for(long x : xs) {
         if( x > (k + 1) / 2 ) {
            res = 2 * (x - ((k + 1) / 2)) - 1;
         }
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



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

int N, W;
int value[110], weight[110];
int dp[110][10010];

int main () {
    
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> value[i] >> weight[i];
    }

    for (int w = 0; w <= W; w++) {
        dp[0][w] = 0;
    }
    for (int i = 0; i < N; i++) {
        for (int w = 0; w <= W; w++) {
            dp[i+1][w] = dp[i][w];
            if (weight[i] <= w) {
                dp[i+1][w] = max(dp[i+1][w], dp[i][w-weight[i]]+value[i]);
            }
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 7044
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 30;
int n,m,ans,dist[N*N][N*N];
char mp[N][N];
it id(int x,int y){return (x-1)*m+y;}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m),del(dist,0x3f);
	for(ri i=1;i<=n;++i)
		scanf("%s",mp[i]+1);
	for(ri i=1;i<=n;++i)
		for(ri j=1;j<=m;++j){
			int id1=id(i,j);
			dist[id1][id1]=0;
			if(mp[i][j]=='#') continue;
			if(i+1<=n&&mp[i+1][j]=='.') dist[id1][id(i+1,j)]=dist[id(i+1,j)][id1]=1;
			if(j+1<=m&&mp[i][j+1]=='.') dist[id1][id(i,j+1)]=dist[id(i,j+1)][id1]=1;
		}
	for(ri k=1;k<=n*m;++k)
		for(ri i=1;i<=n*m;++i)
			for(ri j=1;j<=n*m;++j)
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
	for(ri i=1;i<=n;++i)
		for(ri j=1;j<=m;++j)
			if(mp[i][j]=='.')
				for(ri x=1;x<=n;++x)
					for(ri y=1;y<=m;++y)
						if(mp[x][y]=='.')
							ans=max(ans,dist[id(i,j)][id(x,y)]);
	print(ans);
	return 0;
}

Measured memory_bytes: 3456
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int input = sc.nextInt();
      	int mod = 0;
       	while(input != 0){
        	mod = input % 10;
          	if(mod == 7){
              System.out.println("Yes");
              return;
            }
          	input = input / 10;
        }
        if(input % 10 == 7){
           System.out.println("Yes");
           return;
        }
      	System.out.println("No");
    }
}

Measured memory_bytes: 35832
import sys
input = sys.stdin.readline

O = input().rstrip()
E = input().rstrip()

n_O = len(O)
n_E = len(E)
ans = ""
for i in range(n_E):
  ans += O[i]
  ans += E[i]
if n_O > n_E:
  ans += O[-1]
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string c;
  cin >> c;
  
  if(c=="a" || c=="i" || c=="u"||c=="e"||c=="o"){
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256