akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;
const int X = 1e5 + 7;

int h, w, a, b, e[X], res;

int pw(int x, int y){
    if (y == 0) return 1;
    int res = pw(x, y / 2);
    if (y & 1)
        return (((1LL * res * res) % MOD) * x) % MOD;
    return (1LL * res * res) % MOD;
}

int C(int k, int n){
    int res = 1;
    for (int i = 1; i <= k; i++, n--)
        res = (1LL * (1LL * res * n) % MOD * pw(i, MOD - 2)) % MOD;
    return res;
}

inline void Calc(int &cur, int x, int y){
//    cerr << cur << '*' << x << '/' << y << " = ";
    cur = (1LL * cur * x) % MOD;
    cur = (1LL * cur * pw(y, MOD - 2)) % MOD;
//    cerr << cur << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> h >> w >> a >> b;
    e[0] = 1;
    for (int i = 1; i <= 100000; i++)
        e[i] = (1LL * e[i - 1] * i) % MOD;
    int k = h - a - 1;
    int n = k + b - 1;
    int K = a - 1;
    int N = K + w - b;
    int Up = C(k, n);
    int Down = C(K, N);
//    cerr << Up << ' ' << Down << endl;
    for (int i = b + 1; i <= w; i++){
        n++;
        Calc(Up, n, n - k);
        Calc(Down, N - K, N);
        N--;
//        cerr << Up << ' ' << Down << ' ' << n << ' ' << k << ' ' << N << ' ' << K << endl;
        res = (res + 1LL * Up * Down) % MOD;
    }
    cout << res;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();

        if (n % 2 == 0 && s.Substring(0, n / 2) == s.Substring(n / 2))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include<cctype>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    string ans;
    ans.push_back(s1[0]);
    ans.push_back(s2[0]);
    ans.push_back(s3[0]);
    transform(ans.begin(), ans.end(), ans.begin(), ::toupper);
    cout << ans << endl;
    // cout << (char)(s1[0]-0x20) << (char)(s2[0]-0x20) << (char)(s3[0]-0x20) << endl;
}


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

using namespace std;

void solve(vector<vector<int> >& data, vector<int>& ans){
  int i, k;
  vector<int>::iterator it, jt, j;
  for(i=0; i<data.size(); ++i){
    for(j=data[i].begin(), k=0; j!=data[i].end(); ++j, ++k){
      it = find(data[i].begin(), data[i].end(), *j);
      if(it != j) continue;
      //      cout<< "here"<<endl;
      jt = find(it+1, data[i].end(), *j);
      if(jt != data[i].end()) continue;
      //      cout<< "here2"<<endl;
      ans[k] += *j;
    }
  }
}

int main(){
  int x, n;
  cin >> n;
  const vector<int> _data; // empty
  vector<vector<int> > data(3, _data);
  vector<int> ans(n, 0); // init
  for(int i=0; i<n; ++i){
    for(int j=0; j<3; ++j){
      cin >> x;
      data[j].push_back(x);
    }
  }
  solve(data, ans);
  for(int i=0; i<ans.size(); ++i){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int Vmax = 200000;

vector<int> to[Vmax];
vector<int> ans;

void dfs(int v, int parent = -1) {
    for(int u : to[v]) {
        if(u == parent) {
            continue;
        }
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    ans.resize(n);

    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    dfs(0);

    rep(i, n) {
        cout << ans[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

const int bound = 100010;

struct edge{
	int to;
	int cost;
};

vector<vector<edge>> graph(bound);
vector<int> dist(bound);

bool flag[bound];

int main(){
	fill( dist.begin(), dist.end(), INF );
	int k; cin >> k;
	for( int i = 1; i < k; ++i ){
		edge temp;
		temp.to = (i+1)%k; temp.cost = 1;
		graph[i%k].push_back(temp);
		temp.to = (i*10)%k; temp.cost = 0;
		graph[i%k].push_back(temp);
	}
	priority_queue< pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > q;
	q.emplace(1, 1);
	int ans = 0;
	int cnt = 0;
	while( cnt <= k && !q.empty() ){
		int s = q.top().first;
		int punkt = q.top().second;
		q.pop();
		if( flag[punkt] ) continue;
		++cnt;
		flag[punkt] = true;
		dist[(punkt)%k] = s;
		for( auto nextp : graph[punkt] ){
			if( dist[(nextp.to)%k] <= s+nextp.cost ) continue;
			q.emplace( s+nextp.cost, nextp.to );
		}	
	}
	cout << dist[0] << endl;
	return 0;
}

Measured memory_bytes: 6780
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

void solve(){
    int n;
    cin >> n;
    set <int> s;
    while(n--){
        int x;
        cin >> x;
        s.insert(x);
    }
    cout << s.size();
}

int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

    if (a == 'H' && b == 'H') {
        puts("H");
    } else if (a == 'H' && b == 'D') {
        puts("D");
    } else if (a == 'D' && b == 'H') {
        puts("D");
    } else if (a == 'D' && b == 'D') {
        puts("H");
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  int P[N];
  for (int i = 0; i<N; i++) {
    cin >> P[i];
  }
  int ans = 0;
  int M[N];
  M[0] = P[0];
  for (int i = 1; i < N; i++) {
    M[i] = min(M[i - 1],P[i]);
  }
  for (int i = 0; i < N; i++) {
    if (M[i] == P[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {

  int n, k;
  cin >> n >> k;
  int ans = 0;
  for(int i = 0; i < 10e10; i++) {
    if(n > 0) {
      n = n / k;
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
}

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

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

    int tsuru, kame;
    int flag=0, sum;
    for(int i=0; i<=X; i++){
        tsuru=i;
        kame=X-i;

        sum=tsuru*2 + kame*4;
        if(sum == Y) flag=1;
    }

    if(flag == 0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3556
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

n, r = inm()
print(r if n >= 10 else r + 100 * (10 - n))

Measured memory_bytes: 9128
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N;
    cin>>N;
    ll ans=mod_pow(10,N,MOD);
    ans-=(2*mod_pow(9,N,MOD))%MOD;
    ans%=MOD;
    while(ans<0) ans+=MOD;
    ans+=mod_pow(8,N,MOD);
    ans%=MOD;
    while(ans<0) ans+=MOD;
    cout<<ans<<endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();
const long double EPS =1e-9;

int main() {

    int N,X,Y; cin >> N >> X>>Y;
    int  res[N][N];

    vector<vector<int>> G(N);
    for (int i = 0; i < N-1; ++i) {
        G[i+1].push_back(i);
        G[i].push_back(i+1);
    }

    G[X-1].push_back(Y-1);
    G[Y-1].push_back(X);
    
    REP(t,N){

    
    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[t] = 0;
    que.push(t); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    for (int v = 0; v < N; ++v) res[t][v]=dist[v];
     
    }
  
  int ans[N];REP(i,N)ans[i]=0;
  
  REP(i,N)FOR(j,i+1,N){
    ans[res[i][j]]++;
  }
  FOR(i,1,N)cout<<ans[i]<<endl;
}



Measured memory_bytes: 16000
N,A,B=map(int,input().split())

ans=0
count=0
for n in range(N+1):
  d_sum=0
  count=n
  while n>=1:
    d_sum=d_sum+n%10
    n=n//10
  if A <= d_sum <= B:
    ans=ans+count
    
print(ans)



Measured memory_bytes: 2940
#include<stdio.h>

int main()
{
  int i,j,N,Q,M,date,max,ii;
  int Date[101];

  while(1){
    scanf("%d%d",&N,&Q);
    if(N==0&&Q==0)break;
    for(i=0;i<101;i++)Date[i]=0;
    for(i=0;i<N;i++){
      scanf("%d",&M);
      for(j=0;j<M;j++){
	scanf("%d",&date);
        Date[date]++;
      }
    }
    max=Date[0];
    for(i=1;i<101;i++){
      if(max<Date[i]){
        max=Date[i];
	ii=i;
      }
    }
    if(max>=Q)printf("%d\n",ii);
    else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef vector<vector<ll> > matrix;
const int mod = 1e9+7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
        base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}

double pi = 3.141592653589793238462643;
double error = 0.0000001;
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/* -------Template ends here-------- */

const int M = 100001;

int mat[111][111] , color[111][111];
set<pair<int , int> > se;
int h, w;
bool inside(int x , int y){
    if(x >= 1 && x <= h && y >= 1 && y <= w) return 1;
    return 0;
}
int lef;

void dfs(int x , int y , int col){
    if(lef == 0) return;
    color[x][y] = col;
    cout<<x<<"  "<<y<<"  "<<col<<"  "<<lef<<endl;
    lef--;
    se.erase(make_pair(x , y));
    if(lef == 0) return;
    for(int i = 0 ; i < 4 ; i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(inside(nx , ny) && color[nx][ny] == 0){
            dfs(nx , ny , col);
        }
    }
}
int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    //cin.sync_with_stdio(false);
    //cin.tie(0); cout.tie(0);

    int   n;

    cin >> h >> w >> n;

    int ro = 1 , side = 0;


    int stx = 1 , sty = 1;

    for(int i = 1 ; i <= n ; i++){
        int sq;
        si(sq);
        while(sq){
            color[stx][sty] = i;
            sq--;
            if(stx%2 == 1){
                if(sty == w){
                    stx++;
                }
                else{
                    sty++;
                }
            }
            else{
                if(sty == 1){
                    stx++;
                }
                else{
                    sty--;
                }
            }
        }
    }

    for(int i = 1 ; i <= h ; i++){
        for(int j = 1 ; j <= w ; j++){
            cout<<color[i][j]<<" ";
        }
        cout<<endl;
    }

















}














Measured memory_bytes: 384
import java.util.Scanner;
     
    class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int N = sc.nextInt();
            int count = 0;
            int[] A = new int[N];
            boolean isOdd = false;
     
            for( int i = 0; i < N; i++){
                A[i] = sc.nextInt();
            }
     
            while( isOdd == false ){
                for( int i = 0; i < N; i++){
                    if ( A[i] % 2 != 0 ){
                        isOdd = true;
                    }
                }
                if( isOdd == true ){
                    break;
                }
     
                for( int i = 0; i < N; i++){
                    A[i] /= 2;
                }
                count++;
            }     
            System.out.println(count);
        }
    }

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int>a(n),b(n);
    for(int i=0; i<n; i++)
    {
        cin >> a[i] >> b[i];
    }
    int ok = 0;
    for(int i=0; i<=n-3 && !ok; i++)
    {
        if(a[i]==b[i] && a[i+1]==b[i+1] && a[i+2]==b[i+2])ok=1;
    }
    if(ok)cout <<"Yes\n";
    else cout <<"No\n";
}


Measured memory_bytes: 3628
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}

std::string S;
int64_t dp[200][10][2];
int func(int i, int k, int over = false) {
    if (k < 0) { return 0; }
    if (i == S.size()) {
        return k == 0 ? 1 : 0;
    }
    auto& memo = dp[i][k][over?1:0];
    if (memo != -1) {
        return memo;
    }

    memo = func(i+1,k,over||S[i] !='0');
    for (int v = 1; v < 10; v++)
    {
        if (!over && v >= S[i] - '0') {
            if (S[i] - '0' > 0) {
                memo += func(i + 1, k - 1, false);
            }
            break;
        }
        memo += func(i + 1, k-1, true);
    }
    return memo;
}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    int K;
    in >> S >> K;
    fill_all(dp, -1);
    out << func(0, K) << endl;

    return 0;
}
#endif


#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
std::vector<int> vec;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (size_t i = 0; i < N; i++)
    {
        int a;
        in >> a;
        vec.push_back(a);
    }
    std::sort(all_range(vec));
    auto iter = std::unique(all_range(vec));
    if (iter != vec.end()) {
        out << "NO" << endl;
    }
    else {
        out << "YES" << endl;
    }

    return 0;
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>

using namespace std;

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

  int a, b;
  cin >> a >> b;

  int ans = a + b;
  ans = max(ans, (a - b));
  ans = max(ans, (a * b));

  cout << ans << endl;
}

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

ll n , w;
vector<pair<ll, ll>> v;

ll solve(vector<pair<ll, ll>> &arr)
{
   ll dp[n+1][w+1];

    for(ll i = 0; i < n + 1; i++)
        dp[i][0] = 0;
    for(ll i = 1; i < w + 1; i++)
        dp[0][i] = 0;

    for(ll i = 1; i< n+1; i++)
    {    for(ll j = 1; j < w+1; j++){
                if(arr[i-1].first > j)
                    dp[i][j] = dp[i-1][j];
                else
                    dp[i][j] = max(dp[i-1][j], dp[i-1][j- arr[i-1].first] + arr[i-1].second);
            }
    }
    return dp[n][w];


}



int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cin>> n>> w;

    ll a, b;
    for(ll i = 0; i< n; i++)
    {
        cin>>a;
        cin>>b;
        v.push_back({a, b});
    }
   

   cout<<solve(v)<<endl;


    return 0;
}


Measured memory_bytes: 82368
import heapq

N, M = map(int,input().split())

V = N
G = [[] for _ in range(V)]    #[[to, cost], [], ...]
s = 0

INF = float('inf')

for i in range(V-1):
    G[i+1].append([i, 0])

for _ in range(M):
    l, r, c = map(int,input().split())
    G[l-1].append([r-1, c])

def dijkstra(s):			#始点sからの最短距離のリストを返す
    d = [INF for _ in range(V)]
    d[s] = 0
    que = []
    heapq.heappush(que, (0, s))
    
    while len(que) != 0:
        p = heapq.heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for i in range(len(G[v])):
            e = G[v][i]
            if d[e[0]] > d[v] + e[1]:
                d[e[0]] = d[v] + e[1]
                heapq.heappush(que, (d[e[0]], e[0]))

    return d

L = dijkstra(s)

ans = -1 if L[N-1] == INF else L[N-1]

print(ans)

Measured memory_bytes: 51176
/*
B - Maximum Sum

Time limit : 2sec / Memory limit : 256MB
Score: 200 points
Problem Statement
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:
Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard after K operations?
Constraints
A,B and C are integers between 1 and 50 (inclusive).
K is an integer between 1 and 10 (inclusive).

Input
Input is given from Standard Input in the following format:
A B C
K
Output
Print the largest possible sum of the integers written on the blackboard after K operations by E869220.

Sample Input 1
Copy
5 3 11
1
Sample Output 1
Copy
30
In this sample, 5,3,11 are initially written on the blackboard, and E869120 can perform the operation once.
There are three choices: 
Double 5: The integers written on the board after the operation are 10,3,11.
Double 3: The integers written on the board after the operation are 5,6,11.
Double 11: The integers written on the board after the operation are 5,3,22.
If he chooses 3., the sum of the integers written on the board afterwards is 5+3+22=30, which is the largest among 1. through 3. 

Sample Input 2
Copy
3 3 4
2
Sample Output 2
Copy
22
E869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows: 
First, double 4. The integers written on the board are now 3,3,8. 
Next, double 8. The integers written on the board are now 3,3,16. 
Then, the sum of the integers eventually written on the blackboard is 3+3+16=22.*/

#include<iostream>
#include<cmath>
using namespace std;

int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	long long k;
	cin>>k;
	long long maxn=max(a,max(b,c));
	long long sum=a+b+c-maxn;
	for(int i=1;i<=k;++i)
		maxn=maxn<<1;
	cout<<sum+maxn<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]

res={}

for i in s:
    res[i] = res.get(i, 0) + 1

for i in t:
    res[i] = res.get(i, 0) - 1

print(max(max(res.values()), 0))

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

A_sort = sorted(A)
before = A_sort[0]
num = 1
jisho = {}
for i in range(1,N):
    if before == A_sort[i]:
        num += 1
    else:
        jisho[before] = num
        num = 1
        before = A_sort[i]
jisho[before] = num

total = 0
for v in jisho.values():
    total += ((v)*(v-1))//2

for i in range(N):
    n = jisho[A[i]]
    print(total-n+1)

Measured memory_bytes: 26140
#include<iostream>
#include<cstdio>

const int MAXN=105;

int H,W;
int N;
int seq[MAXN*MAXN],scnt;

int main()
{
	int i,j,x;
	scanf("%d%d%d",&H,&W,&N);
	for(i=1;i<=N;i++)
	{
		scanf("%d",&x);
		for(j=1;j<=x;j++) seq[++scnt]=i;
	}
	for(i=1;i<=H;i++)
	{
		if(i%2) for(j=(i-1)*W+1;j<=i*W;j++)
				printf("%d ",seq[j]);
		else for(j=(i*W);j>=(i-1)*W+1;j--)
			printf("%d ",seq[j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r, d, sib;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];
int H[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", u, T[u].p, T[u].sib, T[u].d, D[u], H[u]);

  if(T[u].p == NIL) printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL) printf("leaf\n");
  else printf("internal node\n");
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l != NIL) calcDepth(T[u].l ,p + 1);
  if(T[u].r != NIL) calcDepth(T[u].r ,p + 1);
}


int calcHeight(int u){
  int hl = 0, hr = 0;

  if(T[u].l != NIL) hl = calcHeight(T[u].l) + 1;
  if(T[u].r != NIL) hr = calcHeight(T[u].r) + 1;

  if(hl > hr){
    H[u] = hl;
    return hl;
  }
  else{
    H[u] = hr;
    return hr;
  }
}

int main(){
  int i, j, k;
  int n;
  int id, child, sib;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    T[i].p = T[i].l = T[i].r = T[i].sib = NIL;
    T[i].d = 0;
  }

  for(i=0; i<n; i++){
    scanf("%d", &id);
    for(j = 0, sib = NIL; j<2; j++){ //子を入力する (input children)                                                                                       
      scanf("%d", &child);
      if(child == -1)
        continue;
      else{
        T[child].p = id;
        if(j == 0){
          T[id].l = child;
          sib = child;
        }
        else{
          T[id].r = child;
          T[child].sib = sib;
          if(sib != NIL)
            T[sib].sib = child;
        }
        T[id].d++;
      }
    }
  }

  //根を求める (find the root)                                                                                                                             
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)                                                                                               
  calcDepth(root, 0);

  //高さを求める                                                                                                                                           
  calcHeight(root);

  //出力 (output)                                                                                                                                          
  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int ans = 0, b = 0, ab = 0, a = 0;
    int n;
    cin >> n;
    for (int _ = 0; _ < n; _++) {
        string s;
        cin >> s;
        if (s[0] == 'B' && s.back() == 'A') {
            ab++;
        } else if (s[0] == 'B') {
            b++;
        } else if (s.back() == 'A'){
            a++;
        }
        for (int i = 0; i < sz(s) - 1; i++) {
            if (s[i] == 'A' && s[i + 1] == 'B') {
                ans++;
            }
        }
    }
    if (ab > 0) {
        ans += ab - 1;
        if (b > 0) {
            ans++;
            b--;
        }
        if (a > 0) {
            ans++;
            a--;
        }
    }
    ans += min(a, b);
    cout << ans << "\n";
}
    


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

int main() {
  int N,M,K;
  cin>>N>>M>>K;
  bool frag=false;
  rep(k, N+1) {
    rep(l, M+1) {
      int tmp=(N-k)*l+(M-l)*k;
      if (tmp==K) frag=true;
    }
  }
  if (frag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define endl            "\n"
#define pb              push_back
#define ppb              pop_back
#define mp              make_pair
#define pii             pair<int, int>
#define vi              vector<int>
#define all(x)          (x).begin(), (x).end()
#define mii             map<int, int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed << setprecision(y) << x
#define mk(arr,n,type)  type *arr = new type[n];
#define w(x)            int x; cin >> x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
inline int ceili(int x, int y) { return (x + y - 1) / y; }
 
void solve()
{
    int d, t, s; cin >> d >> t >> s;

    if(d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
}
 
int32_t main()
{
    FIO;
 
    solve();
 
    return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; ++i){
    cin >> h[i];
  }
  int cnt = 0;
  for(int i = 0; i < N; ++i){
    if(h[i] >= K) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
using System;
using System.Linq;
public class Program {
  public static void Main() {
    string S = Console.ReadLine();
    long K = long.Parse(Console.ReadLine());
    if (S[0] != '1') {
      Console.WriteLine(S[0]);
    } else if (K <= 100 && K <= S.Length && S.ToArray().Take((int)K).Count(x => x != '1') == 0) {
      Console.WriteLine(1);
    } else {
      S = S.Replace("1", "");
      if (S.Length == 0) {
        Console.WriteLine(1);
      } else {
        Console.WriteLine(S[0]);
      }
    }
  }
}


Measured memory_bytes: 13268
mod=10**9+7
def f(a):
    c=0
    for i in range(len(a)):
        c+=a[i]-a[0]
    d=c
    for i in range(1,len(a)-1):
        d+=c-(len(a)-i)*(a[i]-a[i-1])
        c-=(len(a)-i)*(a[i]-a[i-1])
    return d%mod
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
print(f(a)*f(b)%mod)

Measured memory_bytes: 18556
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int P = scanner.nextInt();
    int Q = scanner.nextInt();
    int R = scanner.nextInt();
    System.out.println(minTwo(P, Q, R));
  }

  private static int minTwo(int a, int b, int c) {
    if (a > b) return minTwo(b, a, c);
    if (b > c) return minTwo(a, c, b);
    return a + b;
  }
}


Measured memory_bytes: 24916
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

  int h,a; cin >>h>>a;

  int ans = h /a;
  if (h % a > 0) {
    ans++;
  }
  cout << ans << endl;
  
  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

const int Maxn = 100010;
int a[Maxn];
int m[Maxn];

int main(){
    int n, t;
    cin >> n >> t;
    REP(i,0,n) cin >> a[i];
    RREP(i,n-1,0) m[i] = max(m[i + 1], a[i]);

    map<int, int> cnt;
    int M = 0;
    REP(i,0,n){
        M = max(M, m[i] - a[i]);
        cnt[m[i] - a[i]]++;
    }

    cout << cnt[M] << endl;

    return 0;
}

Measured memory_bytes: 5760
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

type st struct {
	ind int
	min int64
}

func main() {
	var D int
	var T int
	var S int
	fmt.Scan(&D)
	fmt.Scan(&T)
	fmt.Scan(&S)

	// sc.Split(bufio.ScanWords)
	if T*S >= D {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}
func bc(s string, pos int) string {
	ch := "1"
	if string(s[pos]) == "1" {
		ch = "0"
	}
	pre := string(s[:pos])
	post := ""
	if pos != len(s)-1 {
		post = string(s[pos+1:])
	}
	tmp := pre + ch + post
	return tmp
}
func popCount(n string) int {
	count := 0
	for _, s := range n {
		if string(s) == "1" {
			count++
		}
	}
	return count
}
func chc(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for i, l := range m {
		tmp := []bool{}
		for _, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[i] = tmp
	}
	return ret
}
func chl(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for j, l := range m {
		tmp := []bool{}
		for i, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[j] = tmp
	}
	return ret
}
func helper(ma [][]bool) int {
	count := 0
	for _, l := range ma {
		for _, c := range l {
			if c == true {
				count++
			}
		}
	}
	return count
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 1840
def read_input():
    a, b, c, d = map(int, input().split())
    return a, b, c, d


def submit():
    a, b, c, d = read_input()

    if abs(c - a) <= d:
        print('Yes')
        return

    if abs(b - a) <= d and abs(c - b) <= d:
        print('Yes')
        return

    print('No')

if __name__ == '__main__':
    submit()


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

int main()
{
    int n,i;
    cin >> n;
    vector<long long> a(n);
    long long ans = 0,temp1,temp2;
    for(i = 0;i < n;++i){
        cin >> temp1 >> temp2;
        a.at(i) = temp1+temp2;
        ans -= temp2;
    }
    sort(a.begin(),a.end());
    for(i = n-1;i >= 0;i -= 2){
        ans += a.at(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

void calc(vi &a,int N,string &s) {
  srep(i,2,N) {
    bool same = a[i-1]^(s[i-1]=='o');
    if(same) {
      a[i] = a[i-2];
    } else {
      a[i] = 1-a[i-2];
    }
  }
}

bool valid(vi &a,int N,string &s) {
  bool same = a[0]^(s[0]=='o');
  if(same) {
    if(a.back() != a[1]) return false;
  } else {
    if(a.back() == a[1]) return false;
  }
  same = a.back()^(s.back()=='o');
  if(same) {
    if(a[N-2] != a[0]) return false;
  } else {
    if(a[N-2] == a[0]) return false;
  }
  return true;
}

void out(vi &a,int N) {
  rep(i,N) {
    cout << (a[i]?'W':'S');
  }
  cout << endl;
}
  
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  rep(i,1<<2) {
    vi a(N);
    a[0] = i&1;
    a[1] = (i>>1)&1;
    calc(a,N,s);
    if(valid(a,N,s)) {
      out(a,N);
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
vector<int>v;
map<int,int>m;
int main(){
	cin>>N;
	REP(i,N){
		int A;
		cin>>A;
		m[A]++;
		v.push_back(A);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	LL ans=0;
	REP(i,N){
		LL A=v[i];
		if(m[A]!=0){
			LL B=1;
			while(B<A){
				B*=2;
			}
			if(B==A){
				if(m[A]>=2){
					m[A]-=2;
					ans++;
				}
			}else{
				LL C=B-A;
				if(m[C]!=0){
					m[A]--;
					m[C]--;
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		long[][] a;
		long[][] b;
		long[][] c;
		int n = 0;
		int m = 0;
		int l = 0;

		Scanner sc= new Scanner( System.in );
		n = sc.nextInt();
		m = sc.nextInt();
		l = sc.nextInt();

		a = new long[n][m];
		b = new long[m][l];
		c = new long[n][l];


		for ( int i = 0 ; i < n ; i++ ) {
			for ( int j = 0 ; j < m ; j++ ) {
				a[i][j] = sc.nextLong();
			}
		}

		for ( int j = 0 ; j < m ; j++ ) {
			for ( int k = 0 ; k < l ; k++ ) {
				b[j][k] = sc.nextLong();
			}
		}

		for ( int i = 0 ; i < n ; i++ ) {
			for ( int k = 0 ; k < l ; k++ ) {
				for ( int j = 0 ; j < m ; j++ ) {
					if ( j == 0 ) {
						c[i][k] = 0;
					}
					c[i][k] += a[i][j] * b[j][k];
				}
				System.out.print( c[i][k] );
				if ( k != (l-1) ) {
					System.out.print( " " );
				}
			}
			System.out.print( "\n" );
		}
		sc.close();
	}
}


Measured memory_bytes: 54808
#include<stdio.h>

int main(){
	char a[7];
	
	scanf("%s", a);
	if ((a[0]==a[1]&&a[0]!=a[2])||(a[2]==a[1]&&a[0]!=a[2])||
	(a[0]==a[2]&&a[1]!=a[2])){
		puts("Yes");
	}
	else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 1660
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;

void main()
{
    int n = to!int(readln().chomp());
    int[] a = readln().split().map!(a => to!int(a)).array;
    int m = int.min;
    for (int l = 0; l < a.length; ++l)
    {
        for (int r = l + 1; r < a.length; ++r)
        {
            m = max(m, abs(a[l] - a[r]));
        }
    }
    writeln(m);
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int ans;
  ans = 0;
  if (s[0] == t[0]) ans++;
  if (s[1] == t[1]) ans++;
  if (s[2] == t[2]) ans++;

  cout << ans << endl;

  return 0;
}

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

keta = len(str(N))

if keta == 1:
  print(N)
elif keta == 2:
  print(9)
elif keta == 3:
  print(N-90)
elif keta == 4:
  print(909)
elif keta == 5:
  print(N-90-9000)
elif keta == 6:
  print(90909)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(9) << (double)w * h / 2;
  if(w == x * 2 && h == y * 2){
    cout << " " << 1 << endl;
  }
  else{
    cout << " " << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
*ID: juryc
*LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
ll mod=1e9+7; 
int main(){
ll n; cin>>n;
vector<ll> v(n); 
for(ll& i: v) cin>>i;
ll s=v[n-1]; 
ll ans=0; 
for(int i=n-2;i>=0;i--){ ans=(ans+(v[i]*s)%mod)%mod; s=(s+v[i])%mod; }  
cout<<ans<<endl;
return 0;
}


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

using namespace std;

int main(void){
  int n;
  cin>>n;
  int a,b;
  int dp[100010] = {0};
  for(int i = 0 ; i < n ; i ++){
    cin>>a>>b;
    dp[a]++;
    dp[b+1]--;
  }
  int ret = 0;
  for(int i = 0 ; i < 100009 ; i ++){
    dp[i+1] += dp[i];
    if(i-1<=dp[i])ret = max(ret,i-1);
  } 
  cout<<ret<<endl;
}

Measured memory_bytes: 1560
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2000010;
const int MOD=1e9+7;
int POW(int x,int k)
{
	int ans=1;
	for (;k;k>>=1,x=1LL*x*x%MOD) if(k&1) ans=1LL*ans*x%MOD;
	return ans;
}
int fac[MAXN],inv[MAXN];
void pre(int n)
{
	fac[0]=1;
	for (int i=1;i<=n;++i) fac[i]=1LL*fac[i-1]*i%MOD;
	inv[n]=POW(fac[n],MOD-2);
	for (int i=n-1;i>=0;--i) inv[i]=1LL*inv[i+1]*(i+1)%MOD;
}
int getC(int n,int m)
{
	if (n<m) return 0;
	return 1LL*fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int cal(int n,int m)
{
	/*
	int sum=0;
	for (int i=0;i<=n;++i)
		for (int j=0;j<=m;++j)
			sum+=getC(i+j,i);
	return sum;
	*/
	return (getC(n+m+2,n+1)-1+MOD)%MOD;
}
int main()
{
	pre(2000005);
	int r1,c1,r2,c2;
	cin>>r1>>c1>>r2>>c2;
	long long Ans=cal(r2,c2)-cal(r2,c1-1)-cal(r1-1,c2)+cal(r1-1,c1-1);
	Ans%=MOD;
	if (Ans<0) Ans+=MOD;
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<queue>

using namespace std;

#define INF 1e18

struct Node{
  double x,y,r;
};

int main(){
  double sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  int n; cin >> n;
  vector< Node > nodes;
  nodes.push_back({sx, sy, 0});
  for(int i = 0; i < n; i++){
    double x,y,r;
    cin >> x >> y >> r;
    nodes.push_back({x, y, r});
  }
  nodes.push_back({tx, ty, 0});
  vector< vector< pair<double, int> > > edge(n+2);
  for(int i = 0; i < n+2; i++){
    for(int j = 0; j < n+2; j++){
      if(i == j) continue;
      double t =sqrt( pow(nodes[i].x - nodes[j].x, 2) + pow(nodes[i].y - nodes[j].y, 2) ) - (nodes[i].r + nodes[j].r);
      edge[i].push_back({max((double)0, t), j});
    }
  }
  vector<double> d(n+2, INF);
  priority_queue<pair<double,int>, vector<pair<double,int>> , greater< pair<double,int> > > q;
  q.push({0, 0});
  d[0] = 0;

  while(!q.empty()){
    pair<double, int> now = q.top(); q.pop();
    if(d[now.second] < now.first) continue;
    for(auto next:edge[now.second]){
      if(d[next.second] > d[now.second] + next.first){
        d[next.second] = d[now.second] + next.first;
        q.push({d[next.second], next.second});
      }
    }
  }
  printf("%.10lf\n", d[n+1]);
}


Measured memory_bytes: 22652
N = int(input())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

cnt = 0
for i in range(1, N+1):
    i *= -1
    a, b = A[i], B[i]
    a += cnt
    mod = a%b
    if mod != 0:
        cnt += b-mod
        
print(cnt)

Measured memory_bytes: 11052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
const int INF = 1e9;
using namespace std;

signed main() {
    map<string, int> m;
    int N;
    cin >> N;
    rep(i, N) {
        string s;
        cin >> s;
        m[s]++;
    }
    int M;
    cin >> M;
    rep(i, M) {
        string s;
        cin >> s;
        m[s]--;
    }
    int max=0;
    for(auto p:m){
        if(max<p.second) max=p.second;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}



template< typename T >
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;



template< typename T >
vector<T> dijkstra(WG<T> &g,int s){
    const auto lim = numeric_limits<T>::max();
    vector<T> dist(g.size(),lim);
    using Pi = pair<T,int>;
    priority_queue<Pi,vector<Pi>,greater<Pi>> q;
    dist[s] = 0;
    q.emplace(dist[s],s);
    while(!q.empty()){
        T cost;
        int idx;
        tie(cost,idx) = q.top();
        q.pop();
        if(dist[idx] < cost) continue;
        for( auto &e : g[idx]){
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            q.emplace(dist[e.to],e.to);
        }
    }
    return dist;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int n,x,y;
    cin>>n>>x>>y;
    x--;
    y--;
    WG<int> es(n);
    rep(i,n){
        if(i<n-1)es[i].PB(edge<int>(i+1,1));
        if(i)es[i].PB(edge<int>(i-1,1));
    }
    es[x].PB(edge<int>(y,1));
    es[y].PB(edge<int>(x,1));

    vi cnt(n,0);

    rep(i,n){
        vi d = dijkstra(es,i);
        FOR(j,i+1,n){
            cnt[d[j]]++;
        }
    }
           
    FOR(k,1,n){
        cout<<cnt[k]<<endl;
    }


}

Measured memory_bytes: 512
n, Y = map(int, input().split())

Y = Y//1000

ans = '-1 -1 -1'

for x in range(0, n+1):
    for y in range(0, n+1-x):
        if (0 <= n-x-y) and (10*x + 5*y + n-x-y == Y):
            ans = '%s %s %s' % (x, y, n-x-y)
            break

print(ans)


Measured memory_bytes: 40812
#include<stdio.h>

int Maximum(int *,int);
int main(){
  int i,n,a[200000],max;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  max=Maximum(a,n);
  printf("%d\n",max);
  return 0;
}

int Maximum(int *a,int n){
  int i,max=(-1000000000),j,x,min;
  min=a[0];
  for(i=1;i<n;i++){

    if(max<(a[i]-min))max=a[i]-min;
    if(min>a[i])min=a[i];

  }
  return max;
}



Measured memory_bytes: 2548
A = list()
for i in range(3):
  A += list(map(int, input().split()))
  
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(len(A)):
    if A[j] == b:
      A[j] = 0

for i in range(3):
  if A[3*i:3*i+3] == [0, 0, 0]:
    print('Yes')
    exit()
  elif [A[i], A[i+3], A[i+6]] == [0, 0, 0]:
    print('Yes')
    exit()
  elif [A[0], A[4], A[8]] == [0, 0, 0] or [A[2], A[4], A[6]] == [0, 0, 0]:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n)cin >> p[i];
    int ans = 1, mi = p[0];
    REP(i, n-1){
        mi = min(mi, p[i]);
        if(p[i] <= mi)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024