akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := nextInt(), nextInt(), nextInt()
	x := nextInt()

	ans := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			k := (x - 500*i - 100*j) / 50
			if 0 <= k && k <= c {
				ans++
			}
		}
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
n = int(input())
a = []
for i in range(2):
    a.append([int(num) for num in input().split()])
#print(a)
result = 0
for i in range(0, n):
    point = sum(a[0][0:i+1]) + sum(a[1][i:])
#    print(a[0][0:i+1])
#    print(a[1][i:])
    if(result < point):
        result = point

print(result)


Measured memory_bytes: 3060
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
dp=[0]*(n+1)
ans=[0]*(n+1)
num=[0,2,5,5,4,5,6,3,7,6]
INF=10**18
for i in range(1,n+1):
  stack=[]
  chance=[]
  for j in a:
    if i-num[j]>=0:
      stack.append(dp[i-num[j]])
      chance.append([dp[i-num[j]],ans[i-num[j]]])
    else:
      stack.append(-INF)
      chance.append([-1,-1])
  dp[i]=max(stack)+1
  if dp[i]>0:
    for v in range(len(stack)):
      if stack[v]==max(stack):
        ans[i] += chance[v][1]+a[v]*10**(dp[i]-1)
        break
print(ans[n])

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

#define N 100

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int n, a, b, c, x;
    int y[ N ];

    scanf ( "%d%d%d%d%d", &n, &a, &b, &c, &x );
    if ( n == 0 && a == 0 && b == 0 && c == 0 && x == 0 ) break ;
    for ( i = 0; i < n; ++i )
      scanf ( "%d", &y[ i ] );

    j = 0;
    for ( i = 0; i <= 10000; ++i )
    {
      if ( x == y[ j ] )
      {
        ++j;
        if ( j >= n ) break ;
      }

      x = ( x * a + b ) % c;
    }

    printf ( "%d\n", ( i <= 10000 ? i : -1 ) );
  }


  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  int N = S.size();
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (S[i] != T[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3816
#include<stdio.h>

int main(void){
	int tax8,tax10,ans;
	scanf("%d",&tax8);
	scanf("%d",&tax10);
	
	ans=tax8*125/10;
	while(ans*0.1<tax10+1){
		if(ans*0.08>=tax8&&ans*0.08<tax8+1&&ans*0.1>=tax10&&ans*0.1<tax10+1){
			printf("%d",ans);
			return 0;
		}
		ans++;
	}
	printf("-1");
	return 0;
}

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


int mp[5005][5005],n,m;
vector<int> x,y;
// O(n * log n ) n=v.size()
vector<int> compress(vector<int> v){
  // v = {4,6,7,1,1,6}
  //   -> res={1,2,3,0,0,2}

  vector<int> copy=v;

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

  vector<int> res;
  for(int i=0;i<(int)copy.size();i++){
    int num=lower_bound( v.begin(),v.end(), copy[i] ) - v.begin();
    res.push_back( num );
  }
  return res;
}

int sum(int sx,int sy,int gx,int gy){
  sx--,sy--;
  if(gx<0||gy<0)return 0;
  int res=mp[gx][gy];
  
  if(sx>=0)  res-=mp[sx][gy];

  if(sy>=0) res-=mp[gx][sy];

  if(sx>=0&&sy>=0) res+=mp[sx][sy];

  return res;
}

int main(){
  cin>>n>>m;
  x.resize(n),y.resize(n);
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  vector<int> X,Y;
  X=compress(x),Y=compress(y);
  for(int i=0;i<n;i++)mp[X[i]][Y[i]]++;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)mp[i][j+1]+=mp[i][j];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)mp[j+1][i]+=mp[j][i];
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  x.erase( unique( x.begin(), x.end()) , x.end() );
  y.erase( unique( y.begin(), y.end()) , y.end() );
  while(m--){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int sx=lower_bound(x.begin(),x.end(),a)-x.begin();
    int sy=lower_bound(y.begin(),y.end(),b)-y.begin();
    int gx=upper_bound(x.begin(),x.end(),c)-x.begin()-1;
    int gy=upper_bound(y.begin(),y.end(),d)-y.begin()-1;
    cout<<sum(sx,sy,gx,gy)<<endl;
  }
  return 0;
}

Measured memory_bytes: 101000
import numpy as np

h,w=map(int,input().split())

pic=np.zeros((w,h))

for i in range(h):
    line=input()
    for j in range(w):
        if line[j]=='*':
            pic[j][i]=1
        elif line[j]=='.':
            pic[j][i]=0

line=""
print()

for i in range(h):
    for j in range(w):
        if pic[j][i]==1:
            print('*',end="")
            line=line+'*'
        elif pic[j][i]==0:
            print('.',end="")
            line=line+'.'
    print()
    print(line)
    line=""

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

int main(){
  int n;

  while(true){
    cin >> n;
    if(n == 0) break;
    int* S = new int[n];
    double sum=0,var=0,m;

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

    m = sum/n;
    for(int i=0;i<n;i++){
      var += (S[i] - m) * (S[i] - m); 
    }
    delete[] S;
    cout << setprecision(12) << sqrt(var / n) << endl;
  }
}


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

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

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

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> cnt(10000010, 1);
  ll ans = 0;
  for (int i = 2; i <= N; i++) {
    for (int j = i; j < 10000010; j += i) {
      cnt[j]++;
    }
    ll add = i * cnt[i];
    ans += add;
  }
  ans++;
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, score=0;
  cin >> n;
  vecll s(n);
  forll(i, 0, n){
	cin >> s[i];
	score += s[i];
  }
  sort(s.begin(), s.end());
  if(score % 10 == 0){
	forll(i, 0, n){
	  if (s[i] % 10 != 0){
		score -= s[i];
		break;
	  }
	}
  }
  if (score % 10 == 0)
	cout << 0 << endl;
  else
	cout << score << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	long long x, a;

	scanf("%lld", &x);
	a = (x / 11) * 2;
	x -= (a / 2) * 11;
	if (x > 0)
		if (x <= 6)
			a++;
		else
			a += 2;
	printf("%lld\n", a);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int INF=1e9;

int R, C;
vector<vector<char>> maze;  // 迷路の内容を保存する配列
vector<vector<int>> dist;   // 距離を記録しておく配列
int sx, sy, gx, gy;  //sx,syはスタート、gx,gyはゴール、（1-index）

int main() {
    cin >> R >> C;
    sy=0;  
    sx=0;
    gy=R-1;
    gx=C-1;
    ll white=0;

    dist.assign(R, vector<int>(C, INF));   // 初期化
    maze.assign(R, vector<char>(C, '.'));  // 初期化

    rep(i,R) {
      rep(j,C){
        cin >> maze[i][j];
        if(maze[i][j]=='.')white++;
      }
    }

    queue<pair<int, int>> que;
    que.emplace(make_pair(sy, sx));  // sから探索する
    dist[sy][sx] = 0;
    while (que.size() != 0) {              // キューの要素がなくなったら終了
        pair<int, int> now = que.front();  // 現在の状態
        que.pop();

        if (now.first == gy && now.second == gx) {  // 目的地にたどり着いたので終了
            break;
        }

        int dy[4] = {0, 0, 1, -1};  // dx,dy は次の探索場所への距離を表す（４方向分）
        int dx[4] = {1, -1, 0, 0};
        for (int i = 0; i < 4; i++) {
            int ny = now.first + dy[i];                            // 次の探索場所の行番号
            int nx = now.second + dx[i];                           // 次の探索場所の列番号
            if (ny < 0 || R <= ny || nx < 0 || C <= nx) continue;  // 迷路の外に出るならスルー
            if (maze[ny][nx] == '#') continue;                     // 障害物があればスルー
            if (dist[ny][nx] != INF) continue;                     //探索済みならスルー
            que.push(make_pair(ny, nx));
            dist[ny][nx] =dist[now.first][now.second] + 1;
        }
    }

  if(dist[gy][gx]==INF){cout << -1 << endl;}else{cout << white-dist[gy][gx]-1 << endl;}

}

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


int main(){

  while(1){
    int n, x; cin >> n >> x;
    if(n==0)break;
    int ans=0;
    for(int i=1; i<=n; i++)
      for(int j=i+1; j<=n; j++)
	//	for(int k=j+1; k<=n; k++)
	//if(i+j+k==x) ans++;
	if(x-i-j > j && x-i-j <= n){
	  ans++;
	  //	  	  cout << i << j << x-i-j <<endl;;
	}
    cout << ans <<endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  string ans = "Three";
  
  for(int i=0;i<N;i++) {
    cin >> S[i];
    if(S[i] == "Y") {
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)    {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for((i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF  (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  while(1)
    {
      int i,j,k;
      double g[112][112]={};
      double dp[112][112]={};
      in(int,n,m);
      if(!n)break;
      rep(i,n)
	rep(j,n)
	  cin>>g[i][j];
      rep(i,n)
	dp[i][0]=1;
      for(j=1;j<m;j++)
	rep(i,n)
	  {
	    double max=0.0;
	    rep(k,n)
	      max=dp[k][j-1]*g[k][i]>max?dp[k][j-1]*g[k][i]:max;
	    dp[i][j]=max;
	  }
      double max=0.0;
      rep(i,n)
	max=dp[i][m-1]>max?dp[i][m-1]:max;
      printf("%.2f\n",max);
    }
  return 0;
}

Measured memory_bytes: 3324
N,Q=map(int,input().split())
S=input()
cnt=[0]*N
for i in range(1,N):
    cnt[i]+=cnt[i-1]
    if S[i-1:i+1]=="AC": cnt[i]+=1
for j in range(Q):
    l,r=map(int,input().split())
    print(cnt[r-1]-cnt[l-1])

Measured memory_bytes: 7700
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int X;

int main(){
  cin >> X;
  int ans = 1;
  for(int i = 2;i <= X;i++){
    ans = max(ans , (int)pow((int)pow(X,1.0 / i),i));
    int temp = (int)pow((int)pow(X,1.0 / i) + 1,i);
    if(temp <= X){
      ans = max(ans , temp);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int A = GetInt();
		int B = GetInt();
		int K = GetInt();

		for(int i = 0; i < K; i++)
		{
			if(i % 2 == 0)
			{
				if(A % 2 == 1)
					A--;

				B += A / 2;
				A /= 2;
			}
			else
			{
				if(B % 2 == 1)
					B--;

				A += B / 2;
				B /= 2;
			}
		}

		Console.WriteLine($"{A} {B}");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	int r=0,b=0;
	for(int i=0;i<a.size();i++){
		if(a[i]=='0'){
			r++;
		}
		else{
			b++;
		}
	}
	if(r<b){
		cout<<r*2<<endl;
	}
	else{
		cout<<b*2<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define vi vector<int>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

int n,a,b,p,p1,p2,p3;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> a >> b;
    fort (i,n)
    {
        cin >> p;
        if (p<=a) ++p1;
        else if (p<=b) ++p2;
        else ++p3;
    }
    cout << min(p1,min(p2,p3));
}


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

int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n, -1), b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    
    for (int i = 0; i < n; i++) {
        for (int j = n - 1 - i; j >= 0; j--) {
            if (b[j] == j + 1) {
                a[n - 1 - i] = b[j];
                b.erase(b.begin() + j);
                break;
            }
        }
        if (a[n - 1 - i] == -1) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    for (int i = 0; i < n; i++) cout << a[i] << endl;
    
    
    
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lb(x) x&-x
#define il inline
#define ll long long
#define llu unsigned long long
#define mem(x) memset(x,0,sizeof(x))
#define mem3(x) memset(x,0x3f,sizeof(x))
#define ccA() puts("耐心冷静查代码")
#define cc() puts("谁知盘中餐，粒粒皆辛苦")
#define fo(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
#define fk(i,j) for(register int i=fir[j];i;i=nxt[i])
using namespace std;
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
    return x*f;
}
inline void write(ll a){
    if(a==0){putchar('0');return;}
    if(a<0)putchar('-'),a=-a;
    char c1[120];
    ll h=0;
    while(a)c1[++h]=a%10+'0',a/=10;
    fd(i,h,1)putchar(c1[i]);return;
}
inline void write_(ll a){write(a);putchar(' ');}
inline void writeln(ll a){write(a);putchar('\n');}
//------------------------------------------------------
const int N=100;
char a[N];
int len,ans;
int main(){
	scanf("%s",a+1);
	len=strlen(a+1);
	fo(i,1,len){
		if(a[i]=='x')ans++;
	}
	if(ans<=7)puts("YES");
	else puts("NO");
    return 0;
}


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

#define mp make_pair
#define pb push_back 
#define pf push_front 
#define pbp pop_back
#define pfp pop_front 
#define sz(x) x.size()
#define all(x) x.begin(),x.end() 
#define ios_base ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define open(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define F first
#define S second

using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;

const int mod = 1e9+7;
const int N = 3*1e3+123;
const int inf = 1e9+123;
const long long INF = 1e18;
const double eps = 1e-5;

int a, b;

int main (){
 ios_base
 cin >> a >> b;
 if(a <= 0 && 0 <= b) return cout << "Zero", 0;
 if(1 <= a && 1 <= b) return cout << "Positive", 0;
 if(a <= -1 && b <= -1){ 
  if((b-a+1) % 2 == 1) cout << "Negative", 0;
  else cout << "Positive", 0;
 }
 return  0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		int d = 0;
		int r = 0;
		double f = 0;
		d = (int)(a / b);
		r = (int)(a % b);
		f = a / b;
		f = 1.0 * a / b;


		System.out.printf("%d %d %.5f",d, r, f);


	}
}

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

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;




void main() {
    long a, b, c;
    scan(a, b, c);
    auto ans = b;
    if (a + b >= c) {
        ans += c;
    }
    else {
        long t = a + b + 1;
        ans += t;
    }
    writeln(ans);
}






void scan(T...)(ref T args) {
    auto line = readln.split;
    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);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main(void){
    
    int n;
    scanf("%d",&n);
    int h[n];
    for(int i=0;i<n;i++)scanf("%d",&h[i]);
    //double ans=0.0f;
    double dp[500];
    for(int i=0;i<500;i++)dp[i]=0.0f;
    for(int i=1;i<500;i++){
        if(i>h[0])dp[i]=(double)(((double)(i-h[0])*(i-h[0])+(double)(h[0]-1)*(h[0]-1))/((i-1)*2.0f));
        else dp[i]=(double)(((double)(h[0]-1)+(h[0]-i))/2.0f);
    }
            //for(int j=1;j<10;j++)printf("%.10f\n",dp[j]);

    for(int i=1;i<n;i++){
        double newdp[500];
        for(int j=0;j<500;j++)newdp[j]=1145141919.0f;
        for(int j=1;j<500;j++){
            for(int k=1;k<500;k++){
                if(k<h[i]&&j<h[i])newdp[j]=min(newdp[j],dp[k]+(double)(((double)(h[i]-k)+(double)(h[i]-j))/2.0f));
                else if(k>=h[i]&&j>=h[i])newdp[j]=min(newdp[j],dp[k]+(double)(((double)(k-h[i])+(double)(j-h[i]))/2.0f));
                else if(k<h[i]&&j>=h[i])newdp[j]=min(newdp[j],dp[k]+(double)(((double)(j-h[i])*(double)(j-h[i])+(double)(h[i]-k)*(double)(h[i]-k))/(double)((j-k)*2.0f)));
                else newdp[j]=min(newdp[j],dp[k]+(double)(((double)(j-h[i])*(double)(j-h[i])+(double)(h[i]-k)*(double)(h[i]-k))/(double)((k-j)*2.0f)));
            }
        }
        for(int j=0;j<500;j++)dp[j]=newdp[j];
        //for(int j=1;j<10;j++)printf("%.10f\n",dp[j]);
    }
    double ans=1145141919.0f;
    for(int i=1;i<500;i++)ans=min(ans,dp[i]);
    printf("%.10f",ans);
    return 0;
}



Measured memory_bytes: 3212
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

aa,bb=[0],[0]
for i in range(n):
  aa.append(aa[i]+a[i])
for i in range(m):
  bb.append(bb[i]+b[i])
ans,j=0,m
for i in range(n+1):
  if aa[i]>k:
    break
  while bb[j] > k-aa[i]:
    j -= 1
  ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 47600
#include <stdio.h>

#define MAX 30
#define NIL -1

struct Node {
	int parent;
	int left;
	int right;
	int sibling;
	int degree;
	int depth;
	int height;
};

void setDepth(struct Node *tree, int cur, int depth) {
	if (cur == NIL) return;
	tree[cur].depth = depth;
	setDepth(tree, tree[cur].left, depth + 1);
	setDepth(tree, tree[cur].right, depth + 1);
}

int setHeight(struct Node *tree, int cur) {
	int heightL, heightR;
	if (cur == NIL) return 0;
	heightL = setHeight(tree, tree[cur].left);
	heightR = setHeight(tree, tree[cur].right);
	tree[cur].height = heightL > heightR ? heightL : heightR;
	return tree[cur].height + 1;
}

int getStatus(struct Node *p) {
	if (p->parent == NIL) return 0;
	if (p->left == NIL && p->right == NIL) return 1;
	return 2;
}

void print(struct Node *tree, int cur) {
	char strtype[3][14] = { "root","leaf","internal node" };

	printf("node %d: ", cur);
	printf("parent = %d, ", tree[cur].parent);
	printf("sibling = %d, ", tree[cur].sibling);
	printf("degree = %d, ", tree[cur].degree);
	printf("depth = %d, ", tree[cur].depth);
	printf("height = %d, ", tree[cur].height);
	printf("%s\n", strtype[getStatus(&tree[cur])]);

}
int main() {
	int i, n, id, left, right, root;
	struct Node tree[MAX];

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		tree[i].parent = tree[i].left = tree[i].right = tree[i].sibling = NIL;
		tree[i].degree = 0;
	}

	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &id, &left, &right);
		if (left != NIL) {
			tree[left].parent = id;
			tree[left].sibling = right;
			tree[id].left = left;
			tree[id].degree++;
		}
		if (right != NIL) {
			tree[right].parent = id;
			tree[right].sibling = left;
			tree[id].right = right;
			tree[id].degree++;
		}
	}

	root = NIL;
	for (i = 0; i < n; i++) {
		if (tree[i].parent == NIL) {
			root = i;
			break;
		}
	}

	setDepth(tree, root, 0);
	setHeight(tree, root);

	for (i = 0; i < n; i++) {
		print(tree, i);
	}

	return 0;
}


Measured memory_bytes: 2100
a, b, c, x, y = map(int, input().split())

ans = 0
if a + b > c * 2:
    d = min(x, y)
    ans += c * d * 2
    x -= d
    y -= d

if x > 0:
    if a > c * 2:
        ans += x * c * 2
    else:
        ans += x * a

if y > 0:
    if b > c * 2:
        ans += y * c * 2
    else:
        ans += y * b

print(ans)


Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
#define yes        cout<<"Yes"<<"\n"
#define no         cout<<"No"<<"\n"
#define modsum(a,b)  ((a%mod)+(b%mod))%mod
#define modpro(a,b)  ((a%mod)*(b%mod))%mod
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=((result%M) * (x%M))%M;
        x=((x%M)*(x%M))%M;
        n=n/2;
    }
    return result;
}
ll binaryExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
ll pow1(ll x,ll y)
{
    ll z=1;
    while(y--){z=z*x;}
    return z;
}
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 ll n;cin>>n;
 if(n==1) cout<<0;
 else
     {
         ll z=1e9+7;
         ll val1=modularExponentiation(10,n,z);
         ll val2=modularExponentiation(9,n,z);
         val2=(2*val2)%z;
         ll val4=modularExponentiation(8,n,z);
         val1=modsum(val1,val4);
         ll val3=((val1%z)-(val2%z)+z)%z;
         cout<<val3;
     }
}


  


Measured memory_bytes: 3652
#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 = 1000000007;
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; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

vector<bool> eratos(int n) {
	vector<bool> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++) {
		if (!is_prime[i])continue;
		for (int j = i * i; j <= n; j += i)
			is_prime[j] = false;
	}
	return is_prime;
}

// n以下の素数
// O(n log log n)
vector<int> getPrimes(int n) {
	vector<bool> is_prime = eratos(n);
	vector<int> primes;
	for (int i = 0; i <= n; i++)
		if (is_prime[i])
			primes.push_back(i);
	return primes;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X; cin >> X;
	auto p = getPrimes(101000);
	int ans = *lower_bound(all(p), X);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt() - 1;
        int b = sc.nextInt() - 1;
        int c = sc.nextInt() - 1;
        int d = sc.nextInt() - 1;
        String s = sc.next();

        boolean b1 = !s.substring(a, c).contains("##");
        boolean b2 = !s.substring(b, d).contains("##");

        boolean res = false;
        res = b1 && b2;
        if(c > d) {
            res &= s.substring(b-1, d+2).contains("...");
        }
        System.out.println(res ? "Yes" : "No");
    }
}


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

using namespace std;

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

  int n, k, a;
  cin >> n >> k;
  map<int, int> hash;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    hash[a]++;
  }
  vector<pair<int, int>> sorted(hash.begin(), hash.end());
  sort(sorted.begin(), sorted.end(), 
      [&](pair<int,int> x, pair<int, int> y) {return x.second < y.second;});

  int sum = hash.size();
  int res = 0;
  if (sum > k) {
    for (auto &s: sorted) {
      --sum;
      res += s.second;
      if (sum <= k) break;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 11264
/*
                    NAYEEM
    Information and Communication Engineering ,
            University of Rajshahi
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define uu first
#define vv second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)

#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x,y) insert({x,y})
#define sv(a) sort(a.begin(),a.end())
#define zero(arr,a) memset(arr,a,sizeof arr)
#define mx 1005
#define TestCase int t,cs=1;sci(t);while(t--)

//ll modPower(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
//ll power(ll a,ll b){if(b==0)return 1;ll x=power(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}

int fx[]={0,1,1,1,0,-1,-1,-1};
int fy[]={1,1,0,-1,-1,-1,0,1};



int main()
{
    //IOS
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    /*
        Check Contains Limit && Declear Counter in Long Long
        Check Array Size
    */
    ll n,m,i,j,k,cnt=0;
    cin>>n>>m;
    ll ara[n];
    ll sum=0;

    for(i=0;i<n;i++){
        cin>>ara[i];
        sum+=ara[i];
    }
    k = (int)ceil(sum/(4.0*m));
    for(i=0;i<n;i++){
        if(ara[i]>=k)cnt++;
    }
    if(cnt>=m)cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }

    return 0;
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

struct City {
  City(int p_val, int y_val) : p(p_val), y(y_val) {}
  int p;
  int y;
  int identify;
};

signed main() {
  int n, m;
  cin >> n >> m;
  vector<shared_ptr<City>> cities, clone;
  REP(i, m) {
    int p = read(), y = read();
    cities.PB(make_shared<City>(p, y));
  }
  clone = cities;
  sort(ALL(clone), [](const shared_ptr<City> &a, const shared_ptr<City> &b) {
    if (a->p == b->p)
      return a->y < b->y;
    else
      return a->p < b->p;
  });
  clone[0]->identify = clone[0]->p * 1e6 + 1;
  FOR(i, 1, m) {
    clone[i]->identify = clone[i]->p * 1e6;
    if (clone[i]->p == clone[i - 1]->p)
      clone[i]->identify = clone[i - 1]->identify + 1;
    else
      clone[i]->identify += 1;
  }
  REP(i, m) { printf("%012lld\n", cities[i]->identify); }
}


Measured memory_bytes: 9328
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 3010;
const int MAXM = 600010;
const int MAXK = 110;
const int MAXQ = 200010;

int dp[MAXN][MAXN][2], n, t;
II a[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> t;
    FOR(i,1,n) cin >> a[i].FI >> a[i].SE;

    dp[0][0][0] = dp[0][0][1] = 0;
    FOR(i,1,t-1) dp[0][i][0] = dp[0][i][1] = -1000000000;

    FOR(i,1,n)
        FOR(j,0,t-1) {
            FOR(k,0,1) {
                dp[i][j][k] = dp[i-1][j][k];
                if (j - a[i].FI >= 0) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-a[i].FI][k] + a[i].SE);

                if (k) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][1-k] + a[i].SE);
            }
        }

    int res = 0;
    FOR(j,0,t-1) res = max(res, dp[n][j][1]);
    cout << res;
    return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H,W,N;
	cin >> N;
	H = 2;
	W = N;
	vector<vector<int>> A(H,vector<int>(W));
	vector<int> a(N),b(N);
	rep(i,H)rep(j,W)cin >> A[i][j];
	a[0] = A[0][0];
	b[0] = A[1][0];
	for(int i=1;i<N;i++){
		a[i] = a[i-1] + A[0][i];
		b[i] = b[i-1] + A[1][i];
	}
	int ans = 0;
	for(int i=0;i<N;i++){
		//i番目で下に降りた場合の合計数
		int t = 0;
		t += a[i];
		t += b[N-1] - ((i-1>=0)?b[i-1]:0);
		ans = max(ans,t);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product#accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque
def run():
    S = input()
    N = len(S)
    if S[:(N-1)//2] == S[:(N-1)//2][::-1] and S == S[::-1] and S[(N+3)//2-1:] == S[(N+3)//2-1:][::-1]:
        print('Yes')
    else:
        print('No')
if __name__ == "__main__":
    run()


Measured memory_bytes: 3060
s = input()
k = s[0]
if(s[0]=='1'):
    for i in range(1,len(s)):
        if(i%2==1):
            k+='0'
        else:
            k+='1'
else:
    for i in range(1,len(s)):
        if(i%2==1):
            k+='1'
        else:
            k+='0'
u = 0
for i in range(len(k)):
    if(s[i]!=k[i]):
        u+=1
print(u)


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

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

    int base=0, endA=0,startB=0, startBendA=0;
    REP(i,n){
        string s;
        cin >> s;
        int n=s.size();
        bool A=false, B=false;
        for(int i=0; i<=n-1;i++){
            if(i==0 && s[i]=='B') B=true;
            if(i<=n-2 && s.substr(i,2)=="AB") base++;
            if(i==n-1 && s[i]=='A') A=true;
        }
        if(A&&B) startBendA++;
        else if(A) endA++;
        else if(B) startB++;
    };
    // cout << startBendA << ":" << endA << ":"<< startB << endl;
    int ans = base;
    bool exist = false;
    if(startBendA>=1) {ans+=startBendA-1; exist=true;};
    // cout <<"1" << ans << endl;
    if(exist &&endA>=1) {ans++;endA--;}
    // cout << ans << endl;
    if(exist && startB>=1) {ans++;startB--;}
    ans+=min(startB,endA);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double g = 9.8;
const int MAXN = 55;
double L[MAXN],R[MAXN],B[MAXN],T[MAXN];
double N,V,X,Y;
// 计算以Vy的速度竖直向上射出t秒后的位置
double calc(double vy, double t)
{
    return vy * t - g * t * t / 2;
}
// a相对于l和r的位置
int cmp(double l, double r, double a)// 注意判断大小的时候的误差处理
{
    if(a < l + eps) return -1;//if(a <= l)
    if(a > r - eps) return 1;//if(a >= r)
    return 0;
}
// 判断当射出路径经过点（qx,qy）时，卵是否能击中猪
//设初速度在x方向和y方向的分量为vx和vy，设通过（qx，qy）的时间为t
//求解联立方程式vx^2 + vy^2 = V^2 , vx * t = qx, vy * t - g * t^2 * 1/2 = qy
bool check(double qx, double qy)
{
    double a = g * g / 4, b = g * qy - V * V, c = qx * qx + qy * qy;
    double D = b * b - 4 * a * c;
    if(D < 0 && D > -eps) D = 0; //误差处理
    if(D < 0) return false;
    for(int d=-1;d<=1;d+=2)
    {
        double t2 = (-b + d * sqrt(D)) / (2 * a);//解出来的是t^2
        if(t2 <= 0) continue;
        double t = sqrt(t2);
        double vx = qx / t,vy = (qy + g * t * t / 2) / t;
        //判断是否通过猪的正上方
        double yt = calc(vy, X / vx);
        if(yt < Y - eps) continue; //yt < Y
        bool flag = 1;
        for(int i=0;i<N;i++)
        {
            if(L[i] >= X) continue;
            //判断在猪正上方的鸟和猪之间是否有障碍物
            if(R[i] == X && Y <= T[i] && B[i] <= yt)// 由于预处理，这里已经保证了L[i] <= X <= R[i]
            flag = false;
            //判断在飞到猪正上方之前是否会撞到障碍物
            int yl = cmp(B[i], T[i], calc(vy, L[i] / vx));//在障碍物左边缘时的相对位置
            int yr = cmp(B[i], T[i], calc(vy, R[i] / vx));//在障碍物右边缘时的相对位置
            int xh = cmp(L[i], R[i], vx * vy / g);//最高点的相对位置
            int yh = cmp(B[i], T[i], calc(vy, vy / g));
            if(xh == 0 && yh >= 0 && yl < 0) flag = false;
            if(yl * yr <= 0) flag = false;
        }
        if(flag) return 1;
    }
    return 0;
}
int main()
{
    cin >> N >> V >> X >> Y;
    for(int i=0;i<N;i++)
    cin >> L[i] >> B[i] >> R[i] >> T[i], R[i] = min(R[i], X);//预处理，截掉猪以右的障碍物
    bool flag = check(X, Y);//直接撞上猪的情况
    for(int i=0;i<N;i++)
    {
        flag |= check(L[i], T[i]);//经过障碍物左上角的情况
        flag |= check(R[i], T[i]);//经过障碍物右上角的情况
    }
    puts(flag ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h> //全ての標準ライブラリ
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
int main(void){
    int A, B, five, four, two, one, cnt = 0, temp ;
    cin >> A >> B;
    for(int i = A; i <= B; i++){
        one = i % 10;
        temp = i /10;
        two = temp % 10;
        temp /= 100;
        four = temp % 10;
        temp /= 10;
        five = temp% 10;
        
        if(one == five && two == four) cnt++; 
    }
    cout << cnt;
    
    
}


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

int main(void){
  int n; cin >> n;
  int a[n];
  int sum = 0;
  rep(i,n){
    cin >> a[i];
    if(i % 2 == 0){
      sum += a[i];
    }
    else sum -= a[i];
  }
  int x[n];
  x[0] = sum;
  for(int i = 1; i < n; i++){
    x[i] = (a[i-1] - x[i-1]/2)*2;
  }
  rep(i,n) cout << x[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 2048
import heapq

N, M = map(int, input().split())

H = list(map(lambda x: -1 * int(x), input().split()))
heapq.heapify(H)
for m in range(M):
    a = heapq.heappop(H)
    heapq.heappush(H, -1 * (-a // 2))
print(-1 * sum(H))


Measured memory_bytes: 14184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef priority_queue<double, vector<double>, less<double> > QUE_double;
typedef priority_queue<int, vector<int>, less<int> > QUE_int;//lessは大きい順にならべるよ
const int MAX = pow(10, 5)+1;//+1しないとREになる(out of rangeになるんかな?? )



int main(){
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  //cin >> N >> K >> P >> R >> S;//点数を相手の手で表せるように取得する
  string T;
  cin >> T;
  
  int ans = 0;
  vector<bool> is_skip(K, false);
  for(int i=0; i<K; i++){
    if(T[i] == 'r') ans += P;
    else if(T[i] == 's') ans += R;
    else if(T[i] == 'p') ans += S;
  }
  
  
  for(int i=K; i<N; i++){
    
    //cout <<"T[i]  : "<< T[i] << " i : " << i << "  ans : " << ans << " is_skip[i%K]: " << is_skip[i%K] ;
    if(T[i] == T[i-K] && is_skip[i%K] == false){
      is_skip[i%K] = true;//K回後のじゃんけんのときに　前回勝てない手を出したことを伝えるためのもの
      //cout << endl;
      continue;
    }
    if(is_skip[i%K] == true){
      is_skip[i%K] = false;
    }
    
    
    if(T[i] == 'r') ans += P;
    else if(T[i] == 's') ans += R;
    else if(T[i] == 'p') ans += S;
    //cout << "  add: " << ans << endl;
  }
  
  cout << ans << endl;
  

}



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

// DP テーブル (配列全体が false に自然に初期化される)
bool dp[110000]; // 局面数は最大 100001 だが少し余裕もたせる

int main() {
    // 入力受け取り
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    
    // DP
    for (int i = 1; i <= K; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
        }
    }
    
    // 答え
    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


pll A[MAXN+5];
ll dp[2][6005];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	
	sc2(n,m);
	f1(i,n)sc2(A[i].fi,A[i].se);
	soA;
	f1(i,n){		
		fu(j,1,m+A[i].fi-1){
			dp[(i&1)][j]=dp[(i&1)^1][j];
			if(j-A[i].fi>=0)mxz(dp[(i&1)][j],dp[(i&1)^1][j-A[i].fi]+A[i].se),mxz(ans,dp[(i&1)][j]);
		}
	}
	pr(ans);
	
	
	
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll L, R;
    cin >> L >> R;

    ll mod = 2019;
    ll ans = mod;
    if (R-L+1 >= mod) {
        ans = 0;
    } else {
        ll l = L%mod;
        ll r = R%mod;
        for (int i = l; i < r; i++) {
            for (int j = i+1; j <= r; j++) {
                ans = min(ans, i*j%mod);
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = input()

honL = [2, 4, 5, 7, 9]
ponL = [0, 1, 6, 8]
bonL = 3

if int(N[-1:]) in honL:
  print("hon") 
elif int(N[-1:]) in ponL:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9180
x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
x=input()
x0=x.split()
a=[int(n) for n in x0]
for i in range(n-k):
    if a[i]<a[k+i]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 105620
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=2;i<n;++i)
    {
        if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C'){++ans;}
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
flag = True
for i in A:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            pass
        else:
            flag = False
            break

if flag == True:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060