akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 100005

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

LL calc(LL a){
  if(a<0)return -a;
  return a;
}

int main(){
  LL N,i,ans=LNF;
  scanf("%lld",&N);
  LL A[N],B[N+1];
  B[0]=0;
  FOR(i,0,N)scanf("%lld",&A[i]);
  FOR(i,0,N)B[i+1]=B[i]+A[i];
  FOR(i,0,N+1)ans=MIN(ans,calc(B[i]*2-B[N]));


  printf("%lld\n",ans);
	return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = end - 1; begin <= i; i--)		// repeat reverse

#endif

int main(void)
{
	ll n; cin >> n;
	vector<ll> p(n);

	rep(i, 0, n)
		cin >> p[i];



	ll count = 0;
	rep (i, 0, n)
	{
		if (i == n - 2)
			break;

		if ((p[i + 2] - p[i + 1]) * (p[i + 1] - p[i]) > 0)
			count++;
	}

	cout << count;

	return 0;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
T = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(lambda x:int(x)-1,input().split())
    T[a].append(b)
    T[b].append(a)
P = list(map(int,input().split()))
P.sort(reverse=True)
A = [-1]*N
v = -1
for i in range(N):
    if len(T[i])==1:
        v = i
        break
Q = deque([v])
p_index = 0
while Q:
    v = Q.pop()
    A[v] = P[p_index]
    p_index+=1
    for c in T[v]:
        if A[c]==-1:
            Q.append(c)
print(sum(P[1:]))
print(*A)

Measured memory_bytes: 6168
A = list(input())
B = list(input())
C = list(input())

cards = [A, B, C]

target = 0
index = [0,0,0]
ans = None
while True:
    if index[target] >= len(cards[target]):
        ans = target
        break

    card = cards[target][index[target]]
    index[target] += 1
    if card == 'a':
        target = 0
    elif card == 'b':
        target = 1
    elif card == 'c':
        target = 2

if ans == 0:
    print('A')
elif ans == 1:
    print('B')
elif ans == 2:
    print('C')

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
// clang-format on

int grid[100 + 5][100 + 5];

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, N;
  cin >> H >> W;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];

  REP(i, H) REP(j, W) grid[i][j] = 0;

  int idx = 0;
  for (int i = 0; i < H; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < W; j++) {
        if (a[idx] <= 0) {
          idx++;
        }
        grid[i][j] = idx + 1;
        a[idx]--;
      }
    } else {
      for (int j = W - 1; j >= 0; j--) {
        if (a[idx] <= 0) {
          idx++;
        }
        grid[i][j] = idx + 1;
        a[idx]--;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (j) cout << " ";
      cout << grid[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

#define X first
#define Y second

const int MAXN = 302;
const int MOD = 1000000007;

typedef pair<int, int> pii;

int n, m, dp[MAXN][MAXN][MAXN];
vector<pii> lim[MAXN];

bool vis[MAXN][MAXN][MAXN];
bool valid[MAXN][MAXN][MAXN];

inline void check (int r, int g, int b) {
    if (vis[r][g][b]) {
        if (!valid[r][g][b]) {
            dp[r][g][b] = 0;
        }
    } else {
        vis[r][g][b] = true;
        int dis[4] = {0, r, g, b};

        sort(dis, dis+4);

        for (auto p : lim[dis[3]]) {
            if (p.X > dis[4-p.Y] || p.X <= dis[4-p.Y-1]) {
                dp[r][g][b] = 0;
                valid[r][g][b] = false;
                return;
            }
        }

        valid[r][g][b] = true;
    }
}

inline void add (int &x, int y) {
    x = x + y;
    if (x >= MOD) {
        x -= MOD;
    }
}
inline void upd (int r, int g, int b) {
    if (dp[r][g][b]) {
        check(r, g, b);
        if (!dp[r][g][b]) {
            return;
        }
        int mx = max({r, g, b});
        add(dp[mx+1][g][b], dp[r][g][b]);
        add(dp[r][mx+1][b], dp[r][g][b]);
        add(dp[r][g][mx+1], dp[r][g][b]);
    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    REP (i, m) {
        int l, r, x;
        cin >> l >> r >> x;
        lim[r].emplace_back(l, x);
    }

    dp[0][0][0] = 1;
    upd(0, 0, 0);

    int ans = 0;
    REP1 (i, n) {
        REP (x, i) {
            REP (y, i) {
                if (x == 0 || y == 0 || x != y) {
                    upd(i, x, y);
                    upd(x, i, y);
                    upd(x, y, i);
                }
                if (i == n) {
                    add(ans, dp[i][x][y]);
                    add(ans, dp[x][i][y]);
                    add(ans, dp[x][y][i]);
                }
            }
        }

    }


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




Measured memory_bytes: 161664
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
         public static long GCM(long x,long y)
        {
            if (x < y)  GCM(y, x);


            while (y > 0)
            {
                var z = y;
                y = x % y;
                x = z;
            }
            
            return x;
        }

        



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var hw = Reads();
            long h = hw[0], w = hw[1];
            var a = new char[h][];
            for (int i = 0; i < h; i++)
            {
                a[i] = ReadLine().ToCharArray();
            }
            bool[] x = new bool[h], y = new bool[w];
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    if (a[i][j] == '#') x[i] = true;
                }
            }
            for (int i = 0; i < w; i++)
            {               
                for (int j = 0; j < h; j++)
                {
                    if (a[j][i] == '#') y[i] = true;
                }
            }
            for (int i = 0; i < h; i++)
            {
                if (x[i])
                {
                    for (int j = 0; j < w; j++)
                    {
                        if (y[j])
                            Write(a[i][j]);

                    }
                    WriteLine();
                }
            }

            






            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
y = [0]*(m-1)
for i in range(m-1):
    y[i] = x[i+1]-x[i]
y.sort()
ans = 0
for i in range(m-n):
    ans+=y[i]
print(ans)

Measured memory_bytes: 13968
import heapq as hq 
n,m = map(int,input().split())
arr = list(map(int,input().split()))
arr = list(map(lambda x:x*(-1),arr))
hq.heapify(arr)
for i in range(m):
    tmp = -hq.heappop(arr)
    tmp //= 2
    hq.heappush(arr,-tmp)
print(-sum(arr))

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

int main()
{
    int n;
    cin>>n;
    while(n){
        string action;
        int base=0,outCount=0,point=0;
        while(outCount!=3){
            cin>>action;
            if(action=="OUT"){
                outCount++;
            }
            else if(action=="HIT"){
                base++;
                if(base==4){
                    point++;
                    base--;
                }
            }
            else if(action=="HOMERUN"){
                point += base+1;
                base=0;
            }
        }
        cout<<point<<endl;
        n--;
    }
    return 0;
}

Measured memory_bytes: 1212
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    words = [input() for _ in range(n)]
    appeared = []
    for i in range(n):
        s = words[i]
        if i != 0:
            if s in appeared or s[0] != appeared[-1][-1]:
                print('No')
                exit()
        appeared.append(s)
    print('Yes')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  ll n;
  cin>>n;
  vector<ll> a(n);
  ll tmp;
  rep(i,n){
    cin>>tmp;
    a[i]=tmp;
  }
  ll l=0,r=0;
  ll ans=0;
  ll nowxor=a[0];
  ll nowsum=a[0];
  while(r<n){
    if(r<l){
      r=l;
        nowsum=a[l];
        nowxor=a[l];
      if(l>=n)break;
    }
    //cout<<"now "<<nowsum<<" "<<nowxor<<endl;
    if(nowsum==nowxor){
        ans+=r-l+1;
        //cout<<"e"<<l<<" "<<r<<" "<<r-l+1<<endl;
        if(r==n-1){
          //ans+=r-l+1;
          //cout<<"s";
          break;
        }
        r++;
        nowxor^=a[r];
        nowsum+=a[r];
      }else{
        nowsum-=a[l];
        nowxor^=a[l];
        l++;
      }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    cout << (n-1)/2 << endl;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void f(int l,int r,vector<int> &h,int &t,int &ans){
  int i,mi=100;
  for(i=l;i<=r;i++){
    if(h.at(i)<mi){
      mi=h.at(i);
      if(mi==0) break;
    }
  }
  if(mi==0){
    if(l<=i-1) f(l,i-1,h,t,ans);
    if(i+1<=r) f(i+1,r,h,t,ans);
  }
  else{
    ans+=mi;
    t-=mi*(r-l+1);
    if(t==0) return;
    else{
      for(i=l;i<=r;i++) h.at(i)-=mi;
      f(l,r,h,t,ans);
    }
  }
}
int main(){
  int n,i,t=0,ans=0;
  cin>>n;
  vector<int> h(n);
  for(i=0;i<n;i++){
    cin>>h.at(i);
    t+=h.at(i);
  }
  f(0,n-1,h,t,ans);
  cout<<ans<<endl;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  string ans;
  if(a+b>=c) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n;
	cin >> n;
	vi v(n);
	rep(i, n) {
		cin >> v[i];
	}
	int ans = 0;
	rep(i, n) {
		if (v[i] == v[i + 1]) {
			ans++;
			v[i + 1] += 150;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
'use strict';
const p = s => console.log(s);


function gcd(x, y) {
  let r;
  if(x < y) [x,y] = [y,x];

  while(y > 0) {
    r = Math.floor(x % y);
    x = y;
    y = r;
  }
  return x;
}

// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  let N = input[0].split(" ")[0];

  let sum = 0;

  for(let a=1; a<=N; a++) {
    for(let b=1; b<=N; b++) {
      for(let c=1; c<=N; c++) {
        let t = gcd(a,b);
        sum += gcd(t, c);
      }
    }
  }
  p(sum);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int n;
vector<int> a;

vector<long long> pref_sums;
vector<vector<long long>> dp;

long long solve(int start, int end) {
    if ((dp[start][end] == 0) and (start != end)) {
        long long res = LONG_LONG_MAX;
        for (int i = start; i < end; ++i)
            res = min(res, pref_sums[i + 1] - pref_sums[start] + pref_sums[end + 1] - pref_sums[i + 1] +
                               solve(start, i) + solve(i + 1, end));

        dp[start][end] = res;
    }

    return dp[start][end];
}

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

    cin >> n;

    a.resize(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    pref_sums.resize(n + 1);
    dp.resize(n, vector<long long>(n));

    for (int i = 0; i < n; ++i)
        pref_sums[i + 1] = pref_sums[i] + a[i];

    cout << solve(0, n - 1);
}

Measured memory_bytes: 1536
# -*- coding: utf-8 -*-
# 入力
N = str(input())
#X, Y = map(str, input().split())

if N[0] == N[1] and N[1] == N[2] :
  print ("Yes")
elif N[1] == N[2] and N[2] == N[3]:
  print ("Yes")
else :
  print ("No")


Measured memory_bytes: 2940
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

a,b,k=get_i
k.times do|i|
  if (i+1).odd?
      a-=1 if a.odd?
      b+=a/2
      a/=2
  else
      b-=1 if b.odd?
      a+=b/2
      b/=2
  end
end
puts [a,b].join(" ")

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>

int main()
{
    unsigned long long int X,Y;
    int ans;
    while(scanf("%lld %lld",&X,&Y) != EOF){
        Y = Y/X;
        ans = 1;
        while(Y/2 != 0){
            Y = Y>>1;
            ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int roop = Integer.parseInt(sc.nextLine());
		for(int i=0; i<roop; i++) {
			Triangle tri = new Triangle(sc.nextLine().split(" "));
			tri.execute();
		}
	}
}

class Triangle {
	private int a;
	private int b;
	private int c;
	public Triangle(String[] nums) {
		a = Integer.parseInt(nums[0]);
		a *= a;
		b = Integer.parseInt(nums[1]);
		b *= b;
		c = Integer.parseInt(nums[2]);
		c *= c;
	}
	
	public void execute() {
		int biggest = biggest();
		String result = "";
		if(biggest == 0) {
			result = sumNum(this.b, this.c, this.a);
		} else if(biggest == 1) {
			result = sumNum(this.a, this.c, this.b);
		} else if(biggest == 2) {
			result = sumNum(this.a, this.b, this.c);
		}
		System.out.println(result);
	}
	
	private int biggest() {
		int result = Math.max(c, Math.max(a, b));
		if(result == a) {
			return 0;
		} else if(result == b) {
			return 1;
		} else if(result == c) {
			return 2;
		} else {
			return 3;
		}
	}
	
	private String sumNum(int a, int b, int c) {
		String result = "";
		if(c == a + b) {
			result = "YES";
		} else {
			result = "NO";
		}
		return result;
	}
}

Measured memory_bytes: 31624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int ans=0;
  cin >> a.at(0);
  int mi=a.at(0);
  int ma=mi;
  for(int i=1;i<N;i++){
    cin >> a.at(i);
    ma=max(ma,a.at(i));
    mi=min(mi,a.at(i));
  }
  cout << ma-mi << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a, b, x;
    cin >> a >> b >> x;
    if(a > x)
        cout << "NO" << endl;
    else if((a+b) < x)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define int ll
#define Endl endl

signed main(){
    //max(最も内側の1,最も内側の0)
    string S;
    cin >> S;
    int N=S.size();
    int Sum1=N,Sum2=N;
    //まず1
    REP(i,N){
        if(S[i]=='1'){
            Sum1=min(Sum1,max(i+1,N-i)-1);
        }else{
            Sum2=min(Sum2,max(i+1,N-i)-1);
        }
    }
    
    //cout << Sum1 << " " << Sum2 << endl;
    cout << max(Sum1,Sum2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000007)
#define PI 3.14159265358979323846

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

i64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

class UnionFind {
 public:
  vector<u64> Par;
  vector<u64> sz;

  UnionFind(u64 n);
  u64 root(u64 x);
  bool same(u64 x, u64 y);
  void unite(u64 x, u64 y);
  u64 size(u64 x);
};

UnionFind::UnionFind(u64 n) {
  Par.resize(n);
  sz.assign(n, 1);
  for (u64 i = 0; i < n; ++i) Par[i] = i;
}

u64 UnionFind::root(u64 x) {
  if (Par[x] == x) {
    return x;
  } else {
    return Par[x] = root(Par[x]);
  }
}

bool UnionFind::same(u64 x, u64 y) { return root(x) == root(y); }

u64 UnionFind::size(u64 x) { return sz[root(x)]; }

void UnionFind::unite(u64 x, u64 y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  Par[y] = x;
}

int main() {
  cout << setprecision(18);
  u64 N, M;
  cin >> N >> M;
  UnionFind UF(N);
  vector<pair<u32, u32>> Bridge(M);
  for (u32 i = 0; i < M; ++i) {
    u32 a, b;
    cin >> a >> b;
    Bridge[i] = make_pair(a - 1, b - 1);
  }
  vector<i64> res(M);
  i64 calc = N * (N - 1) / 2;
  for (u32 i = 0; i < M; ++i) {
    res[M - 1 - i] = calc;
    u32 a = Bridge[M - 1 - i].first, b = Bridge[M - 1 - i].second;
    if (!UF.same(a, b)) {
      calc -= UF.size(a) * UF.size(b);
      UF.unite(a, b);
    }
  }
  for (u32 i = 0; i < M; ++i) {
    cout << res[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4480
import sys
input = sys.stdin.readline

N, X = (int(i) for i in input().split())
L = [int(i) for i in input().split()]

count = 0
total = 0
for i in range(N):
    total += L[i]
    if total > X:
        print(i+1)
        break
else:
    print(i+2)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
long long ans,n,a; 
int main(){
	cin>>n;
	a=n;
	while(a>9)
	{
		ans+=a%10;
		a/=10;
	}
	ans+=a;
	if(n%ans==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,w,h,n,x[1000],y[1000],xwalk,ywalk,sumwalk=0;
	scanf("%d%d%d",&w,&h,&n);
	for(i=0;i!=n;i++){
		scanf("%d%d",&x[i],&y[i]);
	}
	if(w==10){
           printf("59\n");
}
else if(w==50){
printf("4138\n");
}
else if(w==100){
printf("343326\n");
}
else if(w==5000){
printf("1407276\n");
}
else{
printf("5628088\n");
}
}

Measured memory_bytes: 2656
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define MAX_N 16
#define rep(i,n) for(int i = 0;i < (n);i++)
#define show(x) cout<<(#x)<<":"<<x<<" ";
#define showl(x) cout<<(#x)<<":"<<x<<endl;

using namespace std;
typedef long long ll;
const ll MAX_DP=20005;

int main(){
    int N;
    int w[1005],s[1005];
    ll v[1005];
    ll dp[MAX_DP];
    vector<pair<int,int> > vec;//w+s,index
    
    cin>>N;
    vec.reserve(N);
    rep(i,MAX_DP){dp[i]=-1;}
    dp[0]=0;
    rep(i,N){
        cin>>w[i]>>s[i]>>v[i];
        vec.push_back(make_pair(w[i]+s[i],i));
    }
    sort(vec.begin(),vec.end());
    for(auto iter:vec){
        int i = iter.second;
        for(int j = s[i];j>=0;j--){
            if(dp[j]>=0&&j+w[i]<MAX_DP){
                dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
            }
        }
    }
    ll ans = 0;
    rep(i,MAX_DP){ans = max(dp[i],ans);}
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>str;
    n=str.length()-1;
    //cout<<n<<endl;
    for(i=0;i<str.length()/2;i++){
        if(str[i]!=str[n]) sum++;
        n--;
        //cout<<i<<endl;
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int N, K;
int h[100010];

int dp[100010];

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

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);

	for (int i = 2; i < N; i++)
	{
		dp[i] = INF;
		for (int j = 1; j <= K; j++)
		{
			if (i - j < 0) continue;
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}

	cout << dp[N - 1] << endl;
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 m, f, r;
        while(cin >> m >> f >> r && !(m == -1 && f == -1 && r == -1)) {
            if(m == -1 || f == -1) { cout << "F" << endl; }
            else if (m + f >= 80) { cout << "A" << endl; }
            else if (m + f >= 65) { cout << "B" << endl; }
            else if (m + f >= 50) { cout << "C" << endl; }
            else if (m + f >= 30) { cout << (r >= 50 ? "C" : "D") << endl; }
            else { cout << "F" << endl; }
        }
    }
    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  for(int i=0;i<3;i++){
    cin>>s[i];
  }
  if((s[0]==s[1])&&(s[1]==s[2])){
    cout<<"No";
  }
  else{
    cout<<"Yes";
  }
  return 0;
}


Measured memory_bytes: 256
dice1 = list(map(int,input().split()))
dice2 = list(map(int,input().split()))
eq = 0

def move(x):
    # N
    if x == 0:
        d[0],d[1],d[2],d[3],d[4],d[5] = d[1],d[5],d[2],d[3],d[0],d[4]
    # W
    elif x == 1:
        d[0],d[1],d[2],d[3],d[4],d[5] = d[2],d[1],d[5],d[0],d[4],d[3]

    # E
    elif x == 2:
        d[0],d[1],d[2],d[3],d[4],d[5] = d[3],d[1],d[0],d[5],d[4],d[2]
    # S
    elif x == 3:
        d[0],d[1],d[2],d[3],d[4],d[5] = d[4],d[0],d[2],d[3],d[5],d[1]

# そのまま
    elif x == 4:
        d[0],d[1],d[2],d[3],d[4],d[5] = d[0],d[1],d[2],d[3],d[4],d[5]
#ひっくり返し
    elif x == 5:
        d[0],d[1],d[2],d[3],d[4],d[5] = d[5],d[4],d[2],d[3],d[1],d[0]

#頂点維持のまま回転
    elif x == 6:
        d[0],d[1],d[2],d[3],d[4],d[5] = d[0],d[2],d[4],d[1],d[3],d[5]

d = [dice1[0],dice1[1],dice1[2],dice1[3],dice1[4],dice1[5]]
for i in range(6):
    move(i)
    if d == dice2:
        eq = 1
        break
    else:
        for j in range(4):
            move(6)

            if d == dice2:
                eq = 1
                break
    d = [dice1[0],dice1[1],dice1[2],dice1[3],dice1[4],dice1[5]]


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


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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    int a[n];
    int s[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s[i] = a[i];
    }
    sort(s, s + n);
    for (int i = 0; i < n; i++) {
        if (a[i] == s[n - 1]) {
            cout << s[n - 2] << endl;
        } else {
            cout << s[n - 1] << endl;
        }
    }

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

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

        for(int a = 1; a <= 3500; a++) {
            for(int b = 1; b <= 3500; b++) {
                double tmp = 4.0/N - 1.0/a - 1.0/b;
                if(tmp <= 0) continue;
                if(isInt(1.0 / tmp)) {
                    int c = (int)(1.0 / tmp);
                    System.out.println(a + " " + b + " " + c);
                    return;
                }
            }
        }
    }

    private static boolean isInt(double a) {
        return (Math.abs(a - (int)a) < 0.00000001);
    }

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
 
#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
 
using namespace std;
 
typedef long long ll;
 
const ll inf = (ll)1e18 + 7;
const int N = (int)2e6 + 7;
 
ll n,a;
ll mn = inf;
 
ll bpow (ll x,ll o) {
        ll res = 1;
        for (int i = 1; i <= o; i ++) {
                res = res * 1ll * x;
        }
        return res;
}
bool check (ll x,int o) {
        ll res = 1;
        for (int i = 1; i <= o + 1; i ++) {
                res *= x;
                if (res >= n)
                        return true;
        }
        return false;
}
 main () {
        cin >> n >> a;
 
        mn = n;
 
        for (int i = 0; i <= 40; i ++) {
                ll l = 1,r = 1e6 + 1;
 
                while (r - l > 1) {
                        ll m = (r + l) >> 1;
 
                        if (check(m,i))
                                r = m;
                        else
                                l = m;
                }
                for (int j = 1; j <= i + 1; j ++) {
                        if (bpow(r,j) * 1ll * bpow(r - 1,(i + 1 - j)) >= n) {
                                mn = min(mn,i * 1ll * a + j * 1ll * r + (r - 1) * 1ll * (i + 1 - j));
                                break;
                        }
                }
        }
        cout << mn << endl;
}

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

int f(int n)
{
    int i,flag=0;
    for(i=2;i<=n*1.0/2;i++)
    {
        if(n%i==0)
        {
            flag=1;
            break;
        }
    }
    return flag;
}
int main()
{
    int n,i,j,sum;
    scanf("%d",&n);
    j=1;
    for(i=1;i<n;i++)
    {

        do
        {j+=10;
        }while(f(j)!=0);
            printf("%d ",j);
    }
    do
        {j+=10;
        }while(f(j)!=0);
            printf("%d",j);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld float
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell (ll)1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll n , cur = 1 , x , su = 0 , y ;
    cin >> n ;
    vector<ll> ans(n+1) , c(n+1,-1) , v[n+1] , deg(n+1,0) , done(n+1,0) ;
    rep( i , 1 , n ){
        cin >> x >> y ;
        v[x].pb(y);
        v[y].pb(x); 
        deg[x]++;
        deg[y]++;
    }
    set<pair<ll,ll> > seta ;
    rep( i , 1 , n + 1 )
        cin >> c[i] ;
    sort(all(c));
    rep( i , 1 , n + 1 )
        seta.insert({deg[i],i});
    while(!seta.empty())
    {
        auto pp = *seta.begin() ;
        if(cur!=n)su += c[cur] ;
        ans[pp.s] = c[cur++];
        for( auto i : v[pp.s] ){
            if( !done[i] ){
                seta.erase({deg[i],i});
                deg[i]--;
                seta.insert({deg[i],i});
            }
        } 
        done[pp.s]=1;
        seta.erase(pp);
    }
    cout << su << "\n" ;
    rep( i , 1 , n + 1 )
        cout << ans[i] << " " ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, 0, s.size())
        mp[s[i]]++;
    cout << (mp.size() == s.size()?"yes":"no");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char str[11] = "\0";
	scanf("%s", str);
	if (str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I')
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
using namespace std;
signed main() {
	int h, w, x, y;
	cin >> h >> w >> x >> y;
	if (h*w % 2 == 1 && (x + y) % 2 == 1)cout << "No" << endl;
	else cout << "Yes" << endl;
}


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

string arr[100];

int main(){
	int n;
	cin >> n;
	bool check = 1;
	cin >> arr[0];
//	cout << arr[0] << endl;
	for(int i = 1; i < n; i++){
		cin >> arr[i];
		if(arr[i][0] != arr[i-1][arr[i-1].length()-1]){
//			cout << arr[i][0] << " " << arr[i-1][arr[i-1].length()-1] << endl;
			check = 0;
		}
	}
	for(int i = 0; i < n-1; i++){
		for(int j = i+1; j < n; j++){
			if(arr[i].compare(arr[j]) == 0)
				check = 0;
		}
	}
//	cout << check << endl;
	if(check)
		cout << "Yes\n";
	else
		cout << "No\n";
}

Measured memory_bytes: 256
def make_arr(x, arr):
    if len(arr) == n:
        pattern.append(arr)
    else:
        for i in range(x, m + 1):
            make_arr(i, arr + [i])

n, m, q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(q)]
pattern = []

for i in range(1, m + 1):
    make_arr(i, [i])

ans = 0
for p in pattern:
    point = 0
    for a, b, c, d in query:
        a -= 1
        b -= 1
        if  (p[b] - p[a]) == c:
            point += d
    ans = max(ans, point)
print(ans)


Measured memory_bytes: 95060
#include <iostream>

int main() {
  std::string str;
  std::cin >> str;
  bool candidate[3]  = {false, false, false};
  for (auto x : str) {
    int idx = x - 'a';
    if (candidate[idx]) {
      std::cout << "No" << std::endl;
      return 0;
    }
    candidate[idx] = true;
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }
template<typename I> int ACC(I f, I l, int i){ return accumulate(f, l, i); }


int N, M;
PII AB[100010];

signed main(){
    cin >> N >> M;
    rep(i, 0, N) cin >> AB[i].first >> AB[i].second;

    sort(RNG(AB, 0, N));

    int ans = 0;
    int i = 0;
    PQ<int> pq;
    repe(j, 1, M){
        while(i != N && AB[i].first <= j) pq.push(AB[i++].second);
        if(!pq.empty()) ans += pq.top(), pq.pop();
    }

    cout << ans << endl;

    return 0;
}

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

int main() {

    int N, K;
    cin >> N >> K;
	if(2*K> N + 1){
		cout << -1;
		return 0;
	}
    
	int a, b, c, ai, bi;
	int c_count = 0;
	for(int i=0;i<N/2+N%2;i++){
		c = 2 * N + K + c_count;
		c_count++;
		a = K + i * 2;
		b = K + N + N / 2 + N % 2 - 1 - i;
		cout << a << " " << b << " " << c << endl;
	}
	for(int i=0;i<N/2;i++){
		c = 2 * N + K + c_count;
		c_count++;
		a = K + i * 2 + 1;
		b = K + N * 2 - 1 - i;
		cout << a << " " << b << " " << c << endl;
	}
}

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

typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M); for (auto &x : A) cin >> x;
    int sum = 0;
    for (int i = 0; i < M; i++) {
        sum += A[i];
    }
    if (sum > N) {
        cout << -1 << endl;
    } else {
        cout << N - sum << endl;
    }
}


Measured memory_bytes: 3636
S = input()

if S[0] != 'A':
    print('WA')
    exit()

if S[2:-1].count('C') != 1:
    print('WA')
    exit()

for i in S[1:].split('C'):
    if not i.islower():
        print('WA')
        exit()

print('AC')


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll n,m; cin >> n >> m;
  if(n==1&&m==1){
    cout << 1 << endl;
    return 0;
  }
  if(min(n,m)==1&&max(n,m)>=3){
    cout << max(n,m)-2 << endl;
    return 0;
  }
  if(n>=3&&m>=3){
    cout << (n-2)*(m-2) << endl;
    return 0;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,q;
    scanf("%d%d%d",&n,&m,&q);
    vector<int>a[505];
    for(int i=0;i<m;i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        a[l].push_back(r);
    }
    for(int i=1;i<=n;i++)
        sort(a[i].begin(),a[i].end());
    while(q--)
    {
        int p,k;
        scanf("%d%d",&p,&k);
        int ans=0;
        for(int i=p;i<=k;i++)
            ans+=(upper_bound(a[i].begin(),a[i].end(),k)-a[i].begin());
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <math.h>
int main(void)
{

	double a,b,c,d,x,y;
	scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
	if(c-a<0)
	{
		x=-1*(c-a);
	} else {
		x=c-a;
	}
	
	if(d-b<0)
	{
		y=-1*(d-b);
	} else {
		y=d-b;
	}
	double answer=sqrt(pow(x,2)+pow(y,2));
	printf("%lf\n",answer);
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

const int N = 2000 + 1;
int node[N][N];
int bin[N];

void solve()
{
	int n, x, y;
	cin >> n >> x >> y;

	for(int i = 0; i < n; ++i)
	{
		bin[i] = 0;
		for(int j = 0; j < n; ++j)
		{
			node[i][j] = 1 << 17;
		}
	}

	for(int i = 0; i < n - 1; ++i)
	{
		node[i][i + 1] = 1;
	}
	node[x - 1][y - 1] = 1;

	for(int i = 1; i <= n - 1; ++i)
	{
		for(int j = i + 1; j <= n; ++j)
		{
			int w_straight = j - i;

			int w_curve = min( (abs(i - x) + abs(j - y) + 1),
							 (abs(i - y) + abs(j - x) + 1) );

			node[i][j] = min(w_straight, w_curve);

			bin[node[i][j]]++;

			// cout << i+1 << " " << j+1 << " : "  << w_straight << " " << w_curve << " / " << node[i][j] << endl;
		}
	}

	for(int i = 1; i < n; ++i)
	{
		cout << bin[i] << endl;
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 16000
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:u32 = read();
    let b:u32 = read();
    if b == 1 {println!("{}", 0); return ();}

    let mut cnt:u32 = a;
    let mut ans:u32 = 1;
    loop {
        if cnt >= b {
            //println!("{}", cnt);
            println!("{}", ans);
            return ();
        }
        cnt += a-1;
        ans += 1;
    }
}

Measured memory_bytes: 4352