akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;int64_t N,P,d[1<<20],p,i,r,v;string S;main(){for(cin>>N>>P>>S;i<N;i++)d[i]=S[i]-'0';if(P==2||P==5){for(i=0;i<N;i++)if(!(d[i]%P))r+=i+1;cout<<r;exit(0);}map<int,int>m;m[0]=p=1;for(i=N-1;i>=0;i--)v=(v+d[i]*p)%P,p=(p*10)%P,r+=m[v]++;cout<<r;}

Measured memory_bytes: 2436
/*
author : seryu
title : ABC170C_"Forbidden List"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
	int x, n;
	cin >> x >> n;
	vector<bool> a(101,false);
	rep(i, n)
	{
		int p;
		cin >> p;
		a[p] = true;
	}
	int mi = x+1;
	int ans = -1;
	rep(i, 102)
	{
		if(!a[i] && chmin(mi, abs(x-i)))ans = i;
	}
	cout << ans << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<pair<int,int> > ed[51];
vector<int> ww;
void genera_gr(int n)
{
    int i;
    int j;
    for(j=50;j>=1;j--)
   {

    for(i=1;i<=n;i++)
    {
        ed[j].push_back(make_pair(j%i,i));


    }
    for(i=0;i<ww.size();i++)
        ed[j].push_back(make_pair(j%ww[i],ww[i]));}

    }
    int reach[51];

    void dfs(int x)
    {

        reach[x]=1;
        int i;
        for(i=0;i<ed[x].size();i++)
        {
            int y=ed[x][i].first;

            if(reach[y]==0)
                dfs(y);
        }







    }

int main()
{

    int i,j;
    int n;
    cin>>n;
    int a[n],b[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];

    int fl=0;
    for(i=0;i<n;i++)
        if(b[i]>a[i])
        fl=1;

    if(fl==1)
    {
        cout<<-1<<endl;
        return 0;
    }
    ll ans=0;


    for(i=50;i>=0;i--)
    {

        for(j=0;j<=50;j++)
            ed[j].clear();
        genera_gr(i);
        int xx=0;
        for(j=0;j<n;j++)
        {
            if(a[j]==b[j])
                continue;
                for(int z=0;z<=50;z++)
                    reach[z]=0;

            dfs(a[j]);
            if(reach[b[j]])
                continue;
            if(i==50)
            {
                fl=1;
                break;
            }
            else{


                xx=1;


            }
        }

        if(xx)
           {

            ans=ans+((ll)1<<(i+1));
            ww.push_back(i+1);




            }


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



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart=clock();
#define time (double)(clock() - tStart)/CLOCKS_PER_SEC;
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
int main(){
        int a,b;
        cin >> a >> b;
        if(a == b)
                return cout << "Draw", 0;
        if(a == 1)
                return cout << "Alice", 0;
        if(b == 1)
                return cout << "Bob", 0;
        if(a > b)
                return cout << "Alice", 0;
        return cout << "Bob", 0;
}


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


void solve(long long H, long long W, long long N){
    int mx = max(H,W);
    cout<<N/mx+(N%mx>0)<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long N;
    scanf("%lld",&N);
    solve(H, W, N);
    return 0;
}


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

bool ok(int x, vector<int> &D) {
  while(x) {
    for(int i: D) {
      if(i == x % 10) {
        return false;
      }
    }
    x = x / 10;
  }
  return true;
}

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

  vector<int> D(K);

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

  while(1) {
    if(ok(N, D)) {
      cout << N << endl;
      return 0;
    }
    N += 1;
  }



}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	if (N % 10 == 3) cout << "bon" << endl;
	else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
	else cout << "hon" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
# define ll  long long  int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;  
  
    while (y > 0) 
    { 
      
        if (y & 1) 
            res = (res*x) % p; 
  
      
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 
bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}
typedef pair<int,int> ii;
// bool cmp(ii a,ii b)
// {
// 	if(a.ff==b.ff)
// 	{
// 		return a.ss>b.ss;
// 	}
// 	else
// 		a.ff<b.ff;
// }
   ll dp[27][200004]={0};
   bool visit[100000]={0};
int  main()
{
//    #ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//    #endif
   IOS;
 	ll t;
 	cin>>t;
 	{
 		string x,y;
 		cin>>x>>y;
 		string z;
 		for(ll i=0;i<x.size();i++)
 		{
 			z.pb(x[i]);
 			z.pb(y[i]);
 		}
 		cout<<z;
 	}
}


Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

const int MAX_N = 3100;
vector<bitset<MAX_N>> dp(100);

int main(){
    int a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;
    dp[0][0] = 1;
    rip(i,31,0){
        rip(j,MAX_N,0){
            if(i >= a) dp[i][j] = (dp[i][j]|dp[i-a][j]);
            if(i >= b) dp[i][j] = (dp[i][j]|dp[i-b][j]);
            if(j >= c) dp[i][j] = (dp[i][j]|dp[i][j-c]);
            if(j >= d) dp[i][j] = (dp[i][j]|dp[i][j-d]);
        }
    }
    Pii ans = {100*a,0};
    rip(i,100,0){
        rip(j,MAX_N,0){
            if(i*100+j > f) break;
            if(dp[i][j] && (100+e)*j <= e*(i*100+j)){
                if((ans.first)*j > ans.second*(i*100+j)) ans = {(ll)i*100+j, j};
            }
        }
    }
    // vdeb(dp);
    cout << ans.first MM ans.second << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }
class UnionFindTree {
public:
	int treeCnt; //ツリーの数
	vi rank, p; //rank => 根の高さ, p => 親
	vi num; //木の要素数
	vi diff_weight;
	UnionFindTree() {}
	UnionFindTree(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.assign(size, 1);
		treeCnt = 0;
		REP(i, size) {
			makeset(i);
		}
	}

	void makeset(int x) {
		p[x] = x;
		rank[x] = 0;
		treeCnt++;
	}

	//同じ木に属しているか判定
	bool isSame(int x, int y) {
		return root(x) == root(y);
	}

	//xとyが属している木をつなぐ
	void unite(int x, int y) {
		link(root(x), root(y));
	}

	//木と木を繋ぐ処理をする。
	void link(int x, int y) {
		if (!isSame(x, y)) {
			if (rank[x] > rank[y]) {
				p[y] = x;
				num[x] += num[y];
			}
			else {
				p[x] = y;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
				num[y] += num[x];
			}
			treeCnt--;
		}
	}


	//xが属している木の根を探る
	int root(int x) {
		if (p[x] == x) return x;
		else return p[x] = root(p[x]);
	}

	//このUnion-Find木に存在するグループの数を返す。
	int countTree() {
		return treeCnt;
	}

	//aが所属するグループの要素数を返す。
	int getNum(int a) {
		return num[root(a)];
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	UnionFindTree utf(N);
	int M;
	cin >> M;
	REP(i, M) {
		int X, Y, Z;
		cin >> X >> Y >> Z;
		X--; Y--;
		utf.unite(X, Y);
	}
	cout << utf.countTree() << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int n, a[3009], b[3009], p[3009], col[3009]; vector<int>x[3009];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> p[i];
	for (int i = 1; i <= n - 1; i++) {
		cin >> a[i] >> b[i];
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	queue<int>Q;
	for (int i = 1; i <= n; i++) {
		bool flag = true;
		for (int j = 0; j < x[i].size(); j++) {
			if (p[i] > p[x[i][j]]) flag = false;
		}
		if (flag == true) { col[i] = 1; Q.push(i); }
	}
	while (!Q.empty()) {
		int pos = Q.front(); Q.pop();
		if (col[pos] == 1) {
			for (int i = 0; i < x[pos].size(); i++) {
				if (col[x[pos][i]] == 0 && p[pos] < p[x[pos][i]]) {
					col[x[pos][i]] = 2;
					Q.push(x[pos][i]);
				}
			}
		}
		else {
			for (int i = 0; i < x[pos].size(); i++) {
				if (col[x[pos][i]] != 0) continue;
				bool flag = true; int to = x[pos][i];
				for (int j = 0; j < x[to].size(); j++) {
					if (col[x[to][j]] == 2) continue;
					if (p[to] > p[x[to][j]]) flag = false;
				}
				if (flag == true) {
					col[to] = 1; Q.push(to);
				}
			}
		}
	}
	vector<int>V;
	for (int i = 1; i <= n; i++) { if (col[i] == 2) V.push_back(i); }
	for (int i = 0; i < V.size(); i++) {
		if (i)cout << " "; cout << V[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
process.stdin.resume();
process.stdin.setEncoding("utf8");
process.stdin.on("data", function (chunk) {
    var input = chunk.trim().split("\n");
    var order = 1;
    while (true) {
        var n = input.shift();
        if (n == 0)
            break;
        var dataset = [];
        var x1 = [];
        var x2 = [];
        var y1 = [];
        var y2 = [];
        var sx = [];
        var sy = [];
        for (var i = 0; i < n; i++) {
            dataset.push(input.shift().split(/\s+/).map(Number));
            x1.push(dataset[i][0] - dataset[i][2]);
            x2.push(dataset[i][0] + dataset[i][2]);
            y1.push(dataset[i][1] - dataset[i][2]);
            y2.push(dataset[i][1] + dataset[i][2]);
            sx.push(dataset[i][0] - dataset[i][2]);
            sx.push(dataset[i][0] + dataset[i][2]);
            sy.push(dataset[i][1] - dataset[i][2]);
            sy.push(dataset[i][1] + dataset[i][2]);
        }
        var area = 0;
        sx.sort(function(a, b){return a-b});
        sy.sort(function(a, b){return a-b});
        for (var a = 0; a < sx.length - 1; a++)
            for (var b = 0; b < sy.length - 1; b++)
                for (var c = flag = 0; c < x1.length; c++) {
                    if ((x1[c] < sx[a + 1]) && (sx[a] < x2[c]) && (y1[c] < sy[b + 1]) && (sy[b] < y2[c]))
                        if (flag == 0) {
                            area += (sx[a + 1] - sx[a]) * (sy[b + 1] - sy[b]);
                            flag++;
                        }
                }
        console.log(order + " " + area.toFixed(2));
        order++;
    }
});

Measured memory_bytes: 18140
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#define ld long double
using namespace std;

int n;
ld x[1005], y[1005];
ld v1, v2;
ld d, e;
ld p = 0.1;

ld d2(ld a, ld b) {
	return a*a + b*b;
}

int main() {
	cin>>n;
	for (int i = 0; i < n; i++){
		cin>>x[i]>>y[i];
		v1 += x[i];
        v2 += y[i];
	}
	v1 /= n;
	v2 /= n;
	for (int i = 0; i < 30000; i++) {
		int f = 0;
		d = d2(v1 - x[0], v2 - y[0]);
		for (int j = 1; j < n; j++) {
			e = d2(v1 - x[j], v2 - y[j]);
			if (d < e)
				d = e, f = j;
		}
		v1 += (x[f] - v1)*p;
		v2 += (y[f] - v2)*p;
		p *= 0.999;
	}
	cout<<setprecision(10)<<fixed<<sqrt(d)<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int n; std::cin >> n;
    std::vector<int>a(n+1);
    for(int i=0;i<=n;i+=4){
        for(int j=0;i+j<=n;j+=7){
            a.at(i+j)=true;
        }
    }
    std::cout << (a.at(n)?"Yes":"No") << std::endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

from collections import defaultdict

cnt = defaultdict(int)

for j, a in enumerate(A, 1):
    if j == 1: continue
    cnt[j - a] += 1

ans = 0
for i, a in enumerate(A, 1):
    ans += cnt[i + a]
    cnt[i - a] -= 1

print(ans)

Measured memory_bytes: 123916
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n){
    if(n==1||n==1){
        return false;
    }
    for(int i=2;i<n;++i){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
int fact(int n){
    int ans = 1;
    for(int i = 1; i<= n; ++i){
        ans *= i;
    }
    return ans;
}


int main()
{
    double a,b,c,d;
    bool ch = 1;
    cin>>a>>b>>c>>d;
    while(a > 0 && c > 0){
        if(a > 0){
            ch = 1;
            c -= b;
        }
        if(c > 0){
            ch = 0;
            a -= d;
        }
    }
    if(ch){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3696
#include <iostream>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  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 ans = 0;
  iter(it, m)
    ans = max(ans, it->second);
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	string a, b;
	while (1) {
		cin >> a >> b;
		if (a == "0" && b == "0")break;

		int hit = 0, blow = 0;
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					if (i == j)hit++;
					else blow++;
				}
			}
		}
		cout << hit << " " << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}
const ll W = 1e5+5,K = 19,N = (1<<10)-1;
ll n;
vpii a;
int solve()
{
	cin>>n;
	a.assign(n+1,mp(0ll,0ll));
	rep(i,0,n)
	{
		ll v,w;
		cin>>v>>w;
		a[i+1] = mp(v,w);
	}

	ll t = min(N+1,n+1);
	vvi dp(t,vi (W,0));
	rep(i,1,t) rep(j,0,W) dp[i][j] = max({dp[i][j],dp[i/2][j],(j-a[i].S>=0?dp[i/2][j-a[i].S]+a[i].F:0)});

	ll q;cin>>q;
	while(q--)
	{
		ll v,w;
		cin>>v>>w;
			
		vi big;
		while(v>N) big.pb(v),v/=2;

		ll m = sz(big);
		ll ans = 0;
		rep(i,0,(1<<m))
		{
			ll left = w;
			ll val  = 0;

			rep(j,0,m) if(((i>>j)&1)==1) left-=a[big[j]].S,val+=a[big[j]].F;
			if(left>=0) ans=max(ans,val+dp[v][left]);
		}

		cout<<ans<<"\n";

		
	}

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 811028
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
using int64 = long long;

int main() {
    for (int i=1; i<=5; i++) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3156
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10L^^9+7;

void main()
{
    auto S = readln.chomp;
    auto N = S.length;
    auto DP = new long[][](N+1, 4);
    DP[0][0] = 1;

    foreach (i, c; S) {
        foreach (j; 0..4) DP[i+1][j] = DP[i][j] * (c == '?' ? 3 : 1) % P;
        switch (c) {
            case 'A': (DP[i+1][1] += DP[i][0]) %= P; break;
            case 'B': (DP[i+1][2] += DP[i][1]) %= P; break;
            case 'C': (DP[i+1][3] += DP[i][2]) %= P; break;
            default:
                (DP[i+1][1] += DP[i][0]) %= P;
                (DP[i+1][2] += DP[i][1]) %= P;
                (DP[i+1][3] += DP[i][2]) %= P;
        }
    }

    writeln(DP[N][3]);
}

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

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  vector<vector<int>> graph(n, vector<int>{});
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    graph[b - 1].push_back(a - 1);
    graph[a - 1].push_back(b - 1);
  }
  vector<long long> point(n);

  rep(i, q) {
    int p, x;
    cin >> p >> x;
    point[p - 1] += x;
  }

  vector<bool> seen(n, false);
  queue<int> que;
  que.push(0);
  seen[0] = true;

  while (!que.empty()) {
    int curr = que.front();
    que.pop();
    long long curr_point = point[curr];
    for (auto &next : graph[curr]) {
      if (!seen[next]) {
        point[next] += curr_point;
        que.push(next);
        seen[next] = true;
      }
    }
  }
  print(point);
}


Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, a, b; cin >> n >> a >> b;
  if((b-a)%2==0) cout << (b-a)/2 << endk;
  else {
    cout << min((a-1)+1, (n-b)+1)+(b-a-1)/2 << endk;
  }
  return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_016_45
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();
            Console.ReadLine();
        }

        public class Logic_A
        {
            public void Start()
            {
                var a = Convert.ToDouble(Console.ReadLine());
                var b = Convert.ToDouble(Console.ReadLine());
                var c = Convert.ToDouble(Console.ReadLine());

                Console.WriteLine((a + b) / 2 * c);
            }
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
long long lcm(long long x, long long y) {
	long long z, a = x, b = y;
	if(a < b) {
		z = a;
		a = b;
		b = z;
	}
	z = a % b;
	while(z) {
		a = b;
		b = z;
		z = a % b;
	}
	return(x / b * y);
}
long long tmp, ans, n, i;
int main() {
	scanf("%d%lld", &n, &ans);
	for(i = 1; i < n; i++) {
		scanf("%lld", &tmp);
		ans = lcm(tmp, ans);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
from collections import Counter
a = Counter(A)

T = 0
for k in a.keys():
    c = a[k]
    T += (c * (c-1)) // 2

for i in A:
    t = 0
    c = a[i]
    t = T
    t -= (c * (c-1)) // 2
    c -= 1
    t += (c * (c-1)) // 2
    print(t)

Measured memory_bytes: 88012
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

	ll N; cin >> N;
	ll ans = 0;
	for (ll i=1; i*i<N; i++) {
		if (N%i==0) {
			if (i>2 && N%(i-1)!=0 && N-(i-1)*(N/(i-1))==N/(i-1)) {
				// cout << i-1 << endl;
				ans += i-1ll;
			}
			ll j = N/i;
			if (N%j==0 && j>2 && N%(j-1)!=0 && N-(j-1)*(N/(j-1))==N/(j-1)) {
				// cout << j-1 << endl;
				ans += j-1ll;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;

const int MOD = 1000000007; // 10^9 + 7
/****************************** START ******************************/
int S;

void comb(vector<vector <int> > &v){
  for(int i = 0;i < S+1; i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k < S+1;k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]) % MOD;
    }
  }
}

signed main(){
  cin >> S;
  vector<vector<int> > v(2004,vector<int>(2004,0));
  comb(v);
  
  int ans = 0;
  repeq(i,1,S/3){
    ans += v[S-2*i-1][i-1] % MOD;
    ans %= MOD;
  }
  cout << ans;
}

Measured memory_bytes: 34640
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   ll d[110];
   rep(i,n) cin >> d[i];

   int ans = 0;
   for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
         ans += d[i]*d[j];
      }
   }

   cout << ans << endl;

   return 0;
}

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

ans=-100000
for x in range(A):
  #print(A//B,x//B,A*x//B,A*x//B-A*(x//B))
  ans=max(ans,(A*x//B)-A*(x//B))
  if x==N:break
x=B-1
if x>N:x=N
ans=max(ans,(A*x//B)-A*(x//B))
print(ans)

Measured memory_bytes: 9064
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
int arr[maxn];
int b[maxn];
int main()
{
    int A,B,M;
    cin>>A>>B>>M;
    for(int i=0;i<A;++i)
        cin>>arr[i];
    for(int i=0;i<B;++i)
        cin>>b[i];
    int ai,bi,ci;
    int mi=100000000,MI=100000000;
    for(int i=0;i<A;++i)
    {
        mi=min(mi,arr[i]);
    }
    for(int i=0;i<B;++i)
    {
        MI=min(MI,b[i]);
    }
    int ans=mi+MI;
    for(int i=0;i<M;++i)
    {
        cin>>ai>>bi>>ci;
        ans=min(ans,arr[ai-1]+b[bi-1]-ci);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 


int main(){
  string cross; cin >> cross;
  stack<int> s1;
  stack<pii> s2;
  int Atot = 0;

  rep(i,cross.size()){
    if (cross[i]=='-') continue;
    else if (cross[i]=='\\'){
      s1.push(i);
    }
    else if (cross[i]=='/' && !s1.empty()){
      int Asub = i - s1.top(); 
      Atot += Asub; 

      while (!s2.empty() && s2.top().first>=s1.top()){
        Asub += s2.top().second; s2.pop();
      }
      s2.push(make_pair(i,Asub));
      s1.pop();
    }
  }

  cout << Atot << endl;
  cout << s2.size();
  stack<int> a;
  while(!s2.empty()) {
    a.push(s2.top().second);
    s2.pop();
  }
  while(!a.empty()){
    cout << " " << a.top();
    a.pop();
  }
  cout << endl;
  
   
  return 0;
}



Measured memory_bytes: 3248
#include <iostream>
#include <cstdio>
#define N 200002
using namespace std;
int n,i,p[N],a[N],q[N],s[N],t[2][N*4];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
void build(int p,int l,int r)
{
	t[1][p]=-1<<30;
	if(l==r) return;
	int mid=(l+r)/2;
	build(p*2,l,mid);build(p*2+1,mid+1,r);
}
void change(int op,int p,int l,int r,int x,int v)
{
	if(l==r){
		t[op][p]=v;
		return;
	}
	int mid=(l+r)/2;
	if(x<=mid) change(op,p*2,l,mid,x,v);
	else change(op,p*2+1,mid+1,r,x,v);
	t[op][p]=max(t[op][p*2],t[op][p*2+1]);
}
int ask(int op,int p,int l,int r,int ql,int qr)
{
	if(ql<=l&&r<=qr) return t[op][p];
	int mid=(l+r)/2,ans=-1<<30;
	if(ql<=mid) ans=max(ans,ask(op,p*2,l,mid,ql,qr));
	if(qr>mid) ans=max(ans,ask(op,p*2+1,mid+1,r,ql,qr));
	return ans;
}
bool check(int x,int y)
{
	if(y<0) return 0;
	if(y%2==0) return (ask(0,1,1,n,x,n)>=y);
	else return (ask(1,1,1,n,x,n)>=y);
}
int main()
{
	n=read();
	for(i=1;i<=n;i++) p[i]=read();
	int maxp=0;
	for(i=1;i<=n;i++){
		maxp=max(maxp,p[i]);
		if(p[i]==maxp) a[i]=2;
		else a[i]=1;
	}
	for(i=n;i>=1;i--) q[i]=q[i+1]+a[i]-1;
	build(1,1,n);
	for(i=n;i>=1;i--){
		int tmp0=ask(0,1,1,n,p[i],n)+a[i],tmp1=ask(1,1,1,n,p[i],n)+a[i];
		if(a[i]%2==0) change(0,1,1,n,p[i],tmp0),change(1,1,1,n,p[i],tmp1);
		else change(0,1,1,n,p[i],tmp1),change(1,1,1,n,p[i],tmp0);
	}
	int cntx=0,cnty=0,maxx=0,maxy=0;
	for(i=1;i<=n;i++){
		change(0,1,1,n,p[i],0);
		change(1,1,1,n,p[i],-1<<30);
		if(check(maxy,cntx+(p[i]>maxx)+q[i+1]-cnty)||check(max(maxx,p[i]),cnty+q[i+1]-cntx-(p[i]>maxx))){
			cntx+=(p[i]>maxx);
			maxx=max(maxx,p[i]);
		}
		else{
			s[i]=1;
			cnty+=(p[i]>maxy);
			maxy=max(maxy,p[i]);
		}
	}
	if(cntx!=cnty) puts("-1");
	else{
		for(i=1;i<=n;i++) printf("%d",s[i]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 10368
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] first = splitInt(sc.nextLine(), " ");
		Arrays.sort(first);
		System.out.println(first[0]+first[1]);
		
		
	}
	public static int[] splitInt(String str, String split) {
		String[] array = str.split(split);
		int[] array2 = new int[array.length];
		for(int i=0; i<array.length; i++) {
				array2[i] = Integer.parseInt(array[i]);
		}
		return array2;
	}
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int t_1[1001] = {}, t_2[1002] = {};
    int c1, c2;
    string s;
    while (getline(cin, s), s != "")
    {
        rep(i, s.size()) if (s[i] == ',') s[i] = ' ';
        stringstream ss(s);
        ss >> c1 >> c2;
        t_1[c1]++;
    }
    while (getline(cin, s))
    {
        rep(i, s.size()) if (s[i] == ',') s[i] = ' ';
        stringstream ss(s);
        ss >> c1 >> c2;
        t_2[c1]++;
    }

    rep(i, 1001)
    {
        if (t_1[i] > 0 && t_2[i] > 0)
            cout << i << " " << t_1[i] + t_2[i] << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
    long long n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);

    long long full = n / (a + b);
    long long res = full * a + min(a, n - full * (a + b));
    printf("%lld\n", res);
}


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

using namespace std;
#define forn(i, n) for (int i = 0; i < n; i++)
#define re return
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
typedef long long ll;

const ll mod = 1e9 + 7;
ll n, m;
int main() {
	iostream::sync_with_stdio(0);
	//freopen("a.in", "r", stdin);
	cin >> n >> m;
	if (n > m / 2LL) {
		n = m /2LL;
	}	
	//cout << n << " " << m << "\n"
	cout << n + (m - 2LL * n) / 4LL;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int N, A, B;
    string S;
    cin >> N >> A >> B >> S;
    vector<string> x(N,"No");
    int a = 0; //予選通過人数全員のカウント
    int b = 0; // 予選通過外国人学生のカウント

    for(int i = 0; i < N; i++) {
        if(S[i] == 'a' && a < (A + B)) {
            x[i] = "Yes";
            a++;
        }
        else if(S[i] == 'b' && a < (A + B) && b < B) {
            x[i] = "Yes";
            a++;
            b++;
        }
    }
    for(int i = 0; i < N; i++) {
        cout << x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6272
sx, sy, tx, ty = map(int, input().split())

s = ''

for i in range(ty - sy):
    s = s + 'U'
for i in range(tx - sx):
    s = s + 'R'
for i in range(ty - sy):
    s = s + 'D'
for i in range(tx - sx):
    s = s + 'L'

s = s + 'L'

for i in range(ty - sy + 1):
    s = s + 'U'
for i in range(tx - sx + 1):
    s = s + 'R'

s = s + 'DR'

for i in range(ty - sy + 1):
    s = s + 'D'
for i in range(tx - sx + 1):
    s = s + 'L'

s = s + 'U'

print(s)

Measured memory_bytes: 3064
<?php
$dummy = fgets(STDIN);
$a = str_split(trim(fgets(STDIN)));
$s = [];
foreach ($a as $v) {
	if (!isset($s[$v])) {
		$s[$v] = 1;
	} else {
		$s[$v]++;
	}
}

$ans = 1;
foreach ($s as $v) {
	$ans *= ($v + 1);
	$ans %= pow(10, 9) + 7;
}

echo $ans - 1;


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

using namespace std;

int main(){
  int N, M;
  long long K;
  cin >> N >> M >> K;
  
  vector<long long> A(N + 1), B(M + 1);
  A[0] = 0;
  B[0] = 0;
  
  for(int i = 0; i < N; i++){
    cin >> A[i + 1];
    A[i + 1] += A[i];
  }
  
  for(int i = 0; i < M; i++){
    cin >> B[i + 1];
    B[i + 1] += B[i];
  }
  
  int book = 0;
  for(int left = 0, right = M; left <= N; left++){
    while(right >= 0 && A[left] + B[right] > K) --right;
    if(right == -1) break;
    book = max(left + right, book);
  }
  
  cout << book << endl;
  
  return 0;
}

Measured memory_bytes: 6420
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <unordered_set>
using namespace std;
inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define long long long
long  pw(long  x, long  y){long  ans = 1;for(long  i = 0; i < y; i++){ans = ans * x;}return ans;}
long  factorial(long  x){long  ans = 1; for(int i = 1 ;i < x+1; i++){ans = ans *i;}return ans;}
long  combination(long  x,long  y){return factorial(x)/factorial(y)/factorial(x-y);}
long  permutation(long  x, long  y){return factorial(x)/factorial(x-y);}
#define TimeCount1    auto chrono_start = std::chrono::system_clock::now();
#define TimeCount2   auto chrono_end = std::chrono::system_clock::now();std::cout << "Elapsed time(C++):" << std::chrono::duration_cast<std::chrono::milliseconds>(chrono_end - chrono_start).count() << "[ms]" << std::endl;

//#include "./printer.hpp"

int main(){
	long n;
	cin >> n;
	cout << n * (n+1) / 2;

}
//corner case, printer, dump




Measured memory_bytes: 764
N, T = map(int, input().split())
AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append([A, B])

AB.sort()

dp = [[0 for t in range(T)] for i in range(N+1)]

ans = 0
for i, ab in enumerate(AB):
  ans = max(ans, dp[i][T-1] + ab[1])
  for t in range(T):
    if t < ab[0]:
      dp[i+1][t] = dp[i][t]
    else:
      dp[i+1][t] = max(dp[i][t-ab[0]] + ab[1], dp[i][t])

print(ans)


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

	int x;
	cin>>x;

	for(int i=1;i<=1000;i++) {
		for(int j=-1000;j<=i;j++) {
			// cout<<i<<" "<<j<<" "<<i*i*i*i*i-j*j*j*j*j<<"\n";
			if(i*i*i*i*i-j*j*j*j*j == x) {
				cout<<i<<" "<<j;
				return 0;
			}
		}
	}	

	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll x,k,d;
	scanf("%lld%lld%lld",&x,&k,&d);
	ll a=abs(0LL+x);
	ll m=a/d;
	if(k>m)
	{
		if(x>0)
			x-=m*d;
		else
			x+=m*d;
		k-=m;
		a=abs(0LL+x);
		if(k%2==0)
			printf("%lld\n",a);
		else
		{
			if(x>0)
				x-=d;
			else
				x+=d;
			printf("%lld\n",abs(0LL+x));
		}
	}
	else
	{
		if(x>0)
			x-=k*d;
		else
			x+=k*d;
		printf("%lld\n",abs(0LL+x));
	}
}


Measured memory_bytes: 3772
N = int(input())
S = input()


def count(s):
    res = {}
    for i in range(2**N):
        t1 = ''
        t2 = ''
        for j in range(N):
            if i & 1 << j:
                t1 += s[j]
            else:
                t2 += s[j]
        k = t1 + t2 + 'abcdefghijklmnoprst'[bin(i).count('1')]
        res[k] = res.get(k, 0) + 1
    return res


h1 = count(S[:N])
h2 = count(S[N:][::-1])
ans = 0
for k, v in h1.items():
    if k in h2:
        ans += v * h2[k]
print(ans)

# https://www.youtube.com/watch?v=eB0eT-948Vw


Measured memory_bytes: 71052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int a,b; char c;
    cin>>a>>c>>b;
    if(c=='+') cout<<a+b<<endl;
    else cout<<a-b<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)

//cerrはコメントアウトしなくても通る

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> v;
    rep(i,n){
        int a;
        cin >> a;
        v.push_back(mp(a,i+1));
    } 
    sort(v.begin(),v.end());
    rep(i,n){
        cout<<get<1>(v[i])<<' ';
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1784
N, K = map(int, input().split())
S = input()

cnt_split = 0
for i in range(1, N):
    if S[i-1] != S[i]:
            cnt_split += 1

if cnt_split <= 2*K:
    print(N-1)
else:
    print(N-1 - (cnt_split - 2*K))


Measured memory_bytes: 3316
//
//  kth_term.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>

int main(int argc, const char* argv[]) {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  std::cin >> k;

  std::cout << a[k-1] << std::endl;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

typedef pair<ll, ll> lpair;
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}


int n,m,q;



int main()
{
    cin>>n>>m>>q;
    vec<ll> a(q),b(q),c(q),d(q);
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
    vector<ll> A(n),v(n*m+100);
    ll ans=0;
    // iota(v.begin(), v.end(), 1); //1からはじめるm要素の列

    rep(i,m){
        rep(j,n+1){
            v[i*n+j]=i+1;
        }
    }
    do{
        copy(v.begin(),v.begin()+n,A.begin());
        ll tmp=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i]){
                tmp+=d[i];
            }
        }
        ans=max(tmp,ans);

    }while(next_combination(v.begin(),v.begin() + n,  v.end()-100));

    cout<<ans<<endl;

    return 0;

}




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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N,0);
  for(int i=0; i<N-1; i++){
    int S;
    cin >> S;
    vec[S-1]++;
  }
  for(int i=0; i<N; i++){
    cout << vec[i] << endl;
  }
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using ll = long long;
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)

std::string highlight(std::string s) {
#ifdef _MSC_VER
    return s;
#else
    return "\033[33m" + s + "\033[0m";
#endif
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        print_to(os, ", ", "\n", __VA_ARGS__);            \
        std::cerr << highlight(os.str());                 \
    } while (0)
#define dump_(a)                                          \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #a << " = [";          \
        print_to_(os, ", ", "]\n", all(a));               \
        std::cerr << highlight(os.str());                 \
    } while (0)
#else
#define dump(...)
#define dump_(...)
#endif

template <typename T>
void print_to(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void print_to(std::ostream &os, const char *del, const char *tail, const Fst &fst, const Rst &... rst) {
    os << fst << del;
    print_to(os, del, tail, rst...);
}
template <typename Iter>
void print_to_(std::ostream &os, const char *del, const char *tail, Iter bgn, Iter end) {
    for (Iter it = bgn; it != end;) {
        os << *it;
        if (++it != end) {
            os << del;
        } else {
            os << tail;
        }
    }
}
template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, " ", "\n", fst, rst...);
}
template <typename Iter>
void println_(Iter bgn, Iter end) {
    print_to_(std::cout, "\n", "\n", bgn, end);
}
template <typename Iter>
void print_(Iter bgn, Iter end) {
    print_to_(std::cout, " ", "\n", bgn, end);
}

// const int MOD = 1000000007;
namespace trush {
    int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
             std::ios::sync_with_stdio(0), 0);
}

using namespace std;

int main() {
    int a, b;
    while (cin >> a >> b) {
        cout << 2*b - a << endl;
    }
}


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

// define maximum possible length of string X and Y
#define MAX 3005

// lookup[i][j] stores the length of LCS of substring X[0..i-1], Y[0..j-1]
int lookup[MAX][MAX];

// Recursive Function to find Longest Common Subsequence of
// string X[0..m-1] and Y[0..n-1]
string LCS(string X, string Y, int m, int n)
{
    // return empty string if we have reached the end of
    // either sequence
    if (m == 0 || n == 0)
        return string("");

    // if last character of X and Y matches
    if (X[m - 1] == Y[n - 1])
    {
        // append current character (X[m-1] or Y[n-1]) to LCS of
        // substring X[0..m-2] and Y[0..n-2]
        return LCS(X, Y, m - 1, n - 1) + X[m - 1];
    }

    // else when the last character of X and Y are different

    // if top cell of current cell has more value than the left
    // cell, then drop current character of string X and find LCS
    // of substring X[0..m-2], Y[0..n-1]

    if (lookup[m - 1][n] > lookup[m][n - 1])
        return LCS(X, Y, m - 1, n);

    else

    // if left cell of current cell has more value than the top
    // cell, then drop current character of string Y and find LCS
    // of substring X[0..m-1], Y[0..n-2]

        return LCS(X, Y, m, n - 1);
}

// Function to fill lookup table by finding the length of LCS
// of substring X[0..m-1] and Y[0..n-1]
void LCSLength(string X, string Y, int m, int n)
{
    // first row and first column of the lookup table
    // are already 0 as lookup[][] is globally declared

    // fill the lookup table in bottom-up manner
    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            // if current character of X and Y matches
            if (X[i - 1] == Y[j - 1])
                lookup[i][j] = lookup[i - 1][j - 1] + 1;

            // else if current character of X and Y don't match
            else
                lookup[i][j] = max(lookup[i - 1][j], lookup[i][j - 1]);
        }
    }
}

// main function
int main()
{
    string X,Y;
    cin>>X>>Y;
    int m = X.length(), n = Y.length();

    // fill lookup table
    LCSLength(X, Y, m, n);

    // find longest common sequence
    cout << LCS(X, Y, m, n);

    return 0;
}

Measured memory_bytes: 65792
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
Z=list(map(int,input().split()))

res = "Yes"
for i in range(2):
	if X[i]-X[i+1] == Y[i]-Y[i+1] and X[i]-X[i+1] == Z[i]-Z[i+1]:
		res = "No"
		break
	i
if(X[0]-X[1]==Y[0]-Y[1] and X[0]-X[1]==Z[0]-Z[1] and X[2]-X[1]==Y[2]-Y[1] and X[2]-X[1]==Z[2]-Z[1]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064