akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
using namespace std;
const int N=300005;
int h,w,m,ans,x[N],y[N],tx[N],ty[N];
vector<int> vec[N];
priority_queue<pair<int,int>> pq;
pair<int,int> stk[N];
set<int> st;
int top;
int main(){
	scanf("%d%d%d",&h,&w,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x[i],&y[i]);
		tx[x[i]]++;
		ty[y[i]]++;
		vec[x[i]].push_back(y[i]);
	}
	for(int i=1;i<=w;i++){
		pq.push(make_pair(ty[i],i));
	}
	for(int i=1;i<=m;i++){
		ans=max(ans,tx[x[i]]+ty[y[i]]-1);
	}
	for(int i=1;i<=h;i++){
		if(tx[i]){
			top=0;
			st.clear();
			for(int j=0;j<tx[i];j++){
				st.insert(vec[i][j]);
			}
			while(pq.size()&&st.count(pq.top().second)){
				stk[++top]=pq.top();
				pq.pop();
			}
			if(!pq.empty()){
				ans=max(ans,tx[i]+pq.top().first);
			}
			while(top){
				pq.push(stk[top--]);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 31048
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q, r;
    cin >> p >> q >> r;
    cout << min({p + q, q + r, r + p}) << endl;
    return 0;
}

Measured memory_bytes: 256
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n,m;
    cin >>n >> m;
    if(n > 1){
        n = n * (n-1) / 2;
    }else n=0;
    if(m >1){
        m = m *(m-1)/2;
    }else m = 0;
    cout << m+n <<endl;
    return 0;
}

Measured memory_bytes: 256
tukawan = int(input())
A = list(map(int, input().split())) 
result = 1

if 0 in A:
    print(0)

else:
  for number in A:
    result = result * number
    
    if result > 1000000000000000000:
      result = -1
      break
    
  print(result)  

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

struct tree{
	int* children;
	int degree;
	int parent;
};

int main(){

	ios_base::sync_with_stdio(false);
	int num;
	cin >> num;
	
	tree* array = new tree[num];
	
	for(int i = 0; i < num; i++){
		int index;
		int degree;
		int childID;
		
		cin >> index;
		cin >> degree;
		array[index].children = new int[degree];
		array[index].degree = degree;
		array[index].parent = -1;
		for(int j = 0; j < degree; j ++){
			cin >> childID;
			array[index].children[j] = childID; 	
		}

	}
	for(int i = 0; i < num; i++){
		for(int j = 0; j < array[i].degree; j++){
			array[array[i].children[j]].parent = i;
		}
	}
	for(int i = 0; i < num; i++){
		//parent
		cout << "node " << i << ": parent = " << array[i].parent << ", ";
		//depth
		int counter = 0;
		int index = i;
		while(array[index].parent != -1){
			counter ++;
			index = array[index].parent;
		}
		cout << "depth = " << counter << ", ";

		//type
		if(array[i].parent == -1)cout << "root";
		else if(array[i].degree == 0)cout << "leaf";
		else cout << "internal node";
		cout << ", ";

		//children
		cout << "[";
		for(int j = 0; j < array[i].degree; j++){
			cout << array[i].children[j]; 
			if(j + 1 != array[i].degree){
				cout << ", ";
			}
		}
		cout << "]";
		cout << endl;
		delete [] array[i].children;
	}
	delete [] array;

	return 0;
}

Measured memory_bytes: 6284
// abc164_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int a,b,c,d,takahashi,aoki;
  cin>>a>>b>>c>>d;
  takahashi=a/d;
  aoki=c/b;
  if(a%d!=0)takahashi++;
  if(c%b!=0)aoki++;
  // cout<<takahashi<<" : "<<aoki<<endl;
  if (takahashi>=aoki)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  ll h;
  cin >> h;
  ll res=0;
  ll c = 0;
  while(h!=0){
    //cout << h << c << endl;
    res+=pow(2,c);
    c++;
    h /= 2;
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define inf 20021225
#define ll long long
#define mxn 110
using namespace std;
 
int n,a[mxn],m;
 
int main()
{
	int cnt=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&a[i]);
		cnt+=a[i]%2;
	}
	if(cnt>2)
	{
		printf("Impossible\n");
		return 0;
	}
	int fs=0;
	for(int i=1;i<=m;i++)
	{
		if(a[i]%2==1)
		{
			if(!fs)	swap(a[1],a[i]),fs=1;
			else	swap(a[m],a[i]);
		}
	}
	for(int i=1;i<=m;i++)	printf("%d ",a[i]);puts("");
	if(m==1)
	{
		if(a[1]==1)	printf("1\n1\n");
		else	printf("2\n1 %d\n",a[1]-1);
		return 0;
	}
	a[1]--; a[m]++; 
	if(a[1]==0)
	{
		printf("%d\n",m-1);
		for(int i=2;i<=m;i++)	printf("%d ",a[i]);
	}
	else
	{
		printf("%d\n",m);
		for(int i=1;i<=m;i++)	printf("%d ",a[i]);
	}
	return 0;
}


Measured memory_bytes: 128
import copy

S = list(input())
tmp = 0
count = 0

for s in S:
    if s == 'A' or s == 'C' or s == 'G' or s == 'T':
        tmp += 1
        if count < tmp:
            count = copy.copy(tmp)
    else:
        tmp = 0

print(count)


Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(br.readLine());
        String output = "Yes";
        String before = "";
        Set<String> wordSet = new HashSet<>();
        for (int i = 0; i < N; i++) {
            String word = br.readLine();
            if (before.equals("") 
                || (before.charAt(before.length() - 1) == word.charAt(0)
                && !wordSet.contains(word))) {
                wordSet.add(word);
                before = word;
            } else {
                output = "No";
                break;
            }
        }
        out.println(output);
        out.close();
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

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

    ll res = 1;
    for(int i = 1; i <= n; ++i) {
        ll x; cin >> x;
        res = x / __gcd(x, res) * res;
    }

    cout << res << endl;
}

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

int main() {
	string S;
	cin>>S;
	int x=0;
	for(int i=0;i<4;i++){
		if(S.at(i)=='+'){
			x++;
		}
		else{
			x--;
		}
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007



int main()
{
 //O_O ;
   ll t;
   cin>>t;
   map<string,ll>mp;
   for(ll i=0;i<t;i++)
   {
       string s; cin>>s;
       mp[s]++;
   }
   cout<<mp.size()<<nn;



    return 0;
}


Measured memory_bytes: 19256
#include<bits/stdc++.h>
#define LL long long
#define dl double
template <class T>
void rd(T &x){
  x=0;T f=1;char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  while(ch<='9' && ch>='0')x=x*10+ch-'0',ch=getchar();x*=f;
}
using namespace std;
int n;
int main(){
 // freopen("in.txt","r",stdin);
 // freopen("o.txt","w",stdout);
 rd(n);
 printf("%d\n",n%1000?1000-n%1000:0);
 return 0;
}
/**/

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

int main()
{
  int N;
  cin >> N;  
  vector<char> moji(N);
  vector<int> nishi(N);
  vector<int> higashi(N);
  int nishicount=0;
  int higashicount=0;
  for(int i=0;i<N;i++){
	  cin >> moji.at(i);
  }
  for(int i=0;i<N;i++){
		if(moji.at(i) =='W') nishicount ++;
        nishi.at(i) = nishicount; 
  }
  for(int i=0;i<N;i++){
		if(moji.at(N-1-i) =='E') higashicount ++;
        higashi.at(N-1-i) = higashicount; 
  }
  
/*  for(int i=0;i<N;i++){
      	cout << higashi.at(i); 
  }
*/
  int sum = 300000;
  for(int i=0;i<N;i++){
    int count =0;
    count = nishi.at(i) + higashi.at(i) -1;
    sum = min(sum,count);
}  
	cout << sum << endl;
}
  
  
  
  /*意味不明なことかいてた    int count=0;
  	if(moji.at(i)=='E'){
      count = higashicount - higashi.at(i);
    }
    else if(moji.at(i)=='W'){
      count = nishicount - nishi.at(i);      
    }
    sum = min(sum,count);
  }
  cout << sum << endl;
*/
  
  
  
  
/*  int sum=300000;
  for(int i=0;i<N;i++){
    int count=0;
    for(int j=0;j<N;j++){  
	  if(i<j && moji.at(j) == 'E') {
        count++;
//        if(sum <= count) j+=N;
      }
      else if(i>j && moji.at(j) == 'W') {
        count++;
//        if(sum <= count) j+=N;
      }
    }
    cout << count;
    sum = min(sum,count);
  }
//  cout << sum << endl;
}
*/


Measured memory_bytes: 2944
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int total = Integer.MAX_VALUE;
    for(int i=1; i<n; i++){
      int x = sum(i)+sum(n-i);
      if(total > x){
        total = x;
      }
    }
    System.out.println(total);

    sc.close();
  }

  public static int sum(int x){
    int sum = 0;
    while(x > 0){
      sum += x%10;
      x /= 10;
    }
    return sum;
  }
}

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

int main() {
    int H;
    int W;
    int N;
    cin >> H;
    cin >> W;
    cin >> N;
    
    int maxval;
    int ans;
    
    maxval = max(H,W);
    if ( N % maxval == 0 ) {
        ans =  N / maxval ;
    } else {
        ans =  N / maxval + 1;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys

n = int(input())
a = list(map(int,input().split()))

h =[]

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

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] = a[0]
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] = a[i-1]
    else:
        h.append(0)
        
print(sum(h))

Measured memory_bytes: 32380
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val H, N = in.next().toInt
  val ms = new Array[(Int, Int)](N)
  for (i <- 0 until N) {
    val A, B = in.next().toInt
    ms(i) = (A, B)
  }

  //
  var dp = Array.fill[Int](H+1)(Int.MaxValue)
  dp(0) = 0

  for ((a, b) <- ms) {
    for (i <- (0 to H)) {
      if (dp(i) != Int.MaxValue) {
        if (i + a > H) {
          dp(H) = Math.min(dp(H), dp(i) + b)
        }
        else {
          dp(i+a) = Math.min(dp(i+a), dp(i) + b)
        }
      }
    }
  }

  println(dp(H))
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 28760
// CGL_1_A
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(){
	double xx, yy, X, Y, x, y;
	int q, xp[2], yp[2];

	cin>>xp[0]>>yp[0]>>xp[1]>>yp[1];
	X = xp[1] - xp[0];
	Y = yp[1] - yp[0];

	cin>>q;
	for(int i=0;i<q;i++){
		cin>>xx>>yy;

		if(Y == 0){
			x = xx;
			y = yp[0];
		}else if(X == 0){
			x = xp[0];
			y = yy;
		}else{
			x = (xp[0]*Y*Y+xx*X*X+yy*X*Y-yp[0]*X*Y)/(X*X+Y*Y);
			y = -X/Y*(x-xx)+yy;
		}

		printf("%.10lf %.10lf\n", x, y);
	}

	return 0;
}

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

int main(void){
    int a,b,c,d; cin >> a >> b >> c >> d;

    if((a+b)>(c+d)) cout << "Left" << endl;
    else if((a+b)==(c+d)) cout << "Balanced";
    else cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int H,W;
	int i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 && W ==  0){
			break;
		}
		for(j = 1; j <= H; j++){
			for(i = 1; i <= W; i++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2012
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h;
    cin>>h;
    ll ans = 0, step = 1;
    while(h > 0) {
        ans += step;
        h = h / 2;
        step *= 2;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    size_t X, Y, Z, N;
    cin >> X >> Y >> Z;
    N = X + Y + Z;
    vector<pair<long, long>> coins(N);
    long ans{0};
    for(auto& i : coins){
        long a;
        cin >> a >> i.first >> i.second;
        i.first -= a;
        i.second -= a;
        ans += a;
    }
    sort(coins.begin(), coins.end());
    vector<long> A(Z + 1), C(Z + 1);
    priority_queue<long> pq;
    for(size_t i = 0; i < X; ++i)pq.push(coins[i].second);
    for(size_t i = 0; i < Z; ++i){
        pq.push(coins[X + i].second);
        A[i + 1] = A[i] + pq.top();
        pq.pop();
    }
    pq = priority_queue<long>();
    reverse(coins.begin(), coins.end());
    for(size_t i = 0; i < Y; ++i){
        C[0] += coins[i].first;
        pq.push(coins[i].second - coins[i].first);
    }
    for(size_t i = 0; i < Z; ++i){
        pq.push(coins[Y + i].second - coins[Y + i].first);
        C[i + 1] = C[i] + pq.top() + coins[Y + i].first;
        pq.pop();
    }
    vector<long> B(Z + 1);
    transform(A.begin(), A.end(), C.rbegin(), B.begin(), plus<>());
    cout << *max_element(B.begin(), B.end()) + ans << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  bool b = true;
  for(int i = 0; i < S.size();i++) {
    if(i%2 == 0) {
      if (S.at(i)=='L'){
        b = false;
      }
    }
    else  if(i%2 == 1) {
      if (S.at(i)=='R') {
        b = false;
      }
    }
  }
  if(b == false) {
    cout << "No" << endl;
  }
  if(b == true) {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
vector<int> a;
int cal(int x, int k) {
  for(int i = 0;i < sz(a); i++) {
    int p = a[i] / x + (a[i] % x != 0);
    k -= (p - 1);
  }
  if(k < 0) return 0;
  return 1;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  a = vector<int>(n);
  for(int i = 0;i < n; i++) {
    cin >> a[i];
  }
  int l = 1, h = 1e9;
  int ans = inf;
  while(l <= h) {
    int mid = (l + h) / 2;
    if(cal(mid, k)) {
      ans = min(ans , mid);
      h = mid - 1;
    }
    else l = mid + 1;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int res,k;
int level[MAXN];

void dfs(int here,int par)
{
    int there;

    level[here] = 1;

    for(int i=0;i<graph[here].size();i++)
    {
        there = graph[here][i];
        dfs(there,here);
        level[here] = max(level[there]+1,level[here]);
    }

    if(level[here]>=k&&par){
        res++;
        level[here] = 0;
    }

    return;
}

int main()
{
    int n,m,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;

    graph = vector<vector<int> > (n);

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

    if(A[0])res++;

    for(int i=1;i<n;i++)
        graph[A[i]].push_back(i);

    dfs(0,0);

    cout<<res<<"\n";

    return 0;
}


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


int main()
{
    int n, x, m[100000], min = 1000;
    cin >> n >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> m[i];
        x -= m[i];
        if (min > m[i]) min = m[i];
    }
    cout << n + x / min << endl;
}

Measured memory_bytes: 256
n, a, b, c, d = [int(item) for item in input().split()]

u, l = 0, 0
while n > 1:
    if b <= a + u + (n-1) * d and b >= a + l + (n-1) * c:
        print("YES")
        exit()
    if b <= a + u + (n-1) * -c and b >= a + l + (n-1) * -d:
        print("YES")
        exit()
    n -= 2
    u += d - c
    l -= d - c
print("NO")

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	static boolean[][] map;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int w = stdIn.nextInt();
			int h = stdIn.nextInt();
			if(w == 0 && h == 0) break;
			map = new boolean[h][w];
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					int a = stdIn.nextInt();
					map[i][j] = (a == 1)?true:false;
				}
			}
			int counter = 0;
			for(int i = 0; i < h; i++) {
				for(int j = 0; j < w; j++) {
					if(map[i][j]) {
						counter++;
						sorv(i,j);
					}
					
				}
			}
			System.out.println(counter);
			
		}
	}
	
	static void sorv(int i, int j) {
		if(i < 0 || j < 0)return;
		if(i >= map.length || j >= map[i].length)return;
		if(!map[i][j])return;
		if(map[i][j]) map[i][j] = false;
		sorv(i-1,j-1);
		sorv(i-1,j);
		sorv(i-1,j+1);
		sorv(i,j+1);
		sorv(i,j-1);
		sorv(i+1,j-1);
		sorv(i+1,j);
		sorv(i+1,j+1);
	}
}

Measured memory_bytes: 52512
#include <bits/stdc++.h>
using namespace std;
unsigned long long int gcd( unsigned long long int m, unsigned long long int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	while( m != n )
	{
		if ( m > n ){
      if(m%n==0){
        m = n;
      }
      else{
        m = m%n;
      }
    }
		else{
      if(n%m==0){
        n = m;
      }
      else{
        n = n%m;
      }
	  }
  }
	return m;
}
int main(){
  int n;
  cin>>n;
  unsigned long long int t[n];
  for(int i=0;i<n;++i){
    cin>>t[i];
  }
  unsigned long long int b=t[0];
  for(int i=1;i<n;++i){
    unsigned long long int c = gcd(b,t[i]);
    b=b/c*t[i];
  }
  cout<<b;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2e5+5;
int cnt[2],a[N],n;
bool check(int md){
	For(i,0,n-1){
		if(a[n+i]<=md&&a[n+i+1]<=md) return 1;
		if(a[n-i]<=md&&a[n-i-1]<=md) return 1;
		if(a[n+i]>md&&a[n+i+1]>md) return 0;
		if(a[n-i]>md&&a[n-i-1]>md) return 0;
	}
	return a[1]<=md;
}
int main(){
	n=read();
	For(i,1,2*n-1) a[i]=read();
	int l=1,r=2*n-1,mid,ans=0;
	while(l<=r){
		check(mid=l+r>>1)?r=(ans=mid)-1:l=mid+1;
	}
	cout<<ans;
}

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

int main(){
  while(1){
    int a,b,n,i,j,map[2][17],koji[17][17];

    scanf("%d %d",&a,&b);
    if(a==0&&b==0) break;
    scanf("%d",&n);

    memset(map,0,sizeof(map));
    memset(koji,0,sizeof(koji));

    while(n--){
      int x,y;
      scanf("%d %d",&x,&y);
      koji[x][y] = 1;
    }

    map[1][1] = 1;
    for(i=1; i<=a; i++){
      for(j=1; j<=b; j++)
	if(i!=1||j!=1)
	  map[i&1][j] = (koji[i][j]?0:(map[i&1][j-1]+map[~i&1][j]));
    }

    printf("%d\n",map[a&1][b]);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;
ll ans = NEG_INF;
ll p[5010], c[5010];
void solve(ll pos, ll n, ll k){
	ll curr = pos, sum = 0;
	ll tab[5010] = {0};
	vector<ll> dp;
	ll moves = 0;
	while(curr >= 1 && curr <= n && tab[curr] == 0 && moves < k){
		tab[curr] = 1;
		sum += c[p[curr]];
		curr = p[curr];
		ans = max(ans, sum);
		moves++;
		dp.pb(sum);
	}
	if(curr < 1 || curr > n || moves == k)
		return ;

	ll temp = NEG_INF, extra = NEG_INF;
	if(dp.back() >= 0){
		ll times = k / dp.size();
		k = k % dp.size();
		loop(i, 0, k)
			extra = max(extra, dp[i]);
		
		
		temp = dp.back() * times;
		if(times > 0)
			ans = max(ans, max(temp, 0LL) + max(extra, 0LL));
		else
			ans = extra;
		if(times >= 1){
			for(auto &node : dp)
				extra = max(extra, node);

			temp = dp.back() * (times - 1);
			ans = max(ans, max(temp, 0LL) + max(extra, 0LL));
		}
	
	}else{
		loop(i, 0, min((ll)dp.size(), k))
			extra = max(extra, dp[i]);
		ans = max(ans, extra);
	}
	
}
int main(){
	IOS;
	ll n, k;
	cin >> n >> k;
	ll a, b;
	loop(i, 1, n + 1){
		cin >> a;
		p[i] = a;
	}
	loop(i, 1, n + 1){
		cin >> b;
		c[i] = b;
	}

	loop(i, 1, n + 1)
		solve(i, n, k);
	cout << ans << endl;
}

Measured memory_bytes: 3784
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    x,y,a,b,c = inpm()
    p = inpl()
    q = inpl()
    r = inpl()
    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)
    ans = 0
    que = []
    for i in range(x):
        ans += p[i]
        que.append([p[i],0])
    for i in range(y):
        ans += q[i]
        que.append([q[i],1])
    que.sort()
    cntx = x
    cnty = y
    indexq = 0
    indexr = 0
    while not (indexr == len(r) or indexq == len(que)):
        if r[indexr] <= que[indexq][0]:
            break
        if cntx == 0 and not(que[indexq][1]):
            indexq += 1
            continue
        if cnty == 0 and que[indexq][1]:
            indexq += 1
            continue
        ans += r[indexr]-que[indexq][0]
        if que[indexq][1]:
            cnty -= 1
        else:
            cntx -= 1
        indexr += 1
        indexq += 1
    print(ans)
    
if __name__ == "__main__":
    main()

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

int main() {
  int H,M;
  cin >> H >> M;
  
  vector<int> table((M * 2),0);
  
  for (int i = 0; i < (M * 2); i++) {
    cin >> table.at(i);
  }
  
  for (int i = 1; i <= H; i++) {
  int answer = count(table.begin(), table.end(), i);
   cout << answer << endl;
  }
}

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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    ll n,d; cin >> n >> d;
    ll ans = 0;
    rep(i,n){
        ll x,y; cin >> x >> y;
        if(d*d >= x*x+y*y) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t int64;
typedef int64_t ll;

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

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

using namespace std;


class B {
	int n;
	string s;
public:
	B()
	{
		cin >> n;
		s = to_string(n);
	}
	void solve()
	{
		int sn{ 0 };
		REP(i, SZ(s))
			sn += (s[i] - '0');

		if (!(n % sn))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;

	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define INF 2147483647
#define nl '\n'
#define si(i) scanf("%d", &i)
typedef long long ll;

int n;

int main(){
    cin >> n;
    for( int i = 0 ; i < n ; i++ ){
        int ct; si(ct);
        if( ct % 2 == 1 ){
            cout << "first" << nl;
            exit(0);
        }
    }
    cout << "second" << nl;
}

Measured memory_bytes: 256
using System;
class Program
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int A = int.Parse(input[0]);
    int B = int.Parse(input[1]);
    int C = int.Parse(input[2]);
    
    int ans = C - (A - B);
    if (ans < 0) { ans = 0; }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<cstring>
#include<cstdio>

using namespace std;

int main()
{
    int i, w;
    char s[1005];

    while(scanf("%s%d", s, &w) == 2) {
        if(w == 1){
            cout << s;
        }
        else{
            cout << s[0];
            for(i = 1; s[i]; i++) {
                if((i+1)% w == 1){
                    printf("%c", s[i]);
                }
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n, d;
ll a[500010];

ll q;

ll pos[500010];
bool ok[500010];

int main(){

  n = in();
  d = in();
  REP( i , n ){
    a[i] = in();
  }

  pos[0] = d;
  REP( i , n ){
    pos[i+1] = min( pos[i] , abs( pos[i] - a[i] ) );
  }

  ll cur = 1;
  for( int i = n-1; i >= 0; i-- ){
    if( pos[i] >= cur ){
      ok[i] = true;
    }
    if( a[i] <= cur * 2 - 1 ){
      cur += a[i];
    }
  }
  
  q = in();
  REP( i , q ){
    ll c = in() - 1;
    if( ok[c] ){
      puts( "YES" );
    } else {
      puts( "NO" );
    }
  }

  return 0;
}


Measured memory_bytes: 10240
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
#define int ll

bool check(string s) {
    int n = s.size();
    for(int i=0;i<n;i++) {
        if(s[i]!=s[n-1-i]) return false;
    }
    return true;
}

signed main() {
    fast;

    lld x;
    cin>>x;

    lld ans = (x/3)*(x/3)*(x/3);

    cout<<std::fixed<<std::setprecision(20)<<ans;
}

Measured memory_bytes: 256
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int> pii32;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int r, g, b, n, ans;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> r >> g >> b >> n;
	for (int i = 0; r * i <= n; i++)
		for (int t = 0; r * i + g * t <= n; t++)
			if ((n - r * i - g * t) % b == 0)
				ans++;
	cout << ans << "\n";
}


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

int mx_tmp =0;
vector<int> a,b;
vector<vector<string> > c;
vector<long long> g;

int n;
int dfs(int x,int s,long long y){
    int xxx = 0;
    for(int i=x;i<n;i++){
        if((y>>i)&1)continue;
        xxx += a[i];
    }
    if(s+xxx<mx_tmp)return -1;
    int tmp = a[x];
    int mx = 0;
    y |= g[x];
    for(int i=x+1;i<n;i++){
        if((y&(g[i]-(1LL<<i)))==(g[i]-(1LL<<i))){
            if(((y>>i)&1)==0){
                tmp += a[i];
                y|=g[i];
            }
        }
    }
    for(int i=x+1;i<n;i++){
        if((y>>i)&1)continue;
        int tmp2 = dfs(i,s+tmp,y);
        if(mx < tmp2){
            mx = tmp2;
        }
        mx_tmp = max(mx_tmp,tmp+mx);
    }
    return tmp + mx;
}

int main(){
    while(cin>>n &&n!=0){
        map<string,int>mp;
        int cnt = 0;
        a.clear();
        b.clear();
        c.clear();
        g.clear();
        a.resize(n);
        b.resize(n);
        c.resize(n);
        g.resize(n);
        for(int i=0;i<n;i++){
            string s;
            cin >> s;
            mp[s] = cnt;
            cnt++;
            cin >> a[i] >> b[i];
            for(int j=0;j<b[i];j++){
                cin >> s;
                c[i].push_back(s);
            }
        }
        for(int i=0;i<n;i++){
            g[i] = 1LL<<i;
            for(int j=0;j<b[i];j++){
                g[i]+=(1LL<<mp[c[i][j]]);
            }
        }
        mx_tmp=0;
        int ans = dfs(0,0,0);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3300
"""
AtCoder :: Beginner Contest 175 :: A - Rainy Season 
https://atcoder.jp/contests/abc175/tasks/abc175_a
"""
import sys


def main():
    """Main program."""
    S = sys.stdin.readline().strip()
    run = 0
    max_run = 0
    for c in S:
        if c == 'R':
            run += 1
        else:
            max_run = max(max_run, run)
            run = 0
    max_run = max(max_run, run)
    print(max_run)


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1, 1e9);
  rep(i, n) cin >> a[i];
  
  ll step = 0;
  rep(i, n) {
    if (a[i] <= a[i+1]) continue;
    else {
      step += (a[i] - a[i+1]);
      a[i+1] = a[i];
    }
  }
  
  cout << step << endl;
}

Measured memory_bytes: 3964
#include <stdio.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;
 
int _;

//========================================================================

//========================================================================
int main()
{
    int x,y,flag=0;
    scanf("%d%d",&x,&y);
    if(y<2*x||y>4*x) flag=1;
    if(y%2) flag=1;
    if(flag) puts("No");
    else puts("Yes");
    return 0;
}


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

int main() {
    long long n,m=0,k;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        m = a[i]^m;
        //cout<<m<<'\n';
    }
    if(m==0) cout<<"Yes";
    else cout<<"No";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n,d;
    cin>>n>>d;
    int l = 2*d+1;
    cout<<(n+l-1)/l<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}



int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll n, p; cin >> n >> p;
  vector<pair<ll, ll>> v;
  ll tmp = p;
  for(ll i = 2;i*i<=tmp;i++) {
    if(p % i == 0) {
      v.pb(make_pair(i, 0));
      while(p % i == 0) {
        v[SZ(v)-1].se++;
        p /= i;
      }
    }
  }
  if(p != 1) v.pb(make_pair(p, 1));

  ll ans = 1;
  REP(i, SZ(v)) {
    ans *= pow(v[i].fi, v[i].se / n);
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  //vector<int> a(n);
  vvi data(h,vi(w));
  int x = 0;
  int y = 0;
  int c = 0;
  rep(i,n){
    int a;
    cin >> a;
    c++;
    rep(j,a){
      data.at(x).at(y) = c;
      if(x % 2 == 0){
        if(y == w-1){
          x++;
        }else y++;
      }else{
        if(y == 0){
          x++;
        }else y--;
      }
    }
  }
  rep(i,h){
    rep(j,w) cout << data.at(i).at(j) << " ";
    cout << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979


int main(){
  int X,N;
  cin>>X>>N;
  set<int> se;
  rep(i,N){
    int a;
    cin>>a;
    se.insert(a);
  }
  int p=X,q=X;
  rep(i,100){
    p=X-i;
    if(!se.count(p)){break;}
  }
  rep(i,100){
    q=X+i;
    if(!se.count(q)){break;}
  }
  int g=abs(p-X);
  int h=abs(q-X);
  if(g<=h){cout<<p;}
  else{cout<<q;}
  
  
}

Measured memory_bytes: 3636
// 26
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef LOCAL
#define debug(e) cerr << "\033[48;5;196m\033[38;5;15m" << e << "\033[0m";
#else
#define debug(e)
#endif
// 4
template <class A, class B>
ostream &operator<<(ostream &os, pair<A, B> &p) {
  return os << "(" << p.fi << " " << p.se << ")";
}
// 8
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
  rep(i, (int)v.size()) os << setw(7) << left << v[i];
  return os << endl;
}
// 6
template <class A, class B>
ostream &operator<<(ostream &os, map<A, B> &m) {
  for (auto &kv : m) os << "{" << kv.fi << " " << kv.se << "}";
  return os;
}
// 3
void _main(int tc) {
  int n;
  cin >> n;
  vector<ld> p(n);
  rep(i, n) cin >> p[i];
  /************* Recursive *************
  vector<vector<ld>> mem(n, vector<ld>(n + 1, -1));
  function<ld(int, int)> f = [&](int i, int c) -> ld {
    if (n - i + c <= i - c) return 0;
    if (i == n) return 1;
    if (mem[i][c] != -1) return mem[i][c];
    return mem[i][c] = p[i] * f(i + 1, c) + (1 - p[i]) * f(i + 1, c - 1);
  };
  cout << setprecision(10) << f(0, n) << endl;
  *********** End Recursive ***********/
  vector<vector<ld>> mem(n + 1, vector<ld>(n + 1));

  int mid = n & 1 ? (n + 1) / 2 : n / 2 + 1;
  forn(i, mid, n + 1) mem[n][i] = 1;

  rrep(i, n) {
    forn(c, 1, n + 1) {
      mem[i][c] = p[i] * mem[i + 1][c] + (1 - p[i]) * mem[i + 1][c - 1];
    }
  }

  debug(mem);
  
  cout << setprecision(10) << mem[0][n] << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 184467440737095516;

ll dp[4000][4000], ans, savex, savey;
string s, t;

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

	vector <char> v;
	cin >> s >> t;
	for (ll i = 1; i <= t.length(); i++){                  
		for (ll j = 1; j <= s.length(); j++){                   
			if (s[j - 1] == t[i - 1]){ 								// kalo char nya bernilai sama //
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else{
				dp[i][j] = max(dp[i][j-1], dp[i-1][j]);				// kalo char nya bernilai beda //
			}
		}
	}
	// for (ll i = 1; i <= t.length(); i++){               
	// 	for (ll j = 1; j <= s.length(); j++){
	// 		cout << dp[i][j];
	// 	}
	// 	cout << '\n';
	// }

	ans = dp[t.length()][s.length()];
	savex = t.length();
	savey = s.length();
	while (ans > 0 && savex > 0 && savey > 0 && dp[savex][savey] > 0){					// backtrack //
		if(t[savex-1] == s[savey-1]){
			v.push_back(t[savex - 1]);
			savex--;
			savey--;
		}
		else if (dp[savex-1][savey] > dp[savex][savey-1]){
			savex--;
		}
		else{
			savey--;
		}
	}
	for (ll i = v.size() - 1; i >= 0; i--){
		cout << v[i];
	}
	cout << '\n';
}
  


Measured memory_bytes: 94208
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stack>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int>ii;
const int N=1000005;

int main()
{
   //freopen("test.in","r",stdin);
   ll a,b,n,c,d;
   cin>>n>>a>>b>>c>>d;
   for(int i=0;i<n;i++){
     ll smallest = -d*i + (n-i-1)*c;
     ll largest = -c*i + (n-i-1)*d;
     if(smallest<=b-a&&b-a<=largest){
        cout<<"YES";
        return 0;
     }
   }
   cout<<"NO";
   return 0;
}


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

n, m = map(int, input().split())
A = list(map(int, input().split()))
sm = sum(A)
cnt = 0
for a in A:
    if 4 * m * a >= sm:
        cnt += 1
can = "Yes" if cnt >= m else "No"
print(can)


Measured memory_bytes: 38384