akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;


int main() {
    ll n;
    cin>>n;
    ll x,cnt=0;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x%2==1)  cnt++;
    }
    if(cnt%2==0)    cout << "YES";
    else    cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int r,c,k;
  cin>>r>>c>>k;
  int memo[r+1][c+1];
  for(int i=0;i<r+1;i++){
    for(int j=0;j<c+1;j++){
      memo[i][j]=0;
    }
  }
  for(int i=0;i<k;i++){
    int R,C,v;
    cin>>R>>C>>v;
    memo[R][C]=v;
  }
  vector<vector<vector<ll>>> dp(4,vector<vector<ll>>(r+1,vector<ll>(c+1,0)));
  for(int i=1;i<r+1;i++){
    for(int j=1;j<c+1;j++){
      for(int l=0;l<4;l++){
        dp[0][i][j]=max(dp[0][i][j],dp[l][i-1][j]);
      }
      dp[0][i][j]=max(dp[0][i][j],dp[0][i][j-1]);
      dp[1][i][j]=dp[1][i][j-1];
      dp[2][i][j]=dp[2][i][j-1];
      dp[3][i][j]=dp[3][i][j-1];
      if(memo[i][j]!=0){
        dp[1][i][j]=max(dp[1][i][j-1],dp[0][i][j]+memo[i][j]);
        dp[2][i][j]=max(dp[2][i][j-1],dp[1][i][j-1]+memo[i][j]);
        dp[3][i][j]=max(dp[3][i][j-1],dp[2][i][j-1]+memo[i][j]);
      }
    }
  }
  ll ans=0;
  for(int i=0;i<4;i++){
    ans=max(ans,dp[i][r][c]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 390592
a,b,h,m = map(int,input().split())
import math
minutes = h*60+m
s1 = m/60

s2 = minutes/720

sita = s1-s2

sita *= math.pi*2

c = a**2 + b**2 - 2*a*b*math.cos(sita)
c = math.sqrt(c)
print(c)

Measured memory_bytes: 9444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] lns = in.readLine().split(" ");
      int n = Integer.parseInt(lns[0]);
      int m = Integer.parseInt(lns[1]);
      City[] city = new City[m];
      City[] city2 = new City[m];
      int[] p = new int[n+1];

      int x,y;
      for(int i=0; i<m; i++) {
        lns = in.readLine().split(" ");
        x = Integer.parseInt(lns[0]);
        y = Integer.parseInt(lns[1]);
        city[i] = new City(i, x, y);
        city2[i] = city[i];
      }

      Arrays.parallelSort(city2, new Comparator<City>() {
        public int compare(City a, City b) {
          if(a.y == b.y) return 0;
          return a.y > b.y ? 1 : -1;
        }
      });

      int maxNo = 0;
      for(int i=0; i<m; i++) {
        city2[i].no = ++p[city2[i].p];
        if(maxNo < city2[i].no) maxNo = city2[i].no;
      }

      // String no;
      StringBuilder buf1 = new StringBuilder();
      StringBuilder buf2 = new StringBuilder();
      String[] aP = new String[n+1];
      for(int i=1; i<n+1; i++) {
        buf1.append(i);
        for(int j=buf1.length(); j<6; j++)
          buf2.append("0");
        buf2.append(buf1);
        aP[i] = buf2.toString();
        buf1.setLength(0);
        buf2.setLength(0);
      }
      String[] aNo = new String[maxNo+1];
      for(int i=1; i<maxNo+1; i++) {
        buf1.append(i);
        for(int j=buf1.length(); j<6; j++)
          buf2.append("0");
        buf2.append(buf1);
        aNo[i] = buf2.toString();
        buf1.setLength(0);
        buf2.setLength(0);
      }
      for(int i=0; i<m; i++) {
        // no = String.format("%06d%06d", city[i].p,city[i].no);
        buf2.append(aP[city[i].p])
          .append(aNo[city[i].no])
          .append("\n");
        // out.println(no);
      }
      // out.flush();
      System.out.print(buf2);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  class City {
    int s;
    int p;
    int y;
    int no;

    public City(int s, int p, int y) {
      this.s = s;
      this.p = p;
      this.y = y;
    }
  }
}

Measured memory_bytes: 78412
import sys
from collections import deque as dq
input = sys.stdin.readline
H, W = map(int, input().split())
sy, sx = map(int, input().split())
gy, gx = map(int, input().split())
sy -= 1
sx -= 1
gy -= 1
gx -= 1
a = [list(input())[: -1] for _ in range(H)]
Q = dq([sy * W + sx])
inf = H * W + 1
dp = [inf] * (H * W)
dp[sy * W + sx] = 0
d = [-1, 0, 1, 0]
while len(Q):
  t = Q.popleft()
  y = t // W
  x = t % W
  for k in range(4):
    u = y + d[k]
    v = x + d[-1 - k]
    if u in range(H) and (v in range(W)):
      if a[u][v] == "#": continue
      if dp[u * W + v] > dp[t]:
        dp[u * W + v] = dp[t]
        Q.appendleft(u * W + v)

  for i in range(5):
    for j in range(5):
      u = y + i - 2
      v = x + j - 2
      if u in range(H) and (v in range(W)):
        if a[u][v] == "#": continue
        if dp[u * W + v] > dp[t] + 1:
          dp[u * W + v] = dp[t] + 1
          Q.append(u * W + v)
if dp[gy * W + gx] != inf: print(dp[gy * W + gx])
else: print(-1)

Measured memory_bytes: 124424
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,c = map(int,input().split())
    d = [list(map(int,input().split())) for i in range(c)]
    cmat = [list(map(int,input().split())) for i in range(n)]
    t = [[0]*c for i in range(3)]
    ans = float("inf")
    for i in range(n):
        for j in range(n):
            t[(i+j)%3][cmat[i][j]-1] += 1
    for i in range(c):
        for j in range(c):
            if i != j:
                for k in range(c):
                    if i != k and j != k:
                        sub = 0
                        for l in range(c):
                            sub += d[l][i]*t[0][l]+d[l][j]*t[1][l]+d[l][k]*t[2][l]
                        ans = min(sub,ans)
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 7600
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;
  pair<int,int> task[SIZE];

  scanf("%d", &N);

  for (int i=0; i<N; i++) {
    int A, B;
    scanf("%d%d", &A, &B);
    task[i] = {B, A};
  }

  sort(task, task+N);

  int now = 0;
  bool ok = true;

  for (int i=0; i<N; i++) {
    ok &= now + task[i].second <= task[i].first;
    now += task[i].second;
  }

  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1792
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    flag = 0
    for i in range(n):
        a = int(input())
        if a%2 == 1:
            print('first')
            return
    print('second')


    




                
if __name__ == '__main__':
    main()

Measured memory_bytes: 8812
from collections import deque
h,w = map(int,input().split())
s = [input() for _ in range(h)]
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j] =='#':
      continue
    visited=[[-1]*w for _ in range(h)]
    visited[i][j] = 0
    cnt=0
    q = deque([[i,j]])
    while q:
      x,y = q.popleft()
      for k,l in [[0,-1],[0,1],[1,0],[-1,0]]:
        nx,ny = k+x,l+y
        if nx<0 or ny<0 or nx>=h or ny>=w:
          continue
        if s[nx][ny]=='.' and visited[nx][ny]==-1:
          visited[nx][ny] = visited[x][y] + 1
          q.append([nx,ny])
          ans = max(ans,visited[nx][ny])
print(ans)

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

using namespace std;

void PrintRelatedTo3(int limit){
    for (int i = 1; i <= limit; i++){
        int x = i;
        if( x%3 == 0 ){
            cout << " " << i;
            continue;
        }
        while(x != 0) {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}

int main(){
    // ---------------------------
    // ITP_1_5_A: Print a Rectangle
//    int w, h;
//    std::vector<std::vector<int>> data;
//    while (true){
//        std::cin >> h >> w;
//        if (h == 0 && w ==0)
//            break;
//        data.push_back({h, w});
//    }
//    PrintRectangle(data);
    // ---------------------------

    // ---------------------------
    // ITP_1_5_B: Print a Frame
//    int w, h;
//    std::vector<std::vector<int>> data;
//    while (true){
//        std::cin >> h >> w;
//        if (h == 0 && w ==0)
//            break;
//        data.push_back({h, w});
//    }
//    PrintFrame(data);
    // ---------------------------

    // ---------------------------
    // ITP_1_5_C: Print a Chessboard
//    int w, h;
//    std::vector<std::vector<int>> data;
//    while (true){
//        std::cin >> h >> w;
//        if (h == 0 && w ==0)
//            break;
//        data.push_back({h, w});
//    }
//    PrintChessboard(data);
    // ---------------------------

    // ---------------------------
    // ITP_1_5_D: Structured Programing
    int n;
    std::cin >> n;
    PrintRelatedTo3(n);
    // ---------------------------

    return 0;
}


Measured memory_bytes: 3104
#include <stdio.h>

#define MAX_N 200000
#define MIN -1000000000

int main(void) {
    int n, R[MAX_N+1], maxv, minv;
    
    scanf("%d", &n);

    int i;
    for(i=0;i<n;i++){
        scanf("%d", &R[i]);
    }

    minv = R[0];
    maxv = MIN;
    for(i=1;i<n;i++){
        if(maxv < (R[i]-minv)){
            maxv = R[i]-minv;
        }

        if(minv > R[i]){
            minv = R[i];
        }
    }

    printf("%d\n", maxv);

    return 0;
}

Measured memory_bytes: 1376
#include<iostream>
#include<string>
#include<stdio.h>
#include<vector>
using namespace std;

int main(){
  int N;
  int A;
  int B;
  cin >> N >> A >> B;

  if(N * A < B ){
    cout << N * A << endl;
  }else{
    cout << B << endl;
  }
  

}

Measured memory_bytes: 256
#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++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    cout<<(N*800)-200*(N/15)<< endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		new Main().run();
	}

	public void run() {
		final Scanner scanner = new Scanner(System.in);
		final int numOfStores = scanner.nextInt();
		int want = scanner.nextInt();

		Store[] stores = new Store[numOfStores];
		for (int i = 0; i < numOfStores; i++) {
			stores[i] = new Store(scanner.nextInt(), scanner.nextInt());
		}

		Arrays.sort(stores, new Comparator<Store>() {
			@Override
			public int compare(Store o1, Store o2) {
				return o1.getPrice() - o2.getPrice();
			}
		});

		long result = 0;

		for (int i = 0; i < numOfStores; i++) {
			if (want <= stores[i].getNumber()) {
				result += (long)want * (long)stores[i].getPrice();
				break;
			}

			result += (long)stores[i].getNumber() * (long)stores[i].getPrice();
			want -= (long)stores[i].getNumber();
		}

		System.out.println(result);
		scanner.close();
	}

	public class Store {
		final private int price;
		private int number;

		public Store(final int price, final int number) {
			this.price = price;
			this.number = number;
		}

		public int getPrice() {
			return this.price;
		}

		public int getNumber() {
			return this.number;
		}
	}

}


Measured memory_bytes: 90080
# 1つ目　縦A、横B
# 2つ目　縦C、横D
a, b, c, d = map(int, input().split())
# 面積が大きい方を出力、等しい時は面積を出力

if a * b >= c * d:
    print(a * b)
else:
    print(c * d)


Measured memory_bytes: 9040
#A = 7
#B = 5
#C = 2

lst = input().split(' ')

#lst = [A, B, C]
for i in range(len(lst)):
    lst[i] = int(lst[i])

i = -1
while True:
    i += 1
    lst.sort()
#    print(i, lst)
    if lst[0] == lst [2]:
        break
    
    if lst[0] == lst[1]:
        lst[0] += 1
        lst[1] += 1
    else:
        lst[0] += 2
        


print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N;
	cin>>N;
	map<vector<int>,int>mp;
	REP(i,N){
		string s;
		cin>>s;
		vector<int>tmp(26,0);
		REP(j,s.size()){
			tmp[s[j]-'a']++;
		}
		mp[tmp]++;
	}
	int ans = 0;
	for(auto e:mp){
		ans += e.second*(e.second-1)/2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 29952
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,k;
const int Maxn=5005;
int a[Maxn];
bitset<Maxn>leftsum[Maxn],rightsum[Maxn];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]>k)a[i]=k;
	}
	leftsum[0][0]=true;
	for(int i=1;i<=n;i++){
		leftsum[i]=leftsum[i-1]|(leftsum[i-1]<<a[i]);
	}
	rightsum[n+1][0]=true;
	for(int i=n;i>=1;i--){
		rightsum[i]=rightsum[i+1]|(rightsum[i+1]<<a[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		vector<int>L,R;
		for(int j=k;j>=0;j--)if(leftsum[i-1][j])L.push_back(j);
		for(int j=0;j<=k;j++)if(rightsum[i+1][j])R.push_back(j);
//		foreach(itr,L)cout<<*itr<<' ';cout<<endl;
//		foreach(itr,R)cout<<*itr<<' ';cout<<endl;
		int p1=0,p2=0;
		for(int t:L){
			while(p1<SZ(R)&&R[p1]+t<k-a[i])p1++;
			while(p2<SZ(R)&&R[p2]+t<k)p2++;
			if(p1<p2){
				ans++;
				break;
			}
		}
	}
	printf("%d\n",n-ans);
	return 0;
}

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

int main() {
  int Y=0;
  string N;
  cin >> N;
  for (int X=0; X<N.size(); X++){
    if (N.at(X)=='7'){
      Y=1;
    }
  }
  if (Y==1){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3624
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    MAX = 10**18
    for a in sorted(A):
        if a == 0:
            print(0)
            return
        ans *= a
        if ans > MAX:
            print(-1)
            return

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 21636
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def debug():
    A = [x]
    for _ in range(n - 1):
        next_A = pow(A[-1], 2) % m
        A.append(next_A)
    print(sum(A))


def resolve():
    A = [x]
    target = 0
    for _ in range(n - 1):
        next_A = pow(A[-1], 2) % m
        if next_A == 0:
            print(sum(A))
            exit()
        if next_A in A:
            target = next_A
            break
        A.append(next_A)
    else:
        print(sum(A))
        exit()

    idx = A.index(target)
    loop_length = len(A) - idx
    q, r = divmod(n - len(A), loop_length)
    base = sum(A)
    plus = sum(A[idx:]) * q + (sum(A[idx:idx + r]) if r != 0 else 0)
    print(base + plus)


if __name__ == '__main__':
    n, x, m = map(int, input().split())
    resolve()



Measured memory_bytes: 68728
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int N;
int K;
string S;

int main(){
  // Input
  cin >> N >> K;
  cin >> S;

  // 圧縮
  vector<int> cnts;

  if(S[0] != '1'){
    cnts.push_back(0);
  }

  int tmp_num = S[0] - '0';
  int tmp_cnt = 1;
  for(int i=1; i<S.size(); i++){
    int tmp_digit = S[i] - '0';
    if(tmp_digit != tmp_num){
      cnts.push_back(tmp_cnt);
      tmp_num = tmp_digit;
      tmp_cnt = 1;
    }else{
      tmp_cnt++;
    }
  }
  cnts.push_back(tmp_cnt);

  // for(int i: cnts){
  //   cout << i << " ";
  // }
  // cout << endl;

  int ans = 0;

  vector<int> sum(cnts.size());
  sum[0] = cnts[0];
  for(int i=1; i<sum.size(); i++){
    sum[i] = sum[i-1] + cnts[i];
  }
  sum.push_back(sum.back());

  // for(int i: sum){
  //   cout << i << " ";
  // }
  // cout << endl;

  

  for(int i=0; i<sum.size(); i+=2){
    int left = i-1;
    int right = min((int)sum.size()-1, i+2*K);

    int tmp_ans;
    if(i == 0){
      tmp_ans = sum[right];
    }else{
      tmp_ans = sum[right] - sum[left];
    }
    ans = max(ans, tmp_ans);

    // cout << "===" << endl;
    // cout << "left:" << left << endl;
    // cout << "right:" << right << endl;
    // cout << "tmp_ans:" << tmp_ans << endl;
  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 1656
from fractions import gcd
inpl = lambda: list(map(int,input().split()))

N = int(input())
A = inpl()
L = [A[0]]
R = [A[-1]]
for i in range(1,N-1):
    L.append(gcd(L[i-1],A[i]))
    R.append(gcd(R[i-1],A[-i-1]))

ans = max(L[-1],R[-1])
for i in range(1, N-1):
    g = gcd(L[i-1],R[-i-1])
    if g > ans:
        ans = g
print(ans)

Measured memory_bytes: 16156
N,M = map(int,input().split(" "))
l = 1
r = N
for i in range(M):
    L,R = map(int,input().split(" "))
    l = max(l,L)
    r = min(r,R)

if r - l < 0:
    print(0)
else:
    print(r-l+1)

Measured memory_bytes: 45544
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chkmax(T& a,T b){ return a<b?a=b,1:0; }
template<class T> inline bool chkmin(T& a,T b){ return a>b?a=b,1:0; }
template<typename T> inline T& read(T& x){
    static char c; bool flag=0;
    while(!isdigit(c=getchar())) if(c=='-') flag=1;
    for(x=c-'0';isdigit(c=getchar());(x*=10)+=c-'0');
    if(flag) x=-x;
    return x;
}
typedef long long LL;
const int maxn=300010;
int n,m,a[maxn],stk[maxn];
LL f1[maxn],f2[maxn],f[maxn],sum[maxn],y[maxn];
void DP(LL* F){
    int top=0; stk[++top]=0;
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    for(int i=1;i<=n;i++){
        F[i]=F[i-1];
        while(top>1&&y[stk[top]]-y[stk[top-1]]<=2ll*i*(stk[top]-stk[top-1])) --top;
        int p=stk[top];
        chkmax(F[i],F[p]+1ll*(i-p)*(i-p+1)/2+sum[p]-sum[i]);
        y[i]=2*F[i]+1ll*i*i-i+2*sum[i];
        while(top>1&&(y[stk[top]]-y[stk[top-1]])*(i-stk[top-1])<=(y[i]-y[stk[top-1]])*(stk[top]-stk[top-1])) --top;
        stk[++top]=i;
    }
}
void solve(LL* F1,LL* F2,int l,int r){
    if(l==r){
        chkmax(f[l],F1[l-1]+F2[l+1]-a[l]+1);
        return;
    }
    static LL t[maxn];
    int mid=(l+r)>>1,top=0;
    for(int i=l-1;i<mid;i++){
        y[i]=2*F1[i]+1ll*i*i-i+2*sum[i];
        while(top>1&&(y[stk[top]]-y[stk[top-1]])*(i-stk[top-1])<=(y[i]-y[stk[top-1]])*(stk[top]-stk[top-1])) --top;
        stk[++top]=i;
    }
    for(int i=mid;i<=r;i++){
        while(top>1&&y[stk[top]]-y[stk[top-1]]<=2ll*i*(stk[top]-stk[top-1])) --top;
        int p=stk[top];
        t[i]=F2[i+1]+F1[p]+1ll*(i-p)*(i-p+1)/2+sum[p]-sum[i];
    }
    for(int i=r-1;i>=mid;i--) chkmax(t[i],t[i+1]);
    for(int i=mid;i<=r;i++) chkmax(f[i],t[i]);
    solve(F1,F2,l,mid); solve(F1,F2,mid+1,r);
}
int main(){
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);
    DP(f1); reverse(a+1,a+n+1);
    DP(f2); reverse(a+1,a+n+1);
    reverse(f2+1,f2+n+1);
    for(int i=1;i<=n;i++) f[i]=-a[i];
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    solve(f1,f2,1,n);
    reverse(a+1,a+n+1); reverse(f+1,f+n+1);
    reverse(f1+1,f1+n+1); reverse(f2+1,f2+n+1);
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    solve(f2,f1,1,n);
    reverse(a+1,a+n+1); reverse(f+1,f+n+1);
    reverse(f1+1,f1+n+1); reverse(f2+1,f2+n+1);
    read(m);
    for(int i=1;i<=m;i++){
        int p,x;
        read(p); read(x);
        printf("%lld\n",max(f1[p-1]+f2[p+1],f[p]-x+a[p]));
    }
    return 0;
}


Measured memory_bytes: 19072
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl

using namespace std;

using ll = int64_t;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()

template <class T>
ostream &operator<<(ostream &os, vector<T> const &vec) {
    if (vec.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream &operator<<(ostream &os, array<T, S> const &arr) {
    if (arr.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

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

namespace math {
ll gcd(ll u, ll v) {
    while (v != 0) {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}
ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;

    return ((m / math::gcd(m, n)) * n);
}
}  // namespace math

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) {}
    bool unionSet(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) { return root(x) == root(y); }
    ll root(ll x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    ll size(ll x) { return -data[root(x)]; }
};

template <class T, class U>
pair<T, U> operator+(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first + b.first, a.second + b.second);
}

template <class T, class U>
pair<T, U> operator-(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first - b.first, a.second - b.second);
}

ll bound(function<bool(ll)> f, ll ng, ll ok) {
    while (abs(ng - ok) > 1) {
        ll mid = (ng + ok) / 2;
        if (f(mid))
            ok = mid;
        else
            ng = mid;
    }

    return ok;
}


int main(void) {
    ll H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w) << endl;

    return 0;
}

Measured memory_bytes: 888
S = input()
a = 0
x = 0
j = 0
for i in range(len(S)):
    if S[i] == "A" and a == 0:
        a = 1
    if a == 1:
        j += 1
    if S[i] == "Z" and a == 1:
        x = j
print(x)


Measured memory_bytes: 9232
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

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

	vector<int> d(26, inf);
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		vector<int> v(26, 0);
		for (int j = 0; j < (int)s.size(); j++) {
			v[s[j]-'a']++;
		}

		for (int j = 0; j < 26; j++) {
			d[j] = min(d[j], v[j]);
		}
	}

	string ans = "";
	for (int i = 0; i < 26; i++) {
		if (d[i] != inf) {
			for (int j = 0; j < d[i]; j++) {
				ans += (i+'a');
			}
		}
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll x,n;cin>>x>>n;
    set<ll>st;
    rep(i,n){
        ll a;cin>>a;
        st.insert(a);
    }
    ll ans=101;
    for(int i=101;i>=-1;i--){
        if(abs(ans-x)>=abs(x-i)){
            if(st.find(i)==st.end())ans=i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

struct mint {
    long long x;
    mint(long long _x=0):x((_x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;
    vector<ll> x(N), y(M);
    rep(i,N)cin >> x[i];
    rep(i,M)cin >> y[i];
    vector<mint> xx(N-1), yy(M-1);
    rep(i,N-1)xx[i] = x[i+1] - x[i];
    rep(i,M-1)yy[i] = y[i+1] - y[i];
    vector<mint> a(N-1), b(M-1);
    rep(i,N-1){
        a[i] = mint(i+1) * mint(N - i - 1);
    }
    rep(i,M-1){
        b[i] = mint(i+1) * mint(M - i - 1);
    }
    mint sum[] = {0,0};
    rep(i,N-1)sum[0] += xx[i] * a[i];
    rep(j,M-1)sum[1] += yy[j] * b[j];
    mint ans = sum[0] * sum[1];
    cout << ans << endl;
}


Measured memory_bytes: 7912
def aa(num):
    b=1
    c=0
    for i in range(num-1):
        c+=b
        b+=1
    return c

n=int(input())
s=[]
for i in range(n):
    word=list(input())
    word2=sorted(word)
    word3="".join(word2)
    s.append(word3)
s2=sorted(s)
ans=0
now=s2[0]
num=0
for i in range(n):
    if now==s2[i]:
        num+=1
    else:
        ans+=aa(num)
        now=s2[i]
        num=1
print(ans+aa(num))

Measured memory_bytes: 11380
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  int N; cin >> N;
  string S; cin >> S;

  string ans = "Yes";
  if (N % 2 != 0){
    ans = "No";
  }else{
    for (int i = 0; i < N / 2; i++){
      if (S[i] != S[i + N / 2]){
        ans = "No";
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

int a,b;
int main(){
#ifdef DEBUG
	printf("DEBUGGING ON\n");
#endif
	scanf("%d %d",&a,&b);
	if (b>=a) printf("%d",a);
	else printf("%d",a-1);
	return (0);
}

Measured memory_bytes: 128
import heapq
import math

# get input parameter
n, m = map(int, input().split())

# get price list (convert max heap)
price_list = [ int(x) * -1 for x in input().split() ]
heapq.heapify(price_list)

# use ticket
for use_count in range(m):
    # get most expensive price
    max_price = heapq.heappop(price_list) * -1
    
    # use ticket
    new_price = math.floor(max_price / 2)
    
    # add heap que
    heapq.heappush(price_list, new_price * -1)

# print price sum
print(sum(price_list) * -1)


Measured memory_bytes: 14536
#include <cstdio>
#include <cassert>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>

using namespace std;

#define all(c) begin(c), end(c)
#define dump(c) cerr << "> " << #c << " = " << (c) << endl
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

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

const int INF = 1001001001;
const double EPS = 1e-10;


template<typename T1,typename T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){
  return os << '(' << p.first <<',' << p.second << ')';
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& a){
  os << '[';
  rep(i,a.size()) os << (i ? " " : "") << a[i];
  return os << ']';
}

int main() {
  for(int N, M; cin >> N >> M, (N | M) != 0; ) {
    vector<pii> list;
    int ans = 0;
    rep(i, N) {
      int D, P; cin >> D >> P;
      list.push_back(make_pair(P, D));
      ans += D * P;
    }
    sort(all(list));
    reverse(all(list));

    rep(i, N) {
      int D, P;
      tie(P, D) = list[i];
      ans -= P * min(M, D);
      M -= min(M, D);
    }

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

Measured memory_bytes: 1328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 505
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m,q,a[maxn][maxn],sum[maxn][maxn];
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=m;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		a[l][r]++;
	}
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			sum[i][j] = sum[i][j-1] + a[i][j];
		}
	}
	for(int i=1;i<=q;i++){
		int p1,q1;
		scanf("%d%d",&p1,&q1);
		int ans = 0;
		for(int i=p1;i<=q1;i++){
			ans += sum[i][q1];
		}
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
int a[N];
vector<int> sig;
int main(int argc, char const *argv[]) {
  int n = read(), m = read();
  for (int i = 1; i <= m; ++ i) {
    a[i] = read();
    if (a[i] & 1) {
      sig.push_back(i);
    }
  }
  size_t sigsize = sig.size();
  if (sigsize > 2) {
    return puts("Impossible"), 0;
  }
  if (sigsize > 0) {
    swap(a[1], a[sig[0]]);
  }
  if (sigsize > 1) {
    swap(a[m], a[sig[1]]);
  }

  if (m == 1) {
    if (a[1] == 1) {
      puts("1\n1\n1");
    } else {
      printf("%d\n2\n%d 1\n", a[1], a[1] - 1);
    }
    return 0;
  }
  
  for (int i = 1; i <= m; ++ i) {
    printf("%d ", a[i]);
  }
  puts("");

  printf("%d\n", a[m] == 1 ? m - 1 : m);
  printf("%d", a[1] + 1);
  for (int i = 2; i < m; ++ i) {
    printf(" %d", a[i]);
  }
  if (a[m] != 1) {
    printf(" %d\n", a[m] - 1);
  } else {
    puts("");
  }
  return 0;
}

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

typedef long long ll;

char incrementChar(char x){
    return static_cast<char>(x + 1);
}

// vector<int> v;
// auto it = v.begin();
// 
// it = v.insert(it, A + B);
// it = v.insert(it, A - B);
// it = v.insert(it, A * B);
// 
// int max = *max_element(v.begin(), v.end());
// int min = *min_element(v.begin(), v.end());

// for(int i=0; i<(int)S.size(); i++){
//     sum += count(S.cbegin(), S.cend(), S[i]);
// }
// typedef pair<int, int> pair;
// vector<pair> pair_v;
// int i;
// int x;
// for(i=0; i<3; i++){
//     cin >> x;
//     pair_v.push_back(pair(i, x));
// }
// 
// sort(pair_v.begin(),
//      pair_v.end(),
//      [](const pair& x, const pair& y){return x.second > y.second;}
// );
// 
// for(auto& i:pair_v){
//     cout << i.first << " " << i.second << endl;
// }


int main(){
    vector<int> v;
    int i;
    int A;
    for(i=0; i<9; i++){
        cin >> A;
        v.push_back(A);
    }

    int bingo[9];
    for(i=0; i<9; i++) bingo[i] = 0;

    int N;
    cin >> N;
    int b;
    for(i=0; i<N; i++){
        cin >> b;
        for(int j=0; j<9; j++){
            if(b == v[j]) bingo[j] = 1;
        }
    }

    int sum = 0;
    if(bingo[0] + bingo[1] + bingo[2] == 3) sum++;
    if(bingo[3] + bingo[4] + bingo[5] == 3) sum++;
    if(bingo[6] + bingo[7] + bingo[8] == 3) sum++;

    if(bingo[0] + bingo[3] + bingo[6] == 3) sum++;
    if(bingo[1] + bingo[4] + bingo[7] == 3) sum++;
    if(bingo[2] + bingo[5] + bingo[8] == 3) sum++;

    if(bingo[0] + bingo[4] + bingo[8] == 3) sum++;
    if(bingo[2] + bingo[4] + bingo[6] == 3) sum++;


    if(sum > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define vll vector<long long>
#define mll map<long long,long long>
#define pb push_back
typedef  long long ll;
typedef long double ld;
long double pi=3.14159265358979323846;

vll al[500005];
ll vis[500005],color[500005],I[101][101];

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

bool isPrime(int n)
{
    if (n<=1) return false; 
    if (n<=3) return true; 
    if (n%2==0||n%3==0) return false; 
    for (int i=5;i*i<=n;i=i+6) if (n%i==0||n%(i+2)==0) return false; 
    return true; 
}

ll bpow(ll n, ll po)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res*=n;
			po--;
		}
		else
		{
			n*=n;
			po/=2;
		}
	}
	return res;
}

ll binpow(ll n, ll po, ll mod)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res=(res*n)%mod;
			po--;
		}
		else
		{
			n=(n*n)%mod;
			po/=2;
		}
	}
	return res;
}

ll swap(ll a, ll b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

ll fact(ll n) { 
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}

ll C(ll n, ll r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
        ans=ans%1000000007;
    }

    return ans;
}

//bool bipartite_dfs(ll node, ll flag)
//{
//	vis[node]=1;
//	ll cflag=flag;
//	color[node]=cflag;
//	for(ll child : al[node])
//	{
//		if(!vis[child])
//		{
//			bool n=bipartite_dfs(child,1-cflag);
//			if(n==false) return false;
//		}
//		else if(color[child]==color[node]) return false;
//	}
//	return true;
//}

void mmul(ll A[][101], ll B[][101], ll dim)
{
	ll res[dim][dim];
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		res[i][j]=0;
		for(ll k=0;k<dim;k++) res[i][j]=(res[i][j]+A[i][k]*B[k][j])%1000000007;
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=res[i][j];
}

void mpow(ll A[][101],ll dim, ll po)
{
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		if(i==j) I[i][j]=1;
		else I[i][j]=0;
	}
	while(po>0)
	{
		if(po%2==1)
		{
			mmul(I,A,dim);
			po--;
		}
		else
		{
			mmul(A,A,dim);
			po/=2;
		}
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=I[i][j];
}



int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll t=ceil((float)c/b),k=ceil((float)a/d);
	if(t<=k) cout<<"Yes";
	else cout<<"No";
}


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

struct StPoint
{
  StPoint() :
    m_nTime(0), m_nPntX(0), m_nPntY(0)
  { }

  int m_nTime;
  int m_nPntX;
  int m_nPntY;
};

void fnInput(vector<StPoint>& rvoPoint)
{
  StPoint oPoint;
  int nSiz;
  cin >> nSiz;

  rvoPoint.resize(nSiz, oPoint);

  for (int i = 0; i < nSiz; i++)
    cin >> rvoPoint[i].m_nTime >> rvoPoint[i].m_nPntX >> rvoPoint[i].m_nPntY;
}

int fnTravel(const vector<StPoint> cnrvoPoint)
{
  for (StPoint oPoint : cnrvoPoint)
  {
    int nAbsX = abs(oPoint.m_nPntX);
    int nAbsY = abs(oPoint.m_nPntY);

    if (oPoint.m_nTime < nAbsX + nAbsY)  return 0;
    if (oPoint.m_nTime % 2)
      if (((nAbsX + nAbsY) % 2));
      else                       return 0;
    else
      if ((nAbsX + nAbsY) % 2)   return 0;
      else;
  }
  return 1;
}

int main()
{
  vector<StPoint> oPoint;

  fnInput(oPoint);
  if (fnTravel(oPoint))  cout << "Yes" << endl;
  else                   cout << "No"  << endl;

  return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a+a-1,b+b-1}) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
a=input()
s=[]
i=0
total=1000000
while True:
    s=100*int(a[i])+10*int(a[i+1])+int(a[i+2])
    d=abs(s-753)
    if total>d:
        total=d
    i+=1
    if i+2==len(a):
        print(total)
        break

Measured memory_bytes: 9096
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>

int main()
{
    int64_t N, K;
    std::cin >> N >> K;
    std::vector<int64_t> P;
    for (size_t n = 0; n < N; ++n)
    {
        int64_t p;
        std::cin >> p;
        P.emplace_back(p);
    }

    std::sort(P.begin(), P.end());

    int64_t s = 0;
    for (size_t n = 0; n < K; ++n) {
        s += P.at(n);
    }
    std::cout << s << std::endl;

    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 300005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n;
    cin >> n;
    vector<int> v(n * 3);
    for(int i = 0; i < n * 3; ++i) {
        cin >> v[i];

    }

    LL sumf[SIZE], sumb[SIZE];
    priority_queue<int, vector<int>, greater<int>> pqf;
    LL sum = 0;
    for(int i = 0; i < n; ++i) {
        sum += v[i];
        pqf.push(v[i]);

    }

    sumf[n - 1] = sum;
    for(int i = n; i < n * 2; ++i) {
        if(v[i] > pqf.top()) {
            sum -= pqf.top();
            sum += v[i];
            pqf.pop();
            pqf.push(v[i]);

        }
        sumf[i] = sum;
    }

    priority_queue<int> pqb;
    sum = 0;
    for(int i = n * 2; i < n * 3; ++i) {
        sum += v[i];
        pqb.push(v[i]);

    }

    sumb[n * 2] = sum;
    for(int i = n * 2 - 1; i >= n; --i) {
        if(v[i] < pqb.top()) {
            sum -= pqb.top();
            sum += v[i];
            pqb.pop();
            pqb.push(v[i]);

        }
        sumb[i] = sum;

    }

    LL res = LMIN;
    for(int i = n; i <= n * 2; ++i) {
        res = max(res, sumf[i - 1] - sumb[i]);

    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 6392
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int m,c,f,r; 
    while(1){
        cin>>m>>f>>r;
        c=m+f;  
        if(m==-1&&f==-1&&r==-1)break;
        else if(m==-1||f==-1){
            printf("F\n");
        }
        else if(80<=c){
            printf("A\n");
        }
        else if (65<=c&&c<80){
            printf("B\n");
        }
        else if (50<=c&&c<65){
            printf("C\n");
        }
        else if (c>=30&&r>=50){
            printf("C\n");
        } 
        else if (c>=30&&r<50){
            printf("D\n");
        }
         else if (c<30){
            printf("F\n");
        }
    }
     
    return 0;
}



Measured memory_bytes: 3056
#include <iostream>
#include <cstdio>
using namespace std;
int v[200005],n;
int main()
{
        ios::sync_with_stdio(false);
        cin >> n;
        for (int i = 0; i < n; ++i)
                cin >> v[i];

        int total_xor = 0;

        for(int i = 0; i < n; i++)
                total_xor ^= v[i];

        for(int i = 0; i < n; i++)
                cout << (total_xor ^ v[i]) << ' ';

        return 0;
}


Measured memory_bytes: 4384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	for (int i = 0; i + 1 < (int)s.size(); i++) {
		if (s[i] != s[i + 1]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	a := 0
	for i := 0; i < len(s); i++ {
		for j := i + 1; j <= len(s); j++ {
			k, _ := strconv.Atoi(s[i:j])
			b := 0
			if i > 0 {
				b += i - 1
			}
			if j < len(s) {
				b += len(s) - j - 1
			}
			k <<= uint(b)
			a += k
		}
	}
	fmt.Println(a)
}


Measured memory_bytes: 512
/////////////////////////////////TEST CASES////////////////////////////////////
/*

*/
/////////////////////////////////////CODE/////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define VL vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 1000000000;
ll MOD = 1000000007;
int main()
{
	fastio
	//freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
	ll test = 1;
	//cin>>test;
	while (test--)
	{
		IN(n)IN(d);
        ll cnt=0;
        while(n--)
        {
            IN(p)IN(q);
            if(p*p+q*q<=d*d)
                cnt++;
        }
        cout<<cnt;
	}
}

Measured memory_bytes: 3648
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int n,x,t;
int main() {
	scanf("%d %d %d",&n,&x,&t);
	if(n % x == 0)
	printf("%d",(n / x) * t);
	else
	printf("%d",(n / x + 1) * t);
	return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



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

  rep(i,26){
    rep(j,15){
      if(4*i+7*j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }

  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3628