akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    int x=0;
    while (n % 2 == 0)
    {
        x++;
        n = n/2;
        v.pb(2);
    }
    //if(x>0)
    //v.pb({2,x});
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        int y=0;
        while (n % i == 0)
        {
            y++;
            n = n/i;
            v.pb(i);
        }
        //if(y>0)
        //v.pb({i,y});
    }
    if (n > 2)
        v.pb(n);
    return v;
}

vector<int>leastPrimeFactor(int n)
{
    vector<int>least_prime(n);
    // Create a vector to store least primes.
    // Initialize all entries as 0.
    // We need to print 1 for 1.
    least_prime[1] = 1;

    for (int i = 2; i <= n; i++)
    {
        // least_prime[i] == 0
        // means it i is prime
        if (least_prime[i] == 0)
        {
            // marking the prime number
            // as its own lpf
            least_prime[i] = i;

            // mark it as a divisor for all its
            // multiples if not already marked
            for (int j = 2*i; j <= n; j += i)
                if (least_prime[j] == 0)
                   least_prime[j] = i;
        }
    }
    return least_prime;
}
int maxSubArraySum(int a[], int size)
{
    int max_so_far = INT_MIN, max_ending_here = 0;

    for (int i = 0; i < size; i++)
    {
        max_ending_here = max_ending_here + a[i];
        if (max_so_far < max_ending_here)
            max_so_far = max_ending_here;

        if (max_ending_here < 0)
            max_ending_here = 0;
    }
    return max_so_far;
}
void solve()
{
int n,m,k;
cin>>n>>m>>k;
int a[n],b[m];
for(int i=0;i<n;i++)
    cin>>a[i];
for(int i=0;i<m;i++)
    cin>>b[i];
int dp1[n+1]={0};
int dp2[m+1]={0};
for(int i=1;i<=n;i++)
{
    dp1[i]=dp1[i-1]+a[i-1];
}
for(int i=1;i<=m;i++)
{
    dp2[i]=dp2[i-1]+b[i-1];
}
int ans=0;
for(int i=0;i<=n;i++)
{
    int x=k-dp1[i];
    if(x<0)
        break;
    int y=upper_bound(dp2,dp2+m+1,x)-dp2-1;
    ans=max(i+y,ans);
}
for(int i=0;i<=m;i++)
{
    int x=k-dp2[i];
    if(x<0)
        break;
    int y=upper_bound(dp1,dp1+n+1,x)-dp1-1;
    ans=max(i+y,ans);
}
cout<<ans<<endl;
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
}



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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    string x;

    cin >> n >> x;

    if(n & 1)
        cout << "No\n";
    else{
        bool ok = true;
        for(int i=0;i<n/2;++i)
            if(x[i] != x[n/2+i])
                ok = false;
        
        if(ok) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF 1e8
using namespace std;
int dx[]={0,1,1,0,-1,-1};
int dy[]={1,1,0,-1,-1,0};
bool table[150][150];
int d[150][150];
int turn;
void bfs(int x,int y){
    d[x][y] = 0;
    queue<pair<int,int> > que;
    que.push(pair<int,int>(x,y));
    while(!que.empty()){
		pair<int,int> p = que.front();
        que.pop();
        int x = p.first,y = p.second;
        if(d[x][y] == turn) break;
        rep(i,6){
            int nx = x+dx[i];
            int ny = y+dy[i];
            if(table[nx][ny] || d[nx][ny] != INF) continue;
            d[nx][ny] = d[x][y] + 1;
            que.push(pair<int,int>(nx,ny));
        }
    }
}
int main(){
    int block;
    while(cin >> turn >> block){
        if(turn == 0 && block == 0) break;
        rep(i,150){
            rep(j,150) {
                d[i][j] = INF;
                table[i][j] = 0;
            }
        }
        int x,y;
        rep(i,block){
            cin >> x >> y;
            table[x+70][y+70] = 1;
        }
        int sx,sy;
        cin >> sx >> sy;
        sx += 70; sy += 70;
        bfs(sx,sy);
        int ans = 0;
        rep(i,150){
            rep(j,150){
                if(d[i][j] != INF) ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3232
import java.util.*;
public class Main 
{

	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			double v = stdIn.nextDouble();
			int N = 2;
			while(true)
			{
				double velocity = 1.4 * Math.sqrt(10 * (5 * N - 5));
				if(velocity >= v)
				{
					System.out.println(N);
					break;
				}
				++N;
			}
		}
	}
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

vector<vi> G;
vi deg;
int dp[100005];

int main(){
  int n,m; cin>>n>>m;
  G.assign(n, vi());
  deg.assign(n, 0);
  rep(i,m){
    int x,y; cin>>x>>y;
    x--; y--;
    G[x].push_back(y);
    deg[y]++;
  }
  queue<int> que;
  rep(i,n){
    if(deg[i]==0) que.push(i);
  }
  
  while(!que.empty()){
    auto v=que.front(); que.pop();
    for(auto nv: G[v]){
      deg[nv]--;
      if(deg[nv]==0){
        que.push(nv);
        dp[nv]=dp[v]+1;
      }
    }
  }
  int ans=0;
  rep(i,n) chmax(ans,dp[i]);
  cout<<ans<<endl;
}
 

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int n, Ma, Mb, a[45], b[45], c[45], dp[45][410][410];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> Ma >> Mb;
    FOR(i,1,n) cin >> a[i] >> b[i] >> c[i];
    FOR(i,0,n)
        FOR(j,0,400)
            FOR(k,0,400) dp[i][j][k] = 1000000000;
    dp[0][0][0] = 0;
    FOR(i,1,n)
        FOR(j,0,400)
            FOR(k,0,400) {
                if (j + a[i] <= 400 && k + b[i] <= 400) dp[i][j+a[i]][k+b[i]] = min(dp[i][j+a[i]][k+b[i]], dp[i-1][j][k] + c[i]);
                dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k]);
            }
    int res = 1000000000;
    FOR(i,1,n)
        FOR(j,1,400)
            FOR(k,1,400)
                if (j*Mb == k*Ma) res = min(res, dp[i][j][k]);
    if (res == 1000000000) res = -1;
    cout << res;
    return 0;
}


Measured memory_bytes: 29056
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n){
        if(a[i] % 2 != 0 && i % 2 == 0){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
def solve(ss)
  g = Array.new(26){Array.new(26,false)}
  ss[0...-1].zip(ss[1..-1]).each{|a,b|
    if [a.size,b.size].min.times{|k|
        if a[k] != b[k]
          g[a[k].ord-'a'.ord][b[k].ord-'a'.ord] = true
          break
        end
      }
      return false if a.size > b.size
    end
  }
  26.times{|k|
    26.times{|i|
      26.times{|j|
        g[i][j] |= g[i][k]&&g[k][j]
      }
      return false if g[i][i]
    }
  }
end  
  
while (inp = gets) && inp.chomp != '0'
  ss = []
  n = inp.to_i
  n.times{ss << gets.chomp}
  puts solve(ss) ? 'yes' : 'no'
end

Measured memory_bytes: 6188
#include <stdio.h>
#include <stdlib.h>
#define alp(i) for (i = 'a'; i <= 'z'; i++)
#define rep(j) for (j = 0;; j++)

int main(void) {
    char string[1200];
    int char_arr[26] = {};
    char i;
    int j, k;
    while (fgets(string, sizeof(string), stdin) != NULL) {
        alp(i)
            rep(j) {
                if (string[j] == 0) break;
                if (string[j] == i || string[j] == (i - 32)) char_arr[i-97]++;
            }
    }
    for (k = 0; k < 26; k++) {
        printf("%c : %d\n", k+97, char_arr[k]);
    }
    return 0;
}


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

#include <iostream>
using namespace std;
int main() {
  uint64_t n, m;
  cin >> n >> m;
  vector<uint64_t> h(n);
  for (auto& hi : h) {
    cin >> hi;
  }
  vector<vector<uint64_t>> ab(m, vector<uint64_t>(2));
  vector<bool> is_good(n, true);
  for (auto& ab_i : ab) {
    cin >> ab_i[0] >> ab_i[1];
    if (h[ab_i[0] - 1] <= h[ab_i[1] - 1]) {
      is_good[ab_i[0] - 1] = false;
    }
    if (h[ab_i[1] - 1] <= h[ab_i[0] - 1]) {
      is_good[ab_i[1] - 1] = false;
    }
  }

  uint64_t cnt = 0;
  for (auto is_good_i : is_good) {
    if (is_good_i) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 9596
def main():
    # 下、右、上、左
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    H, W = map(int, input().split())
    s = ["." * (W + 2)]
    s += ["." + input() + "." for i in range(H)]
    s.append("." * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if "." == s[y][x]:
                continue
            if "#" == s[y + dy[0]][x + dx[0]]:
                continue
            if "#" == s[y + dy[1]][x + dx[1]]:
                continue
            if "#" == s[y + dy[2]][x + dx[2]]:
                continue
            if "#" == s[y + dy[3]][x + dx[3]]:
                continue
            print("No")
            return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true){
            double sum = 0.0, ave,x=0.0;
            int n = sc.nextInt();
            if(n == 0){
                break;
            }
            int a[] = new int[n];
            for(int i=0;i<n;i++){
                a[i] = sc.nextInt();
                sum += a[i];
            }
            ave = sum / n;
            for(int i=0;i<n;i++){
                x += Math.pow(a[i]-ave, 2);
            }
            x /= n;
            System.out.println(Math.sqrt(x));
        }
        sc.close();
    }
}


Measured memory_bytes: 31452
#include <bits/stdc++.h>
using namespace std;
class finite_field {
	const int md;
	const int sz;
	vector<int> fct, fnv;
	public :
		finite_field(
				const int md,
				const int init_factorial_size = 0
			) :
			md(md), sz(init_factorial_size),
			fct(sz), fnv(sz)
			{
				if (sz) {
					fct[0] = 1;
					for (int i = 1; i < sz; i++) fct[i] = prod(fct[i - 1], i);
					fnv[sz - 1] = inv(fct[sz - 1]);
					for (int i = sz - 1; i >= 1; i--) fnv[i - 1] = prod(fnv[i], i);
				}
			}
		inline void add (int& a, const int b) const {
			a += b;
			if (a >= md) a -= md;
		}
		inline void sub (int& a, const int b) const {
			a -= b;
			if (a < 0) a += md;
		}
		template<class... A> inline int sum (A... args) const {
			int ret = 0;
			for (int a : initializer_list<int>{args...}) {
				add(ret, a);
			}
			return ret;
		}
		inline int dif (int a, int b) const {
			sub(a, b);
			return a;
		}
		template<class... A> inline int prod (A... args) const {
			long long ret = 1;
			for (int a : initializer_list<int>{args...}) {
				ret *= a;
				ret %= md;
			}
			return (int)ret;
		}
		void mul (int& a, int b) const {
			a = prod(a, b);
		}
		inline int inv (int a) const {
			a %= md; if (a < 0) a += md;
			int b = md, u = 0, v = 1;
			while (a) {
				int t = b / a;
				b -= a * t; swap(a, b);
				u -= v * t; swap(u, v);
			}
			assert(b == 1);
			if(u < 0) u += md;
			return u;
		}
		inline int quat (int a, int b) const {
			return prod(a, inv(b));
		}
		void div (int& a, int b) const {
			a = quat(a, b);
		}
		inline int pow (int a, long long b) {
			int ret = 1;
			for (; b; b >>= 1) {
				if (b & 1) mul(ret, a);
				a = prod(a, a);
			}
			return ret;
		}
		inline int binom (int n, int k) const {
			assert(0 <= n && n < sz);
			if (k < 0 || n < k) return 0;
			return prod(fct[n], fnv[k], fnv[n - k]);
		}
};
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	int n, m; string s;
	cin >> n >> m >> s;
	finite_field fld(1e9 + 7);
	if (s == string(m, s[0])) {
		vector<int> dp(n + 1, 0);
		dp[1] = 1;
		for (int i = 2; i <= n; i++) {
			fld.add(dp[i], dp[i - 1]);
			fld.add(dp[i], dp[i - 2]);
		}
		int ret = 0;
		fld.add(ret, dp[n]);
		fld.add(ret, fld.prod(dp[n - 1], 2));
		cout << ret << endl;
		return 0;
	}
	if (n % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> seqs;
	int t = 0;
	for (int i = 0; i < m; i++) {
		if (s[i] == s[0]) {
			++t;
		} else {
			seqs.push_back(t);
			t = 0;
		}
	}
	int bound = seqs[0];
	if (!(bound & 1)) {
		++bound;
	}
	for (int it = 1; it < (int) seqs.size(); it++) {
		if (seqs[it] % 2 == 1) {
			bound = min(bound, seqs[it]);
		}
	}
	n /= 2;
	bound /= 2;
	int ret = 0;
	if (bound == 0) {
		ret = 1;
	} else {
		vector<int> dp(n + 1);
		dp[1] = 1;
		for (int i = 1; i < n; i++) {
			dp[i + 1] = fld.prod(2, dp[i]);
			if (i - bound - 1 >= 0) {
				fld.sub(dp[i + 1], dp[i - bound - 1]);
			}
		}
		for (int i = n - 1; i >= 0; i--) {
			fld.sub(dp[i + 1], dp[i]);
		}
		for (int i = n - 1 - bound; i < n; i++) {
			fld.add(ret, fld.prod(dp[i + 1], n - i));
		}
	}
	cout << fld.prod(2, ret) << endl;
	return 0;
}

Measured memory_bytes: 1484
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int ly[60], pt[60];
int f(int n, int x) {
	int r = 0;
	x--;
	if (x <= 0)return r;
	if (x < ly[n - 1])return r+f(n - 1, x);
	x -= ly[n - 1]; r += pt[n - 1];
	if (x <= 0)return r;
	x--; r++;
	if (x <= 0)return r;
	if (x < ly[n - 1])return r+f(n - 1, x);
	x -= ly[n - 1]; r += pt[n - 1];
	return r;
}
signed main() {
	int n, x; cin >> n >> x;
	ly[0] = 1; pt[0] = 1;
	for1(i, n) {
		ly[i] = ly[i - 1] * 2 + 3;
		pt[i] = pt[i - 1] * 2 + 1;
	}
	cout << f(n, x) << endl;
}

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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999
#define MOD            1000000007

typedef long long ll;

ll C[100050][32] = {};


int main()
{
	ll N, M;
	cin >> N >> M;

    C[0][0] = 1;
    for (int a = 1; a < 100050; a++) {
        C[a][0] = 1;
        for (int b = 1; b < 32; b++)
            C[a][b] = (C[a-1][b] + C[a-1][b-1]) % MOD;
    }

	ll ans = 1;

	ll cur = M;
	for(ll k = 2; k * k <= M; k++){
		int cnt = 0;
		while(cur % k == 0){
			cur /= k;
			cnt++;
		}

		if(cnt > 0){
			ans = (ans * C[N + cnt - 1][cnt]) % MOD;
		}
	}

	if(cur != 1){
		ans = (ans * N) % MOD;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 25216
w,h,n=map(int,input().split())
record=[]
xmin=[]
xmax=[]
ymin=[]
ymax=[]

for i in range(n):
    x,y,a=list(map(int,input().split()))
    record.append([x,y,a])
    
for i in range(n):
    if record[i][2] == 1:
        xmin.append(record[i][0])
    elif record[i][2] == 2:
        xmax.append(record[i][0])
    elif record[i][2] == 3:
        ymin.append(record[i][1])
    else:
        ymax.append(record[i][1])

if xmax==[] and xmin==[]:
    X=w
elif xmax==[]:
    X=w-max(xmin)
elif xmin==[]:
    X=min(xmax)-0
else:
    X=min(xmax)-max(xmin)

if ymax==[] and ymin==[]:
    Y=h
elif ymax==[]:
    Y=h-max(ymin)
elif ymin==[]:
    Y=min(ymax)-0
else:
    Y=min(ymax)-max(ymin)
    
print(X*Y) if (X > 0 and Y > 0) else print(0) 


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

const int N = 1e5+10;
const int INF = 1e9+7;
typedef pair<int,int> P;
#define l first
#define r second
P a[N];
int prefix[N], suffix[N], preL[N], preR[N], sufL[N], sufR[N];
int n;
int main() {
    scanf("%d", &n);
    int ans = 0;
    for (int i = 0; i < n; i++) scanf("%d%d", &a[i].l, &a[i].r);

    preL[0] = 0, preR[0] = INF;
    sufL[n] = 0, sufR[n] = INF;

    for (int i = 0; i < n; i++) {
        preL[i+1] = max(preL[i], a[i].l);
        preR[i+1] = min(preR[i], a[i].r);
    }
    for (int i = n-1; i >= 0; i--) {
        sufL[i] = max(sufL[i+1], a[i].l);
        sufR[i] = min(sufR[i+1], a[i].r);
    }

    for (int i = 0; i < n; i++) {
        int L = max(preL[i], sufL[i+1]);
        int R = min(preR[i], sufR[i+1]);
        int d = (R>=L?R-L+1:0);
        ans = max(ans, a[i].r-a[i].l+1+d);
    }




    sort(a,a+n,[](const P&p1, const P&p2) {
        return p1.r < p2.r || p1.r == p2.r && p1.l < p2.l;
    });
    sort(a+1, a+n);
    int L = 0, R = INF;
    for (int i = 0; i < n; i++) {
        L = max(L, a[i].l);
        R = min(R, a[i].r);
        if (L<=R)prefix[i] = R-L+1; else prefix[i] = 0;

    //    printf("prefix[%d]=%d\n", i, prefix[i]);
    }
    L = 0, R = INF;
    for (int i = n-1; i >= 0; i--) {
        L = max(L, a[i].l);
        R = min(R, a[i].r);
        if (L<=R)suffix[i] = R-L+1; else suffix[i] = 0;
     //   printf("suffix[%d]=%d\n", i, suffix[i]);
    }
    
    for (int i = 0; i + 1 < n; i++) {
        ans = max(ans, prefix[i]+suffix[i+1]);
    }
    printf("%d\n", ans);

}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) {

            var array = Console.ReadLine().Split(' ');
            var a = int.Parse(array[0]);
            var b = int.Parse(array[1]);

            if(a > b * 2) {

                Console.WriteLine(a - (b * 2));

            } else {

                Console.WriteLine(0);

            }

        }

        

    }
}


Measured memory_bytes: 27504
import java.io.*;
import java.util.*;

public class Main{

    static int cnt;
    static int m;
    static List<Integer> G=new ArrayList<>();
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	int n=Integer.parseInt(br.readLine());
	int a[]=new int[n];

	for(int i=0;i<n;i++){
	    a[i]=Integer.parseInt(br.readLine());
	}

	shellSort(a,n);

	System.out.println(m);

	for(int i=G.size()-1;i>=0;i--){
	    if(i==0)
		System.out.print(G.get(i));
	    else
		System.out.print(G.get(i)+" ");
	}

	System.out.println("\n"+cnt);
	
	for(int i=0;i<n;i++){
	    System.out.println(a[i]);
	}
    }
    
    static void shellSort(int a[],int n){
	cnt=0;
	
	for(int i=1;i<=n;i=3*i+1){
	    G.add(i);
	    m++;
	}
	
	for(int i=m-1;i>=0;i--){
	    insertionSort(a,n, G.get(i));
	}
    }
    
    static void insertionSort(int a[],int n,int g){
	for(int i=g;i<n;i++){
	    int v=a[i];
	    int j=i-g;
	    while(j>=0&&a[j]>v){
		a[j+g]=a[j];
		j=j-g;
		cnt++;
	    }
	    a[j+g]=v;
	}
    }
}



Measured memory_bytes: 106704
import java.util.Scanner;

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

		// 入力値の取得
		long N = sc.nextLong();
		
		StringBuilder sb = new StringBuilder();
		while (N > 0) {
			N = N - 1;
			long r = N % 26;
			sb.append((char)('a' + r));
			N = N / 26;
		}
		// 結果の出力
		System.out.println(sb.reverse().toString());
		
		sc.close();
	}
}


Measured memory_bytes: 27056
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
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 dp[N];
int inf=1e17;

struct line
{
	int m,c;
	line()
	{
		m=0;
		c=inf;
	}
	int getY(int x){
		return m*x+c;
	}
};

vector<line> bit(4*N);

void insert(int id,int l,int r,line nline)
{
	if(l==r)
	{
		if(bit[id].getY(l)>=nline.getY(l))
			bit[id]=nline;
		return;
	}
	int mid=(l+r)/2;
	if(nline.getY(l)<=bit[id].getY(l)&&nline.getY(mid)<=bit[id].getY(mid))
	{
		swap(bit[id],nline);
		insert(2*id+1,mid+1,r,nline);
	}
	else if(nline.getY(r)<=bit[id].getY(r)&&nline.getY(mid+1)<=bit[id].getY(mid+1))
	{
		swap(bit[id],nline);
		insert(2*id,l,mid,nline);
	}
	else if(nline.getY(l)>=bit[id].getY(l)&&nline.getY(mid)>=bit[id].getY(mid))
	{
		insert(2*id+1,mid+1,r,nline);
	}
	else if(nline.getY(r)>=bit[id].getY(r)&&nline.getY(mid+1)>=bit[id].getY(mid+1))
	{
		insert(2*id,l,mid,nline);
	}
	else
	{
	//	cout<<nline.m<<" "<<nline.c<<endl;
		return;
	}
}


int get(int id,int l,int r,int x)
{
	int y=bit[id].getY(x);
	if(l==r)
	{
		return y;
	}
	int mid=(l+r)/2;
	if(x<=mid)
		return min(y,get(2*id,l,mid,x));
	else
		return min(y,get(2*id+1,mid+1,r,x));
}

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

 int n,c;
 cin>>n>>c;
 int h[n+1];
 for(int i=1;i<=n;i++)
 {
 	cin>>h[i];
 }
 
 for(int i=1;i<=n;i++)
 {
 	if(i==1)
 		dp[i]=0;
 	else
 		dp[i]=c+h[i]*h[i]+get(1,1,1e6,h[i]);
 	line nline;
 	nline.m=-2*h[i];
 	nline.c=h[i]*h[i]+dp[i];
 	insert(1,1,1e6,nline);
 //	cout<<dp[i]<<endl;
 }
 cout<<dp[n];



}

/*
335136462
*/

Measured memory_bytes: 68944
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans=0;
    rep(i,3001){
        rep(j,3001){
            if(((n-r*i-g*j)%b==0) && (n>=r*i+g*j)){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	string o, e;
	cin >> o >> e;
	int num;

	string ans = "";
	for (int i = 0; i < e.length(); i++) {
		ans += o.at(i);
		ans += e.at(i);
	}
	if (e.length() < o.length()) {
		ans += o.at(o.length()-1);
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sim template < class c
#define ris return *this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", ", d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int N = 1e5 + 5;
vector<int> adj[N];
ll dp[N];

ll solve(int v) {
	if (dp[v] != -1) {
		return dp[v];
	}
	dp[v] = 0;
	for (auto it : adj[v]) {
		dp[v] = max(dp[v], 1 + solve(it));
	}
	return dp[v];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	int x, y;
	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		x--;
		y--;
		adj[x].push_back(y);
	}
	memset(dp, -1, sizeof(dp));
	ll answer = 0;
	for (int i = 0; i < n; i++) {
		answer = max(answer, solve(i));
	}
	cout << answer;
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i].second >> A[i].first;
  }
  sort(A.begin(), A.end());
  int time = 0;
  bool can = true;
  for (int i = 0; i< N; i++) {
    time += A[i].second;
    if (time > A[i].first) {
      can = false;
      break;
    }
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;
struct card{
    char suit,value;
};
void BubbleSort (struct card A[], int n){
    for (int i = 0; i < n; ++i){
        for (int j = n-1; j > i; --j){
            if (A[j].value < A[j-1].value)
                swap(A[j], A[j-1]);
        }
    }
}
void SelectionSort (struct card A[], int n){
    for (int i = 0; i < n; ++i){
        int minj = i;
        for (int j = i; j < n; ++j){
            if (A[j].value < A[minj].value)
                minj = j;
        }
        swap(A[minj], A[i]);
    }
}
int main()
{
    card c1[36];
    card c2[36];
    int n,flag;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> c1[i].suit >> c1[i].value;
    }
    for (int i = 0; i < n; ++i){
        c2[i].suit = c1[i].suit;
        c2[i].value = c1[i].value;
    }
    BubbleSort(c1, n);
    SelectionSort(c2, n);
    for (int i = 0; i < n; ++i){
        if (i == 0)
            cout << c1[i].suit << c1[i].value;
        else
            cout << " " << c1[i].suit << c1[i].value;
    }
    cout << endl;
    cout << "Stable" << endl;
    for (int i = 0; i < n; ++i){
        if (i == 0)
            cout << c2[i].suit << c2[i].value;
        else
            cout << " " << c2[i].suit << c2[i].value;
    }
    cout << endl;
    // 
    flag = 1;
    for (int i = 0; i < n; ++i){
        if (c1[i].suit != c2[i].suit){
            flag = 0;
        }
    }
    if (flag == 1)
        cout << "Stable" << endl;
    else
        cout << "Not stable" <<endl;
    return 0;
}



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

int N;
string W;
bool able = true;
map<string, int> term;


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

  cin >> W;                        //一番最初の単語を取得
  int len = W.size();       
  term[W] = 1;                //その単語が既出であること
  h = W[len-1];               //最初の単語の末尾を保存

  for(int i = 1; i < N; i++){
    cin >> W;
    len = W.size();
    if(h != W[0] || term[W] == 1) { able = false; break; }
    term[W] = 1;     //既出単語として登録
    h = W[len-1];    //次単語の頭について更新
   }

  if(able)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int a, b;
    scanf("%d %d", &a, &b);
    if(a % 2 == 0 || b % 2 == 0)
        printf("No\n");
    else
        printf("Yes\n");
	return 0;
}




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

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

Measured memory_bytes: 3620
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
using namespace std;

inline int getint(){
    int x = 0, c = getchar();
    while(c > 47 && c < 58){
        x = x * 10 + c - 48;
        c = getchar();
    }
    return x;
}

constexpr int MAX = 300001;
int res[MAX * 4];

int main(){
    int H = getint();
    int W = getint();
    int M = getint();

    int h, w, ans;
    int mxr = 0;
    int mxc = 0;
    int ctrow = 0;
    int ctcol = 0;
    for(int i = 0; i < M; ++i){
        h = getint(), w = getint();
        res[i + 2 * MAX] = h, res[i + 3 * MAX] = w;
        int x = ++res[h], y = ++res[w + MAX];

        if(x == mxr) ++ctrow;
        else if(x > mxr) mxr = x, ctrow = 1;

        if(y == mxc) ++ctcol;
        else if(y > mxc) mxc = y, ctcol = 1;
    }
    ans = mxr + mxc;

    long ct = ctrow;
    ct *= ctcol;
    if(ct > M){
        printf("%d\n", ans);
        return 0;
    }

    for(int i = 0; i < M; ++i) if(res[res[i + 2 * MAX]] == mxr && res[res[i + 3 * MAX] + MAX] == mxc) --ct;
    if(ct <= 0) --ans;
    printf("%d\n", ans);
}


Measured memory_bytes: 6256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	int n;cin>>n;
	int a[n];for(int i=0;i<n;i++)cin>>a[i];
	ll res=0;
	for(ll i=0;i<n-1;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			res+=a[i]*a[j];
		}
	}
	cout<<res;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int main()
{
	int h, w;
	cin >> h >> w;
	int m;
	cin >> m;
	vector<pair<int,int>> v1(h);
	vector<pair<int, int>> v2(w);
	map<pair<int, int>, int> mp;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		mp[{a, b}]++;
		v1[a].first++;
		v1[a].second = a;
		v2[b].first++;
		v2[b].second = b;
	}
	sort(v1.rbegin(), v1.rend(), [](pair<int, int> p1, pair<int, int> p2) {return p1.first < p2.first; });
	sort(v2.rbegin(), v2.rend(), [](pair<int, int> p1, pair<int, int> p2) {return p1.first < p2.first; });
	int mx1 = v1[0].first, mx2 = v2[0].first;
	vector<pair<int, int>> temp1, temp2;
	for (auto p : v1) if (p.first == mx1) temp1.push_back(p);
	for (auto p : v2)  if (p.first == mx2) temp2.push_back(p);
	int dis = -1;
	for (auto e1 : temp1) {
		for (auto e2 : temp2) {
			if (mp[{e1.second, e2.second}] == 0) dis = 0;
			if (dis == 0) break;
		}
		if (dis == 0) break;
	}
	
	
	
	cout << v1[0].first + v2[0].first + dis;

}


Measured memory_bytes: 34956
#-*- using:utf-8 -*-

x1,x2,x3,x4,x5 = input().split(' ')
if(int(x1) == 0):
    print("1")
elif(int(x2) == 0):
    print("2")
elif(int(x3) == 0):
    print("3")
elif(int(x4) == 0):
    print("4")
elif(int(x5) == 0):
    print("5")

Measured memory_bytes: 9184
#include <stdio.h>

int main(void){
    long int N,S=0;
    long int Aar[200000],cou[200000];
    scanf("%ld",&N);
    int i;
    for(i=0;i<N;i++){
        scanf("%ld",&Aar[i]);
    }
    for(i=0;i<N;i++){
        cou[i]=0;
    }
    for(i=0;i<N;i++){
        cou[Aar[i]-1] ++;
    }
    /*for(i=0;i<N;i++){
        printf("%lld",cou[i]);
    }*/
    for(i=0;i<N;i++){
        if(cou[i]!=0) S+=cou[i]*(cou[i]-1)/2;
    }
    /*printf("%lld",S);*/
    long int temp1,temp2;
    for(i=0;i<N;i++){
        if(cou[Aar[i]-1]>=2){
            temp1=cou[Aar[i]-1];
            temp2=S-temp1*(temp1-1)/2+(temp1-1)*(temp1-2)/2;
        }
        else{
            temp2=S;
        }
        printf("%ld\n",temp2);
    }

    return 0;
}

Measured memory_bytes: 5632
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(bf.readLine());
    String[] list = bf.readLine().split(" ");

    float sum = 0;
    for (String s : list){
      sum = sum + Integer.parseInt(s);
    }

    int num = Math.round(sum / n);

    int ans = 0;

    for (String s : list){
      ans = ans + (Integer.parseInt(s) - num) * (Integer.parseInt(s) - num);
    }
    System.out.println(ans);
    bf.close();
  }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int sum=a+b;
  if(sum%2 != 0){
    int c=sum%2;
    sum /= 2;
    sum += c;
  }else{
    sum /= 2;
  }
  cout<<sum<<endl;
}


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

typedef long long ll;

const int MAXN = 3002;

ll dp[MAXN][MAXN];
bool vis[MAXN][MAXN];
int A[MAXN],N;

ll solve(int i,int j){

	if(vis[i][j]) return dp[i][j];

	vis[i][j] = 1;

	if(i == j) return dp[i][j] = A[i];

	return dp[i][j] = max(A[i] - solve(i+1,j), A[j] - solve(i,j-1));

}

int main(){

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

	cout << solve(1,N) << endl;

	return 0;

}

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

const int N = 2000;
int a[2 * N], cost[N];

int main() {
    int n; cin >> n;
    int rotCost; cin >> rotCost;
    for (int i = 0; i < n; ++i) cin >> a[i], a[n + i] = cost[i] = a[i];
    long long best = accumulate(cost, cost + n, 0LL);
    for (int rot = 1; rot < n; ++rot) {
        for (int i = 0; i < n; ++i) cost[i] = min(cost[i], a[rot + i]);
        best = min(best, accumulate(cost, cost + n, 0LL) + 1LL * rot * rotCost);
    }
    cout << best << '\n';
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = []
for _ in range(n):
    a,b=map(int,input().split())
    p.append([b,a])
p.sort()
p = [t[::-1] for t in p]
t = 0
for i in range(n):
    t += p[i][0]
    if t > p[i][1]:
        print ('No')
        exit(0)
print ('Yes')

Measured memory_bytes: 55332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());

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

    set<char> t;
  for (char i = 0; i < S.size(); i++) {
    if (t.count(S[i])) {
      cout << "no" << endl;
      return 0;
    }else{
      t.insert(S[i]);
    }
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

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

    ll h, w;
    in >> h >> w;
    string a[h];
    REP(i, h){
        in >> a[i];
    }
    ll b[h][w] = {};
    b[0][0] = 1;
    queue<pair<ll, ll> > q;
    q.push(pair<ll, ll>(0, 0));
    while(!q.empty()){
        ll y = q.front().first;
        ll x = q.front().second;
        q.pop();
        if(y + 1 < h && a[y+1][x] == '.'){
            if(b[y+1][x] == 0) q.push(pair<ll, ll>(y+1, x));
            b[y+1][x] += b[y][x];
            b[y+1][x] %= MOD;
        }
        if(x + 1 < w && a[y][x+1] == '.'){
            if(b[y][x+1] == 0) q.push(pair<ll, ll>(y, x+1));
            b[y][x+1] += b[y][x];
            b[y][x+1] %= MOD;
        }
    }
    out << b[h-1][w-1] << endl;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  int n;
  int v[50], c[50];
  cin >> n;
  REP(i, n)cin >> v[i];
  REP(i, n)cin >> c[i];
  int ans = 0;
  REP(i, n) if (v[i] > c[i]) ans += v[i] - c[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

using P = pair<ll, int>;

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N, M;
  while (cin >> N >> M) {
    vector<P> P(N);
    for (int i = 0; i < N; i++) cin >> P[i].fst >> P[i].snd;
    sort(P.begin(), P.end());
    ll res = 0;
    for (auto& p : P) {
      ll buy = min(p.snd, M);
      res += buy * p.fst;
      M -= buy;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
import java. util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int[][][] bingo = new int[3][3][2];

		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				bingo[i][j][0] = scan.nextInt();
			}
		}

		int n = scan.nextInt();
		int[] b = new int[n];

		for(int i=0;i<n;i++) {
			b[i] = scan.nextInt();
		}

		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				for(int k=0;k<n;k++) {
					if(b[k]==bingo[i][j][0]) {
						bingo[i][j][1] = 1;
					}
				}
			}
		}

		isSameI(bingo);
		isSameJ(bingo);
		isSameR(bingo);
		isSameL(bingo);

		if(isSameI(bingo)||isSameJ(bingo)||isSameR(bingo)||isSameL(bingo)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}



	}

	public static boolean isSameI(int[][][] b) {
		boolean result = false;
		for(int i=0;i<3;i++) {
			if(b[i][0][1]==1&&b[i][1][1]==1&&b[i][2][1]==1) {
				result = true;
			}
		}
		return result;
	}

	public static boolean isSameJ(int[][][] b) {
		boolean result = false;
		for(int i=0;i<3;i++) {
			if(b[0][i][1]==1&&b[1][i][1]==1&&b[2][i][1]==1) {
				result = true;
			}
		}
		return result;
	}


	public static boolean isSameR(int[][][] b) {
		boolean result = false;
		if(b[0][0][1]==1&&b[1][1][1]==1&&b[2][2][1]==1) {
			result = true;
		}
		return result;
	}

	public static boolean isSameL(int[][][] b) {
		boolean result = false;
		if(b[0][2][1]==1&&b[1][1][1]==1&&b[2][0][1]==1) {
			result = true;
		}
		return result;
	}

}


Measured memory_bytes: 22868
#include<stdio.h>
int main(){
  long long n,count=0,i;
  scanf("%lld",&n);
  if(n%2!=0)
    printf("0\n");
  else{
    while(n/10!=0){
      n/=10;
      count+=n;
      i=n;
      while(i!=0){
        count=count+i/5-i/10;
        i/=5;
      }
    }
    printf("%lld\n",count);
  }
  return 0;
}


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

using namespace std;

int main(){
    int hei, wid, h, w;
    cin >> hei >> wid >> h >> w;
    if(hei%h == 0 && wid%w == 0){
        cout << "No";
    }
    else{
        cout << "Yes" << endl;
        //max 1000000000
        long long x = 999999999/(h*w-1);
        long long y = x*(h*w-1)+1;
        for(int one = 1; one <= hei; one++){
            for(int two = 1; two <= wid; two++){
                if(one%h == 0 && two%w == 0){
                    cout << -y << ' ';
                }
                else{
                    cout << x << ' ';
                }
            }
            cout << endl;
        }
    }
}

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

using namespace std;
int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<long double> suger;
    vector<long double> water;
    for (int i = 0; i * a <= f; i += 100) {
        for (int j = 0; j * b <= f; j += 100) {
            if (i * a + j * b > f)break;
            water.push_back(i * a + j * b);
        }
    }
    for (int i = 0; i * c <= f; i++) {
        for (int j = 0; j * d <= f; j++) {
            if (i * c + j * d > f)break;
            suger.push_back(i * c + j * d);
        }
    }
    long double ma = -1;
    int ansW;
    int ansS;
    for (auto w:water) {
        for (auto s:suger) {
            if (w + s <= f && w / 100 * e >= s) {
                if (ma < s / (w + s)) {
                    ma = s / (w + s);
                    ansW = w + s;
                    ansS = s;
                }
            }
        }
    }
    cout << ansW << " " << ansS << endl;
    return 0;
}

Measured memory_bytes: 7252
program main
  implicit none
  
  integer :: n,i,j
  
  read(*,*)n
  
  do i = 1, 9
    do j = i, 9
      if (n == i*j) then
        write(*,*)'Yes'
        stop
      endif
    end do
  end do
  write(*,*)'No'
end program main


Measured memory_bytes: 512
fun main(args:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    var div = 1
    var po = 0
    for(i in 1..n) {
        if(i >= k) {
            po += div
            continue
        }
        var mul = 0
        var tmp = i
        for(j in 1..k) {
            if(tmp >= k) {
                break
            }
            mul++
            tmp *= 2
        }
        var newDiv = Math.pow(2.toDouble(), mul.toDouble()).toInt()
        if(newDiv < div) {
            po += (div/newDiv)
        } else {
            po+=div
            div = newDiv * div
        }
    }
    print(po.toDouble()/(div*n))
}


Measured memory_bytes: 36000
from itertools import product
 
 
def main():
    N = int(input())
    testimonies = []
    for _ in range(N):
        a = int(input())
        xy = []
        for _ in range(a):
            xy.append(list(map(int, input().split(" "))))
        testimonies.append(xy)
 
    assumptions = product([0, 1], repeat=N)
    assumptions = sorted(assumptions, key=lambda x: x.count(0))
    for assumption in assumptions:
        for i in range(N):
            if assumption[i]:
                for testimony in testimonies[i]:
                    if not assumption[testimony[0] - 1] == testimony[1]:
                        break
                else:
                    continue
                break
        else:
            print(assumption.count(1))
            break
        continue
 
 
if __name__ == '__main__':
    main()
from itertools import product


def main():
    N = int(input())
    testimonies = []
    for _ in range(N):
        a = int(input())
        xy = []
        for _ in range(a):
            xy.append(list(map(int, input().split(" "))))
        testimonies.append(xy)

Measured memory_bytes: 9460
#!/usr/bin/env python
"""A - Product
https://atcoder.jp/contests/abc086/tasks/abc086_a
"""

__author__ = 'bugttle <bugttle@gmail.com>'


def is_even(num):
    return num % 2 == 0


def main():
    a, b = map(int, input().split())
    if is_even(a * b):
        print('Even')
    else:
        print('Odd')


if __name__ == '__main__':
    main()


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

def prime_pair(n):
    pairs = {}
    tmp = n
    for i in range(2, n):
        if i * i > n:
            break
        if tmp % i != 0:
            continue
        ex = 0
        while tmp % i == 0:
            ex += 1
            tmp /= i
        pairs[i] = ex
    if tmp != 1:
        pairs[int(tmp)] = 1
    return pairs

pp_n = prime_pair(N)
res = 0
for k in pp_n.keys():
    val = pp_n[k]
    power = 1
    while val >= power:
        val -= power
        power += 1
        res += 1

print(res)


Measured memory_bytes: 9276
#include<iostream>
using namespace std;
char map[256];
int main(){
  while(true){
    for(int i = 0;i < 256;i++){
      map[i] = i;
    }
    int n;
    
    cin >> n;
    if(n==0)break;
    for(int i = 0; i < n;i ++){
      char c,d;
      cin >> c >> d;
      map[c] = d;
    }

    cin >> n;
    
    for(int i = 0;i < n;i++){
      char c;
      cin >> c;
      cout << map[c];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152