akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
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;}
//******************************************************************************
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 V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int N;
map<int,int>mp;

signed main()
{
	//IOS();
	cin>>N;
	vpint a;
	rep(i,0,N){
		int t;
		cin>>t;
		if(!mp.count(t)){
			a.push_back({t,i});
		}
		mp[t]++;
	}
	a.push_back({0,INF});
	sort(all(a));
	reverse(all(a));
	vector<int>ans(N,0);
	int sum = 0,mi=INF;
	rep(i,0,a.size()-1){
		sum+=mp[a[i].fi];
		chmin(mi,a[i].se);
		ans[mi]+=(a[i].fi-a[i+1].fi)*sum;
	}
	rep(i,0,N){
		cout<<ans[i]<<endl;
	}
}


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

int main(){
  int t,n;
  string str;
  bool book[2][50000];
  int v[3][20000],a[3][20000];

  cin >> t;
  while(t--){
    cin >> n >> str;
    for(int i=0;i<2;i++){
      for(int j=0;j<2*n;j++)book[i][j+1] = (str[i*2*n+j]=='Y');
      book[i][0] = book[i][2*n+1] = false;
    }

    for(int i=0;i<3;i++)
      for(int j=0;j<=n;j++){
	v[i][j] = a[i][j] = 100000000;
      }
    a[0][0] = 0;

    for(int i=0;i<=n;i++){
      if(book[1][2*i] || book[1][2*i+1]){
	v[0][i] = min(min(v[0][i],a[0][i] + 3),min(a[1][i] + 2,a[2][i] + 2));
	if(book[0][2*i] || book[0][2*i+1]){
	  v[1][i] = min(min(v[1][i],a[0][i] + 2),min(a[1][i] + 2,a[2][i] + 2));
	  v[2][i] = min(min(v[2][i],a[0][i] + 2),min(a[1][i] + 2,a[2][i] + 3));
	}else{
	  v[1][i] = min(min(v[1][i],a[0][i] + 2),min(a[1][i] + 1,a[2][i] + 1));
	  v[2][i] = min(min(v[2][i],a[0][i] + 2),min(a[1][i] + 1,a[2][i] + 1));
	}
      }else if(book[0][2*i] || book[0][2*i+1]){
	v[0][i] = min(min(v[0][i],a[0][i] + 1),min(a[1][i] + 1,a[2][i] + 2));
	v[1][i] = min(min(v[1][i],a[0][i] + 1),min(a[1][i] + 1,a[2][i] + 2));
	v[2][i] = min(min(v[2][i],a[0][i] + 2),min(a[1][i] + 2,a[2][i] + 3));
      }else{
	v[0][i] = min(min(v[0][i],a[0][i]),min(a[1][i] + 1,a[2][i] + 2));
	v[1][i] = min(min(v[1][i],a[0][i] + 1),min(a[1][i],a[2][i] + 1));
	v[2][i] = min(min(v[2][i],a[0][i] + 2),min(a[1][i] + 1,a[2][i]));
      }

      if(i==n)break;

      for(int j=0;j<3;j++)a[j][i+1] = v[j][i] + 1;
    }
    cout << v[0][n] << endl;
  }  
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

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

    int now = 1;
    for (int i = 0; i < N; i++) {
        if (now == 2) {
            cout << i << endl;
            return 0;
        }
        now = a[now];
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
a,b,x,y;
main()
{
  while(scanf("%d%d",&a,&b)>0)
    {
      x=z(a,b);
      printf("%d %.f\n",x,(float)a*b/x);
    }
  exit(0);
}
z(a,b){
  if(a%b==0)
    return b;
  else
    return z(b,a%b);
}

Measured memory_bytes: 0
S = input()

left = 0
left_end = (len(S)-1)//2 -1
right = len(S)-1
right_start = (len(S)+3)//2 -1
flag = 0

for i in range((len(S)-1)//2):
	if(S[left] != S[right]) or (S[left] != S[left_end]) or (S[right_start] != S[right]):
		flag += 1
		break
	left += 1
	left_end -= 1
	right_start += 1
	right -= 1

if flag == 0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
def input_from_console():
    n, m = map(int, input().split())
    a_list = map(int, input().split())

    bc_list = []
    for i in range(m):
        b, c = map(int, input().split())
        bc_list.append((b, c))
    return n, m, a_list, bc_list


def solve(n, m, a_list, bc_list):
    bc_list.sort(key=lambda x: x[1], reverse=True)
    a_list = sorted(a_list)

    position = 0
    a_length = len(a_list)

    for item in bc_list:
        b, c = item
        for i in range(b):
            if position >= a_length or a_list[position] >= c:
                return sum(a_list)
            else:
                a_list[position] = c
                position += 1
    return sum(a_list)


def main():
    n, m, a_list, bc_list = input_from_console()
    print(solve(n, m, a_list, bc_list))


if __name__ == "__main__":
    main()

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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

const ll maxn=1e3+1,mod=1e9+7;

ll memo[maxn][maxn][2];
string a;
ll n;
vector<ll> alpha(26);


int main(){
    sync
    ll n;
    cin>>n;
    vector<ll> v;
    ll pre[2*n+1];
    forn(i,n){
        ll x;
        cin>>x;
        v.pb(x);
    }
    forn(i,n) v.pb(v[i]);
    pre[0] = 0;
    bool f = true;
    forn(i,2*n){
        if(f){
            pre[i+1] = pre[i]+v[i];
        }
        else{
            pre[i+1] = pre[i]-v[i];
        }
        f = !f;
    }
    f = true;
    fore(i,n,2*n-1){
        if(f){
            cout<<pre[i]-pre[i-n]<<" ";
        }
        else{
            cout<<pre[i-n]-pre[i]<<" ";
        }
        f = !f;
    }

    return 0;
}

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

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

    int length = s.length();
    ll sum = 0;
    for (int mask = 0; mask < (1 << length - 1); mask++) {
        string temp = s.substr(length - 1, 1);
        for (int i = 0; i < length - 1; i++)  {
            if (1 & (mask >> i)) {
                sum += stol(temp);
                temp = s.substr(length - (i + 2), 1);
            } else {
                temp = s.substr(length - (i + 2), 1) + temp;
            }
        }
        sum += stol(temp);
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

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

		@SuppressWarnings("unchecked")
		Queue<Integer>[] queue = new Queue[3];
		queue[0] = new ArrayDeque<Integer>();
		queue[1] = new ArrayDeque<Integer>();
		queue[2] = new ArrayDeque<Integer>();

		for(int i = 0; i < 3; i++){
			String str = sc.next();
			for(int j = 0; j < str.length(); j++){
				queue[i].add(str.charAt(j) - 'a');
			}

//			System.out.println(queue[i].size());
		}

		int player = 0;
		while(queue[player].size() != 0){
			player = queue[player].poll();
		}

		System.out.println((char)(player + 'A'));
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

string S;

cin >> S;
/*
for(ll i = 0;i < S.size();++i){

    string subS = "";

    for(ll j = i;j < S.size();++j){
    
        subS = subS + S[j];
        ll num = atoi(subS.c_str());

        if(num%2019 == 0){

            ++ans;

        } 

    }

}

*/

ll x = 1;
ll tot = 0;
vector<ll> cnt(2019);
ll ans=0;
ll mod = 2019;

cnt[0] = 1;

reverse(S.begin(),S.end());

for(ll i = 0;i < S.size();++i){

    ll num = S[i] - '0';
    tot = (tot + (num*x)) % mod;
    cnt[tot] = cnt[tot] + 1;
    x = (10 * x) % mod;

}

for(ll n : cnt) ans += (n * (n - 1)) / 2;

cout << ans << endl;

return 0;

}


Measured memory_bytes: 3740
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<list>
#define rep(i,n) for(i = 0; i < n; i++)
#define rep2(i,s,l) for(i = s; i < l; i++)

using namespace std;

bool dfs(int, int);

int main() {
	int i, j,k;
	int n; cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	std::sort(l.begin(), l.end());
	long long ans = 0;
	
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			for (k = j + 1; k < n; k++) {
				if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) ans++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <vector>
using namespace std;
int main(){
	string S;
	cin >> S;
	string::iterator itr = S.begin();
	int cnt = 0;
	int loop = 1;
	size_t i = 0;
	while(i + 1< S.length()){
		if(*(itr + i) != *(itr + 1 + i)){
			S.erase(itr + i, itr + 2 + i);
			cnt = cnt + 2;
			itr = S.begin();
			if(i > 0){
				i--;
			}
		}
		else{
			i++;
		}
	}
	cout << cnt << endl;
}

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

#define ff               first
#define ss               second
#define mp               make_pair
#define pb               push_back
#define pii              pair<int,int>
#define vi               vector<int> 
#define mii              map<int,int>
#define setbits(x)       __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod              1000000007
#define inf              1e18
#define endl             "\n"

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

void l_code()
{
 #ifndef ONLINE_JUDGE
     cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
 #endif
}
const int N=200005;

int main() {
   // h_code();
    int t=1;
    int arr[N];
    while(t--)
    {
       int n,k;
       cin>>n>>k;
       for (int i = 0; i < n; i++)
       {
           cin>>arr[i];
       }
       sort(arr,arr+n);
       n=n-k;
       long long sum=0;
       for (int i = 0; i < n; i++)
       {
           sum+=arr[i];
       }
       cout<<sum;
       

    }
  //  l_code();
}

Measured memory_bytes: 1024
program ABC
    integer(8) a, b, c, d, L
    read*, a, b, c, d
    a = a - 1
    L = c * d / GCD(c, d)
    print"(i0)", ((b - b / c - b / d + b / L) - (a - a / c - a / d + a / L))
contains
    !GCDを求めるよ！
    recursive integer(8) function GCD (a, b) result (res)
        implicit none
        integer(8) a, b
        if (b > 0) then
            res = GCD(b, mod(a, b))
        else 
            res = a
        end if
    end function
end program ABC


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int i;
    int vote = 0;
    int count=0;
    for(i=0;i<n;i++){
        cin >> a.at(i);
        vote += a.at(i);
    }

    for(i=0;i<n;i++){
        if(a.at(i) >= vote/(4.0*m))
            count++;
    }

    if(count>=m)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3112
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

string str;

int main() {
	cin >> str;
	if (str[0] != str[str.size() - 1]) {
		if (str.size() % 2) puts("First");
		else puts("Second");
	}
	else {
		if (str.size() % 2) puts("Second");
		else puts("First");
	}
	return 0;
}


Measured memory_bytes: 640
import collections

def main():
    S = list(input())
    Scount = collections.Counter(S)
    a = Scount['a']; b = Scount['b']; c = Scount['c']
    if abs(a-b) <= 1 and abs(b-c) <= 1 and abs(c-a) <= 1:
        print('YES')
    else:
        print('NO')

if __name__ == "__main__":
    main()


Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <set>

using namespace std;

int n;
string w[105];
set<string> s;

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++) cin >> w[i];
	
	s.insert(w[0]);
	for(int i = 1; i < n; i++){
		if(s.count(w[i])) goto ng;
		if(w[i-1][w[i-1].size()-1] != w[i][0]) goto ng;
		s.insert(w[i]);
	}
	cout << "Yes" << endl;
	return 0;
	
	ng:;
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
object Main {
    def main(args : Array[String]) : Unit = {
        val a = io.StdIn.readLine().split(" ").map(_.toInt)
        if (a(0) < a(1)) println("a < b")
        else if (a(0) > a(1)) println("a > b")
        else println("a == b")
    }
}

Measured memory_bytes: 43644
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
 int main(void){
	 int n,k,t,u,v,l;
	 cin>>n>>k>>t>>u>>v>>l;
	 vector<int> d(n);
	 vector<bool> x(l,false);
	 vector<bool> a(l,false);
	 for(int i=0;i<n;i++){
		 cin>>d[i];
		 x[d[i]]= true;
	 } 
	 int rest=0;
	 int a1=t*v;
	 int amax=a1*(k+1);
	// cout<<amax<<endl;
	 for(int i=0;i<l;i++){
		 if(x[i])rest+=a1;
		 if(rest>amax)rest=amax;
		 if(rest!=0) {
	//		 cout<<rest<<" ";
			 rest--;
			 a[i]=true;
	//		 cout<<i<<" ";
		 }
	 }
		int nl=0,al=0;
		for(int i=0;i<l;i++){
			if(a[i])al++;
			else nl++;
		}
	//	cout<<al<<" "<<nl<<endl;
	printf("%f\n",(double)al/v+(double)nl/u);

	//cout<<(double)al/v+(double)nl/u;

	 return 0;
 }

Measured memory_bytes: 3220
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = 1.0 * a/b;
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
    return 0;
}


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


#define ll long long
#define MOD 1000000007



int main(){
    int n;
    cin>>n;
    
    vector<ll> a(n);
    ll m;
    for(int i=0;i<n;i++){
        cin>>a.at(i);
        if(i==0){
            m = a.at(i);
        }else{
            m = m^a.at(i);
        }
    }
    
    for(int i=0;i<n;i++){
        cout<<(m^a.at(i))<<" ";
    }
}


Measured memory_bytes: 4780
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>
#include <math.h>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
#define PI (acos(-1))  // 円周率pi

/* typedef */
// long long
typedef long long ll;

// pair
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<double, double> d_d;

/* main関数 */
int main(void) {
	int a1 = 100;

	int x;
	cin >> x;
	int count = x / a1;
	int r = x % a1;
	if ((r / 5 + 1 <= count) || (r / 5 == count && r % 5 == 0)) cout << 1;
	else cout << 0;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int mod=1e9+7;
typedef long long ll;
const int N=2e5+5;
int main()
{
	// std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
	// freopen("a.in","r",stdin);
	// int T;scanf("%d",&T);while(T--){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int l1=(a+d-1)/d,l2=(b+c-1)/b;
	if(l1>=l2) printf("Yes\n");
	else printf("No\n");
	// }
	return 0;
}


Measured memory_bytes: 3688
import bisect
import heapq
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,M=mi()
    
    L,R,_L = [],[],[]
    for i in range(M):
        a,b=mi()
        L.append((a,i))
        R.append((b,i))
        _L.append(a)

    L.sort()
    R.sort()
    _L.sort()

    heapq.heapify(L)    
    heapq.heapify(R)

    l_e = 0
    ans = 0
    seen = set()
    while R:
        r,j = heapq.heappop(R)
        if j in seen: continue

        li = bisect.bisect_left(_L,r)
        if li > 0: li -= 1

        for i in range(l_e,li+1):
            seen.add(L[i][1])

        l_e = li
        ans += 1

    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 107360
#include<stdio.h>

int main(){
  int n,s=1; scanf("%d",&n);
  char a[n]; scanf("%s",a);
  for(int i=0; i<n-1; i++){
    if(a[i]==a[i+1]) continue;
    else s++;
  }
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
#include <cmath>
using namespace std;

void solve() {
	string s;
	cin >> s;
	int cnt = 0;
	for (size_t i = 0, j = s.size() - 1; i < s.size() / 2; ++i, --j) {
		cnt += (s[i] != s[j]);
	}
	cout << cnt << endl;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
const ll mod =1000000007;
#define inf 100000
using namespace std;
int main()
{
   ll n; cin>>n;
   ll arr[n];
   for(ll i=0;i<n;i++)
    cin>>arr[i];
   bool dp[2][n];
   dp[0][0]=true;
   dp[1][0]=true;
   for(ll i=1;i<n;i++)
   {
       if(arr[i]>=arr[i-1]  and dp[0][i-1]==true)
       {
           dp[0][i]=true;
       }
       else if(arr[i]>=arr[i-1]-1 and dp[1][i-1]==true)
       {
           dp[0][i]=true;
       }
       else
        dp[0][i]=false;
       if(arr[i]-1>=arr[i-1]  and dp[0][i-1]==true)
       {
           dp[1][i]=true;
       }
       else if(arr[i]-1>=arr[i-1]-1 and dp[1][i-1]==true)
       {
           dp[1][i]=true;
       }
       else
        dp[1][i]=false;
   }
   if(dp[0][n-1]==true or dp[1][n-1]==true)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}



Measured memory_bytes: 1280
fun main(args: Array<String>) {
    var (x, y, xx, yy) = readLine()!!.split(" ").map { it.toInt() }
    while (true){
        xx = xx - y
        if(xx <= 0 ){
            println("Yes")
            break
        }
        x = x - yy
        if(x <= 0 ){
            println("No")
            break
        }
    }
}



Measured memory_bytes: 36396
#include<stdio.h>

int main(void){
  int a[10];
  int b[3];
  int max=0;
  int max_i=0;
  int i=0,j=0;

  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }

  for(j=0;j<3;j++){
    max = a[0];
      for(i=0;i<10;i++){
	if(max < a[i]){
	  max = a[i];
	  max_i = i;
	}
      }
      a[max_i]=0;
      printf("%d\n",max);
  }

  return 0;

}

Measured memory_bytes: 0
N, M =list(map(int, input().split()))
A_list =list(map(int, input().split()))
BC_list = [list(map(int, input().split())) for _ in range(M)]
for A in A_list:
    BC_list.append([1, A])
desc_C = lambda BC: BC[1]
desc_C_list = sorted(BC_list, key=desc_C, reverse=True)
cnt = 0
s = 0
# print("===========")
for b, c in desc_C_list:
    # print(cnt, s)
    if (cnt <= (N-b)):
        s += b * c
        cnt += b
    elif ( cnt < N < (cnt + b) ):
        s += (N-cnt) * c
        break
    else:
        break
print(s)


Measured memory_bytes: 98968
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;

int main(){
   int x,y,z;
   cin>>x>>y>>z;
   int ans=(x-z)/(y+z);
   cout<<ans<<endl;
   
}

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

int main() {
    int N, Y;
    cin >> N >> Y;
    int man = 0;
    int gos = 0;
    int sen = 0;
    int ha1  = Y % 5000;
    Y -= ha1;
    sen += ha1 / 1000;

    int ha5 = Y % 10000;
    Y -= ha5;
    gos += ha5 / 5000;
    man += Y / 10000;

    while (N - man - gos - sen != 0) {
        bool change = false;
        if (man > 0) {
            man--;
            gos += 2;
            change = true;
        }
        if (N - man - gos - sen >= 8 && gos >= 2) {
            gos -= 2;
            sen += 10;
            change = true;
        }
        else if (N - man - gos - sen >= 4 && gos >=1) {
            gos -= 1;
            sen += 5;
            change = true;
        }
        if (change == false) break;
    };

    if (N - man - gos - sen != 0) { printf("-1 -1 -1\n"); }
    else {
        printf("%d %d %d\n", man, gos, sen);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[100005];
int dp[100005][50];

ll read()
{
	ll sum=0;int f=1,c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}

int main()
{
    int n=read();
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int l=read(),q=read();
    for(int i=1;i<=n;i++)
    {
        int id=upper_bound(a+1,a+1+n,a[i]+l)-a-1;
        if(a[i]+l>=a[n])
            dp[i][0]=n;
        else
            dp[i][0]=id;
    }
     
    for(int i=1;i<=30;i++)
    {
        for(int j=1;j<=n;j++)
            dp[j][i]=dp[dp[j][i-1]][i-1];
    }
    while(q--)
    {
        int s=read(),e=read();
        if(e<s)
            swap(s,e);  
        long long ans=0;
        for(int i=30;i>=0;i--)
        {
            if(dp[s][i]<e)
            {
                ans=ans+(1ll<<i);
                s=dp[s][i];
            }
        }
        printf("%lld\n",ans+1);
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visited[MAX]; // 訪問状況

int n, m; // 変数
string s;

int main() {
// input
    cin >> s; // 整数nを文字列で受け取る
// solve
    n = stoi(s); // 整数n
    ll sum = 0;
    rep(i, s.size()) { // 整数nの格桁の和
        sum += s[i] - '0';
    }
// output
    if (n % sum == 0) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int h,w;
        cin>>h>>w;
        if(h==0&&w==0){
            break;
        }
        else{
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i==0||i==h-1){
                        cout<<'#';
                    }
                    else{
                        if(j==0||j==w-1){
                            cout<<'#';
                        }
                        else{
                            cout<<'.';
                        }
                    }
                }
                cout<<endl;
            }
        }
        cout<<endl;
    }
}


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

int main(){
  int N;
  int W[100];

  cin >> N;
  int i,j;
  for(i=0;i<N;i++) {
    cin >> W[i];
  }

  int result = 10000;
  for(i=0;i<N;i++){
    int a=0,b=0;
    for(j=0;j<=i;j++){
      a += W[j];
    }
    if(i==N-1){
      b=0;
    }
    else{
      for(j=i+1;j<N;j++){
        b += W[j];
      }
    }

    int sub = a-b;
    if(a<b){
      sub = b-a;
    }

    if(result > sub) result = sub;

  }


  cout << result << endl;
}


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

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int d_min = (H2 - H1)*60 + (M2 - M1);
  int ans = d_min - K;

  cout << ans << endl;
  
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b;
	cin>>a>>b;
	if(a<0 && b<0)
	{
		if((b-a)%2==0)
		{
			cout<<"Negative"<<endl;
		}
		else cout<<"Positive"<<endl;
	}
	else if(a>0 && b>0) cout<<"Positive"<<endl;
	else cout<<"Zero"<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll n;cin>>n;
  vector<ll> a(3*n);
  for(ll i=0;i<3*n;++i){
    cin>>a[i];
  }
  sort(all(a), greater<ll>());
  ll sum=0LL;
  for(ll j=0;j<n;++j){
    sum += a[2*j+1];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main() {
	int N, K; cin >> N >> K;
	string S; cin >> S;
	S[K-1] += 'a' - 'A';
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = False
count = 0
D1, D2 = 0, 0
for i in range(N):
    D1, D2 = list(map(int, input().split()))
    if D1 == D2:
        count += 1
        if count >= 3:
            ans = True
    else:
        count = 0

if ans == True:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

bool cmp(int a,int b){
		return a > b;
}

signed main() {
		vector<int> a;
		vector<int> b;
		map<int,int> cnta;
		map<int,int> cntb;
		int n;
		cin >> n;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				if(i % 2 == 0){
						a.push_back(tmp);
						cnta[tmp]++;
				}else{
						b.push_back(tmp);
						cntb[tmp]++;
				}
		}
		int saia[2] = {0};
		int saib[2] = {0};
		int nia[2] = {0};
		int nib[2] = {0};
		for(auto& A : cnta){
				if(A.second > saia[1]){
						saia[0] = A.first;
						saia[1] = A.second;
				}
		}
		cnta[saia[0]] = -INF;
		for(auto& A : cnta){
				if(A.second > nia[1]){
						nia[0] = A.first;
						nia[1] = A.second;
				}
		}
		for(auto& B : cntb){
				if(B.second > saib[1]){
						saib[0] = B.first;
						saib[1] = B.second;
				}
		}
		cntb[saib[0]] = -INF;
		for(auto& B : cntb){
				if(B.second > nib[1]){
						nib[0] = B.first;
						nib[1] = B.second;
				}
		}
		int ansa = 0;
		int ansb = 0;
		int ans = 0;
		if(saia[0] != saib[0]){
				ansa = a.size() - saia[1];
				ansb = b.size() - saib[1];
				ans = ansa + ansb;
		}else if(saia[0] == saib[0]){
				if(saia[1] == nia[1] || saib[1] == nib[1]){
					ansa = a.size() - saia[1];
					ansb = b.size() - saib[1];
					ans = ansa + ansb;
				}else{
						ansa = a.size() - saia[1];
						ansb = b.size() - nib[1];
						ans = ansa + ansb;
						ansa = a.size() - nia[1];
						ansb = b.size() - saib[1];
						if(ans > ansa + ansb) ans = ansa + ansb;
				}
		}
		cout << ans;
}


Measured memory_bytes: 7280
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

int main(){
    int n, m;
    std::cin >> n >> m;

    std::vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> h[i];
    }

    std::vector<int> obs(n);
    // obs = 0(未比較), 1(少なくともどれか１つより低いか同じ), 2(他のどれよりも高い)
    for (int i = 0; i < m; i++)
    {
        int a, b;
        std::cin >> a >> b;
        if (h[a - 1] < h[b - 1])
        {
            if (obs[b - 1] == 0)
            {
                obs[a - 1] = 1;
                obs[b - 1] = 2;
            }
            else
            {
                obs[a - 1] = 1;
            }
        }
        else if (h[b - 1] < h[a - 1])
        {
            if (obs[a - 1] == 0)
            {
                obs[a - 1] = 2;
                obs[b - 1] = 1;
            }
            else
            {
                obs[b - 1] = 1;
            }
        }
        else //h[a - 1] = h[b - 1]
        {
            obs[a - 1] = 1;
            obs[b - 1] = 1;
        }
    }
    
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (obs[i] == 0 || obs[i] == 2)
        {
            count++;
        }
    }
    
    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 4032
#include<iostream>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int64_t a, b, c; std::cin >> a >> b >> c;
  int64_t k = c - (a+b);
  if(k < 0) fin("No");
  if(k*k > 4*a*b) fin("Yes");
  fin("No");
  return 0;
}


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

int main(){
  int A;
  double B;
  cin>>A>>B;
  double C[A];
  double count = 0;
  double cc=0;
  double num= 1/(4*B);
  for(int i=0;i<A;i++){
       cin>>C[i];
       cc += C[i];
  }
 for(int i = 0;i < A;i++){
  if(C[i] >= cc*num)count++;
}
  if(count>=B)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

void next(string& s) {
    rFOR(i, 0, s.length()) {
        if (i == 0) {
            if (s[0] == '9')s = '1' + s;
            else ++s[0];
            FOR(j, 1, s.length())s[j] = max('0', char(s[j - 1] - 1));
            return;
        }
        else {
            if (s[i] == '9')continue;
            else if (abs(int(s[i - 1]) - int(s[i] + 1)) > 1)continue;
            else {
                ++s[i];
                FOR(j, i + 1, s.length())s[j] = max('0', char(s[j - 1] - 1));
                return;
            }
        }
    }
}

int main() {
    init();

    int k; cin >> k;
    string ans = "1";
    FOR(i, 0, k - 1) {
        next(ans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import math
import sys

#素数か(x>=2)
def prime_check(x): #x>=2
    if x==2:
        return True,2
    elif x%2==0:
        return False,2
    else:
        limit=int(math.sqrt(x))
        for factor in range(3,limit+1,2):
            if x%factor==0:
                return False,factor
        return True,x

#素因数分解(x>=2)
def prime_factorization(x): #x>=2
    factor_dictionary={}
    factor_set=set()
    judge,factor=prime_check(x)
    while True:
        if factor in factor_set:
            factor_dictionary[factor]+=1
        else:
            factor_dictionary[factor]=1
            factor_set.add(factor)

        if judge:
            return factor_dictionary,factor_set
            break
        else:
            x//=factor
            judge,factor=prime_check(x)

n=int(input())
Fd,Fs=prime_factorization(n)

def culc(x):
    temp=1
    while True:
        if x>=temp:
            x-=temp
            temp+=1
        else:
            return temp-1
            break

if n==1:
    print(0)
    sys.exit()

ans=0
while Fs:
    now=Fs.pop()
    ans+=culc(Fd[now])

print(ans)


Measured memory_bytes: 9256
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x;
#define outb(x) cout << x << ' ';
#define outn(x) cout << x << '\n';

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define len length()
#define all(x) x.begin(), x.end()

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

pl arr[100009];
list<pl> li, lii;
int check[100009];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	inl(n); inl(k);
	forn(i, 0, n) {
		inl(a); inl(b);
		arr[i] = mp(-b, a);	
	}
	sort(arr, arr+n);
	ll ret = 0, s = 0, cnt = 0;
	forn(i, 0, k) if (!check[arr[i].se]) {
		arr[i].se = -arr[i].se;
		check[-arr[i].se] = 1;
		cnt++;
	}
	forn(i, 0, k) {
		if (arr[i].se < 0) li.pb(arr[i]);
		s -= arr[i].fi;
	}
	forn(i, 0, k) if (arr[i].se > 0) li.pb(arr[i]);
	forn(i, k, n) lii.pb(arr[i]);
	ret = cnt*cnt + s;
	for (auto i : lii) {
 		 if (check[i.se]) {
 		 	continue;
 		 } else {
 		 	if (li.back().se < 0) break;
 		 	s += li.back().fi;
 		 	li.pop_back();
 		 	s -= i.fi;
 		 	li.push_front(i);
 		 	cnt++;
 		 	check[i.se] = 1;
 		 	ret = max(ret, cnt*cnt + s);
 		 	//outn(cnt*cnt+s);
 		 }
	}
	outn(ret);
	return 0;
}


Measured memory_bytes: 6912
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

typedef pair<int,int> ans_t;

ans_t dp[105][50005];
int N;
int shops[105];

const ans_t& chmax(const ans_t& src,ans_t& target){
    if (src.first>target.first||(src.first==target.first&&src.second<target.second))
        return target=src;
    else 
        return target;
}

int main(){

    while(scanf("%d",&N)&&N){
        for(int i=1;i<=N;i++) scanf("%d",shops+i);

        for(int i=0;i<=N;i++)
            for(int change=0;change<=50003;change++) 
                dp[i][change]=ans_t(-1,0);

        dp[0][0]=ans_t(0,0);

        ans_t ans(0,0);

        for(int i=0;i<N;i++){
            for(int change=0;change<=50000;change++){
                const auto &cost=dp[i][change];
                if (cost.first==-1) continue;

                chmax(cost,dp[i+1][change]);
                chmax(dp[i+1][change],ans);

                auto cur_price=shops[i+1];

                auto remain=(1000-cur_price%1000)%1000;
                auto new_change=remain%500,new_500=remain/500;
                chmax(ans_t(cost.first+new_500,cost.second+cur_price),
                    dp[i+1][min(change+new_change,50000)]);
                chmax(dp[i+1][min(change+new_change,50000)],ans);

                remain=(cur_price+500)%1000;
                if (change>=remain){
                    chmax(ans_t(cost.first+1,cost.second+cur_price),
                        dp[i+1][change-remain]
                    );
                    chmax(dp[i+1][change-remain],ans);
                }

            }
            // printf("%d %d\n",ans.first,ans.second);
        }

        printf("%d %d\n",ans.first,ans.second);
    }

    return 0;
}


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

int main() {
  string S;
  char n;
  int cnt(0);
  cin>>S;
  n=S[0];
  for (int i(1);i<S.size();i++){
    if(n!=S[i]){
      cnt+=1;
    }
    n=S[i];
  }
  cout << cnt;
}


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

int main() {
  int N, M;
  cin >> N >>M ;
  
  vector<int> road(M*2);
  for(int i; i<M*2; i++){
  cin >> road.at(i) ;
  }
  
  vector<int> num(N);
  for(int k=1; k<=N; k++){
  for(int i=0; i<M*2; i++){
    if(road.at(i) == k){ 
      num.at(k-1)++;
    }
  }
  }
      
 for(int i=0; i<N; i++){
   cout << num.at(i) <<endl;
 }
    
  
}


Measured memory_bytes: 256
// abc143_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;



struct Graph {

    struct Edge {
        int u, v;
        ll w;
        Edge() {}
        Edge(int u, int v, ll w) : u(u), v(v), w(w) {}
        friend ostream& operator<<(ostream& os, const Edge& e) {cout << "(" << e.u << "->" << e.v << "," << e.w << ")"; return os;}
    };

    int n;

    vector<vector<Edge>> edges;
    Graph(int n): n(n), edges(n) {}

    void add_edge(int u, int v, ll c){
        edges[u].emplace_back(u, v, c);
        edges[v].emplace_back(v, u, c);
    }

    vector<int> dijkstra(int s, int L){

        using PP = pair<pair<int, ll>, int>;

        priority_queue<PP, vector<PP>, greater<PP>> pq;
        pq.push(PP( P(0, 0), s));

        vector<P> dist(n, P(INF,0));
        dist[s] = P(0,0);

        while (!pq.empty()){
            PP pp = pq.top(); pq.pop();

            int cnt = pp.first.first;
            ll l = pp.first.second;

            int v = pp.second;
//            if (v == t) return cnt;

            for (auto edge: edges[v]){

                int ncnt = cnt;
                ll nl = l + edge.w;

                if (nl > L){
                    ncnt++;
                    nl = edge.w;
                }

                P ncost = P(ncnt, nl);

                if (ncost < dist[edge.v]){
                    dist[edge.v] = ncost;
                    pq.push(PP(ncost, edge.v));
                }
            }
        }

        vector<int> ret(n);
        REP(i, n) ret[i] = dist[i].first;
        return ret;
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M, L;
    cin >> N >> M >> L;

    Graph g(N);

    REP(i, M){
        int a, b, c;
        cin >> a >> b >> c; a--; b--;
        if (c <= L) {
            g.add_edge(a, b, c);
        }
    }

    vector<vector<int>> dist;
    REP(i, N){
        dist.emplace_back(g.dijkstra(i, L));
    }

    int Q;
    cin >> Q;
    REP(i, Q){
        int s, t;
        cin >> s >> t; s--; t--;
        int ans = dist[s][t];
        if (ans == INF){
            print(-1);
        } else {
            print(ans);
        }
    }


    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    vector<pair<ll, ll>> v(n);

    rep(i, n) {
        ll l, r;
        cin >> l >> r;
        v[i] = make_pair(l, r + 1);
    }

    sort(v.begin(), v.end());

    ll l1, l2, r1, r2;
    l2 = v[n - 1].first;

    ll min_left[n], min_right[n];
    min_left[0] = v[0].second;
    repd(i, 1, n) { min_left[i] = min(min_left[i - 1], v[i].second); }

    min_right[n - 1] = v[n - 1].second;
    repd(i, 1, n) {
        ll index = n - i - 1;
        min_right[index] = min(min_right[index + 1], v[index].second);
    }

    ll ans = 0;
    rep(i, n - 1) {
        l1 = v[i].first;
        r1 = v[i].second;
        r2 = min_right[i + 1];

        ll ans_temp;
        if (i != 0) {
            ll r_temp = min_left[i - 1];
            ll ans0 = max((min(r_temp, r1) - l1), 0LL) + max((r2 - l2), 0LL);
            ll ans1 = max((r1 - l1), 0LL) + max((min(r_temp, r2) - l2), 0LL);
            ans_temp = max(ans0, ans1);
        } else {
            ans_temp = max((r1 - l1), 0LL) + max((r2 - l2), 0LL);
        }

        ans = max(ans, ans_temp);
    }

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



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

int main()
{
    string s;
    cin>>s;
    int a[3] ;
    a[0]=s[0];
    a[1]=s[1];
    a[2]=s[2];

   sort(a,a+3);
if(a[0]=='a'&&a[1]=='b'&&a[2]=='c')
    cout<<"Yes";
else
    cout << "No" ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> PL;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<PL> v(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        v[i] = make_pair(b, a);
    }

    sort(v.begin(), v.end());
    
    bool ok = true;
    ll t = 0;
    rep(i, n) {
        ll b = v[i].first;
        ll a = v[i].second;
        t += a;
        if (t > b) {
            ok = false;
            break;
        }
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main(void){
    
    int  N;
//    string in_str,tmp_str;
    string ans = "hon";
 
//  cin >> in_str;
    cin >> N;
    
    N = N % 10;

//    int length = int(in_str.length());
  
    if (N==3){
        ans = "bon";
    }else if(N==0||N==1||N==6||N==8){
        ans = "pon";
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 25, inf = 1e9;
bool a[N][N];
int b[N*N][N*N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, m;
    cin >> n >> m;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            char c;
            cin >> c;
            if (c == '.') a[i][j] = 1;
            else a[i][j] = 0;
        }
    }
    for (int i=1; i<=n*m; i++) {
        for (int j=1; j<=n*m; j++) {
            b[i][j] = inf;
        }
        b[i][i] = 0;
    }
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m-1; j++) {
            if (a[i][j] && a[i][j+1]) {
                int x = (i - 1) * m + j, y = (i - 1) * m + j + 1;
                b[x][y] = b[y][x] = 1;
            }
        }
    }
    for (int i=1; i<=n-1; i++) {
        for (int j=1; j<=m; j++) {
            if (a[i][j] && a[i+1][j]) {
                int x = (i - 1) * m + j, y = i * m + j;
                b[x][y] = b[y][x] = 1;
            }
        }
    }
    n = n * m;
    for (int k=1; k<=n; k++) {
        for (int i=1; i<=n; i++) {
            for (int j=1; j<=n; j++) {
                b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
            }
        }
    }
    int ans = 0;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            if (b[i][j] < inf) {
                ans = max(ans, b[i][j]);
            }
        }
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007 
using namespace std;
void solve(){
   ll n,w;
   cin>>n>>w;
   pair<ll,ll> a[n+1];
   for(ll i=1;i<=n;i++){
    ll x,y;
    cin>>x>>y;
    a[i]={x,y};
   }
   ll dp[n+1][w+1];
   for(ll i=0;i<n+1;i++){
     for(ll j=0;j<w+1;j++){
         dp[i][j]=0;
     }
   }   
   for(ll i=0;i<=w;i++){
      if(a[1].first<=i){
        dp[1][i]=a[1].second;
      }
      else{
        dp[1][i]=0;
      }
   }
   for(ll i=2;i<=n;i++){
     for(ll j=0;j<=w;j++){
        if(a[i].first<=j){
            dp[i][j]=max((a[i].second+dp[i-1][j-(a[i].first)]),dp[i-1][j]);
        }
        else{
             dp[i][j]=dp[i-1][j];
        }
     }
   }
   cout<<dp[n][w]<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 82468
x, y = map(int, input().split())

group1 = [1, 3, 5, 7, 8, 10, 12]
group2 = [4, 6, 9, 11]
group3 = [2]

if (x in group1 and y in group1) or (x in group2 and y in group2) or (x in group3 and y in group3):
    print("Yes")
else:
    print("No")


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

int main(){
  long long int n,x,count=0;
  cin >> n >> x;
  long long int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=0;i<n-1;i++){
    if(a[i]>x){
      count+=a[i+1]+a[i]-x;
      a[i]=x;
      a[i+1]=0;
    }
    else if(a[i]+a[i+1]>x){
      count+=a[i+1]+a[i]-x;
      a[i+1]-=a[i+1]+a[i]-x;    
    }
  }
  	cout <<count <<endl;
}

Measured memory_bytes: 1024
# パスカルの三角形
N, K = map(int, input().split())

c = [[0] * 2001 for _ in range(2000 + 1)]
c[0][0] = 1
for i in range(1, 2000 + 1):
    ci = c[i]
    ci1 = c[i - 1]
    ci[0] = 1
    for j in range(1, i + 1):
        ci[j] = (ci1[j - 1] + ci1[j]) % 1000000007

result = []
for i in range(1, K + 1):
    result.append(c[K - 1][i - 1] * c[N - K + 1][i] % 1000000007)
print('\n'.join(str(i) for i in result))


Measured memory_bytes: 98156