akhauriyash/Code-Regression huggingface dataset:
object Main {
  trait Monoid[A]{
    def op(a1: A, a2: A): A
    def zero: A
  }

  class SegmentTree[A](val numOfNode: Int, val M: Monoid[A]){

    sealed trait Tree{ val value: A }
    case object Leaf extends Tree{ val value: A = M.zero }
    case class Node(value: A, left: Tree, right: Tree) extends Tree
    object Node {
        def apply(value: A) = new Node(value, Leaf, Leaf)
        def apply(l: Tree, r: Tree) = new Node(M.op(l.value,r.value),l,r)
    }

    private val empty: Node = Node(M.zero,Leaf,Leaf)
    private[this] var root: Tree = empty

    private def updateRec(id: Int, x:A, l: Int = 0, r: Int = numOfNode, t: Tree = root): Tree = {
        def branch(now: Node): Node = {
            val m = (l + r)>>1
            if(r-l<=1)Node(x)
            else if(id < m)Node(updateRec(id,x,l,m, now.left), now.right)
            else Node(now.left,updateRec(id,x,m,r,now.right))
        }
        t match {
            case now: Node => branch(now)
            case _ => branch(empty)
        }
    }

    def update(id: Int, x: A): Unit = {
        root = updateRec(id, x)
    }

    def query(a: Int, b: Int, l: Int = 0, r: Int = numOfNode, t: Tree = root): A = {
      val m = (l + r)/2
      t match {
        case now: Node =>
          if(b<=l || r<=a)M.zero
          else if(a<=l && r<=b)now.value
          else M.op(query(a,b,l,m,now.left),query(a,b,m,r,now.right))
        case _ => M.zero
      }
    }
  }

  def main(args: Array[String]): Unit = {
    val line = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val n = line(0)
    val q = line(1)
    val m = new Monoid[Int]{
        def op(a1: Int, a2: Int): Int = a1 min a2
        def zero: Int = Int.MaxValue
    }

    val segtree = new SegmentTree[Int](n,m)

    for(i <- 1 to q){
        val input = scala.io.StdIn.readLine.split(" ").map(_.toInt)
        val x = input(1)
        val y = input(2)
        if(input(0)==0)segtree.update(x,y)
        else println(segtree.query(x,y+1))
    }
  }
}

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

using namespace std;

//Swap a and b
void swap(int *a, int *b)
{
	int tmp;

	tmp = *a;
	*a = *b;
	*b = tmp;
}

void selectionSort(vector<int> &vec)
{
	int cmp_num = 0;
	int min_idx;
	int vec_size;

	vec_size = vec.size();

	for(int i = 0; i < vec_size; i++)
	{
		min_idx = i;
		for(int j = i+1; j < vec_size; j++)
		{
			if(vec[j] < vec[min_idx])
			{
				min_idx = j;
			}
		}
		if(i != min_idx)
		{
			swap(&vec[min_idx], &vec[i]);
			cmp_num++;
		}
	}

	for(int i = 0; i < vec_size-1; i++)
	{
		cout << vec[i] << " ";
	}
	cout << vec[vec_size-1] << endl;
	cout << cmp_num << endl;
}

int main(void)
{
	int n;

	cin >> n;
	vector<int> A(n);

	//データを入力
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
	}

	selectionSort(A);
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }


int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  const int N = 4e6 + 5;
  bitset<N> heh;
  heh[0] = 1;
  int n;
  cin>>n;
  int S = 0;
  RE (i, n) {
    int a;
    cin>>a;
    S += a;
    heh = heh | (heh << a);
  }
  int best = 0;
  RE (i, S / 2) {
    if (heh[i]) {
      maxi(best, i);
    }
  }
  cout<<S - best<<endl;

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W,a,b;
  cin>>W>>a>>b;
  if(a+W<=b){
    cout<<b-(a+W)<<endl;
  }
  else if(b+W<=a){
    cout<<a-(b+W)<<endl;
  }
  else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n,m,l,ans;
  cin>>n>>m>>l;
  ans=0;
  ans+=n/(m+l)*m;
  if(n%(m+l)>=m){
  	ans+=m;
  }else{
  	ans+=n%(m+l);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
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=ii()
    X = []
    for i in range(N):
        x,y=mi()
        X.append((x,y))
    
    count = 0
    for i in range(N):
        if X[i][0] == X[i][1]:
            count += 1
        else:
            count = 0
        
        if count >= 3:
            print("Yes")
            exit()
    
    print("No")





if __name__ == "__main__":
    main()

Measured memory_bytes: 62516
//
//  main.cpp
//  1_4
//
//  Created by Keita on 2020/03/11.
//  Copyright © 2020 Keita. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;

void doProblemA(){
    string S;
    cin >> S;
    if(S == "SSS"){
        cout << 0 << endl;
    }else if(S == "SSR" or S == "SRS" or S == "RSS" or S == "RSR"){
        cout << 1 << endl;
    }else if(S == "SRR" or S == "RRS"){
        cout << 2 << endl;
    }else{
        cout << 3<< endl;
    }
}

void doProblemB(){
    // X:初期地点 K:移動回数 D:移動距離
    long long int X, K, D;
    cin >> X >> K >> D;
    
    long long int A = X / D + 1;
    
    // ゴールの手前で止まる場合
    if(X >= K * D){
        cout << X - K * D << endl;
    }
    // ゴールを超える場合
    else if(A % 2 == 0){
        cout << A * D - X << endl;
    }else{
        cout << X - (A - 1) * D << endl;
    }
}

void doProblemB_2(){
    // X:初期地点 K:移動回数 D:移動距離
    long long int X, K, D;
    cin >> X >> K >> D;
    
    // Xがマイナスの場合があるので絶対値の場合がある。
    X = abs(X);
    
    
    long long int A = X / D;
    long long int moveNum = min(K,A);

    K -= moveNum;
    X -= moveNum * D;
    
    // ゴールの手前で止まる場合
    if(K % 2 == 0){
        cout << X << endl;
    }
    else{
        cout << D - X << endl;
    }
//    // ゴールを超える場合
//    else if(A % 2 == 0){
//        cout << A * D - X << endl;
//    }else{
//        cout << X - (A - 1) * D << endl;
//    }
}


int main(int argc, const char * argv[]){
    // insert code here...
    doProblemB_2();
    return 0;
}


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

#define Fi first
#define Se second
#define mp make_pair
#define bug cout << "check\n";
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;


const int maxn = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

int visited[maxn],cost[maxn];
vector < pii > v[maxn];
bool f = 1;

inline void solve(int n1) {
	visited[n1] = 1;	
	for(int i = 0; i < v[n1].size(); ++i) {
		int n2 = v[n1][i].Fi;
		int amt = v[n1][i].Se; 
		if(!visited[n2]) {
			cost[n2] = cost[n1] + amt;
			solve(n2);
		}
		else {
			if(cost[n1] + amt != cost[n2])
				f = 0;
		}
	}
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int n,m; cin >> n >> m;
	int start = 0;
	for(int i = 0; i < m; ++i)	{
		int n1,n2,w1; cin >> n1 >> n2 >> w1;
		if(i == 0)	start = n1;
		v[n1].push_back(mp(n2,w1));
		v[n2].push_back(mp(n1,-w1));
	}
	for(int i = 1; i <= n; ++i) {
		if(!visited[i]) 
			solve(i);
	}
	(f == 1) ? cout << "Yes\n" : cout << "No\n";

	//cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;

}

Measured memory_bytes: 11520
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ
int n;
vector<int> v;
int main()
{
	cin>>n;
	for(int i=1;i<=30000;++i)
		if(i%2==0||i%3==0||i%5==0) v.pb(i);
	while(1)
	{
		random_shuffle(v.begin(),v.end());
		int g=0,su=0;
		for(int i=0;i<n;++i)
			su+=v[i],g=__gcd(g,v[i]);
		for(int i=0;i<n&&g==1;++i)
			if(__gcd(su,v[i])==1) g=2;
		if(g==1)
		{
			for(int i=0;i<n;++i)
				printf("%d ",v[i]);
			puts("");
			return 0;
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll H,W,N,posH,posW,Sr,Sc;
string S,T;

void solve() {

	cin >> H >> W >> N >> Sr >> Sc >> S >> T;

	bool ans = false;

	posH = Sr;
	posW = Sc;
	rep(i, N) {
		if (ans) break;
		if (S[i] == 'R') posW++;
		if (posW == W+1) ans = true;
		if (T[i] == 'L' && posW!=1) posW--;
	}

	posH = Sr;
	posW = Sc;
	rep(i, N) {
		if (ans) break;
		if (S[i] == 'L') posW--;
		if (posW == 0) ans = true;
		if (T[i] == 'R' && posW != W) posW++;
	}

	posH = Sr;
	posW = Sc;
	rep(i, N) {
		if (ans) break;
		if (S[i] == 'U') posH--;
		if (posH == 0) ans = true;
		if (T[i] == 'D' && posH != H) posH++;
	}

	posH = Sr;
	posW = Sc;
	rep(i, N) {
		if (ans) break;
		if (S[i] == 'D') posH++;
		if (posH == H + 1) ans = true;
		if (T[i] == 'U' && posH != 1) posH--;
	}

	if (ans) {
		cout << "NO";
	}
	else {
		cout << "YES";
	}

	return;
}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 776
N=int(input())
from functools import reduce
size=int(N**.5+(1-1e-9))
a=[0]*N
b=[0]*size
f=lambda v: reduce(lambda x,y:x|y,v,0)
def init(v):
    a=v
    b=[f(a[j*size:(j+1)*size]) for j in range(size)]
    return a,b
def update(i,v):
    a[i]=v
    j=i//size
    b[j]=f(a[j*size:(j+1)*size])
def r_query(l,r):
    L,R=0--l//size,r//size
    if L>=R:
        return f(a[l:r])
    else:
        return f(a[l:L*size]+b[L:R]+a[R*size:r])
def c(n):
    r=0
    while n:
        r+=n&1
        n>>=1
    return r

o=lambda c:ord(c)-ord('a')
bit=[2**i for i in range(26)]
S=input()
Q=int(input())
XYZ=[input().split() for i in range(Q)]
a,b=init([bit[o(c)] for c in S])
for x,y,z in XYZ:
    if x=='1':
        update(int(y)-1,bit[o(z)])
    else:
        print(c(r_query(int(y)-1,int(z))))

Measured memory_bytes: 79304
N,Q = map(int,input().split())
f = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    f[a-1].append(b-1)
    f[b-1].append(a-1)
ans = [0] * N
for i in range(Q):
    p,x = map(int,input().split())
    ans[p-1] += x
from collections import deque
d = deque()
d.append(0)
root = [-1]*N
root[0] = 0
while len(d) > 0:
    z = d.popleft()
    for i in f[z]:
        if root[i] == -1:
            root[i] = z
            ans[i] += ans[z]
            d.append(i)
print(*ans)

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

using str = string;
using ll = long long;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    str s;
    cin>>s;
    
    ll cntb=0;
    ll cntw=0;
    
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='B')cntb++;
        else cntw+=cntb;
    }
    
    cout<<cntw<<"\n";
    
    return 0;
}



Measured memory_bytes: 3704
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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


signed main(void)
{
    int a, b;
    
    cin >> a >> b;
    
    mes(lcm(a, b));
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;


int main(int argc, char const *argv[]) {
    int n,k;cin>>n>>k;
    vector<long long> a(n);
    for(int i=0;i<n;++i)cin>>a[i];
    vector<long long> dp(n,1ll<<62);
    dp[0]=0;
    for(int i=1;i<n;++i){
        for(int l=1;l<=k;++l){
            if(i-l>=0)dp[i]=min(dp[i],dp[i-l]+abs(a[i]-a[i-l]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

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

    int cnt0 = 0;
    int cnt1 = 0;
    int i = 0;
    while(s[i] != '\0'){
        if(s[i] == '0'){
            cnt0++;
        }
        else{
            cnt1++;
        }
        i++;
    }

    cout << ((cnt0 > cnt1) ? cnt1 * 2 : cnt0 * 2) << endl;

    return 0;
}

Measured memory_bytes: 512
a,b = map(int,input().split())
s = list(input())
ans = "Yes"
if len(s) != a + b + 1:
    ans = "No"
if s[a] != "-":
    ans = "No"
for i in range(a - 1):
    if s[i] == "-":
        ans = "No"
for i in range(a + 1,a + b + 1):
    if s[i] == "-":
        ans = "No"
print(ans)

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

int main() {
    vector<int> vec(3);
    rep(i, 3) cin >> vec[i];
    sort(vec.begin(), vec.end());
    cout << vec[0] + vec[1] << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc062b()
}

fun abc062b() {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val aList = (1..h).map { readLine()!! }

    val answerList = mutableListOf("#".repeat(w + 2))
    for (i in 0 until h) {
        answerList += """#${aList[i]}#"""
    }
    answerList += "#".repeat(w + 2)

    println(answerList.joinToString(separator = System.lineSeparator()))
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int a, b, c, x; cin >> a >> b >> c >> x;
  int cnt=0;
  for(int i = 0; i <= a; i++) {
    for(int j = 0; j <= b; j++) {
      for(int k = 0; k <= c; k++) {
        int tmp = i * 500 + j * 100 + k * 50;
        if(tmp == x) cnt++;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	//入力
  int isu,hito,kokoro,i=0;
  scanf("%d %d %d",&isu,&hito,&kokoro);
    // 出力
  while(isu>0){
    isu = isu - (hito+ kokoro);
    i++;
  }
  if(isu+hito+kokoro < kokoro)i=i-1;
  printf("%d",i-1);
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
ll power(ll a,ll b){
	ll k=1;
	for(int i=0;i<b;i++)
		k*=a;
	return k;
}
void solve();
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	int q=1;//cin>>q;
	while(q--){
		solve();
	}
}
void solve(){
	int x,k;
	cin>>x>>k;
	if(k%2==0 && k>=2*x && k<=x*4)
		cout<<"Yes";
	else 
		cout<<"No";
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int total = 0;
  for(int i=0;i<N;i++) {
    cin >> m[i];
    total += m[i];
  }

  X -= total;

  int min = *min_element(m.begin(), m.end());
  cout << N + X / min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <atcoder/all>
#include <set>
using namespace std;
using namespace atcoder;

int op(int a, int b) {
	return max(a, b);
}
int e() {
	return 0;
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	segtree<int, op, e> Seg(3000000);
	for (int i = 0; i < N; i++) {
		int ap = Seg.prod(max(0, A[i] - K), min(A[i] + K + 1, 3000000));
		Seg.set(A[i], ap + 1);
	}
	cout << Seg.all_prod() << endl;
}


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

void sortString(string &str){
	sort(str.begin(),str.end());
}


int main(){
	int n;
	cin >> n;
	vector<string> s(n);
	string tmp;
	for(int i=0;i<n;i++){
		cin >> tmp;
		sortString(tmp);
		s[i] = tmp;
		//cout << s[i] << endl;
	}
	sort(s.begin(),s.end());
//	for(int i=0;i<n;i++) cout << s.at(i) << endl;
	long sum=0;
	long same_set=0;
	for(int i=0;i<n-1;i++){
		same_set=0;
		int j=i+1;
//		cout << "s[i]: " << s[i] << endl;
		while((j<n) && (s[j]==s[i])){
			j++;
			same_set++;
			sum += same_set;
		}
		if(j==n-1){
			break;
		}
		i=j-1;
	}
	cout << sum << endl;
	return 0;
}



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

int main() {
    int n, t, a[100000], ilosc = 0;
    cin >> n >> t;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(a[i] >= t) {
            ilosc++;
        }
    }
    cout << ilosc;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void print(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void print(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


const int n = 7;
int a[n];
signed main(){
  rep(i,n)scanf("%lld", &a[i]);
  int ans = a[1];
  if(a[3]%2 == 1 and a[4]%2 == 1){
    ans += (a[3]-1)+(a[4]-1);
    if(a[0] == 0){cout << ans << endl;return 0;}
    ans += (a[0]-1)/2*2;
    cout << ans+3 << endl;
    return 0;
  }
  if(a[0]%2 == 1 and a[3]%2 == 1){
    if(a[4] == 0){
      ans += (a[0]-1)+(a[3]-1);
      cout << ans << endl;return 0;
    }
    int sum = a[0]+a[3]+a[4];
    cout << ans+sum-1 << endl;return 0;
  }
  if(a[0]%2 == 1 and a[4]%2 == 1){
    if(a[3] == 0){
      ans += (a[0]-1)+(a[4]-1);
      cout << ans << endl;return 0;
    }
    int sum = a[0]+a[3]+a[4];
    cout << ans+sum-1 << endl;return 0;
  }
  ans += a[0]/2*2;
  ans += a[3]/2*2;
  ans += a[4]/2*2;
  cout << ans << endl;
	return 0;
}










Measured memory_bytes: 256
#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>
#include <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

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

#define amari(x) ((x) % 1000000007)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(int i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

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

  long n;
  cin >> n;
  vector<long> a(n);
  fillLong(a, n);

  map<long, int> cnts;

  long cnt = 0;
  sortv(a);

  long m = 1;
  
  while (m <= 1000000000*2) {
    m*=2;
  }

  rep(i, n) {
    cnts[a[i]]++;
  }

  for (long i = n-1; i > 0; i--) {
    if (cnts[a[i]] == 0) continue;
    for (long j = m; j > 1; j = j/2) {
      if (bs(a, j-a[i]) && ((j-a[i] == a[i] && cnts[j-a[i]]>1) || (j-a[i] != a[i] && cnts[j-a[i]]>0))) {
        cnt++;
        cnts[a[i]]--;
        cnts[j-a[i]]--;
        break;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int N;
	int max=0, ctr=0;
	cin >> N;
	vector<int> P(N);
	for (int i = 0; i < N; ++i) {
		cin >> P.at(i);
		if(i==0){
			ctr++;
			max = P.at(i);
		}else if(max>=P.at(i)){
			ctr++;
			max = P.at(i);
		}
	}
	cout << ctr<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] c = new int[n];
        int[][] a = new int[n][m];

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

        long ans = Long.MAX_VALUE;

        for (int i = 0; i < Math.pow(2,n); i++) {
            boolean ok = true;
            long res = 0;
            for (int k = 0; k < m; k++) {
                long sum = 0;
                for (int j = 0; j < n; j++) {
                    if ((1&i >> j) == 1) {
                        res += c[j];
                        sum += a[j][k];
                    }
                    // System.out.println(sum);
                }
                if (sum < x) {
                    ok = false;
                    break;
                }
                // System.out.println();
            }
            // System.out.println(res/m);
            if (ok) {
                ans = Math.min(ans,res/m);
            }
        }

        if (ans == Long.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 37524
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
int a[3010];
ll md=998244353;
ll d[3010][3010];
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	d[0][0]=1;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<=m;j++)
		{
			if (j+a[i]>m) break;
			d[i+1][j+a[i]]=(d[i+1][j+a[i]]+d[i][j])%md;
		}
		for (int j=0;j<=m;j++)
			d[i+1][j]=(d[i+1][j]+d[i][j]*2)%md;
	}
	cout <<d[n][m];
	return 0;
}

Measured memory_bytes: 74164
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	int n, m;
	cin >> n >> m;
	int maxL = 0;
	int minR = n + 1;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		maxL = max(maxL, l);
		minR = min(minR, r);
	}
	int ans = 0;
	rep(i, n) {
		if (maxL <= i + 1 && i + 1 <= minR) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

int[] di = [-1, 0, 1, -1, 0, 1, -1, 0, 1];
int[] dj = [-1, -1, -1, 0, 0, 0, 1, 1, 1];
alias Block = Tuple!(int, "i", int, "j");

void main() {
    int h, w, n;
    scan(h, w, n);

    //int[Block] cnt;
    Block[] bs;

    foreach (i ; 0 .. n) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;

        foreach (k ; 0 .. 9) {
            int ni = ai + di[k];
            int nj = bi + dj[k];
            if (ni < 1 || nj < 1 || ni >= h - 1 || nj >= w - 1) continue;
            //cnt[Block(ni, nj)]++;
            bs ~= Block(ni, nj);
        }
    }

    auto gs = bs.sort().group.map!(i => i[1]);

    debug {
        //writeln(cnt);
    }

    auto ans = new long[](10);
    long t;

    foreach (g; gs) {
        ans[g]++;
        t++;
    }

    ans[0] = 1L * (h - 2) * (w - 2) - t;

    writefln("%(%d\n%)", ans);
}





void yes(bool b) {writeln(b ? "Yes" : "No");}
void YES(bool b) {writeln(b ? "YES" : "NO");}
T[] readArr(T)() {return readln.split.to!(T[]);}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 13820
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  VVI a(n, VI(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int res = 2e9;
  for (int i = 0; i < m; i++) {
    VI c(m + 1);
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < m; k++) {
        if (a[j][k]) {
          c[a[j][k]]++;
          break;
        }
      }
    }
    res = min(res, *max_element(c.begin(), c.end()));
    int t = max_element(c.begin(), c.end()) - c.begin();
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < m; k++) {
        if (a[j][k] == t) a[j][k] = 0;
      }
    }
  }
  cout << res << '\n';
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<P> points;
  int minX = 1e9 + 1, minY = 1e9 + 1, maxX = 0, maxY = 0;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    points.push_back(P(x, y));
    minX = min(minX, x);
    minY = min(minY, y);
    maxX = max(maxX, x);
    maxY = max(maxY, y);
  }

  P leftlow = points.at(0), rightlow = points.at(0), lefthigh = points.at(0), righthigh = points.at(0);
  for (int i = 1; i < n; i++) {
    P p = points.at(i);
    if (abs(leftlow.first - minX) + abs(leftlow.second - minY) > abs(p.first - minX) + abs(p.second - minY)) leftlow = p;
    if (abs(rightlow.first - maxX) + abs(rightlow.second - minY) > abs(p.first - maxX) + abs(p.second - minY)) rightlow = p;
    if (abs(lefthigh.first - minX) + abs(lefthigh.second - maxY) > abs(p.first - minX) + abs(p.second - maxY)) lefthigh = p;
    if (abs(righthigh.first - maxX) + abs(righthigh.second - maxY) > abs(p.first - maxX) + abs(p.second - maxY)) righthigh = p;
  }

  int ans = max(abs(righthigh.first - leftlow.first) + abs(righthigh.second - leftlow.second), abs(rightlow.first - lefthigh.first) + abs(rightlow.second - lefthigh.second));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 
const int SEARCH_MAX = 6e3;

int main() {
  long long int N, K, ans;
  cin >> N >> K;
  ans = min(N, N % K);
  ans = min(ans, abs(ans-K)); // 負の場合の対処
  
  cout << ans << endl;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-------------------------------------------------

int e, y;

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

	cin >> e >> y;
	if (e == 0) {
		if (y <= 1911) cout << "M" << y - 1867 << endl;
		else if (y <= 1925) cout << "T" << y - 1911 << endl;
		else if (y <= 1988) cout << "S" << y - 1925 << endl;
		else cout << "H" << y - 1988 << endl;
	}
	else if (e == 1) cout << 1867 + y << endl;
	else if (e == 2) cout << 1911 + y << endl;
	else if (e == 3) cout << 1925 + y << endl;
	else cout << 1988 + y << endl;

    return 0;
}




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

int main(void) {
	using namespace std;
	int N;
	vector<int> a;
	vector<int> b;
	cin >> N;
	int interval = N + 1;
	for(int i = 0; i < N; ++i) {
		a.push_back(interval * i + 1);
		b.push_back(interval * (N - i));
	}
	for(int i = 0; i < N; ++i) {
		int p;
		cin >> p;
		a[p - 1] += i;
	}
	for(int i = 0; i < N; ++i) {
		if(i != 0) {
			cout << ' ';
		}
		cout << a[i];
	}
	cout << '\n';
	for(int i = 0; i < N; ++i) {
		if(i != 0) {
			cout << ' ';
		}
		cout << b[i];
	}
	cout << '\n';
	return 0;
}



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

int main()
{
	int n = 0;
	std::cin >> n;

	std::vector<int> numbers(n);

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

	for (int j = 0; j < n; j++)//??¨???
	{
		std::cout << numbers[j];
		if (j != n - 1)
		{
			std::cout << " ";
		}
	}
	std::cout << std::endl;

	int inserting = 0;
	for (int i = 1; i < n; i++)
	{
		inserting = numbers[i];
		for (int j = i; j > 0; j--)
		{
			if (numbers[j - 1] > inserting)
			{
				numbers[j] = numbers[j - 1];
				numbers[j - 1] = inserting;
			}
			else
			{
				break;
			}
		}

		for (int j = 0; j < n; j++)//??¨???
		{
			std::cout << numbers[j];
			if (j != n - 1)
			{
				std::cout << " ";
			}
		}
		std::cout << std::endl;
	}
}

Measured memory_bytes: 3036
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RSInt;
            var a = new int[] { 1, 4, 7, 9 };
            Array.Sort(n);
            bool f = n.SequenceEqual(a);
            IO.WriteLineYES_or_NO(f);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 19300
const mod=10^9+7
const L,R=map(x->parse(Int,x),split(readline()))
const dp=zeros(Int,64,2,2)
for k=1:62
	dp[63-k,(L<=1<<(k-1))+1,((1<<k)-1<=R)+1]=1<<k>L&&R>=1<<(k-1)
end
for i=0:60
	x=(L>>(60-i))%2
	y=(R>>(60-i))%2
	for xl=1:2,yl=1:2
		limx=xl==1?x:0
		limy=yl==1?y:1
		for yy=0:limy,xx=limx:yy
			dp[i+2,(xl>1||xx>limx)+1,(yl>1||yy<limy)+1]+=dp[i+1,xl,yl]
			dp[i+2,(xl>1||xx>limx)+1,(yl>1||yy<limy)+1]%=mod
		end
	end
end
ans=0
for i=1:2,j=1:2
	ans+=dp[62,i,j]
end
println(ans%mod)


Measured memory_bytes: 113884
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ar array
#define mxn 200005
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	string s;
	cin>>s;
	int n=s.length();
	if(s[n-1]=='s')
	s+="es";
	else
	s+="s";
	cout<<s;
}


Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;


int main() {
	ll N;
	cin >> N;
	vector<ll>S(N);
	rep(i, N)cin >> S[i];
	ll Q;
	cin >> Q;
	int ans = 0;
	rep(j, Q) {
		ll a;
		cin >> a;
		ll left = 0;
		ll right = N ;
		while (0<right-left)
		{
			ll mid = (left + right) / 2;
			if (a==S[mid]) {
				ans++;
				break;
			}
			else if (a<S[mid]) {
				right = mid;
			}
			else {
				left = mid+1;
			}
		}
	}

	cout << ans << endl;

	return 0;
}





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

int n;

void dfs(int i, string s, char maxc){
    if(i == n){
        cout << s << endl;
        return;
    }
    for(char c = 'a'; c <= maxc+1; c++){
        dfs(i+1, s + c, max(maxc, c));
    }
}

int main(){
    cin >> n;
    dfs(1, "a", 'a');
    return 0;
}

Measured memory_bytes: 3564
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  double X[N];
  char check[3];
  int YorB[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%lf ", &X[i]);
    for (size_t j = 0; j <3; j++) {
      scanf("%c", &check[j]);
    }
    if (check[0]=='J') {
      YorB[i]=1;
    }else{
      YorB[i]=0;
    }
  }
  // for (size_t i = 0; i < N; i++) {
  //   printf("%lf %d\n", X[i],YorB[i]);
  // }

  double ans=0;
  for (size_t i = 0; i < N; i++) {
    if (YorB[i]==1) {
      ans=ans+X[i];
    }else{
      ans=ans+X[i]*380000.0;
    }
  }
  printf("%lf",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(void)
{
	int N, K;
	
	cin >> N >> K;
	
	vector<int> price(N);
	
	for(int i = 0; i < N; i++)
	{
		cin >> price[i];
	}
	
	//価格をソート
	sort(price.begin(), price.end());
	
	int total_price = 0;
	for(int i = 0; i < K; i++)
	{
		total_price += price[i];
	}
	
	cout << total_price << endl;
	
	return 0;
}


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

s = input()
n = len(s)+1
a = [0 for _  in range(n)]

for i in range(n-1):
    if s[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in reversed(range(1, n)):
    if s[i-1] == '>':
        a[i-1] = max(a[i-1], a[i]+1)

ans = sum(a)

#print('a = ', a)
print(ans)


Measured memory_bytes: 23976
w, h, n = [int(e) for e in input().split()]
x_under, x_lim, y_under, y_lim = 0, w, 0, h
for _ in range(n):
    x, y, a = [int(e) for e in input().split()]
    if a == 1 and x_under < x:
        x_under = x
    elif a == 2 and x < x_lim:
        x_lim = x
    elif a == 3 and y_under < y:
        y_under = y
    elif a == 4 and y < y_lim:
        y_lim = y
x_len = x_lim - x_under
y_len = y_lim - y_under
if x_len < 0 or y_len < 0:
    print('0')
else:
    print(x_len * y_len)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,b,n; cin >> a >> b >> n;
    cout << (a*(min(n,b-1)))/b << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll m,k; cin >> m >> k;
  if(m==1){
      if(k==0){
          cout << "0 0 1 1" << endl;
      }else{
          cout << -1 << endl;
      }
      return 0;
  }
  if(k>=(1<<m)){
      cout << -1 << endl;
      return 0;
  }
  queue<ll> q;
  q.push(k);
  rep(i,(1<<m)){
      if(i!=k){
          q.push(i);
      }
  }
  q.push(k);
  repr(i,(1<<m)-1){
      if(i!=k){
          q.push(i);
      }
  }
  while(q.size()){
      cout << q.front() << " ";
      q.pop();
  }

}

Measured memory_bytes: 3968
#include <stdio.h>

int main()
{
  int n;
  scanf("%d", &n);
  float a[n];
  int i;
  float ans = 0;
  for (i = 0; i < n; i++) {
    scanf("%f", &a[i]);
    ans += 1 / a[i];
  }

  printf("%f\n", 1 / ans);
  return 0;
}


Measured memory_bytes: 128
def D_160():
    N, X, Y = map(int, input().split())
    #count_list = [[0]*N for i in range(N)]
    ans = [0 for i in range(N-1)]
    for i in range(0,N):
        for j in range(1+i,N):
            ans_i = min(j-i,abs((X-1)-i) + abs(j-(Y-1)) + 1)
            ans[ans_i-1] += 1
    
    
    for i in ans:
        print(i)

D_160()

Measured memory_bytes: 3444