akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

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

bool flag[2000];

int main() {
  int n, ret = 1;
  scanf("%d", &n);
  for (int i = 2; i <= n; ++i) {
    if (flag[i]) continue;
    for (int j = i * i; j <= n; j += i) flag[j] = true;
    int cnt = 1;
    for (int m = n; m; m /= i) cnt += m / i;
    ret = (int64)ret * cnt % MOD;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    ans+=min(a,k);
    k-=min(a,k);
    
    k-=min(b,k);
    
    ans-=min(c,k);
    k-=min(c,k);
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3648
def find(x):
    if parents[x]==x:
        return x
    return find(parents[x])

def unite(x,y):
    px=find(x)
    py=find(y)
    if deepth[px]>deepth[py]:
        parents[py]=px
        deepth[px]=max(deepth[px],deepth[py]+1)
    else:
        parents[px]=py
        deepth[py]=max(deepth[py],deepth[px]+1)

def same(x,y):
    if find(x)==find(y):
        return True
    else:
        return False

N,M=map(int,input().split())
Graph=[]
for _ in range(M):
    a,b=map(int,input().split())
    Graph.append((a-1,b-1))

cnt=0
for i in range(M):
    flag=True
    parents=[i for i in range(N)]
    deepth=[0 for _ in range(N)]
    for k in range(M):
        if i!=k:
            unite(Graph[k][0],Graph[k][1])
    for l in range(N-1):
        if find(l)!=find(l+1):
            flag=False
    if not flag:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,c;
Vi x,v;
Vi sum,sum2;
Vi ma,ma2;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>c;
    x.resize(n);
    v.resize(n);
    rep(i,n){
        cin>>x[i]>>v[i];
    }
    sum.resize(n+1,0);sum2.resize(n+1,0);
    ma.resize(n+1,-INF);ma2.resize(n+1,-INF);
    rep(i,n){
        sum[i+1] += sum[i] + v[i];
        if(i==0)sum[i+1] -= x[i];
        else sum[i+1] -= x[i] - x[i-1];
        
        chmax(ma[i],sum[i]);
        if(i!=0)chmax(ma[i],ma[i-1]);
    }
    rep(i,n){
        sum2[i+1] += sum2[i] + v[n-1-i];
        if(i==0)sum2[i+1] -= c-x[n-1-i];
        else sum2[i+1] -= x[n-i] - x[n-1-i];

        chmax(ma2[i],sum2[i]);
        if(i!=0)chmax(ma2[i],ma2[i-1]);
    }
    ll ans = 0;
    ll tmp = 0;
    rep(i,n){
        tmp = sum[i+1];
        if(ma2[n-i-1]>x[i])tmp += ma2[n-1-i] -x[i];
        chmax(ans,tmp);
    }
    rep(i,n){
        tmp = max(sum2[i+1] - c + x[n-1-i]+ma[n-1-i],sum2[i+1]);
        chmax(ans,tmp);
    }
    print(ans);
    return 0;
}

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



int main() {

	int N, M;
	int P;
	char S[2];
	int ansWA = 0, ansAC = 0;
	int ListWA[110000], ListAC[110000];


	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d %s", &P, S);
		if (strcmp(S, "WA") == 0) {
			if (ListAC[P] != 1) {
				if (ListWA[P] < 0) {
					ListWA[P] = 1;
				}
				else {
					ListWA[P] += 1;
				}
			}
		}
		else {
			if (ListAC[P] != 1) {
				ListAC[P] = 1;
				ansAC += 1;
				if (ListWA[P] > 0) {
					ansWA += ListWA[P];
				}
			}
		}
	}

	printf("%d %d", ansAC, ansWA);
	
	return 0;
}

	





Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main () {
  vector<long> data(7);
  for (int i = 0;i < 7; i++){
    cin >> data.at(i);
  }
  vector<int> n{0, 3, 4};
  int count = 0;
  for(int a: n) {
    if (data.at(a) % 2 == 1) count++;
  }
  int flag = 0;
  if(data.at(0) > 0 && data.at(3) > 0 && data.at(4) > 0) {
    if (count > 1) {
      flag = 1;
    }
  }
  long ans = 0;
  if(flag == 0) ans = (data.at(0) / 2) * 2 + data.at(1) + (data.at(3)/ 2 + data.at(4) / 2) * 2;
  else ans = ((data.at(0) - 1) / 2) * 2 + data.at(1) + ((data.at(3) - 1) / 2 + (data.at(4) - 1) / 2) * 2 + 3;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
struct edge{
	int to;
	int cost;
};
// sを始点とした全頂点の最短経路長（ダイクストラ）
// sからtに到達不可ならば d[t] = INF
vector<ll> dijkstra(int s, vector<vector<edge>> &to){
	// <最短距離、頂点番号>
	typedef pair<ll,int> P;
	
	priority_queue<P, vector<P>, greater<P>> que;
	vector<ll> d(to.size(), INF);
	
	d[s] = 0;
	que.push(P(0,s));
	
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		
		for(edge e : to[v]){
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
	
	return d;
}



void mainsolve(){

	ll n,m,r;
	cin >> n >> m >> r;
	vector<ll> p(r);
	rep(i,r){
		cin >> p[i];
		--p[i];
	}

	vector<vector<edge>> to(n);

	rep(i,m){
		ll a,b,c;
		cin >> a >> b >> c;
		--a; --b;
		to[a].push_back(edge{b,c});
		to[b].push_back(edge{a,c});
	}

	vector<vector<ll>> d(r);
	rep(i,r){
		d[i] = dijkstra(p[i], to);
	}

	vector<ll> nn(r);
	rep(i,r) nn[i] = i;

	ll res = INF;
	do{
		ll tmp = 0;
		rep(i,r-1){
			tmp += d[nn[i]][p[nn[i+1]]];
		}
		res = min(res, tmp);
	} while(next_permutation(nn.begin(),nn.end()));

	cout << res << endl;

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string k;
    lli d,M=1e9+7;
    cin>>k>>d;
    lli i,j,where,l,dp[d][2],len=k.length(),cur=0;
    memset(dp, 0LL, sizeof(dp));
    
    dp[0][0]=1;
    
    for(where=0;where<len;where++)
    {
        lli new_dp[d][2];
        memset(new_dp, 0LL, sizeof(dp));
        
        for(i=0;i<d;i++)
        {
            cur=0;
            for(j=0;j<2;j++)
            {
                for(l=0;l<10;l++)
                {
                    if(l>k[where]-'0' && cur==0)
                        break;
                    
                    new_dp[(i+l)%d][cur || (l<k[where]-'0')]+=dp[i][cur];
                    new_dp[(i+l)%d][cur || (l<k[where]-'0')]%=M;
                }
                cur=1;
            }
        }
        
        for(i=0;i<d;i++) dp[i][0]=new_dp[i][0],dp[i][1]=new_dp[i][1];
    }
    
    cout<<((dp[0][0]+dp[0][1])%M -1+M)%M;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [list(list(input())) for _ in range(n)]

l = sorted(l, key = len)

x = []
for i in range(len(l[0])):
    y = 0
    for j in range(n):
        if l[0][i] in l[j]:
            y +=1
            if y == n:
                x.append(l[0][i])
                for k in range(1, n):
                    l[k].remove(l[0][i])

print(''.join(sorted(x)))

Measured memory_bytes: 3316
import java.util.Scanner;
import java.lang.StringBuffer;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        String base = input.nextLine();
        int times = input.nextInt();
        for(int i = 0; i < times; i ++ ){
            String operation = input.next();
            if(operation.compareTo("print") == 0){
                int a = input.nextInt();
                int b = input.nextInt();
                System.out.println(base.substring(a, b + 1));
            }
            if(operation.compareTo("reverse") == 0){
                int a = input.nextInt();
                int b = input.nextInt();
                StringBuffer buffer1 = new StringBuffer(base.substring(a, b + 1));
                StringBuffer buffer2 = new StringBuffer(base);
                buffer1.reverse();
                buffer2.replace(a, b + 1, buffer1.toString());
                base = buffer2.toString();
            }
            if(operation.compareTo("replace") == 0){
                int a = input.nextInt();
                int b = input.nextInt();
                String change = input.next();
                StringBuffer buffer = new StringBuffer(base);
                buffer.replace(a, b + 1, change);
                base = buffer.toString();
            }
        }
    }
}


Measured memory_bytes: 29056
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define MAX 1e9+7
#define MIN -1e9-7
#define int long long
#define endl "\n"
#define s(n) scanf("%d",&n)
#define mem memset(a, 0, sizeof(a))
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<string> vs;
/*
* * * * * * * * * * * * * * * * * * * * * *
*       ☆꧁𝓑𝓐𝓒𝓚_𝓛𝓞𝓖꧂☆              **
*                                        ***
* * * * * * * * * * * * * * * * * * * * *****
*/ 

int32_t main()
{
   int n;
   cin>>n;
   if(n==0)
   {
	   cout<<1<<endl;
   }
   else if(n==1)
   {
	   cout<<0<<endl;
   }
return 0;

}




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

using namespace std;

bool f(vector<char> arr) {
    if (arr[0] != arr[5]) {
        return false;
    }

    if (arr[1] != arr[4]) {
        return false;
    }

    if (arr[2] != arr[3]) {
        return false;
    }

    return true;
}

int main() {

    vector<char> arr;
    for (int i = 0; i < 6; i++) {
        char tmp;
        cin >> tmp;
        arr.push_back(tmp);
    }

    if (f(arr)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>

using namespace std;

int main(void)
{
    int n;
    int l[11];

    cin >> n;

    int max = 0;
    int sum = 0;
    int index;
    for (int i = 1; i <= n; i++) {
        cin >> l[i];
        sum += l[i];
        if (max < l[i]) {
            max = l[i];
            index = i;
        }
    }

    sum -= l[index];

    if (l[index] < sum) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
 * 2544.cc: Older Research Bldg. No.7
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, q;
  cin >> n >> q;

  string name("kogakubu10gokan");

  for (int i = 0; i < n; i++) {
    int yi;
    string namei;
    cin >> yi >> namei;

    if (yi > q) break;
    name = namei;
  }

  cout << name << endl;
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n,k;
  cin>>n>>k;
  ll a[n+1];
  fo(i,n)
  cin>>a[i+1];
  map <ll,pair<ll,ll>> mp;
  ll r=1,c=0,ans;
  mp[r].fi=1;mp[r].se=0;
  while(1)
  {
    if(c==k-1)
    {
      cout<<a[r];
      return 0;
    }
    r=a[r];
    c++;
    if(mp[r].fi)
    {
      ans=c-mp[r].se;
      k=k-mp[r].se;
      break;
    }
    else
    {
      mp[r].fi=1;
      mp[r].se=c;
    }
  }
  ans=k%ans;c=0;
  while(1)
  {
    if(c==ans)
      break;
    r=a[r];
    c++;
  }
  cout<<r;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << " ";cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t; cin >> s >> t;
	vector<vector<pair<int, pair<int, int>>>> dp(size(s)+1, vector<pair<int, pair<int, int>>>(size(t) + 1));
	for (int i = 0; i<=size(s); i++) dp[i][0] = make_pair(0, make_pair(-1, -1));
	for (int i = 1; i<=size(t); i++) dp[0][i] = make_pair(0, make_pair(-1, -1));
	for (int i = 1; i<=size(s); i++) {
		for (int j = 1; j<=size(t); j++) {
			if (s[i-1] == t[j-1]) {
				dp[i][j] = make_pair(dp[i-1][j-1].first + 1, make_pair(i-1, j-1));
			}
			else if (dp[i-1][j].first > dp[i][j-1].first) {
				dp[i][j] = make_pair(dp[i-1][j].first, make_pair(i-1, j));
			}
			else {
				dp[i][j] = make_pair(dp[i][j-1].first, make_pair(i, j-1));
			}
		}
	}
	string ret = "";
	int ptr1 = size(s), ptr2 = size(t);
	while (ptr1 != 0 && ptr2 != 0) {
		if (s[ptr1-1] == t[ptr2-1]) ret = s[ptr1-1] + ret;
		pair<int, int> temp = dp[ptr1][ptr2].second;
		ptr1 = temp.first, ptr2 = temp.second;
	}
	cout << ret << '\n';
}



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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


long long oddsolve(long long a) { return (a+1)/2 % 2; }
long long solve(long long a) {
    if (a % 2 == 1) return oddsolve(a);
    else return oddsolve(a+1) ^ (a+1);
}

int main() {

 
  int A, B, K;
  cin >> A >> B >> K;
  int count = 0;
  if(A>B)swap(A, B);
  int i = A;
  while(1){
    if(A%i==0 && B%i==0){
      count++;
      if(count==K)break;
    }
    i--;
  }
  cout << i << endl;
}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign


int length, n;
int l[102], r[102];

signed main()
{
    while (cin >> n >> length, (n|length)) {
        memset(r, 0, sizeof(r));
        memset(l, 0, sizeof(l));
        rep(i, n) {
            char tmpc;
            int tmp;
            cin >> tmpc >> tmp;
            if (tmpc == 'L') {
                l[tmp] = i+1;
            } else {
                r[tmp] = i+1;
            }
        }
            //rep(i, length+1) { cout << l[i] << " "; } cout << endl;
            //rep(i, length+1) { cout << r[i] << " "; } cout << endl;
        int fl = n;
        int ans_num = 0, ans_time = 0;
        while (fl) {
            rep(i, length) {
                if (l[i]) {
                    l[i-1] = l[i];
                    l[i] = 0;
                }
            }
            for (int i = length-1; i >= 0; i--) {
                if (r[i]) {
                    r[i+1] = r[i];
                    r[i] = 0;
                }
            }
            //rep(i, length+1) { cout << l[i] << " "; } cout << endl;
            //rep(i, length+1) { cout << r[i] << " "; } cout << endl;
            rep(i, length+1) {
                if (r[i] && l[i]) {
                    int tmp = r[i];
                    r[i] = l[i];
                    l[i] = tmp;
                }
            }
            if (r[length]) {
                fl--;
                ans_num = r[length];
                r[length] = 0;
            }
            if (l[0]) {
                fl--;
                ans_num = l[0];
                l[0] = 0;
            } 
            ans_time++;
        }
        cout << ans_time << " " << ans_num << endl;
    }

    return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
#define PB push_back
#define MP make_pair
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,s,e) for(ll i=e; i>=s; i--)
#define vasort(v) sort(v.begin(), v.end())
#define vdsort(v) sort(v.begin(), v.end(),greater<int>())
#define F first
#define S second

#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << ln
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << ln
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define out5(x1,x2,x3,x4,x5) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << ln
#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << " " << x2 << " " << x3 << " " << x4 << " " << x5 << " " << x6 << ln

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4
#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5
#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6

#define arrin(a,n) forn(i,n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    string s,t;
    in1(s);
    in1(t);
    ll x=s.size();
    ll y=t.size();
    ll len[x+1][y+1];
    for(ll i=0;i<=x;i++){
        for(ll j=0;j<=y;j++){
            if (i==0 || j==0) len[i][j]=0;
            else if (s[i-1]==t[j-1]) len[i][j]=len[i-1][j-1]+1;
            else len[i][j]=max(len[i-1][j],len[i][j-1]);
        }
    }
    ll l=len[x][y];
    vector<char> a(l);
    while (x>0 && y>0){
        if (s[x-1]==t[y-1]){
            a[l-1]=s[x-1];
            //out1(s[x-1]);
            --l;
            --x;
            --y;
        }else if (len[x-1][y]>=len[x][y-1]) --x;
        else --y;
    }
    for(auto i:a) cout<<i;


    return 0;
}

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

int main(){
    string N;
    cin>>N;
    if(N.at(0)==N.at(1)&&N.at(1)==N.at(2)){
        cout<<"Yes"<<endl;
    }else if(N.at(1)==N.at(2)&&N.at(2)==N.at(3)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

using namespace std;

int get(vector<long long> a) {
  int n = a.size();
  if (n & 1) {
    return a[n / 2];
  } else {
    return (a[n / 2 - 1] + a[n / 2]) / 2;
  }
}

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

  int n;
  cin >> n;
  long long ans = 0;
  vector<long long> A, B;
  for (int i = 0; i < n; ++i) {
    long long a, b;
    cin >> a >> b;
    a *= 2, b *= 2;
    A.push_back(a);
    B.push_back(b);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  if (n & 1) {
    cout << (get(B) - get(A)) / 2 + 1;
  } else {
    cout << get(B) - get(A) + 1;
  }

  return 0;
}


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

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    string x;
    cin  >> x;
    cout << x[0] << x[1] << x[2] << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}



int main()
{
    fastio();
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(min(a+b,b+c),a+c)<<endl;
    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int dp[10][330];
bool used[10];

void solve(int k,int s)
{
    if(k == 11) return ;
    for(int i = 0; i < 10; i++){
        if(!used[i]){
            used[i] = true;

            dp[k+1][s + i * (k+1)]++;
            solve(k + 1,s + i * (k+1));

            used[i] = false;
        }
    }
}

int main()
{
    int n,s;
    solve(0,0);
    while(cin >> n >> s){
        if(s > 330){
            cout << 0 << endl;
        }else{
            cout << dp[n][s] << endl;
        }
    }
}



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

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

int main() {
    int N; cin >> N;
    vector<int> p(N); rep(i, N) cin >> p[i];

    vector<int> a(N), b(N);
    rep(i, N) {
        a[i] = N*(i + 1);
        b[i] = N*(N - i);
    }

    rep(i, N) {
        a[p[i] - 1] -= (N - i - 1);
    }

    rep(i, N) {
        if (i > 0) cout << ' ';
        cout << a[i];
    }
    cout << endl;
    rep(i, N) {
        if (i > 0) cout << ' ';
        cout << b[i];    
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    char A[101], B[101], C[101];
    scanf("%s%s%s", A, B, C);
    int cnta = 0, cntb = 0, cntc = 0;
    int firstb = 1, firstc = 1;
    bool a = 1, b = 0, c = 0;

    while (1)
    {
        if (a == true)
        {
            if (A[cnta] == 'a')
                cnta++;
            else if (A[cnta] == 'b')
            {
                b = 1;
                a = 0;
                if (!firstb)
                    cntb++;
                    else firstb = 0;
            }
            else if (A[cnta] == 'c')
            {
                a = 0;
                c = 1;
                if (!firstc)
                    cntc++;
                    else firstc = 0;
                
                        
                    
            }
        }
        else if (b == true)
        {
            if (B[cntb] == 'a')
            {
                b = 0;
                a = 1;
                cnta++;
            }
            else if (B[cntb] == 'b')
                cntb++;
            else if (B[cntb] == 'c')
            {
                b = 0;
                c = 1;
                if (!firstc)
                    cntc++;
                    else firstc = 0;
            }
        }
        else
        {
            if (C[cntc] == 'a')
            {
                c = 0;
                a = 1;
                cnta++;
            }
            else if (C[cntc] == 'b')
            {
                c = 0;
                b = 1;
                if (!firstb)
                    cntb++;
                    else firstb = 0;
            }
            else
            {
                cntc++;
            }
        }
        if (cnta == strlen(A))
        {
            cout << 'A' << endl;
            return 0;
        }
        else if (cntb == strlen(B))
        {
            cout << 'B' << endl;
            return 0;
        }
        else if (cntc == strlen(C))
        {
            cout << 'C' << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
Minute = 60*H+M
pi = math.pi
long=2*pi*Minute/720
short=2*pi*M/60
if -pi<=long-short<=pi:
    cos = math.cos(long-short)
else:
    cos =math.cos(2*pi - (long-short))
ans = (A**2 + B**2 - 2*A*B*cos)**0.5
print(ans)

Measured memory_bytes: 62432
// AtCoder Beginner Contest 126A - Changing a Character (https://atcoder.jp/contests/abc126/tasks/abc126_a)
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, K;
    string S;

    cin >> N >> K >> S;

    S[K - 1] = tolower(S[K - 1]);

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
	long i, n, a[100000], ans = 0, min = 1;


	cin >> n ;

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

	ans += a[0] - 1;
	min += 1;


	for (i = 1; i < n; i++) {
		if (a[i] == min) {
			//cout << "aaa"  << endl;
			min += 1;
			//continue;
		}
		else{
			ans += (a[i] - 1) / min;
			//cout << "ans" << ans << endl;
		}
	}




	/*for (i = 0; i < n; i++) {
		x = xmin;
		if (a[i] == x) xmin++; x++;
		if (a[i] - 1 < x) continue;
		ans += a[i] - 1 / x;
		cout << "ans" << ans << endl;
		a[i] = a[i] - 1 % x + 1;
		if (a[i] == 1 && xmin == 1) {
			xmin++;
		}
		else if (a[i] == xmin) {
			a[i] -= 1;
		}
	
	}*/


	/*while (-1) {
		if(a[i] == x) {
			amin = a[i];
			if (amin == 1) xmin++;
		}
		else if(a[i] > x) {
			a[i] -= x;
			ans++;
			if(a[i]>)
		}

		i++;
	}*/




	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int (i) = (x); (i) <= (y); (i) ++)
#define eps 1e-9
#define del(i) ab.erase(mp(a[i] - b[i], i)), ba.erase(mp(b[i] - a[i], i)), ac.erase(mp(a[i] - c[i], i)), ca.erase(mp(c[i] - a[i], i)), bc.erase(mp(b[i] - c[i], i)), cb.erase(mp(c[i] - b[i], i));
#define insa(i) ab.insert(mp(a[i] - b[i], i)), ac.insert(mp(a[i] - c[i], i));
#define insb(i) ba.insert(mp(b[i] - a[i], i)), bc.insert(mp(b[i] - c[i], i));
#define insc(i) ca.insert(mp(c[i] - a[i], i)), cb.insert(mp(c[i] - b[i], i));
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 3e5 + 10;
int n, x, y, z;
ll ans = 0;
int a[N], b[N], c[N];
set<pii> ab, ba, ac, ca, bc, cb;
inline bool Do1(int *a, int *b, int *c, set<pii> &ab, set<pii> &ba,
									set<pii> &ac, set<pii> &ca, set<pii> &bc, set<pii> &cb)
{
	pii l = *ab.begin(), r = *ba.begin();
	if (l.X + r.X < 0)
	{
		ans -= l.X + r.X;
		int x = l.Y, y = r.Y;
		del(x); del(y);
		insb(x); insa(y);
		return 1;
	}
	return 0;
}
inline bool Do2(int *a, int *b, int *c, set<pii> &ab, set<pii> &ba,
									set<pii> &ac, set<pii> &ca, set<pii> &bc, set<pii> &cb)
{
	pii pa = *ab.begin(), pb = *bc.begin(), pc = *ca.begin();
	if (pa.X + pb.X + pc.X < 0)
	{
		ans -= pa.X + pb.X + pc.X;
		int x = pa.Y, y = pb.Y, z = pc.Y;
		del(x); del(y); del(z);
		insb(x); insc(y); insa(z);
		return 1;
	}
	return 0;
}
bool Do(int *a, int *b, int *c, set<pii> &ab, set<pii> &ba, set<pii> &ac,
					set<pii> &ca, set<pii> &bc, set<pii> &cb)
{
	return Do1(a, b, c, ab, ba, ac, ca, bc, cb) ||
				 Do2(a, b, c, ab, ba, ac, ca, bc, cb);
}

int main()
{
	cin >> x >> y >> z;
	n = x + y + z;
	rep(i, 1, n)
		a[i] = read(), b[i] = read(), c[i] = read();
	rep(i, 1, x) ans += a[i], insa(i);
	rep(i, x + 1, x + y) ans += b[i], insb(i);
	rep(i, x + y + 1, n) ans += c[i], insc(i);
	while(1)
	{
		int flag = 0;
		flag |= Do(a, b, c, ab, ba, ac, ca, bc, cb);
		flag |= Do(a, c, b, ac, ca, ab, ba, cb, bc);
		flag |= Do(b, c, a, bc, cb, ba, ab, ca, ac);
		flag |= Do(b, a, c, ba, ab, bc, cb, ac, ca);
		flag |= Do(c, a, b, ca, ac, cb, bc, ab, ba);
		flag |= Do(c, b, a, cb, bc, ca, ac, ba, ab);
		if (!flag) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10752
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

// ────────────────────────────────────────────────────

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

	if (b % a == 0) cout << b / a << endl;
	else cout << b / a + 1 << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, m;
	cin >> n >> m;
	vector<vector<int>> adj(n + 1);
	while (m--) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	vector<int> dis(n + 1, INF), prev(n + 1, -1);
	queue<int> q;
	q.push(1);
	dis[1] = 0;
	while (sz(q)) {
		int cur = q.front();
		q.pop();
		for (int ch : adj[cur])
			if (dis[ch] > dis[cur] + 1) {
				dis[ch] = dis[cur] + 1;
				prev[ch] = cur;
				q.push(ch);
			}
	}
	for (int i = 2; i <= n; i++)
		if (prev[i] == -1) {
			cout << "No\n";
			return 0;
		}
	cout << "Yes\n";
	for (int i = 2; i <= n; i++)
		cout << prev[i] << endl;
}


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

#define int long long

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

int N;
vector<int> child[100001];

int dp(int v) {
    if (child[v].size() == 0) {
        return 1;
    }
    vector<int> dps;
    for (int i = 0; i < child[v].size(); i++) {
        dps.push_back(dp(child[v][i]));
    }
    sort(dps.begin(), dps.end());
    reverse(dps.begin(), dps.end());
    int res = 0;
    for (int i = 0; i < child[v].size(); i++) {
        res = max(res, dps[i] + i + 1);
    }
    return res;
}

signed main() {
    cin >> N;
    for (int i = 2; i <= N; i++) {
        int a;
        cin >> a;
        child[a].push_back(i);
    }
    cout << dp(1) - 1 << endl;
    return 0;
}


Measured memory_bytes: 15104
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    def check(x):
        cnt = 0
        for a in A:
            cnt += (a - 1) // x
        return cnt <= k

    l = 0
    r = 10 ** 10
    while r - l > 1:
        m = (l + r) // 2
        if check(m):
            r = m
        else:
            l = m
    print(r)
resolve()

Measured memory_bytes: 93720
#define ONLINE_JUDGE
#include <bits/stdc++.h>
#include <unordered_map>
int solve();
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif 
	::std::ios::sync_with_stdio(false);
	::std::cin.tie(0);

	solve();
	return 0;
}

using namespace std;
typedef long long ll;




int solve() {
	vector<int> a(3);
	int ret = 0;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
		ret += a[i];
	}

	ret += 9*(*max_element(a.begin(), a.end()));

	cout << ret << endl;
	
	


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

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

	int T, div[3] = {2, 3, 5};
	cin >> T;
	while(T --> 0) {
		ll N, cs[3], D;
		cin >> N >> cs[0] >> cs[1] >> cs[2] >> D;
		priority_queue<pll> q;
		unordered_map<ll, ll> ds;
		q.emplace(0, N);
		ds[N] = 0;
		ds[0] = INT64_MAX;
		while(!q.empty()) {
			ll n = q.top().second;
			ll d = - q.top().first;
			q.pop();
			if(ds[n] < d) continue;
			if(d >= ds[0]) break;
			if(n <= (INT64_MAX-d) / D) ds[0] = min(ds[0], d+n*D);
			for(int i = 0; i < 3; ++i) {
				ll m = n%div[i];
				ll n2 = n/div[i], d2 = d+cs[i]+D*m;
				if(!ds.count(n2) || d2 < ds[n2]) {
					ds[n2] = d2;
					q.emplace(-d2, n2);
				}
				if(m == 0) continue;
				++ n2;
				d2 = d+cs[i]+D*(div[i]-m);
				if(!ds.count(n2) || d2 < ds[n2]) {
					ds[n2] = d2;
					q.emplace(-d2, n2);
				}
			}
		}
		cout << ds[0] << "\n";
	}

	return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

template <class T>
struct LazySegmentTree {
    int n;
    T def;
    vector<T> node, lazy;
    vector<bool> flag;
    function<T(T, T)> func;

    LazySegmentTree(int _n, T _def, function<T(T, T)> _func)
        : def(_def), func(_func) {
        n = 1;
        while (n < _n) n *= 2;
        node.resize(2 * n - 1, def);
        lazy.resize(2 * n - 1, def);
        flag.resize(2 * n - 1, false);
    }

    void eval(int k, int l, int r) {
        if (flag[k]) {
            node[k] += lazy[k];
            if (r - l > 1) {
                lazy[k * 2 + 1] += lazy[k];
                lazy[k * 2 + 2] += lazy[k];
                flag[k * 2 + 1] = flag[k * 2 + 2] = true;
            }
            lazy[k] = def;
            flag[k] = false;
        }
    }

    void update(int a, int b, T v, int k, int l, int r) {
        eval(k, l, r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            lazy[k] += v;
            flag[k] = true;
            eval(k, l, r);
        } else {
            update(a, b, v, 2 * k + 1, l, (l + r) / 2);
            update(a, b, v, 2 * k + 2, (l + r) / 2, r);
            node[k] = func(node[2 * k + 1], node[2 * k + 2]);
        }
    }

    T get(int a, int b, int k, int l, int r) {
        eval(k, l, r);
        if (b <= l || r <= a) return def;
        if (a <= l && r <= b) return node[k];
        T vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
        return func(vl, vr);
    }

    void update(int a, int b, T v) {
        update(a, b, v, 0, 0, n);
    }

    T get(int a, int b) {
        return get(a, b, 0, 0, n);
    }
};

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

    ll n, d, a;
    cin >> n >> d >> a;
    ll ans = 0;
    vector<pair<ll, ll>> z(n);
    rep(i, 0, n) {
        ll x, h;
        cin >> x >> h;
        z[i].first = x;
        z[i].second = (h + a - 1) / a;
    }
    sort(z.begin(), z.end());
    vector<ll> x(n), h(n);
    rep(i, 0, n) {
        x[i] = z[i].first;
        h[i] = z[i].second;
    }

    auto func = [](ll a, ll b) { return max(a, b); };
    LazySegmentTree<ll> st(200200, 0, func);

    rep(i, 0, n) {
        int j = upper_bound(x.begin(), x.end(), x[i] + 2LL * d) - x.begin() - 1;
        ll s = h[i] - st.get(i, i + 1);
        //cout << i << ' ' << j << endl;
        //cout << s << endl;
        if (s > 0) {
            ans += s;
            st.update(i, j + 1, s);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14848
n, m, l = map(int, input().split())

a = []
b = []
c = []
d = []
for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(m):
    b.append(list(map(int, input().split())))

ele = 0

for i in range(n):
    for j in range(l):
        for k in range(m):
            ele += a[i][k] * b[k][j]
        d.append(ele)
        ele = 0
    c.append(d)
    d = []

for i in range(n):
    print(*c[i])



Measured memory_bytes: 7060
macro_rules! read {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_trim() -> String {
    read!().trim().to_owned()
}

fn main() {
    let input = read_trim();
    let mut buf = String::new();

    for c in input.chars() {
        match c {
            '0' => buf.push('0'),
            '1' => buf.push('1'),
            'B' => if let Some(_) = buf.pop() {},
            _ => {},
        }
    }

    println!("{}", buf)
}

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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))

char S[1010], T[1010];

int solve() {
  int ans = 1e9;
  int slen = strlen(S);
  int tlen = strlen(T);

  int diff = slen - tlen;

  // printf("diff: %d\n", diff);
  if (diff == 0) {
    ans = 0;
    rep(i, slen) {
      if (S[i] != T[i]) {
        ans += 1;
      }
    }
  }

  rep(i, diff) {
    int cnt = 0;
    // printf("i: %d\n", i);
    rep(j, tlen) {
      int k = i + j;
      // printf("j: %d\n", j);
      // printf("k: %d\n", k);
      if (S[k] != T[j]) {
        cnt += 1;
      }
    }
    ans = min(ans, cnt);
  }
  return ans;
}

int main() {
  scanf("%s", S);
  scanf("%s", T);

  printf("%d\n", solve());

  return 0;
}


Measured memory_bytes: 1716
#include <iostream>
#include <iomanip>
#include <map>
#include <vector>
#include <cmath>
#include <string> // これがないとstringの出力がエラー
#include <sstream>
#include <algorithm>
#include <bitset>
#include <list>
#include <set>
using namespace std;

typedef long long ll;

void flip(string& str, int n) {
	str[n] = '0';
	str[n + 1] = '1';
	str[n + 2] = '0';
}

map<string,ll> dp;
ll dfs(string str, ll cnt)
{
	if (dp.count(str) != 0) {
		return dp[str];
	}
	//cerr << str << " " << cnt << endl;
	ll maximum = 0;
	for (int i = 0; i < str.size() - 2; ++i) {
		if (i + 2 >= str.size()) continue;
		if (str[i] == '1' && str[i + 1] == '0' && str[i + 2] == '1') {
			string next = str;
			flip(next, i);
			maximum = max(maximum, dfs(next, cnt + 1));
		}
	}
	ll ret = max(cnt, maximum);
	dp[str] = ret;
	return ret;
}

void pA()
{
	int A, B, C; cin >> A >> B >> C;
    if (A == B)
      cout << C << endl;
    else if (B == C)
      cout << A << endl;
    else
      cout << B << endl;
}

void pB()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << A * 1728 + B * 144 + C * 12 + D << endl;
}

unsigned bit_count(unsigned n)
{
	unsigned i = 0;

	while (n) {
		i += n & 1;
		n >>= 1;
	}

	return i;
}

int N, M;
set<int> path[100004];

ll addPath()
{
	ll cnt = 0;
	for (int n0 = 1; n0 <= N; ++n0) {
		for (auto n1 : path[n0]) {
			if (n0 == n1) continue;
			for (auto n2 : path[n1]) {
				if (n1 == n2) continue;
				if (n0 == n2) continue;
				for (auto n3 : path[n2]) {
					if (n2 == n3) continue;
					if (n1 == n3) continue;
					if (n0 == n3) continue;
					if (path[n0].find(n3) == path[n0].end()) {
						cnt++;
						path[n0].insert(n3);
						path[n3].insert(n0);
					}
				}
			}
		}
	}
	return cnt;
}

void pC()
{
	cin >> N >> M;
	for (int m = 0; m < M; ++m) {
		int a, b; cin >> a >> b;
		path[a].insert(b);
		path[b].insert(a);
	}

	cout << addPath() << endl;
}

int main()
{
	pA();

	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int h,w;
pair<int,int> src,dest;
int mat[1001][1001];
bool vis[1001][1001];
int res[1001][1001];

int x_mov[]={1,-1,0,0};
int y_mov[]={0,0,-1,1};

bool is_valid(int x,int y){

    if(x< 0 || y<0 || x>=h || y>=w || !mat[x][y] || vis[x][y])
        return false;

    return true;
}

void bfs(){

    memset(vis,false,sizeof(vis));
    memset(res,0,sizeof(res));

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout<<res[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    deque<pair<pair<int,int>,int>> q;
    q.push_front({src,0});
    // vis[src.F][src.S]=true;

    while(!q.empty()){
        // cout<<"Im in loop"<<endl;
        pair<int,int> pp =q.front().F;
        int cost=q.front().S;

        // cout<<pp.F<<" "<<pp.S<<" -->"<<cost<<endl;
        q.pop_front();
        if(vis[pp.F][pp.S]) continue;
        vis[pp.F][pp.S]=true;
        
        if(pp.F==dest.F && pp.S==dest.S){
            cout<<cost<<endl;
            return;
        }

        for(int i=0;i<4;i++){
            int new_x=pp.F + x_mov[i];
            int new_y=pp.S + y_mov[i];

            if(is_valid(new_x,new_y)){

                // vis[new_x][new_y]=true;
                q.push_front({{new_x,new_y},cost+0});
                res[new_x][new_y]=min(cost,res[new_x][new_y]);
                // cout<<new_x<<"  -->"<<new_y<<" "<<res[new_x][new_y]<<endl;
            }
        }

        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int new_x=pp.F + i;
                int new_y=pp.S + j;

                if(is_valid(new_x,new_y)){

                    // cout<<new_x<<" === "<<new_y<<endl;
                    // vis[new_x][new_y]=true;
                    q.push_back({{new_x,new_y},cost+1});
                    res[new_x][new_y]=cost+1;
                }
            }
        }
    }

    cout<<-1<<endl;
}

int32_t main()
{
    cin>>h>>w;

    cin>>src.F>>src.S;
    cin>>dest.F>>dest.S;

    src.F--;src.S--;dest.F--;dest.S--;
    memset(mat,0,sizeof(mat));
    for(int i=0;i<h;i++){
        string str;cin>>str;
        for(int j=0;j<w;j++){
            if(str[j]=='.')
                mat[i][j]=1;
        }
    }

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout<<mat[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }

    bfs();
    return 0;
}

Measured memory_bytes: 21676