akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,we;
ll w[101],v[101];
ll memo[101][100001];
ll findans(ll i,ll n,ll sum)
{
    if(i==n)
    {
        if(sum<=we)
        {
           return 0;
        }
        else
        {
            return -1000000000000000;
        }
    }
    /*if(i==n-1)
    {
       
        if(sum+w[i]<=we)
        {
            return v[i];
        }
        else
        {
            return 0;
        }
    }*/
    if(memo[i][sum]!=-1)
    {
        return memo[i][sum];
    }
    ll ans1=-1000000000000000;
    if(sum+w[i]<=we)
    {
        ans1=v[i]+findans(i+1,n,sum+w[i]);
    }
    ll ans2=findans(i+1,n,sum);
    return memo[i][sum]=max(ans1,ans2);
}
int main(){
    // Your code here!
    
    cin>>n>>we;
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    for(ll i=0;i<=100;i++)
    {
        for(ll j=0;j<=100000;j++)
        {
            memo[i][j]=-1;
        }
    }
    cout<<findans(0,n,0);
    
}


Measured memory_bytes: 82532
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
 
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
 
#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll n; cin >> n;
    vector<ll> alis(n), blis(n);
    REP(i, 0, n){
        cin >> alis[i] >> blis[i];
    }
    sort(ALL(alis));
    sort(ALL(blis));
    if(n % 2 == 1){
        cout << blis[n/2] - alis[n/2] + 1 << endl;
    }else{
        int pre = (n-1) / 2;
        int fro = n / 2;
        int k = alis[fro] + alis[pre];
        int kk = blis[fro] + blis[pre];
        cout << kk - k + 1 << endl;
    }
}

Measured memory_bytes: 6428
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

struct restaurant {
  string name;
  int point, num;
};

int main() {
  int n;
  scan(n);
  vector<restaurant> res(n);
  rep (i, n) {
    string s;
    scan(s);
    int p;
    scan(p);
    res[i] = restaurant{s, p, i + 1};
  }
  sort(all(res), [](auto x, auto y) {
      return (x.name == y.name && x.point > y.point) || (x.name < y.name);
      });
  rep (i, n) {
    print(res[i].num);
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

//clang++ -std=c++11 -stdlib=libc++ 
int main() {
  char c; cin >> c;
  cout << static_cast<char>(c+1) << endl;
  return 0;
}

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
const int N = 2e5;
vi gr[N];
int vis[N] = {};
int dis[N];

void dfs(int cur) {
    vis[cur] = 1;
    for (auto x : gr[cur]) {
        if (!vis[x]) {
            dfs(x);

        }
        dis[cur] = max(dis[cur], dis[x] + 1);
    }
}

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

int32_t main()
{
    c_p_c();
    int n, m;
    cin >> n >> m;
    memset(dis, 0, sizeof(dis));
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        gr[x].pb(y);
    }
    rep(i, 1, n + 1) {
        if (!vis[i]) {
            dfs(i);
        }
    }
    int ans = 0;
    rep(i, 1, n + 1) {
        ans = max(ans, dis[i]);
        //cout << i << " " << dis[i] << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16412
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    char haystack[201], needle[102];
    if (fgets(haystack, 102, stdin) && fgets(needle, 102, stdin))
    {
        const size_t hlen = strlen(haystack) - !!(haystack[strlen(haystack) - 1] == '\n');
        (void)memcpy(haystack + hlen, haystack, hlen);
        haystack[hlen * 2] = '\0';
        const size_t nlen = strlen(needle) - !!(needle[strlen(needle) - 1] == '\n');
        needle[nlen] = '\0';
        printf("%s\n", strstr(haystack, needle) ? "Yes" : "No");
    }
    return 0;
}



Measured memory_bytes: 2140
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  int u = max_element(a.begin(), a.end()) - a.begin();
  int v = min_element(a.begin(), a.end()) - a.begin();
  if (a[u] + a[v] >= 0) {
    printf("%d\n", 2 * n);
    printf("%d %d\n", u + 1, 1);
    printf("%d %d\n", u + 1, 1);
    for (int i = 1; i < n; ++i) {
      printf("%d %d\n", i, i + 1);
      printf("%d %d\n", i, i + 1);
    }
  } else {
    printf("%d\n", 2 * n);
    printf("%d %d\n", v + 1, n);
    printf("%d %d\n", v + 1, n);
    for (int i = n; i > 1; --i) {
      printf("%d %d\n", i, i - 1);
      printf("%d %d\n", i, i - 1);
    }
  }
  return 0;
}


Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var a = one[0];
  var b = one[1];
  var x = one[2] / a;
  if(a * b / 2 > x){
    var diffA = x * 2 / b;
    var kakudo = Math.atan(b / diffA) * 180 / Math.PI;
    myout(kakudo);
  }else{
    var diffB = b - (2 * x / a - b);
    var kakudo = Math.atan(diffB / a) * 180 / Math.PI;
    myout(kakudo);
  }
}


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

 
int main() {
   int n,m,x;
   cin>>n>>m>>x;
   vector<int> C(n);
   vector<vector<int>> A(n,vector<int>(m));
   rep(i,n){
       cin>>C[i];
       rep(j,m)cin>>A[i][j];
   }

   int ans=10101010;
   for(int bit=0;bit<(1<<n);bit++){
       int Csum=0;
       vector<int> Asum(m);
       for(int i=0;i<n;i++){
           if(bit&(1<<i)){//iが含まれるとき
              Csum+=C[i];
              rep(j,m)Asum[j]+=A[i][j];
           }
       }
       bool ok=true;
       rep(j,m){
           if(Asum[j]<x)ok=false;
       }
       if(ok)ans=min(ans,Csum);
   }

   if(ans==10101010)cout<<-1<<endl;
   else cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
const int INF=1e9;
int a[105];
int ma[105];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long res=0;
	for(int st=0;st<n;st++){
		for(int ed=st-1;ed<n;ed++){
			vector<int> tmp;
			for(int i=0;i<st;i++) tmp.push_back(a[i]);
			for(int i=ed+1;i<n;i++) tmp.push_back(a[i]);
			sort(tmp.begin(),tmp.end());
			if((int)tmp.size()>k) continue;
			long long cnt=0;
			for(int i=0;i<tmp.size();i++) cnt+=1ll*tmp[i];
			for(int i=0;i<min((int)tmp.size(),k-(int)tmp.size());i++) if(tmp[i]<0) cnt-=tmp[i];
			res=max(res,cnt);
		}
	}
	cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define V(i) vector<i>
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define crep(i,N,n) for (__typeof(n) i = N; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define P(i,j) pair<i,j>
#define MP make_pair
#define MOD 1000000007
typedef long long ll;
typedef long l;
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll n;
    cin>>n;
    map<string,ll> mp;
    rep(i,n)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";

    return 0;
}

Measured memory_bytes: 3584
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <map>
# include <stack>
using namespace std;
//# define M_PI 3.141592
# define INF ((int)(1<<30))
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };

int a[10010][1500];
bool f[10010];

int main()
{
	int n, m;
	while (cin >> n >> m&&n)
	{
		FOR(i, 10001)
		{
			FOR(j, 1500)a[i][j] = 0;
			f[i] = false;
		}
		int r; cin >> r;
		FOR(i, r)
		{
			int T, N, M, S;
			cin >> T >> N >> M >> S;
			if (S == 0)
			{
				S = -1;
				//T++;
			}
			a[M][T] += S;
		}
		int q; cin >> q;
		FOR(i, q)
		{
			int st, en, x;
			cin >> st >> en >> x;
			if (!f[x])
			{
				for (int j = 1; j < 1500; j++)
				{
					a[x][j] += a[x][j - 1];
				}
				f[x] = true;
			}
			int ans = 0;
			for (int j = st; j < en; j++)if (a[x][j])ans++;
			cout << ans << endl;
		}

	}
}

Measured memory_bytes: 61596
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int G = sc.nextInt()/100;
		int[] p = new int[D+1];
		int[] c = new int[D+1];
		int[] score = new int[D+1];
		for(int i = 1; i <= D; i++) {
			p[i] = sc.nextInt();
			c[i] = sc.nextInt()/100;
			score[i] = i * p[i] + c[i];
		}
		int ans = Integer.MAX_VALUE;
		for(int i = 0; i < 1 << D; i++) {
			int max = 0, num = 0, value = 0;
			for(int j = 0; j < D; j++) {
				if((1 & (i >> j)) == 1) {
					num += p[j+1];
					value += score[j+1];
				}
				else
					max = j+1;
			}
			if(value < G) {
				for(int j = 0; j < p[max]-1; j++) {
					value += max;
					num += 1;
					if(value >= G) 
						break;
				}
			}
			if(value >= G)
				ans = Math.min(ans, num);
		}
		System.out.println(ans);
	}

}

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

int main()
{
    while (true)
    {
        int a, b;
        char op;
        cin >> a >> op >> b;
        if (op == '?')
            break;

        if (op == '+')
        {
            cout << a + b << endl;
        }
        if (op == '-')
        {
            cout << a - b << endl;
        }
        if (op == '*')
        {
            cout << a * b << endl;
        }
        if (op == '/')
        {
            cout << a / b << endl;
        }
    }
}


Measured memory_bytes: 3096
#include <stdio.h>

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

using ll = long long;

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  n -= 2;
  ll ans = 0;
  rep(i, 11) {
    rep(j, 7 - 2) {
      ll a = 0;
      rep(ii, 3) {
        rep(jj, 3) {
          a += (i + ii + 1) * 7 + (j + jj + 1) - 7;
        }
      }
      if(a % 11 == k) {
        ans += n / 11 + (i < n % 11 ? 1 : 0);
      }
    }
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }

map<long long, int> prime_factorize(long long n) {
    map<long long, int> res;
    for (long long p = 2; p * p <= n; ++p) {
        while (n % p == 0) { ++res[p]; n /= p; }
    }
    if (n != 1) res[n] = 1;
    return res;
}

int main() {
    long long p, q; cin >> p >> q;
    long long g = gcd(p, q);
    q /= g;
    long long ans = 1;
    for (auto &p: prime_factorize(q)) ans *= p.first;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <regex>
#include <vector>


int main(){
    int N , Q;
    std::string S;
    std::cin >> N >> Q;
    std::cin >> S;
    std::vector<int> sum(N+1,0);
    std::vector<int> l(Q),r(Q);
    for (int i = 0;i < Q; i++){
        std::cin >> l[i] >> r[i];
    }

    for(int i = 1; i < N; i++){
        if(S[i - 1] == 'A' && S[i] == 'C'){
            sum[i + 1] = sum[i] + 1;
        }else{
            sum[i + 1] = sum[i];
        }
    }
    for (int i = 0;i < Q; i++){
        int ans = sum[r[i]] - sum[l[i]];
        std::cout << ans << std::endl;
    }

    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
const double pi =acos(-1);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    m = m/60;
    h=h/12;
    double goc = (h+m/12-m)*2*pi;
    double S = sqrt(a*a+b*b-2*a*b*cos(goc));
    printf("%.20f", S);
    return 0;
}

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
int main() {
  int s1, s2;
  while( cin >> s1 >> s2, s1+s2 ) {
    int maxn = s1 + s2;
    char maxi = 'A';
    for(int i=1; i<5; i++) {
      cin >> s1 >> s2;
      if( maxn < s1 + s2 ) {
	maxn = s1 + s2;
	maxi = 'A' + i;
      }
    }

    cout << maxi << ' ' << maxn << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  ll sum = 0;
  rep(i,N){
    int x;
    cin >> x;
    sum += x;
  }
  cout << sum -N << endl;
}


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

int main() {
  vector<int> x(5);
  rep(i, 5) {
    cin >> x.at(i);
  }
  int ans;
  rep(i, 5) {
    if (x.at(i) == 0) {
      ans = x.at(0) + i;
      if (i== 0) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine();
        var b = Console.ReadLine();
        var c = Console.ReadLine();
        int res = 0;
        for (int i = 0; i < n; i++)
        {
            res += new[] { a[i], b[i], c[i] }.Distinct().Count() - 1;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13268
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = [A, B, C, D, E]
max_fp = 10
ans = 0
last_order = 0

for i, order in enumerate(orders):
    if order % 10 < max_fp and order % 10 != 0:
        max_fp = order % 10
        last_order = i

for i, order in enumerate(orders):
    if i == last_order or order % 10 == 0:
        ans += order
    else:
        ans += (order // 10 + 1) * 10

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define clr(a, x) memset(a, x, sizeof(a))
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define X first
#define Y second
#define fastin                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

const int maxn = 1 << 17;
PII a[maxn];

int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);
#endif
    int n;
    while (cin >> n)
    {
        for (int i = 0; i < n; i++)
            cin >> a[i].X >> a[i].Y;
        sort(a, a + n);
        cout << a[n - 1].X + a[n - 1].Y << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
// 2012/08/08 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int cnt[10] = {0};

		for(int i=0; i<n; i++){
			int ice;
			cin >> ice;

			cnt[ice]++;
		}

		for(int i=0; i<10; i++){
			if(cnt[i]==0){
				cout << '-' << endl;
			}
			else{
				for(int j=0; j<cnt[i]; j++){
					cout << '*';
				}
				cout << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner; 
import java.lang.Math;

public class Main { 
     public static void main(String[] args) { 
         Scanner sc = new Scanner(System.in);
         int n = Integer.parseInt(sc.next());

         System.out.println(solve(n));
     } 
    public static int solve(int n) {
        int ans = 0;
        for (int i = 1; i <= n; i++) {
             int digit = (int) Math.log10(i) + 1;
             if (digit %2==1) {
                ans++;
             } 
         } 
         return ans;
     } 
} 

Measured memory_bytes: 21972
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	vi a(n+1);
	rep(i,n+1)cin>>a[i];
	vi b(n);
	rep(i,n)cin>>b[i];
	int out=0;
	rep(i,n){
		if(i){
			out+=min(a[i],b[i-1]);
			a[i]-=min(a[i],b[i-1]);
		}
		out+=min(a[i],b[i]);
		b[i]-=min(a[i],b[i]);
	}
	out+=min(a[n],b[n-1]);
	cout<<out<<endl;
}












Measured memory_bytes: 1792
#include<bits/stdc++.h>   
#include<tr1/unordered_map>
#define ll long long int  
#define mkp make_pair 
#define mod 1000000007 
#define maxn 100001 
#define ff first
#define ss second
using namespace std;    
int32_t main(){ 	 ll x,k,d; cin>>x>>k>>d;  
  if(x<0)x*=-1;  
 ll mn = x/d;  
 if(k<=mn){ x-=k*d; cout<<x<<"\n"; }  
else{ x-=mn*d; int left = k-mn;  if(left%2==0){ cout<<abs(x)<<"\n"; } else{ cout<<abs(x-d)<<"\n"; } } }


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

int main(){
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  bool same = true;
  for(int i=0; i<n-1; ++i){
    if(s[i] != s[i+1]){
      same = false;
      break;
    }
  }
  if(same){
    cout << (ll)n*k/2 << endl;
    return 0;
  }
  int cnt = 1;
  for(int i=0; i<n; ++i){
    if(s[i] == s[i+1]) ++cnt;
    else break;
  }
  ll ans = 0;
  for(int i=0; i<n-1; ++i){
    if(s[i] == s[i+1]){
      ans += k;
      s[i+1] = '.';
    }
  }
  if(s[0] == s[n-1] && cnt%2 == 1){
    ans += k-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
 
const int N=505;
const int LIM=8000;
int fl[LIM],pri[LIM],n;
void initprime(){
	For(i,2,LIM-1) For(j,2,(LIM-1)/i) fl[i*j]=1;
	For(i,1,LIM-1) if (!fl[i]) pri[++*pri]=i;
}
map<int,int> mp1,mp2;
map<ll,int> mp3;
ll ans[N][N];
ll gcd(ll x,ll y){
	return y?gcd(y,x%y):x;
}
void work(){
	int l=4;
	For(i,1,n) For(j,1,n) if ((i+j)&1){
		if (!mp1[i+j]) mp1[i+j]=pri[l++];
		if (l>333) l=4;
		ans[i][j]=mp1[i+j];
	}
	l=4;
	Rep(i,n,1) For(j,1,n) if ((i+j)&1){
		if (!mp2[i-j]) mp2[i-j]=pri[l++];
		if (l>333) l=4;
		ans[i][j]*=mp2[i-j];
	}
	For(i,1,n) For(j,1,n) if ((i+j)&1){
		int v=mp1[i+j]*mp2[i-j];
		for (;mp3[ans[i][j]];ans[i][j]+=v);
		mp3[ans[i][j]]++;
	}
	ll mx=0;
	For(i,1,n) For(j,1,n) if (!ans[i][j]){
		ll lcm=1;
		if (i!=1) lcm*=ans[i-1][j]/gcd(ans[i-1][j],lcm);
		if (i!=n) lcm*=ans[i+1][j]/gcd(ans[i+1][j],lcm);
		if (j!=1) lcm*=ans[i][j-1]/gcd(ans[i][j-1],lcm);
		if (j!=n) lcm*=ans[i][j+1]/gcd(ans[i][j+1],lcm);
		ans[i][j]=lcm+1;
		for (;mp3[ans[i][j]];ans[i][j]+=lcm);
		mp3[ans[i][j]]=1;
		mx=max(mx,ans[i][j]);
	}
	For(i,1,n){
		For(j,1,n) printf("%lld ",ans[i][j]);
		puts("");
	}
}
 
int main(){
	scanf("%d",&n);
	initprime();
	work();
}

Measured memory_bytes: 20480
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}

int solve(const int n, vector<int> & in){
  int cand=  0;
  ll sum = 0;
  rep(i, n-1){
    if ((sum + in[i]) * 2 >= in[i+1]){
      cand++;
    } else {
      cand = 0;
    }
    sum += in[i];
  }
  cand++;
  return cand;
}

int main(){
  int n;
  cin >> n;
  vector<int> in(n);
  rep(i,n){
    cin >> in[i];
  }
  sort(ALL(in));
  cout << solve(n,in) << endl;
}
 
 


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<double> prob(n);
    for(int i=0;i<n;i++)
    {
        cin>>prob[i];
    }
    vector<double> dp(n+1);
    dp[0]=1;
    for(int coins=0;coins<n;coins++)
    {
        for(int i=coins+1;i>=0;i--)
        {
            if(i==coins+1)
            {
                dp[i]=dp[i-1]*prob[coins];
            }
            else if(i==0)
            {
                dp[i]*=(1-prob[coins]);
            }
            else
            {
                dp[i]=dp[i]*(1-prob[coins]);
                dp[i]+=(dp[i-1]*prob[coins]);
            }
        }
        // for(double i:dp)
        //     cout<<i<<" ";
        // cout<<endl;
    }
    
    double ans=0.0;
    for(int i=n/2+1;i<=n;i++)
        ans+=dp[i];
    cout<< fixed << setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n, m;
    scanf("%d%d", &n, &m);
    int h[n + 1];
    h[0] = 0;
    for(int i = 1; i < n + 1; i++){
        scanf("%d", &h[i]);
    }

    int c[n + 1];
    for(int i = 0; i < n + 1; i++){
        c[i] = 1;
    }
    int a, b;
    for(int i = 0; i < m; i++){
        scanf("%d%d", &a, &b);
        if(h[a] < h[b]){
            c[a]--;
        }else if(h[a] == h[b]){
            c[a]--;
            c[b]--;
        }else{
            c[b]--;
        }
    }

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

    printf("%d", count);
    return 0;
}

Measured memory_bytes: 2504
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL a[1005];
LL sum[1005];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    vector<LL> vec;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            vec.push_back(sum[j] - sum[i - 1]);
        }
    }
    LL ans = 0;
    for (int b = 40; b >= 0; b--) {
        LL x = ans | (1LL << b);
        int count = 0;
        for (auto v: vec) {
            if ((x & v) == x) {
                count++;
            }
        }
        if (count >= k) {
            ans = x;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 7472
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=1e6+5;
int mp[N]={0};


void solve()
{
  int n,k;
  cin>>n>>k;
  int a[n+1];
  for(int i=1;i<=n;i++)
    cin>>a[i];
  int l=1;
  int h=1e9;
  int ans=-1;
  while(l<=h)
  {
      int mid=(l+h)/2;
      int x=0;
      for(int i=1;i<=n;i++)
      {
        x+=((a[i]+mid-1)/mid)-1;
      }
      if(x<=k)
      {
        ans=mid;
        h=mid-1;
      }
      else
      {
        l=mid+1;
      }
      //cout<<mid<<" "<<x<<endl;
  }
  cout<<ans;
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int ans=0,sum;
  string s;
  cin>>s;  
  for(int bit=0;bit<(1<<s.size());bit++){
    sum=0;
    for(int i=0;i<s.size();i++){
      if(bit&(1<<i)){
        ans+=sum;
        sum=0;
      }
      sum*=10;
      sum+=s[i]-'0';
    }
    ans+=sum;
  }
  cout<<ans/2<<"\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int H,W;
	int i, j;
	while(1){
	scanf("%d %d" ,&H ,&W);
	if(H == 0 && W == 0) break;
		for ( i = 0; i < H; i++ ){
		for ( j = 0; j < W; j++ ){
	if(j==0||j==W-1||i==0||i==H-1){
			printf("#");
	}else{
			printf(".");
		}
	}
		printf("\n");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2544
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [a,b] <- readInts
  putStrLn $ if isOddOrEven a b 
               then "Odd"
               else "Even"

isOddOrEven
  :: Int -> Int -> Bool
isOddOrEven a b = odd a && odd b

Measured memory_bytes: 380
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))

L_max=max(L)

L_max_count=0
for l in L:
    if l==L_max:
        L_max_count+=1
    if L_max_count > 1:
        break

for i in range(N):
    now=L[i]
    
    if L_max_count > 1:
        ans=L_max
    
    elif now!=L_max:
        ans=L_max
        
    else:
        L_temp=L.copy()
        L_temp_p=L_temp.pop(i)
        ans=max(L_temp)
    
    print(ans)

Measured memory_bytes: 14068
#include<iostream>

using namespace std;

int main(){
    int a,b,S,L;
    //cout <<"長方形の縦と、横の長さを半角で入力してください"<<endl;
    cin >> a >> b;
    S = a*b;
    L = 2*(a+b);
    //cout <<"結果を面積、周の長さの順に表示します"<<endl;
    cout << S <<" "<< L <<endl;
}


Measured memory_bytes: 3080
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    b = sum(a)
    ans =  b >> 1
    if ans in a:
        print(b - 2*ans)
        continue
    c = [v for v in a if v < ans]
    s , f, q, qlen = set(), True, [0], 1
    for v in c:
        i, k = 0, qlen
        while k:
            v2 = v + q[i]
            k, i = k-1, i+1
            if v2 == ans:
                f = False
                break
            if v2 < ans and v2 not in s:
                s.add(v2)
                q.append(v2)
                qlen += 1
                
    if f:
        while True:
            ans -= 1
            if ans == 0:
                break
            if ans in s:
                break
    print(b - 2 * ans)


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

int main(){
    int n,i;
    int count=0,odd=0;

    cin>> n;

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

    while(1){
        for(i=0; i<n; i++){
            if(a[i]%2!=0) odd++;
        }
        if(odd!=0) break;

        for(i=0; i<n; i++){
            a[i]=a[i]/2;
        }
        count++;

    }
    cout<< count << endl;
}

Measured memory_bytes: 3636
while True:
	H,W=map(int,input().split())
	if W==0 and H==0:
		break
	for a in range(H):
		if a%2==0:
			for b in range(W):
				if b%2==0:
					print('#',end='')
				else:
					print('.',end='')
			print()
		else:
			for c in range(W):
				if c%2==0:
					print('.',end='')
				else:
					print('#',end='')
			print()
	print()


Measured memory_bytes: 7000
<?php
$p=array();
while(1){
  list($h,$w)=explode(' ',trim(fgets(STDIN)));
  if($h||$w){
    $l='';
    for($i=0;$i<$w;$i++){$l.='#';}
    for($i=0;$i<$h;$i++){$p[]=$l;}
    $p[]='';
  }
  else break;
}
print implode(PHP_EOL,$p);
?>

Measured memory_bytes: 15356
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

const int MAX_N = 300005;
const LL mod = 1e9+7;
int n;
LL a[MAX_N];
void input() {
    RI(n);
    REP(i,n) scanf("%lld", &a[i]);
}

void solve() {
    LL ans = 0;
    REP(k,60) {
        LL zeros = 0, ones = 0;
        REP(i,n) {
            if((1LL<<k) & a[i]) ones++;
            else zeros++;
        }
        ans = (ans + (((ones * zeros) % mod) * ((1LL << k) % mod) % mod)) % mod;
    }
    printf("%lld\n",ans);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    ll n,m;
    ll ans=0;
    cin >> n >> m;
    vector<pair<ll,ll>>e(n);
    rep(i,n){
        ll a,b;
        cin >> a >>b;
        e[i]=make_pair(a,b);
    }
    sort(e.begin(),e.end());
    rep(i,n){
        ans+=e[i].first*min(m,e[i].second);
        m-=e[i].second;
        if(m<=0) break;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

    vector<int> B(N-1);
    for(int i=0; i<N-1; i++) {
        cin >> B[i];
    }
    
    int Acur, Asum;
    Asum = 0;
    {
        for(int i=0; i<N; i++) {
            if (i==0) {
                Acur = B[i];
                Asum += Acur;
            }
            else if (i == (N-1)) {
                Acur = B[i-1];
                Asum += Acur;
            }
            else {
                Acur = min(B[i-1], B[i]);
                Asum += Acur;
            }
        }
    }

    cout << Asum << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n, ans = 0, maxn = 0, j;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> j;
        if (i == 1)
            maxn = j;
        else
        {
            if (maxn > j)
                ans += maxn - j;
            else
                maxn = j;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
P = 1

for i, a in enumerate(A):
    if i == 0:
        ans += (a - 1) // P
        P += 1
        continue

    if a < P:
        continue

    if a == P:
        P += 1
        continue

    ans += (a - 1) // P

print(ans)


Measured memory_bytes: 7080
import sys
m = int(input())
f = [0]*50
def fib(n):
  if n==0 or n==1:
    f[n] == 1
    return 1
  if f[n]!=0:
    return f[n]
  f[n] = fib(n-2) + fib(n-1)
  return f[n]

print(fib(m))


Measured memory_bytes: 5604
S = input()
N = len(S)
s = S[::-1]
A = S[:(N-1)//2]
a = A[::-1]
B = S[(N+3)//2-1:]
b = B[::-1]

if S==s and A==a and B == b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,C=10000;
  cin>>N;
  for(int i=0;i<N;i++){
  	int a;
    cin>>a;
    for(int j=0;;j++){
     // cout<<a<<endl;
    	if(a%2 == 0){
      	  a/=2;}
      else{
        if(j<C){
        C=j;
        }
         break;}
    }
   
  }
  cout<<C<<endl;

}

Measured memory_bytes: 3600
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
a,b,c,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しに4 3sum変数使用はsum関数使用できないので注意
if a==b:
    print(0)
else:
    if abs(a-b) > pow(10,18):print("unfair")
    elif k%2: print(b-a)
    else:print(a-b)

Measured memory_bytes: 13420
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int digitsum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(int argc, const char * argv[]) {
    
    int N;
    cin >> N;
    
    int minsum = 72;
    for (int a = 1; a <= N / 2; a++) {
        if (digitsum(a) + digitsum(N - a) < minsum) {
            minsum = digitsum(a) + digitsum(N - a);
        }
    }
    
    cout << minsum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,v;
    vector<int> E,O;
    cin >> N;
    REP(i,N){
        cin >> v;
        if(i%2==0){
            E.push_back(v);
        }else{
            O.push_back(v);
        }
    }
    int mode[2]={},fir[2]={},sec[2]={};
    map<int,int> Me,Mo;
    vector<int> Fe,Fo;
    REP(i,E.size()){
        Me[E[i]]++;
    }
    REP(i,E.size()){
        if(Me[E[i]]>0){
            if(fir[0]<Me[E[i]]){
                mode[0]=E[i];
                fir[0]=Me[E[i]];
            }
            Fe.push_back(Me[E[i]]);
            Me[E[i]]=0;
        }
    }
    
    REP(i,O.size()){
        Mo[O[i]]++;
    }
    REP(i,O.size()){
        if(Mo[O[i]]>0){
            if(fir[1]<Mo[O[i]]){
                mode[1]=O[i];
                fir[1]=Mo[O[i]];
            }
            Fo.push_back(Mo[O[i]]);
            Mo[O[i]]=0;
        }
    }
    sort(Fe.begin(),Fe.end(),greater<>());
    sort(Fo.begin(),Fo.end(),greater<>());
    fir[0]=Fe[0];if(Fe.size()>1){sec[0]=Fe[1];}
    fir[1]=Fo[0];if(Fo.size()>1){sec[1]=Fo[1];}
    
    //cout << mode[0] MM mode[1] << endl;
    //cout << fir[0] MM fir[1] << endl;
    //cout << sec[0] MM sec[1] << endl;
    
    if(mode[0]!=mode[1]){
        cout << N-fir[0]-fir[1];
    }else{
        cout << N-max(fir[0]+sec[1],fir[1]+sec[0]);
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 8436
S = input()
T = input()

def chr_count(S):
    count = [0]*1000
    for i in S:
        count[ord(i)] += 1
    return count

Sc = chr_count(S)
Tc = chr_count(T)
Sc.sort()
Tc.sort()

if Sc == Tc:
    print("Yes")
else:
    print("No")

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

typedef long long ll;
//typedef ll int;
ll mod = 1000000007;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll a, b, c;
    cin >> a >> b;
    cout << max(a*b, max(a-b, a+b)) << endl;
}

Measured memory_bytes: 256
/*
 * VJUDGE C - GCD on Blackboard
 * author: roy4801
 * (C++)
 */
#include <bits/stdc++.h>

using namespace std;

#define PROB "C"
#define TESTC ""

#define USE_CPPIO() ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MP make_pair
#define MT make_tuple
#define PB push_back
int n, ans;
#define N 1000000
int a[N+5], l[N+5], r[N+5];
int main()
{
	#ifdef DBG
	freopen("./testdata/" PROB TESTC ".in", "r", stdin);
	freopen("./testdata/" PROB ".out", "w", stdout);
	#endif
	while(cin >> n)
	{
		for(int i = 0; i < n && cin >> a[i]; i++);

		l[0] = a[0];
		for(int i = 1; i < n; i++)
			l[i] = __gcd(l[i-1], a[i]);

		r[n-1] = a[n-1];
		for(int i = n-2; i >= 0; i--)
			r[i] = __gcd(r[i+1], a[i]);

		ans = 1;
		for(int i = 1; i < n-1; i++) // [1, n-2]
			ans = max(__gcd(l[i-1], r[i+1]), ans);

		ans = max(max(l[n-2], r[1]), ans);
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 8832
x1, y1, x2, y2 = map(int, input().split())
a = x2 - x1
b = y2 - y1
x3 = x2 - b
y3 = y2 + a
x4 = x3 - a
y4 = y3 - b
print(x3, y3, x4, y4)

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

int main() {
  string S,T;
  cin >> S >> T;
  int ssize = S.size();
  int tsize = T.size();
  int ans = 100100100;
  for(int i = 0; i < ssize-tsize+1; i++){
    string S2 = S.substr(i,tsize);
    int cnt = 0;
    rep(j,tsize){
      if(S2.at(j) != T.at(j)) cnt++;
    }
    ans = min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
}

long long n;

int main()
{
	file(1);
	cin >> n;
	cout << 3 * n*n << endl;
	return 0;
}

Measured memory_bytes: 256