akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
bool linearSearch(int,int*,int);

int main(){
  int n,S[10000],T,q,c=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>S[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>T;
    c+=linearSearch(n,S,T);}
  cout<<c<<endl;
  return 0;
}
//番兵を用いた線形探索
  bool linearSearch(int n,int S[],int T){
    int i=0;
    S[n] =T;
    while(S[i]!=T){
      i++;}
    if(i==n)return false;
    else return true;
  }
      
 

Measured memory_bytes: 1200
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("in.txt",  "r",  stdin);
        freopen("out.txt", "w", stdout);
    #endif
//*/

 	       
	
	int r;
	cin>>r;
	cout<<r*r;        
        












    return 0;
}

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

int f(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}



int main() {
    int N;
    scanf("%d", &N);
    int *v = malloc(N * sizeof(int));
    for (int i = 0; i < N; i++) {
        scanf("%d", &v[i]);
    }
    qsort(v, N, sizeof(int), f);
    double ans = 0;
    for (int i = 0; i < N - 2; i++){
        ans += pow(2.0, N - 2 - i) * v[i];
    }
    ans += v[N-2];
    ans += v[N-1];
    ans /= pow(2.0, N - 1);
    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 128
# https://atcoder.jp/contests/abc119/tasks/abc119_c
import itertools
import collections
from bisect import bisect



def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in range(N)]

    def solve(i, a, b, c):
        if i == N:
            # 最初の追加は合成じゃないので +10 * 3(A,B,Cの分)が余分なので除外する
            # 最低でも１本使わないとダメ
            return abs(A-a) + abs(B-b) + abs(C-c) - 30 if min(a, b, c) > 0 else int(1e15)
        ret0 = solve(i + 1, a, b, c)
        ret1 = solve(i + 1, a + L[i], b, c) + 10
        ret2 = solve(i + 1, a, b + L[i], c) + 10
        ret3 = solve(i + 1, a, b, c + L[i]) + 10
        return min(ret0, ret1, ret2, ret3)

    print(solve(0, 0, 0, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
/*
 * ALDS1_9_A.cpp
 *
 *  Created on: May 5, 2018
 *      Author: 13743
 */

#include<iostream>

using namespace std;

int main() {
	int n;
	int T[251];

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

	for(int i=1; i<=n; i++) {
		cout << "node " << i << ": key = " << T[i] << ", ";
		if(i/2 > 0) {
			cout << "parent key = " << T[i/2] << ", ";
		}
		if(2*i <= n) {
			cout << "left key = " << T[2*i] << ", ";
		}
		if(2*i+1 <= n) {
			cout << "right key = " << T[2*i+1] << ", ";
		}
		cout << endl;
	}
}





Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int MAXN = 1e5+5;
const LL INF = 1LL<<30;
const long double eps = 1e-10;
const double PI=3.1415926535897932;

vector<int> adj[100009];

int main(){
	DRII(n,m);
	REP(i,m){
		DRII(a,b);a--;b--;
		adj[a].PB(b);
		adj[b].PB(a);
	}
	REP(i,n){
		if(SZ(adj[i])%2){puts("NO");return 0;}
	}
	puts("YES");
}


Measured memory_bytes: 5376
n = int(input())
s = list(map(int, input().split()))
cnt = 0

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    L.append(float('inf'))
    R.append(float('inf'))
    
    i = 0
    j = 0
    global cnt
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            
def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left+right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
        
mergeSort(s, 0, n)
print(' '.join(map(str, s)))
print(cnt)


Measured memory_bytes: 66588
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef vector<int> vi;
typedef vector<string> vs;
#define pb push_back
#define sz(c) int((c).size())

vs field;

vi dx = {0, -1, 0, 1};
vi dy = {-1, 0, 1, 0};

void dfs(int x, int y)
{
  field[x][y] = '0';
  for (int i = 0; i < sz(dx); i++) {
    int nx = x+dx[i], ny = y+dy[i];
    if (0 <= nx && nx < 12 && 0 <= ny && ny < 12 && field[nx][ny] == '1')
      dfs(nx, ny);
  }
}

int islands()
{
  int res = 0;
  for (int i = 0; i < 12; i++) {
    for (int j = 0; j < 12; j++) {
      if (field[i][j] == '1') {
        res++;
        dfs(i, j);
      }
    }
  }
  return res;
}

int main(int argc, char **argv)
{
  string s;
  while (getline(cin, s)) {
    if (sz(s) == 0) {
      cout << islands() << endl;
      field.clear();
    } else {
      field.pb(s);
    }
  }
  cout << islands() << endl;
  return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i] << endl;}}

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




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int a[2][n];
    int mx = 0;
    int sum[n+1] = {0} ;
    rep(i, 2){
        rep(j, n){
            cin >> a[i][j];
        }
    }

    rep(i, 2){
        rep(j, n){
            sum[i*n+j+1] = a[i][j] + sum[i*n+j];
        }
    }

    rep(i, n){
        mx = max(mx, sum[n*2] - sum[n+i] + sum[i+1]);
    }

    ppp(mx);

    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  S = S + "G";

  // K こ穴を塞いで、一番大きいものを、LについてとRについてそれぞれ求める。

  //int lind, rind = 0;
  int Lmax = 0;
  int Rmax = 0;
  int cntK = 0;
  int right = 0;

  int optl = 0;
  int optr = 0;

  // Rを埋める
  for(int left = 0; left < N; ++left){

    while(true){
      if(S[right] == 'R' && S[right+1] == 'L'){
        cntK++;
      }

      if(S[right] == 'L' && S[right+1] == 'R'){
        if(cntK == K){
          break;
        }
      }
      if(S[right+1] == 'G'){
        break;
      }
      right++;
    }

    if(chmax(Lmax, right-left+1)){
      optl = left;
      optr = right;
    }

    while(true){
      if(S[left]=='R' && S[left+1] == 'L'){
        left++;
        break;
      }
      if(S[left+1] == 'G'){
        break;
      }
      left++;
    }
    cntK -= 1;
  }

//  cout << optl << " " << optr << Lmax << endl;

  string S_l;
  for(int i = 0; i < N; i++){
    if(optl <= i && i <= optr){
      S_l += "L";
    }else{
      S_l += S[i];
    }
  }

  //cout << S_l << endl;

  int ans_l = 0;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(S_l[i] != S_l[i+1]){
      ans_l += cnt;
      cnt = 0;
    }else{
      cnt += 1;
    }
  }

  //cout << ans_l << endl;

  Lmax = 0;
  Rmax = 0;
  cntK = 0;
  right = 0;

  optl = 0;
  optr = 0;

  // Rを埋める
  for(int left = 0; left < N; ++left){

    while(true){
      if(S[right] == 'L' && S[right+1] == 'R'){
        cntK++;
      }

      if(S[right] == 'R' && S[right+1] == 'L'){
        if(cntK == K){
          break;
        }
      }
      if(S[right+1] == 'G'){
        break;
      }
      right++;
    }

    if(chmax(Rmax, right-left+1)){
      optl = left;
      optr = right;
    }

    while(true){
      if(S[left]=='L' && S[left+1] == 'R'){
        left++;
        break;
      }
      if(S[left+1] == 'G'){
        break;
      }
      left++; 
    }
    cntK -= 1;
  }

  string S_r;
  for(int i = 0; i < N; i++){
    if(optl <= i && i <= optr){
      S_r += "R";
    }else{
      S_r += S[i];
    }
  }

  //cout << S_r << endl;

  int ans_r = 0;
  cnt = 0;
  for(int i = 0; i < N; i++){
    if(S_r[i] != S_r[i+1]){
      ans_r += cnt;
      cnt = 0;
    }else{
      cnt += 1;
    }
  }

  cout << max(ans_l, ans_r) << endl;

  //cout << ans_r << endl;


  return 0;
}



Measured memory_bytes: 768
//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
main()
{
	fast();
	int t=1;
//	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int arr[n];
		map<int,int> mp;
		int sum=0;
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
			mp[arr[i]]++;
			sum+=arr[i];
		}
		int q;
		cin>>q;
		while(q--)
		{
			int b,c;
			cin>>b>>c;
			int x=mp[b];
			mp[c]+=mp[b];
			sum-=b*mp[b];
			sum+=mp[b]*c;
			mp[b]=0;
				cout<<sum<<endl;
		}
	
	
	}
	
}




Measured memory_bytes: 10168
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 3e5 + 10;
using namespace std;

int n, m, T, kase = 1;
string s;
int w, e;

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> s;
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == 'W') w++;
		else e++;
	}
	int ans = n;
	int ww = 0, ee = 0;
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == 'W') {
			ans = min(ans, ww + e - ee);
			ww++;
		} else {
			ans = min(ans, ww + e - ee - 1);
			ee++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
# N = int(input())
def cmb(n, r, mod):
    x = 1
    for i in range(r):
        x = x * (n-i) % mod
    return (x * g2[r]) % mod


mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

def pow_(x, n):
    if n == 0:
        return 1

    k = 1
    while n > 1:
        if n % 2 != 0:
            k = (k * x) % MOD
        x = (x * x) % MOD
        n //= 2

    return (k * x) % MOD

n, a, b = [int(i) for i in input().split()]
MOD = 10 ** 9 + 7
n_num = pow_(2, n) - 1
a_num = cmb(n, a, MOD)
b_num = cmb(n, b, MOD)
print((n_num - a_num - b_num) % MOD)


Measured memory_bytes: 80880
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m=0;
  cin>>n;
  string ans="Yes";
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin>>c[i];
    if(m-c[i]>=2){cout<<"No";return 0;}
    m=max(m,c[i]);
  }
  cout<<ans;
}


Measured memory_bytes: 640
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 10000000000LL //long long int専用
#define NUM 1000000007
#define all(x) begin(x), end(x)

int main() {
	int n;
	cin >> n;
	VI a(n);
	ll sum=0,ans = INF,x=0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) sum += a[i];

	for (int i = 0; i < n; i++) {
		 x+= a[i];
		 if (i+1<n) {
			 ans = min(ans,abs(sum-2*x));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;

class Point{
public:
  double x, y;
  Point(double x=0, double y=0):x(x), y(y){}
  Point operator + (Point p){ return Point(x+p.x, y+p.x);}
  Point operator - (Point p){ return Point(x-p.x, y-p.y);}
  Point operator * (double a){ return Point(a*x, a*y);}
  double abs(){ return sqrt(norm());}
  double norm(){ return x*x+y*y;}
  bool operator < (const Point &p) const{
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

main(){
  int n;
  double ansx[1000];
  double ansy[1000];
  ansx[0]=1.0;
  ansy[0]=0.0;

  for(int i=1;i<1000;i++){
    Point a, b, c;
    a.x=a.y=0.0;
    b.x=ansx[i-1];
    b.y=ansy[i-1];
    double t=atan(1.0/(b-a).abs());
    c.x=cos(t)*b.x-sin(t)*b.y;
    c.y=sin(t)*b.x+cos(t)*b.y;
    double tn=c.abs();
    double tmp=sqrt((b-a).abs()*(b-a).abs()+1);
    c.x=c.x/tn*tmp;
    c.y=c.y/tn*tmp;
    ansx[i]=c.x;
    ansy[i]=c.y;
    } 
  while(1){
    cin >> n;
    if(n==-1) break;
    printf("%.2f\n%.2f\n", ansx[n-1], ansy[n-1]);
  }
  return 0;
}

Measured memory_bytes: 0
import sys


def solve():
    readline = sys.stdin.readline
    H, W, M = map(int, readline().split())
    h = [0] * H
    w = [0] * W
    b = set()
    for _ in range(M):
        y, x = map(int, readline().split())
        x -= 1
        y -= 1
        h[y] += 1
        w[x] += 1
        b.add(y * W + x)
    h = sorted(zip(h, range(H)), reverse=True)
    ans = 0
    for i in range(W):
        x = w[i]
        for y, j in h:
            if x + y > ans:
                if j * W + i in b:
                    ans = x + y - 1
                else:
                    ans = x + y
                    break
            else:
                break
    print(ans)


if __name__ == '__main__':
    solve()


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

using namespace std;

int a[100005];

int main(){
      int n, h;
      scanf("%d%d", &n, &h);
      
      int mx = 0;
      
      for(int i = 0; i < n; i++){
            int x;
            scanf("%d%d", &x, &a[i]);
            mx = max(mx, x);
      }
      
      sort(a, a + n);
      reverse(a, a + n);
      
      long long res = (long long)ceil(h * 1.0 / mx);
      
      for(int i = 0; i < n; i++){
            h -= a[i];
            long long extra = 0;
            if(h >= 0)
            extra = (long long)ceil(h * 1.0 / mx);
            
            res = min(res, i + 1 + extra);
      }
      
      printf("%lld\n", res);
}

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

int main() {

    int N, K;
    cin >> N >> K;

    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }

    int num = 1;
    int dig = 0;
    while (num <= N) {
        num *= K;
        dig++;
    }

    cout << dig << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [[0] * 2 for i in range(M)]
for i in range(M):
    BC[i][0],BC[i][1] = map(int, input().split())

A.sort()
BC = sorted(BC, key=lambda x:x[1],reverse=True)

k = 0
for i in range(M):
    for j in range(BC[i][0]):
        
        if k >= N:
            print(sum(A))
            sys.exit()
        
        if A[k] < BC[i][1]:
            A[k] = BC[i][1]
            k += 1
        else:
            print(sum(A))
            sys.exit()

print(sum(A))

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

int main(){
	int a,b,ab,x,y;
	cin >> a >> b >> ab >> x >> y;
	int yen = 0;

	if(a+b <= ab*2){
		yen = x * a + y * b;
	}else{
		if(x < y){
			yen += x * ab * 2;
			if(b > ab * 2){
				yen += (y - x) * ab * 2;
			}else{
				yen += (y - x) * b;
			}
		}else{
			yen += y * ab * 2;
			if(a > ab * 2){
				yen += (x - y) * ab * 2;
			}else{
				yen += (x - y) * a;
			}
		}
	}
	
	cout << yen << endl;

	return 0;
}

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

int N;
int A[100002];
int memo[100002][4];

int dfs(int p, int t) {
	if (p == N) return 1;
	if (memo[p][t] != -1) return memo[p][t];
	int ret = 1 + dfs(p + 1, 0);
	if(t == 0) {
		if(A[p - 1] < A[p]) {
			ret = min(ret, dfs(p + 1, 1));
		}else if(A[p - 1] > A[p]) {
			ret = min(ret, dfs(p + 1, 2));
		}else {
			ret = min(ret, dfs(p + 1, 0));
		}
	}else if(t == 1) {
		if (A[p - 1] <= A[p]) {
			ret = min(ret, dfs(p + 1, 1));
		}
	}else {
		if (A[p - 1] >= A[p]) {
			ret = min(ret, dfs(p + 1, 2));
		}
	}
	memo[p][t] = ret;
	return ret;
}

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

	memset(memo, -1, sizeof(memo));
	cout << dfs(1, 0) << endl;

	return 0;
}


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

int main(){

    string S = "";
    cin >> S;

    if(S == "AAA" || S == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define FOR(i, n) for(int i = 0; i < (n); i ++)
#define CIN(type, val) type val; cin >> val;
#define COUT(val) cout << (val) << "\n";
using namespace std;

int main(void){
    CIN(int, n);
    vector<int> a(n);
    int m = -1, sum = 0;
    FOR(i, n){
        cin >> a[i];
        sum += a[i];
        m = max(m, a[i]);
    }
    
    
    
    
    COUT((m < (sum-m)) ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int main(){
	int N;
	ll x;
	cin>>N>>x;
	vector<ll> A(N);
	rep(i,N)cin>>A[i];
	sort(all(A));
	ll sum=0;
	int now=0;
	while(now<N){
		if(sum+A[now]>x)break;
		sum+=A[now];
		now++;
	}
	if(now==N&&sum!=x)now--;
	cout<<now<<endl;
}

Measured memory_bytes: 256
#define _crt_secure_no_warnings

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

int main()
{
	int N;
	cin >> N;
	for (size_t p = 0; p < N; p++)
	{
		int data[9][9];
		bool ans[9][9] = {};
		for (size_t i = 0; i < 9; i++)
		{
			for (size_t j = 0; j < 9; j++)
			{
				cin >> data[i][j];
				data[i][j]--;
			}
		}
		for (size_t i = 0; i < 9; i++)
		{
			int a[9] = {}, b[9] = {};
			for (size_t j = 0; j < 9; j++)
			{
				a[data[i][j]]++;
				b[data[j][i]]++;
			}
			for (size_t j = 0; j < 9; j++)
			{
				if (a[j] != 1)
				{
					for (size_t k = 0; k < 9; k++)
					{
						if (data[i][k] == j)
						{
							ans[i][k] = 1;
						}
					}
				}
				if (b[j] != 1)
				{
					for (size_t k = 0; k < 9; k++)
					{
						if (data[k][i] == j)
						{
							ans[k][i] = 1;
						}
					}
				}
			}
		}
		for (size_t i = 0; i < 3; i++)
		{
			for (size_t j = 0; j < 3; j++)
			{
				int c[9] = {};
				for (size_t k = 0; k < 3; k++)
				{
					for (size_t l = 0; l < 3; l++)
					{
						c[data[i * 3 + k][j * 3 + l]]++;
					}
				}
				for (size_t k = 0; k < 9; k++)
				{
					if (c[k] != 1)
					{
						for (size_t l = 0; l < 3; l++)
						{
							for (size_t m = 0; m < 3; m++)
							{
								if (data[i * 3 + l][j * 3 + m] == k)
								{
									ans[i * 3 + l][j * 3 + m] = 1;
								}
							}
						}
					}
				}
			}
		}
		for (size_t i = 0; i < 9; i++)
		{
			for (size_t j = 0; j < 9; j++)
			{
				cout << (ans[i][j] ? "*" : " ") << data[i][j] + 1;
			}
			cout << endl;
		}
		if (p != N - 1)
		{
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

int n,k,a[105],sum[N],dp[105][N];
signed main(){
    FastIO;
    cin>>n>>k;
    rep(i,1,n) cin>>a[i];
    rep(i,0,n) dp[i][0]=1;
    rep(i,1,n){
        sum[0]=dp[i-1][0];
        rep(j,1,k) sum[j]=(sum[j-1]+dp[i-1][j])%mod;
        rep(j,0,k){
            if(j>=a[i]) dp[i][j]=(sum[j]-sum[j-a[i]-1]+mod)%mod;
            else dp[i][j]=sum[j];
        }
    }
    cout<<dp[n][k];
    return 0;
}



Measured memory_bytes: 43076
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  for (int i = 0; i < n; i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while ( !q.empty() ) {
    u = q.front(); q.pop();
    for ( int v = 0; v < n; v++) {
      if (M[u][v] == 0) continue;
      if (d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << i+1 << " " << ((d[i] == INFTY) ? (-1) : d[i] ) << endl;
  }
}

int main() {
  int u, k, v;

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

  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}

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

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 200001


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

    ll n , m;
    ll ans = 1;
    cin >> n >> m;
    for (ll i = 1; i * i <= m ; i++) {
    	if (m % i == 0) {
    		ll d1 = m / i;
    		if (i * n <= m) {
    			ans = max(ans , i);
    		}
    		if (d1 * n <= m) {
    			ans = max(ans , d1);
    		}
    	}
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=1e5+10;
using namespace std;
inline ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
inline ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
inline void umax(ll &p,ll q){if(p<q)p=q;}
inline void umin(ll &p,ll q){if(p>q)p=q;}
inline ll read()
{
    ll x=0;int f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,k,t,a[maxn];
ll cnt[maxn];
vi e[maxn];
bool flag=true;
void dfs(int x,int y)
{
    if(!flag)return;
    ll p=0;
    for(int z:e[x])
    {
        if(z==y)continue;
        dfs(z,x);
        if(cnt[z]>a[x])
        {
            flag=false;
            return;
        }
        p+=cnt[z];
    }
    if((int)e[x].size()==1)
    {
        cnt[x]=a[x];
    }
    else
    {
        cnt[x]=(ll)2*a[x]-p;
        if(cnt[x]<0||cnt[x]>a[x])
        {
            flag=false;
            return;
        }
    }
}
int main()
{
    int i,j;
    scanf("%d",&n);
    rep(i,1,n)scanf("%d",&a[i]);
    rep(i,1,n-1)scanf("%d%d",&j,&k),e[j].pb(k),e[k].pb(j);
    if(n==2)
    {
        puts(a[1]==a[2]?"YES":"NO");
        return 0;
    }
    rep(i,1,n)
    {
        if((int)e[i].size()>1)
        {
            dfs(i,-1);
            if(!flag)puts("NO");
            else if(cnt[i]!=0)puts("NO");
            else puts("YES");
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 13568
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	ll a, b, k;
	scanf("%lld %lld %lld", &a, &b, &k);
	if(a >= k) {
		printf("%lld %lld\n", a - k, b);
	} else if(b - (k - a) >= 0) {
		printf("%lld %lld\n", 0, b - (k - a));
	} else {
		puts("0 0");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long n,sum=0;
    cin>>n;
    for(long i=1; i<=n; i++)
    {
        if(i%3==0 || i%5==0)
           continue;
        else
           sum=sum+i;
    }
    cout<<sum;
return 0;
}

Measured memory_bytes: 3624
def main():
    N = int(input())
    A = [None]*N
    B = [None]*N
    for i in range(N):
        A[i],B[i] = map(int,input().split())
    tmp = 0
    ans = 0
    for i in range(N-1,-1,-1):
        if (A[i]+tmp)%B[i] == 0:
            continue
        ans += (B[i] - (A[i]+tmp)%B[i])
        tmp += (B[i] - (A[i]+tmp)%B[i])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 49472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int h,w,d;
    cin>>h>>w>>d;
    pair<int,int> pos[h*w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;
            cin>>a;
            pos[a-1]={i,j};
        }
    }
    int sum[h*w]={};
    for(int i=d;i<h*w;i++){
        auto a=pos[i];
        auto b=pos[i-d];
        sum[i]=sum[i-d]+abs(a.first-b.first)+abs(a.second-b.second);
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        --l,--r;
        cout<<sum[r]-sum[l]<<endl;
    }
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll k;

int main() {
    cin >> k;

    ll n = k / 50, m = k % 50;

    Vl res(50);
    REP(i, 50) res[i] = i - m + n;
    REP(i, m) res[i] += 51;

    cout << 50 << '\n';
    REP(i, 50) {
        cout << res[i];
        if (i != 49) {
            cout << ' ';
        }
    }
    cout << '\n';

    return 0;
}


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

#define REP(i,n) for(decltype(n) i=0; i<(n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

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

using ll=long long;

void solve(){
    int n,k,x,y;
    cin>>n>>k;
    vector<pii> v;
    set<int> xs;
    set<int> ys;
    v.reserve(n);
    REP(i,n){
        cin>>x>>y;
        v.pb({x,y});
        xs.insert(x);
    }
    sort(ALL(v));
    ll ans=LLONG_MAX;
    for(int x1 : xs){
        for(int x2: xs){
            if(x2 < x1) continue;
            auto fst = lower_bound(ALL(v), pii{x1, INT_MIN});
            auto lst = lower_bound(ALL(v), pii{x2, INT_MAX});
            if(lst - fst < k) continue;
            vi ys;
            while(fst < lst)
                ys.pb((fst++)->nd);
            sort(ALL(ys));
            ll wdth = x2-x1;
            REP(i,ys.size()-k+1)
                ans=min(ans, wdth*(ys[i+k-1]-ys[i]));
        }
    }
    cout<<ans<<'\n';
}

int main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
    return 0;
}


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

#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  dsu dsu(n);
  REP(i, m) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    dsu.merge(a, b);
  }
  cout << SZ(dsu.groups()) - 1 << endl;
}

Measured memory_bytes: 9012
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>

#define ll long long

using namespace std;

int main()
{
    int D, N; cin >> D >> N;
    int base = pow(100, D);
    int target;
    if (N == 100) {
        target = base * N + pow(100, D);
    }
    else {
        target = base * N;
    }
    cout << target << endl;
}


Measured memory_bytes: 256
n,x,y = map(int,input().split())
x,y=x-1,y-1

dist = [0]*5000

for i in range(n):
    for j in range(i+1,n):
        tmp = j - i
        tmp = min(tmp,abs(i-x) + abs(y-j)+1)
        tmp = min(tmp,abs(i-y) + abs(x-j)+1)
        dist[tmp] +=1

for i in range(1,n):
    print(dist[i])

Measured memory_bytes: 49628
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int i,j,k,h,r,mat[200][2][2],stk,ans[2];
int n[2];

int main(){
	while(scanf("%d",&n)*n[0]){
		for(i=0;i<n[0];i++)scanf("%d %d",&mat[i][0][0],&mat[i][0][1]);
		mat[n[0]][0][0]=9999;mat[n[0]][0][1]=9999;
		scanf("%d",&n[1]);
		for(i=0;i<n[1];i++)scanf("%d %d",&mat[i][1][0],&mat[i][1][1]);
		mat[n[1]][1][0]=9999;mat[n[1]][1][1]=9999;

		ans[0]=n[0];ans[1]=n[1];
		for(k=0;k<2;k++){
			h=0;r=0;
			for(i=0,j=0;j<n[(k+1)%2];j++){
				while(mat[j][(k+1)%2][0]>=mat[i][k%2][0] || mat[j][(k+1)%2][1]>=mat[i][k%2][1]){
					h=mat[i][k%2][0];r=mat[i][k%2][1];
					i++;
				}
				if(mat[j][(k+1)%2][0]>h && mat[j][(k+1)%2][1]>r){
					ans[k%2]++;
					h=mat[j][(k+1)%2][0];r=mat[j][(k+1)%2][1];
				}
			}
		}

		printf("%d\n",ans[0]>ans[1]?ans[0]:ans[1]);
	}
	return 0;
}

Measured memory_bytes: 600
import datetime

a,b,c,d,e = map(int, input().split())

t1 = datetime.datetime(year=2020, month=1, day=1, hour=a, minute=b)
t2 = datetime.datetime(year=2020, month=1, day=1, hour=c, minute=d)

delta = t2 - t1
m = int(delta.seconds / 60)
print(m - e)

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

int main(){

    int x, n;
    
    cin >> x >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    int i;
    for (i = 0; i < n; i++) {
        if (p[i] == x) {
            break;
        }
    }
    if (i == n) {
        cout << x << endl;
        return 0;
    }

    int t = 1;
    int a = 1;
    int b = 1;
    while (true) {
        if (i-a >= 0 && (p[i]-t) == p[i-a]) {
            a++;
        }
        else {
            cout << p[i]-t << endl;
            return 0;
        }

        if (i+b < n && (p[i]+t) == p[i+b]) {
            b++;
        }
        else {
            cout << p[i]+t << endl;
            return 0;
        }
        t++;
    }

    return 0;
} 


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,m; cin>>n>>m;
  vector<pair<ll, ll>> p(n);
  rep(i, n) {
    ll a,b; cin>>a>>b;
    p[i] = make_pair(a,b);
  }
  sort(p.begin(),p.end());
  ll ans = 0;
  ll cnt = 0;
  rep(i, n) {
    rep(j, p[i].second) {
      if (cnt >= m) break;
      ans += p[i].first;
      cnt++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4752
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<set>
using namespace std;
typedef long long ll;
int main(){
  ll n; cin>>n;
  string s;
  cin>>s;
  vector<ll> rp,gp;
  set<ll> st;
  for(int i=0;i<n;i++){
    if(s[i]=='R') rp.push_back(i);
    else if(s[i]=='G') gp.push_back(i);
    else st.insert(i);
  }
  ll rs=rp.size(),gs=gp.size();
  ll ans=rs*gs*(n-(rs+gs));
  for(int x=0;x<rs;x++){
    for(int y=0;y<gs;y++){
      ll i=rp[x],j=gp[y];
      ll a1=(2*i-j),a2=(2*j-i);
      if(st.find(a1)!=st.end()) ans--;
      if(st.find(a2)!=st.end()) ans--;
      if((i+j)%2==0){
        if(st.find((i+j)/2)!=st.end()) ans--;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
 
const ll MOD=1000000007;
 
ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}
 
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}
 
int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}
 
ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}
 
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}
 
ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}
 
ll binom1(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

int main(){
  ll i,j,k,l,cnt=0;
  int n;
  cin>>n;
  string s[n],a[n+1],z[n+1];
  for(i=0;i<n;i++){
    cin>>s[i];
    a[i]="";
    z[i]="";
  }
  string t;
  cin>>t;
  a[n]=t;
  z[n]=t;
  for(i=0;i<n;i++){
    for(j=0;j<s[i].size();j++){
      if(s[i][j]=='?'){
        a[i]+='a';
        z[i]+='z';
      }else{
        a[i]+=s[i][j];
        z[i]+=s[i][j];
      }
    }
  }
  sort(a,a+n+1);
  sort(z,z+n+1);
  int mi,ma;
  for(i=n;i>=0;i--){
    if(t==a[i]){
      ma=i;
      break;
    }
  }
  for(i=0;i<=n;i++){
    if(t==z[i]){
      mi=i;
      break;
    }
  }
  for(i=mi;i<ma;i++)cout<<i+1<<" ";
  cout<<ma+1<<endl;
}

Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            Console.WriteLine(s.Last() == 's' ? s + "es" : s + "s");
        }
    }
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    if (a == 1 || b == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << (a * b + 1) / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt = 0;

void merge(int A[], int n, int left, int right, int mid){
    int n1 = mid - left;
    int n2 = right - mid;
    int idx_l = 0;
    int idx_r = 0;
    
    for(int i = 0; i < n1; i++) L[i] = A[left + i];
    for(int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = SENTINEL;
    R[n2] = SENTINEL;
    
    for(int i = left; i < right; i++){
        if(L[idx_l] <= R[idx_r]){
            A[i] = L[idx_l];
            idx_l++;
        }
        else{
            A[i] = R[idx_r];
            idx_r++;
        }
        cnt++;
    }
}

void mergeSort(int A[], int n, int left, int right){
    int mid;
    
    if(left + 1 < right){
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, right, mid);
    }
}

int main(){
    int A[MAX], n;
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    
    mergeSort(A, n, 0, n);
    
    for(int i = 0; i < n; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 6980
import * as fs from 'fs'
function main(input: string) {
  const lines = input.split('\n')

  const [a, b] = lines[0].split(' ').map(Number)
  // console.log({ a, b, c })

  console.log(Math.max(a + b, a - b, a * b))
}

const path = process.argv[2]
if (!path) {
  main(fs.readFileSync('/dev/stdin', 'utf8'))
} else {
  const testPath = `${path}/tests`
  const files = fs.readdirSync(testPath)
  const qn = files.length / 2
  for (let i = 1; i <= qn; i++) {
    console.log(`${testPath}/sample-${i}.in`)
    console.log('-- res')
    main(fs.readFileSync(`${testPath}/sample-${i}.in`, 'utf8'))
    console.log('-- expected')
    console.log(fs.readFileSync(`${testPath}/sample-${i}.out`, 'utf8'))
  }
}


Measured memory_bytes: 7500
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    #define int long long
    int n; cin >> n;
    int x[n], y[n], h[n];
    for(int i = 0 ; i < n ; i++) cin >> x[i] >> y[i] >> h[i];
    int ansx, ansy, ansh = -1;
    for(int cx = 0 ; cx <= 100 ; cx++) {
        for(int cy = 0 ; cy <= 100 ; cy++) {
            bool success = 1;
            int nowh = -1, maxh = 1e10;
            for(int i = 0 ; i < n ; i++) {
                int X = abs(x[i]-cx), Y = abs(y[i]-cy);
                if(h[i] == 0) maxh = min(maxh, X+Y);
                else {
                    if(nowh != -1 && nowh != h[i]+X+Y) { success = 0; break; }
                    else nowh = h[i]+X+Y;
                }
            }
            if(nowh >= 1 && nowh <= maxh && success) { ansx = cx; ansy = cy; ansh = nowh; break;}
        }
        if(ansh != -1) break;
    }
    cout << ansx << " " << ansy << " " << ansh << "\n";
}


Measured memory_bytes: 256