akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> T(N);
    int time = 0;
    rep(i,N){
        cin >> T[i];
        time += T[i];
    }
    int M;
    cin >> M;
    vector<pair<int,int> > vec(M);
    rep(i,M){
        cin >> vec[i].first;
        vec[i].first--;
        cin >> vec[i].second;
    }
    rep(i,M){
        cout << time - T[vec[i].first] + vec[i].second << endl;
    }
}


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

void daruma(pair<int, vector<int>> dataset)
{
  int n;
  vector<int> w;
  tie(n, w) = dataset;
  vector<vector<int>> dp(n, vector<int>(n, 0));
  for (int W = 2; W <= n; W++)
  {
    for (int l = 0; l < n; l++)
    {
      int r = l + W - 1;
      if (r >= n)
        continue;

      if (dp[l + 1][r - 1] == W - 2 && abs(w[l] - w[r]) <= 1) {
        dp[l][r] = W;
      } else {
        for (int mid = l; mid < r; mid++)
        {
          dp[l][r] = max(dp[l][r], dp[l][mid] + dp[mid + 1][r]);
        }
      }
    }
  }
  cout << dp[0][n - 1] << endl;
}

int main()
{
  vector<pair<int, vector<int>>> dataset;
  while (1)
  {
    int n;
    cin >> n;
    if (n < 1)
      break;
    vector<int> w(n);
    for (int i = 0; i < n; ++i)
    {
      cin >> w[i];
    }
    dataset.push_back(make_pair(n, w));
  }
  for (int i = 0; i < dataset.size(); ++i)
  {
    daruma(dataset.at(i));
  }
}



Measured memory_bytes: 3340
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    if(M % N == 0) {
        cout << M / N << endl;
        return 0;
    }

    int ans = 1;
    for(int i = 2; i * i <= M; ++i) {
        if(M % i == 0) {
            if(M / i >= N) {
                ans = max(ans, i);
            }
            if(i >= N) {
                ans = max(ans, M / i);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
ansl = 1
ansr = n
m.times do
  l, r = gets.split.map(&:to_i)
  ansl = l if ansl < l
  ansr = r if ansr > r
end

if ansr >= ansl
  puts ansr - ansl + 1
else
  puts 0
end

Measured memory_bytes: 1788
#include<iostream>
#include<map>
#include<queue>
#include<vector>
using namespace std;
#define fr first
#define sc second
typedef pair<int,int>Pi;
struct edge{
  int to,element/*時間もしくは金額*/;
};
typedef vector< vector< edge > > Graph;

int dijkstr(Graph& info, int s, int g){
  vector<int> min_cost;
  priority_queue<Pi, vector<Pi>, greater<Pi> >que;
  min_cost.resize(info.size(),-1);
  que.push( Pi(0,s) ); //firstが時間(金額) , secondが場所
  min_cost[s]=0;
  while(!que.empty()){
    Pi p = que.top();
    que.pop();
    if(p.sc == g) return p.fr; //ゴールに着いたら
    if(p.fr > min_cost[p.sc]) continue; //現在地が前にきたときの最小より大きかった場合continue
    for(int i=0;i<info[p.sc].size();i++){ //現在地からの道の数だけ回る
      edge& e = info[p.sc][i];
      if(min_cost[e.to] == -1 || p.fr + e.element < min_cost[e.to]){ //次の場所はまだコストを調べていない || 次の場所の最小値よりも移動後のコストが小さい場合。
	min_cost[e.to] = p.fr + e.element;
	que.push( Pi(min_cost[e.to] , e.to));
      }
    }
  }
  return min_cost[g];
}

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n==0 && m==0) break;
    Graph info[2];
    info[0].resize(n);
    info[1].resize(n);
    
    int a,b,COST,TIME;
    for(int i=0;i<n;i++){
      cin >> a >> b >> COST >> TIME;
      info[0][a].push_back( (edge){b, COST} );
      info[0][b].push_back( (edge){a, COST} );
      info[1][a].push_back( (edge){b, TIME} );
      info[1][b].push_back( (edge){a, TIME} );
    }
    
    int k,p,q,r;
    cin >> k;
    for(int i=0;i<k;i++){
     cin >> p >> q >> r;
     cout << dijkstr(info[r],p,q) << endl;
    }
  }
}

Measured memory_bytes: 1484
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
int n;
  cin>>n;
  if(n==7||n==5||n==3) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}










Measured memory_bytes: 3584
l = list(map(str, input().split()))
m = []
for i in range(len(l)):
    m.append(l[i])
    x = l[i]
    if x == "+":
        m.pop()
        tmp = int(m.pop()) + int(m.pop())
        m.append(tmp)
    if x == "-":
        m.pop()
        tmp = -int(m.pop()) + int(m.pop())
        m.append(tmp)
    if x == "*":
        m.pop()
        tmp = int(m.pop()) * int(m.pop())
        m.append(tmp)
    #print(m)
print(int(m.pop()))


Measured memory_bytes: 5600
import java.util.*;
// im sorry
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int H = in.nextInt();
		int W = in.nextInt();
		int D = in.nextInt();
		Point[] ary = new Point[H*W+1];
		int[] save = new int[H*W+1];
		for( int i = 0; i < H; i++ ) {
			for( int j = 0; j < W; j++ ) {
				int ind = in.nextInt();
				ary[ind] = new Point(i+1, j+1);
			}
		}

		for( int i = 1; i <= H*W-D; i++ ) {
			save[i] = getPoints(ary[i].x,ary[i].y,ary[i+D].x,ary[i+D].y);
			if( i-D > 0 ) save[i] += save[i-D];
		//	System.out.println(Arrays.toString(save));
		}
		int Q = in.nextInt();
		while(Q-->0){
			int total = 0;
			int L = in.nextInt();
			int R = in.nextInt();
			if( L == R ) {
				System.out.println(0); continue;
			}
			if(L-D > 0)
				System.out.println(save[R-D]-save[L-D]);
			else
				System.out.println(save[R-D]);
		}
	}

	public static int getPoints( int i, int j, int x, int y ) {
		return Math.abs(x-i)+Math.abs(y-j);
	}

	public static class Point {
		int x, y;
		public Point( int x, int y ) {
			this.x = x;
			this.y = y;
		}
	}
}

Measured memory_bytes: 121012
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	int cntA = 0, cntB = 0, cntC = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'a')cntA++;
		else if (s[i] == 'b')cntB++;
		else if (s[i] == 'c')cntC++;
	}
	if(cntA == 1 && cntB == 1 && cntC == 1)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define endl '\n'
using namespace std;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max(a*c,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
    return 0;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N; cin >> N;
  ll ans = 0;
  ll tmp1 = N / 500;
  N -= 500 * tmp1;
  ans += tmp1 * 1000;

  ll tmp2 = N / 5;
  ans += tmp2 * 5;

  cout << ans << endl;
}


Measured memory_bytes: 3608
def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    w = (100*A)*a + (100*B)*b
                    s = C*c + D*d
                    if w ==0:
                        break
                    if w+s > F:
                        break
                    else:
                        if w/100 * E >= s:
                            density = 100*s/(w+s)
                            memo[a,b,c,d] = density
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
            break
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 39648
N, K = map(int, input().split())
num = 0
if K == 0:
    print(N * N)
else:
    for b in range(1, N + 1):
        p, r = N // b, N % b
        num += p * max(0, b - K)
        num += max(0, r - K + 1)

    print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  for (int i=0;i<N;i++){
    cin >> T[i];
  }
  int M;
  cin >> M;
  vector<vector<int>> PX(M,vector<int>(2));
  for (int i=0;i<M;i++){
    cin >> PX.at(i).at(0) >> PX.at(i).at(1);
  }
  for (int i=0;i<M;i++){
    int time=0;
    for (int j=0;j<N;j++){
      if (j!=PX.at(i).at(0)-1){
        time+=T[j];
      }
      else {
        time+=PX.at(i).at(1);
      }
    }
    cout << time << endl;
  }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;
int32_t main() {
int n,m;
cin>>n>>m;
string a[n],b[m];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int i = 0; i < m; ++i) {
         cin>>b[i];
    }
    bool ok=true;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            ok=true;
            for (int k = 0; k < m; ++k) {
              if(!ok)break;
                for (int l = 0;  l < m; ++l) {
                    if(i+k>n-1||j+l>n-1||a[i+k][j+l]!=b[k][l]){ok=false;break;}
                }
            } if(ok)return cout<<"Yes"<<endl,0;
        }

    }
    cout<<"No"<<endl;
}

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

#define mod 1000000007

long long inv[1000010];
long long fac[1000010];
long long invfac[1000010];

long long x[1000010];

void getinv(){
  for (int i = 1; i < 1000010; i++) {
    if (i == 1) inv[i] = 1;
    else {
      inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
      if (inv[i] < 0) inv[i] += mod;
    }
  }
}

void getfac(){
  fac[0] = 1; invfac[0] = 1;
  for (int i = 1; i < 1000010; i++) {
    fac[i] = fac[i-1] * i; invfac[i] = invfac[i-1] * inv[i];
    fac[i] %= mod; invfac[i] %= mod;
    if (invfac[i] < 0 || fac[i] < 0) cout << "a" << endl;
  }
}

int main(){
  int n; cin >> n;
  getinv();
  getfac();
  int m = n - 1;
  long long s = 0;
  for (int i = 1; i <= m; i++) {
    if (i - 1 < m - i) x[i] = 0;
    else {
      x[i] = fac[i-1] * invfac[m-i];
      x[i] %= mod;
      x[i] *= invfac[2*i-m-1];
      x[i] %= mod;
      x[i] *= fac[i];
      x[i] %= mod;
      x[i] *= fac[m-i];
      x[i] %= mod;
    }
    x[i] += mod - s; x[i] %= mod;
    s += x[i]; s %= mod;
    //printf("%d\t%lld\n", i, x[i]);
  }
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    ans += (x[i] * i) % mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 31488
N = int(input())
counter = 0
ans = 0
for i in range(1,N+1):
    if i % 2 == 0:
        continue
    for j in range(1, i+1):
        if i % j == 0:
            counter += 1
    
    if counter == 8:
        ans += 1

    counter = 0


print(ans)



Measured memory_bytes: 2940
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
if N == 1:
    print(A.count(0))
    exit(0)

S = [0]*(N+1)
S[0] = A[0]
for k in range(1,N):
    S[k] = A[k]+S[k-1]
C = Counter(S)
ans = 0
for e in C:
    if C[e] >= 2:
        ans += (C[e]*(C[e]-1))//2
print(ans)


Measured memory_bytes: 112976
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main() {
    int k,x;
    cin>>k>>x;
    int start = max(-1000000, x - k + 1);
    int end = min(1000000, k + x - 1);
    while(start <= end)
    {
        cout<<start++<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
lr = [list(map(int,input().split())) for _ in range(m)]

l = 0
r = 10**10

for l1,r1 in lr:
    l = max(l, l1)
    r = min(r, r1)

print(max(0, r - l + 1))


Measured memory_bytes: 27328
// atcoder002

import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int input = scanner.nextInt();
		long ans = 1;
		for(int i = 1; i <= input; i++){
			ans *= i;
			ans %= 1000000007;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
using namespace std;
int n,k,m;
//f(n + 1,n) = f(n,n - 1) - [(n - 1) - (k - 1)% n] % n
void solve(){	
	int res = 0;
	for(int i = 2;i < n;i ++){
		res = (res - ((i - 1) - (k - 1) % i + i)%i + i)% i; 
		
	}
	res =  (res + m) % n + 1;
	printf("%d\n",res);
}

int main(){
	while(scanf("%d%d%d",&n,&k,&m) && !(n == 0 && m == 0 && k == 0)){
		solve();
		
	}
	
}

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

int main()
{

  int a[3];
  map<int,int> mp;
  rep(i,3){
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(a, a+3);
  cout << mp.size() << endl; 
  return 0;
}


Measured memory_bytes: 3580
package main

import (
	"fmt"
)

func main() {
	var n, sum int

	fmt.Scan(&n)

	d := make([]int, n)
	for i, _ := range d {
		fmt.Scan(&d[i])
	}

	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if i < j {
				sum += d[i] * d[j]
			}
		}
	}
	fmt.Println(sum)
}


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

int a,b;
int main() {
cin >> a >> b;
double f;
f = 1.0 * a / b;
cout << a/b << " " << a%b << " " <<
 fixed << setprecision(8)
 << f << endl;
return 0;
}

Measured memory_bytes: 1244
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder ans = new StringBuilder();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        long[] arr = new long[n];
        Arrays.fill(arr, k - q);
        for(int i = 0; i < q; i++) arr[Integer.parseInt(sc.next()) - 1]++;
        for(long a : arr) ans.append(a > 0 ? "Yes\n" : "No\n");
        System.out.println(ans);
    }
}


Measured memory_bytes: 49268
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    cin >> s;

    int ans = s.length();
    
    vector<int> num(s.length());
    int cnt = 0;
    for(int i = 0; i < s.length(); i++) {
        if (s[i] == 'S') {
            num[i] = 0;
            cnt++;
        }
        else num[i] = cnt;
    }

    cnt = 0;
    for(int i = 0; i < s.length(); i++) {
        if (s[i] == 'T') {
            if (num[i]-cnt >= 1) {
                ans -= 2;
                cnt++;
            }
        }
    }

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

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

#define pb push_back

#define prev I_love_Chtholly
#define sthFun 1e9

int N;
vector<int> e[100010];

vector<int> path;
int col[100010];

void get_path();
void save_path();
void get_col();
void paint_col(int,int);

int prev[100010];
queue<int> q;
void get_path()
{
	memset(prev,-1,sizeof(prev));
	queue<int> tmp;
	swap(q,tmp);
	
	q.push(1);
	prev[1]=sthFun;
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		if(u==N)
		{
			save_path();
			return;
		}
		for(int i=0;i<e[u].size();i++)
		{
			int& v=e[u][i];
			if(prev[v]==-1)
			{
				prev[v]=u;
				q.push(v);
			}
		}
	}
}
void save_path()
{
	int now=N;
	while(prev[now]!=sthFun)
	{
		path.pb(now);
		now=prev[now];
	}
	path.pb(1);
	reverse(path.begin(),path.end());
}

void get_col()
{
	memset(col,-1,sizeof(col));
	for(int i=0,j=path.size()-1;i<=j;i++,j--)
	{
		col[path[j]]=2;
		col[path[i]]=1;
	}
	for(int i=0;i<path.size();i++)
	{
		paint_col(path[i],col[path[i]]);
	}
}
void paint_col(int S,int c)
{
	queue<int> tmp;
	swap(q,tmp);
	
	q.push(S);
	while(!q.empty())
	{
		int u=q.front(); q.pop();
		for(int i=0;i<e[u].size();i++)
		{
			int& v=e[u][i];
			if(col[v]==-1)
			{
				col[v]=c;
				q.push(v);
			}
		}
	}
}

int main()
{
	scanf("%d",&N);
	for(int i=1,u,v;i<=N-1;i++)
	{
		scanf("%d%d",&u,&v);
		e[u].pb(v);
		e[v].pb(u);
	}
	
	get_path();
	get_col();
	
	int Fennec=0,Snuke=0;
	for(int i=1;i<=N;i++)
	{
		if(col[i]==1) Fennec++;
		else if(col[i]==2) Snuke++;
		else assert(0);
	}
	cout<<( (Fennec>Snuke)?"Fennec":"Snuke" )<<endl;
	return 0;
}

Measured memory_bytes: 7032
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <limits>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cassert>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
  int n, minv, maxv, r1, r2;
  cin >> n;
  cin >> r1;
  cin >> r2;
  
  minv = min(r1, r2);
  maxv = r2 - r1;
  
  for (int i = 2; i < n; ++i) {
    int v;
    cin >> v;
    
    maxv = max(maxv, v - minv);
    minv = min(minv, v);
  }
  
  cout << maxv << endl;
  
  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;



int main(){
  LLI N;
  while(cin >> N){
    LLI ans = N*(N+1)/2 - N;


    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if((a*c)<=b)
	{
		cout<<c<<endl;
	}
	else
	{
		cout<<b/a<<endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;  
  cout << fixed << setprecision(12) << w*h/2;

  if(x*2 == w & y*2 == h) 
    cout << " " << 1 << endl;
  else cout << " " << 0 << endl;
}


Measured memory_bytes: 3740
w, h, n = map(int, input().split())

min_x, min_y, max_x, max_y = 0, 0, w, h
for _ in range(n):
    x, y, a = map(int, input().split())

    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        max_x = min(max_x, x)
    elif a == 3:
        min_y = max(min_y, y)
    else:
        max_y = min(max_y, y)

if min_x < max_x and min_y < max_y:
    print((max_x - min_x) * (max_y - min_y))
else:
    print(0)

Measured memory_bytes: 62696
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

const int MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    vector<int> t(m);

    REP(i, n){
        cin >> s[i];
    }
    REP(i, m){
        cin >> t[i];
    }
    vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
    dp[0][0] = 1;

    vector<vector<ll>> accum(n+1, vector<ll>(m+1, 0));
    IFOR(i, 0, n){
        accum[i][0] = 1;
    }
    IFOR(j, 0, m){
        accum[0][j] = 1;
    }

    IFOR(i, 1, n){
        IFOR(j, 1, m){
            if(s[i-1] != t[j-1])
                dp[i][j] = 0;
            else {
                dp[i][j] = accum[i-1][j-1];
            }
            accum[i][j] = (MOD + accum[i-1][j] + accum[i][j-1] - accum[i-1][j-1] + dp[i][j]) % MOD;
        }
    }

    cout << accum[n][m] << endl;
    return 0;
}

Measured memory_bytes: 62976
#include<iostream>
using namespace std;
long n,y,i,j,k;
main()
{
	cin>>n>>y;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n-i;j++)
		{
			k=n-i-j;
			if(i*10000+j*5000+k*1000==y)
			{
				cout<<i<<" "<<j<<" "<<k<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,K;
int path[21][21];

int from[1<<19];
int to[1<<19];
ll mo=1000000007;

int add(int& a,int& b) {
	a+=b;
	if(a>=mo) a-=mo;
	return a;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	FOR(x,N) FOR(y,M+1) path[y][x]=3;
	N--;
	
	FOR(i,K) {
		cin>>x>>y>>j;
		path[x][y-1]=1<<j;
	}
	from[0]=1;
	
	for(int line=1;line<=M;line++) {
		for(int step=0;step<N;step++) {
			int sm=1<<step;
			ZERO(to);
			FOR(i,1<<N) if(from[i]) {
				if(path[line][step]&1) {
					if((i&sm)==0) add(to[i],from[i]);
				}
				if(path[line][step]&2) {
					if((i&sm)==0) {
						if(i<sm) add(to[i^sm],from[i]);
						else add(to[((i-sm)&i) | sm],from[i]);
					}
					else add(to[i],from[i]);
				}
			}
			swap(from,to);
		}
	}
	
	ll ret=0;
	FOR(i,1<<N) ret+=from[i];
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 4480
import math
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}



n, m = map(int, input().split())

a, b = [0] * m, [0] * m

for i in range(m):
    a[i],b[i] = map(int,input().split())

uni = UnionFind(n)

def C(n):
    return n*(n-1)//2

f =[C(n)]
com = C(n)
for i in range(m-1,-1,-1):

    na, nb = a[i]-1,b[i]-1
    if not uni.same(na,nb):
        n1 = uni.size(na)
        n2 = uni.size(nb)
        uni.union(na,nb)

        com -= n1*n2
    # print(n1, n2)

    f.append(com)

f.reverse()
print(*f[1:])


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int ans=0;
    int n;cin >>n;
    vector<int>a(n-1);
    for (int i = 0; i < n-1; ++i) {
        cin >>a[i];
    }
    ans+=a[0];
    ans+=a[n-2];
    for (int j = 0; j < n -2; ++j) {
        ans+=min(a[j],a[j+1]);
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Edge;
const ll INF=2e18;
const ll MOD=1e9+7;

class UnionFind {
  vector<ll> par, rank; // par > 0: number, par < 0: -par
public:
  void init(ll n) {
    par.resize(n, 1); rank.resize(n, 0);
  }
  ll getSize(ll x) {
    return par[find(x)];
  }
  ll find(ll x) {
    if (par[x] > 0) return x;
    return -(par[x] = -find(-par[x]));
  }
  void merge(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
      par[y] += par[x];
      par[x] = -y;
    } else {
      par[x] += par[y];
      par[y] = -x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool isSame(ll x, ll y) {
    return find(x) == find(y);
  }
};

ll V,E;
Edge e[100010];
int main(){
    cin>>V>>E;
    UnionFind UF;
    UF.init(V);
    for(ll i=0;i<E;i++){
        ll s,t,w;
        cin>>s>>t>>w;
        e[i]=Edge(w,P(s,t));
    }
    sort(e,e+E);
    ll ans=0;
    for(ll i=0;i<E;i++){
        ll s=e[i].second.first;
        ll t=e[i].second.second;
        if(!UF.isSame(s,t)){
            UF.merge(s,t);
            ans+=e[i].first;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    int c = 0;
    rep(i, n) {
        if (a[i] == 0) {
            ans += c / 2;
            c = 0;
        } else {
            if (a[i] % 2 > 0) {
                a[i]--; c++;
            }
            ans += a[i] / 2;
        }
    }
    ans += c / 2;

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define MAXN 200005
const lli INF = 1e18+10;
template<typename T>
class SegmentTree
{
	public:
		vector<T> ST,lazy;
		int n;
		T base_value;
		SegmentTree(int n,vector<T> & a){
			this->n = n;
			base_value = INF;//0: sum,gcd 1:multiplication INF:min -INF:max 
			int h = ceil(log2(n));
			ST.resize((1 << (h+1)),base_value);
			lazy.resize((1 << (h+1)),0);
			build(0,n-1,1,a);
		}
		T F(T a,T b){
			return min(a,b);
		}
		void build(int ini,int fin,int pos,vector<T> &a){
			if(ini == fin){
				ST[pos] = a[ini];	
				return;
			}
			int mitad = (ini+fin)/2;
			build(ini,mitad,pos*2,a);
			build(mitad+1,fin,pos*2+1,a);
			ST[pos] =  F(ST[pos*2],ST[pos*2+1]);
		}

		void propagate(int start, int end, int pos, T val){
			ST[pos]+=val;//Min,max
			if(start!=end){
				lazy[pos*2]+=val;
				lazy[pos*2+1]+=val;
			}
		}
		void UpdateLazy(int left,int right,int pos,int start,int end,T val){
			if(lazy[pos] != 0){
				propagate(start,end,pos,lazy[pos]);
				lazy[pos]=0;
			}
			if(end < left || right < start)
				return;
			if(start >= left && end <= right){
				propagate(start,end,pos,val);
				return;
			}
			int mitad = (start+end)/2;
			UpdateLazy(left,right,pos*2,start,mitad,val);
			UpdateLazy(left,right,pos*2+1,mitad+1,end,val);
			ST[pos] = F(ST[pos*2],ST[pos*2+1]);	
		}

		T Query(int start,int end,int pos,int left,int right){
			if(lazy[pos] != 0){
				propagate(start,end,pos,lazy[pos]);
				lazy[pos]=0;
			}
			if(end < left || right < start) 
				return base_value;//0 para suma, -INF para max e INF para min
			if(start >= left && end <= right)
				return ST[pos];

			int mitad = (start+end)/2;
			T izq = Query(start,mitad,pos*2,left,right);
			T der = Query(mitad+1,end,pos*2+1,left,right);
			return F(izq,der);
		}
};
vector<pii> fin[MAXN];

int main(){__
	int n,m;
	cin >> n >> m;
	lli tot =0ll;
	for(int i=0; i < m; i++){
		int l,r,a;
		cin >> l >> r >> a;
		tot+=a;
		fin[r].pb(pii(l,a));
	}

	vector<lli> a(n+2,INF);
	a[0] = 0ll;
	SegmentTree<lli> st(n+2,a);
	lli ans = 0ll;
	for(int i =1; i <=n+1; i++){
		for(auto e : fin[i-1]){
			st.UpdateLazy(0,e.fi-1,1,0,n+1,e.se);
		}
		lli mini = INF;
		mini = st.Query(0,n+1,1,0,n+1);
		if(i == n+1){
			ans = mini;
		}
		st.UpdateLazy(i,i,1,0,n+1,mini - INF);
	}
	cout << tot - ans << endl;
	return 0;
}


Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

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

int main(){
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1) cout << 1 << endl;
    else cout << (h * w+1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll powermod(ll a, ll b , ll m) {ll r=1; while(b) { if(b%2==1)r = (r*a)%m; b/=2;a = (a*a)%m;}return r;}
int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 1;
    vector<int> count(26);
        
    for(ll i=0;i<n;i++)
    {
      count[s[i]-'a']++;
    }
    for(ll i=0;i<26;i++)
    {
        ans = ans*(count[i]+1)%MOD;
    }
    cout << (ans-1)%MOD << endl;
    
}

Measured memory_bytes: 512
def main():
    A, B = map(int, input().split(' '))
    result = -1
    for i in range(1, 1001):
        if int(i * 0.1) == B:
            if int(i * 0.08) == A:
                result = i
                break
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, q, li, ri;
    int cnt = 0;
    string inputString;
    scanf("%d %d\n", &n, &q);
    cin >> inputString;
    int cntAC[n];
    int flag = 0;
    for (int i = 0; i < n; i++)
    {
        if (inputString[i] == 'A')
        {
            flag = 1;
        }
        if (inputString[i] == 'C' && flag == 1)
        {
            cnt += 1;
        }
        if (inputString[i] != 'A')
        {
            flag = 0;
        }
        cntAC[i] = cnt;
    }

    for (int i = 0; i < q; i++)
    {
        scanf("%d %d", &li, &ri);
        printf("%d\n", cntAC[ri - 1] - cntAC[li - 1]);
    }
}

Measured memory_bytes: 1408
import re

N = int(input())
s = [input() for _ in range(N)]

num_end_with_A = 0
num_start_with_B = 0
num_both = 0
num_inner_AB = 0

for ss in s:
    res = re.findall('AB', ss)
    if res:
        num_inner_AB += len(res)
    if ss[0] == 'B' and ss[-1] == 'A':
        num_both += 1
    elif ss[0] == 'B':
        num_start_with_B += 1
    elif ss[-1] == 'A':
        num_end_with_A += 1

if num_end_with_A == 0 and num_start_with_B == 0:
    print(num_inner_AB + max(num_both - 1, 0))
else:
    print(num_inner_AB + min(num_end_with_A, num_start_with_B) + num_both)


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

using namespace std;


#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); blockTime.second;debug("%s: %.5lf s\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()/1000.0), blockTime.second = false)

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

string StrCpy(string str, long long int start, long long int end){string temp = "";for(long long int i=start; i<=end; i++){temp += str[i];}return temp;}

#define ull unsigned long long int
#define ll long long int
#define gcd(a, b)  __gcd(a, b)
#define lcm(a, b)  ((a*b)/gcd(a, b))

ll row[200009];

int solve(){

    ll n;

    cin >> n;

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

    ll cnt  = 0;
    ll max = row[0];

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

        if(row[i] < max){
            cnt += max - row[i];
        }
        else max = row[i];

    }

    cout << cnt << endl;




    return 0;

}

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

    //freopen("english.txt","r",stdin);

    time__("programm time"){
        solve();
	}
    return 0;

}


Measured memory_bytes: 5272
n=int(input())
h=list(map(int,input().split()))
mcount=0
maxc=0
for i in range(n-1):
    if h[i+1]<=h[i]:
        mcount+=1
    else:
        maxc=max(mcount,maxc)
        mcount=0
maxc=max(mcount,maxc)
print(maxc)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

// G13E_6.cpp

template<int N> void mat_prod(LL a[N][N], LL b[N][N], LL c[N][N], LL MOD) { // a = b * c;
	LL d[N][N];
	inc(i, N) {
	inc(j, N) {
		d[i][j] = 0;
	}
	}
	
	inc(i, N) {
	inc(j, N) {
	inc(k, N) {
		(d[i][j] += b[i][k] * c[k][j]) %= MOD;
	}
	}
	}
	
	inc(i, N) {
	inc(j, N) {
		a[i][j] = d[i][j];
	}
	}
}

template<int N> void mat_exp(LL a[N][N], LL b[N][N], LL c, LL MOD) { // a = b ^ c;
	LL cc = c, d = 0;
	while(cc) { cc >>= 1; d++; }
	
	LL t[60][N][N];
	inc(i, N) {
	inc(j, N) {
		t[0][i][j] = b[i][j];
	}
	}
	inc(i, d - 1) {
		mat_prod<N>(t[i + 1], t[i], t[i], MOD);
	}
	
	inc(i, N) {
	inc(j, N) {
		a[i][j] = 0;
	}
	}
	inc(i, N) { a[i][i] = 1; }
	inc(i, d) {
		if((c >> i) % 2 == 1) {
			mat_prod<N>(a, a, t[i], MOD);
		}
	}
}

// ----

LL n, m, x[100002];
const LL MOD = 1000000007;

int main() {
	cin >> n >> m;
	inc1(i, m) { cin >> x[i]; }
	x[0] = 0;
	x[m + 1] = n + 1;
	
	LL a[3][3] = { { 2, 1, 1 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL b[3][3] = { { 1, 0, 0 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL c[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
	LL d[3][3];
	
	inc(i, m + 1) {
		if(i != 0) { mat_prod<3>(c, b, c, MOD); }
		mat_exp<3>(d, a, x[i + 1] - x[i] - 1, MOD);
		mat_prod<3>(c, d, c, MOD);
	}
	
	cout << c[2][0] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a[] = new int[3];
        for(int i=0;i<3;i++)a[i]=sc.nextInt();
        Arrays.sort(a);
        System.out.println(a[1]-a[0]+a[2]-a[1]);
    }
}


Measured memory_bytes: 21716
n, a, b, c, d = map(int, raw_input().split())
dd = b - a
n -= 1
if dd < 0:
  dd = -dd
#print(dd)

def get(n, c, d):
  l = -1
  r = n
  while l + 1 < r:
    mid = (l + r) / 2
    if mid * c - (n - mid) * d >= 0:
      r = mid
    else:
      l = mid
  return l if l >= 0 else 0

l = get(n, c, d)

ok = False
#print(l)
for i in range(l, n + 1):
  ll = i * c - (n - i) * d
  rr = i * d - (n - i) * c
  #print(ll, rr)
  if ll <= dd and rr >= dd:
    #print(i, ll, rr, dd)
    ok = True
  if ll > dd:
    break

if ok:
  print('YES')
else:
  print('NO')


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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using si = set<int>;
using sll = set<ll>;


ll dp[3005][3005];
ll a[3005];

ll solve(int l, int r, int turn){
	if (l > r) return 0;
	if (dp[l][r] != -1) return dp[l][r];
	if (turn % 2 == 0){
		return dp[l][r] = max(solve(l + 1, r, turn + 1) + a[l], solve(l, r - 1, turn + 1) + a[r]);
	}
	else{
		return dp[l][r] = min(solve(l + 1, r, turn + 1) - a[l], solve(l, r - 1, turn + 1) - a[r]);
	}
 }

void init(){
	for (int i = 0 ; i< 3005; i++){
		for (int j = 0; j < 3005; j++)
			dp[i][j] = -1;
	}
}

int main(){
	int n; cin >> n;
	for (int i = 0; i  < n; i++) cin >> a[i];
	init();
	ll ans = solve(0, n - 1, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 71040
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e6 + 3;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    string s;
    cin >> s;
    vector<vector<bool>> arrs;
    arrs.push_back({});
    for(int i = 0; i < s.size(); ){
        if(s[i] == 'A'){
            arrs.back().push_back(1);
            i++;
        }else if(s.substr(i, 2) == "BC"){
            arrs.back().push_back(0);
            i += 2;
        }else{
            arrs.push_back({});
            i++;
        }
    }
    lint ans = 0;
    for(auto x: arrs){
        lint this_ans = 0, sum = 0;
        for(bool i: x){
            if(i){
                sum++;
            }else{
                this_ans += sum;
            }
        }
        ans += this_ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12016
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A
#include <iostream>
#include <vector>

using namespace std;

bool dfs(vector<vector<int>> &A, vector<int> &M, vector<bool> &U, int v)
{
        U[v] = true;
        for (auto a: A[v]) {
                int b = M[a];
                if (b < 0 || (!U[b] && dfs(A, M, U, b))) {
                        M[v] = a;
                        M[a] = v;
                        return true;
                }
        }
        return false;
}

int main(int argc, char **argv)
{
        int X, Y, E;
        cin >> X >> Y >> E;
        int V = X + Y;
        vector<vector<int>> A(V);
        for (int i = 0; i < E; i++) {
                int x, y;
                cin >> x >> y;
                A[x].push_back(X+y);
                A[X+y].push_back(x);
        }
        vector<int> M(V, -1);
        int matched = 0;
        for (int v = 0; v < V; v++) {
                if (M[v] < 0) {
                        vector<bool> U(V);
                        if (dfs(A, M, U, v))
                                matched++;
                }
        }
        cout << matched << endl;
        return 0;
}

Measured memory_bytes: 3248
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int main(){int a,b,c;cin>>a>>b>>c;cout<<c<<' '<<a<<' '<<b<<endl;return 0;}

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

int n, m, l;

int main() {
    cin >> n >> m >> l;
    int a[n*m], b[m*l];
    long long c[n*l];
    for (int i=0; i<n*l; i++) c[i]=0;
    for (int i=0; i<n*m; i++) cin >> a[i];
    for (int i=0; i<m*l; i++) cin >> b[i];
    for (int i=0; i<n; i++) {
        for (int j=0; j<l; j++) {
            for (int k=0; k<m; k++) c[i*l+j]+=a[i*m+k]*b[k*l+j];
        }
    }
    for (int i=0; i<n; i++) {
        for (int j=0; j<l; j++) {
            cout << c[i*l+j];
            if (j==l-1) cout << endl;
            else cout << " ";
        }
    }
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main(){
    vector<int>x(5);
    rep(i,5)cin>>x[i];

    rep(i,5){
        if(x[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define M 1000000007
#define gb(co, k) ((co)>>(k)&1)

int main(){
   int n;
   cin>>n;
   vector<ll> a(n);
   rep(i, n) cin>>a[i];

   vector<vector<int>> sb(n);
   rep(i, n) sb[i]=vector<int>(60);

   rep(i, n){
      rep(j, 60) sb[i][j]=((i==0)?0:sb[i-1][j]) + gb(a[i], j);
   }
   int ans=0;
   for(int i=1; i<n; i++) rep(j, 60){
      int c;
      if(gb(a[i], j))
         c=((ll)(i-sb[i-1][j]) * (((ll)1<<j)%M))%M;
      else
         c=((ll)sb[i-1][j] * (((ll)1<<j)%M))%M;
      ans=(ans+c)%M;
   }

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


Measured memory_bytes: 87688
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
typedef long long ll;
#define anyfill(n,s) setw(n) << setfill(s)
int N,M;
int P[100000],Y[100000];
vector<int> yd[100001];
int main(){
  cin>>N>>M;
  for(int i = 0; M > i; i++){
    cin >> P[i] >> Y[i];
    yd[P[i]].push_back(Y[i]);
  }
  for(int i = 1; N >= i; i++){
    sort(yd[i].begin(),yd[i].end());
  }
  for(int i = 0; M > i; i++){
  // cout << anyfill(7-to_string(P[i]).size(),'0') << P[i];
  int b = lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin()+1;
  // cout << anyfill(7-to_string(b).size(),'0') << b << endl;
    printf("%012lld\n",ll(P[i])*1000000+b);
  }
}

Measured memory_bytes: 7808
#include<iostream>
#include<stdio.h>
using namespace std;

int N,H,W;
int main () {
    cin >> N >> H >> W;
    int cnt = 0;
    for(int i=0; i<N; i++) {
        int a,b;
        cin >> a >> b;
        if( H <= a && W <= b ) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256