akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int A, B, C;
   cin >> A >> B >> C;
   cout << max(0, C - (A - B)) << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N(222222);
int vst[N], msk[N], label[N];
vector<int> adj[N];
void dfs(int v) {
	vst[v] = 1;
	msk[v] = 0;
	int ban(0);
	for(int y : adj[v]) {
		if(vst[y]) continue;
		dfs(y);
		int k(msk[y] & (~((1 << label[y]) - 1)));
		for(int j(0); j <= 30; j++)
			if(msk[v] >> j & 1)
				if(k >> j & 1) 
					ban |= 1 << j;
		msk[v] |= k;
	}
	while((msk[v] >> label[v] & 1) || (1 << label[v]) <= ban) {
		label[v]++;
	}
	msk[v] |= 1 << label[v];
}
int main() {
	int n;
	scanf("%d", &n);
	for(int i(0); i < n - 1; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs(1);
	int ans(0);
	while(msk[1]) {
		ans++;
		msk[1] /= 2;
	}
	cout << ans-1 << endl;
}


Measured memory_bytes: 14848
import sys

input = sys.stdin.readline


def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    i_A = -1
    time = sum(A)
    for i, a in enumerate(reversed(A)):
        if time <= K:
            i_A = N - 1 - i
            break
        time -= a

    ans = i_A + 1
    cnt = i_A + 1
    for b in range(M):
        time += B[b]
        cnt += 1
        while True:
            if time <= K:
                break
            if i_A == -1:
                break
            time -= A[i_A]
            cnt -= 1
            i_A -= 1
        if time <= K and cnt > ans:
            ans = cnt

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39856
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
inline int rd() {int r;scanf("%d",&r);return r;}
vector<int> e[N];
int p[N],n;
void link(int a,int b) {e[a].push_back(b), e[b].push_back(a);}

void dfs(int u,int f) {
	for (int i=0;i<(int)e[u].size();i++) {
		int v=e[u][i]; if (v==f) continue;
		dfs(v,u);
	}
	if (!p[u] && !p[f]) p[u] = p[f] = 1; 
}

int main() {
	n = rd();
	for (int i=1;i<n;i++) link(rd(),rd());
	p[0] = 1;
	dfs(1,0);
	int ans = 1;
	for (int i=1;i<=n;i++) if (!p[i]) ans = 0;
	puts(!ans?"First":"Second");
	return 0;
}

Measured memory_bytes: 29184
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;


int main()
{
    int H ,W;
    cin>>H>>W;
    vector<string> v(H);
    for(int i = 0 ; i<H; i++)
        cin>>v[i];

    const int MOD = 1e9 + 7;
    vector<vector<ll> > dp(H,vector<ll> (W,0));
    dp[0][0] = 1;
    for(int i =0; i<H ; i++)
    {
        for(int j = 0; j< W; j++)
        {
            if(v[i][j]=='.'&&(i>0||j>0))
            {
                dp[i][j] = ((i > 0? dp[i-1][j] : 0) + (j> 0? dp[i][j-1] : 0))%MOD;
            }
        }
    }

    cout<<dp[H-1][W-1]<<"\n";

    
}

Measured memory_bytes: 9216
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007

c = Counter()
c[0] = 3
ans = 1

for a in A:
    ans = (ans * c[a]) % MOD
    c[a] -= 1
    c[a+1] += 1
print(ans)

Measured memory_bytes: 20960
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,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;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
char maps[100][100];
int step[100][100];
int n, m;
queue<int> q;
void GO(int x, int y, int steps)
{
    if(maps[x][y] == '#' || x <= 0 || x > n || y < 1 || y > m)return;
    if(step[x][y] > steps+1)
    {
        q.push(x);
        q.push(y);
        step[x][y] = steps+1;
    }
}
void bfs(int x, int y)
{
    memset(step, INF, sizeof(step));
    while(!q.empty())q.pop();
    step[x][y] = 0;
    q.push(x);
    q.push(y);
    while(!q.empty())
    {
        int x1 = q.front();
        q.pop();
        int yy1 = q.front();
        q.pop();
        GO(x1+1, yy1, step[x1][yy1]);
        GO(x1-1, yy1, step[x1][yy1]);
        GO(x1, yy1-1, step[x1][yy1]);
        GO(x1, yy1+1, step[x1][yy1]);
    }
}
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    cin >> maps[i]+1;
    bfs(1, 1);
    if(step[n][m] == INF)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        int sum = n*m;
        int hei = 0;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= m; j++)
            if(maps[i][j] == '#')hei++;
        }
        int ans = sum-hei-step[n][m]-1;
        cout << ans << endl;
    }
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;
    scanf("%d",&N);
    int a[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
        scanf("%d",&a[i]);
        if(a[i] % 4 == 0){
            a[i] = 2;
        }else if(a[i] % 2 == 0){
            a[i] = 1;
        }else{
            a[i] = 0;
        }
    }


    for(int i = 0; i < N; i++){
        sum += a[i];
    }
    if(sum < 2){
        printf("No");
        return 0;
    }
    if( N % 2 == 1){
        if( (N-1)/(double)sum <= 1){
            printf("Yes");
        }else{
            printf("No");
        }
    }else{
        if( N/(double)sum <= 1){
            printf("Yes");
        }else{
            printf("No");
        }
    }
    

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;


int main(){
	int n;cin >> n;
	vector<P> point(n),score(n),score2(n);
	rep(i,n) {
		cin >> point[i].first >> point[i].second;
		score[i].first = point[i].first+point[i].second;
		score[i].second = i;
		score2[i].first = -point[i].first + point[i].second;
	}
	sort(score.begin(),score.end());
	sort(score2.begin(),score2.end());
	int ans = score[n-1].first-score[0].first;
	int ans2 = score2[n-1].first - score2[0].first;
	cout << max(ans,ans2) << endl;
	
} 
 

Measured memory_bytes: 7920
#include <cstdio>
#include <cstdlib>
int main()
{
    int n;
    scanf("%d", &n);
    while (n--)
    {
        long long a[10]={};
        char s[20];
        for(int i=0;i<9;++i) {
            scanf("%s", s);
            a[i+1]=strtoll(s, 0, 16);
        }

        for(int i=0;i<32;++i) {
            unsigned x=0;
            for(int j=0;j<10;++j) {
                unsigned t=a[j]&(1u<<i);
                x^=t;
            }
            for(int j=1;j<9;++j) a[0]+=(a[j]^x)&(1u<<i);
        }
        printf("%x\n", (unsigned)a[0]^(unsigned)a[9]);
    }
}

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

int main(void){
	int n;
	cin >> n;
	while(n!=0){
		int s[n];
		int sum=0;
		for(int i = 0; i < n; i++){
			cin >>s[i];
			sum += s[i];
		}
		double m = (double)sum/n;
		double a =0;
		for(int i = 0; i < n; i++){
			a+=(s[i]-m)*(s[i]-m);
		}
		cout<<setprecision(10)<<sqrt(a/n)<<endl;
		cin >> n;
	}
	
}


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

int main(){

  int n,m,a[10000],k;

  cin >> n >> m;

  for(int i=1;i<=2*n;i++) a[i] = i;

  for(int p=0;p<m;p++){

    int x[10000] = {0}, y[10000] = {0},s = 1,t = 1;

    cin >> k;

    if(k == 0){

      for(int i=1;i<=n;i++) x[i] = a[i];

      for(int j=n+1;j<=2*n;j++) y[j] = a[j];

      s = n+1;

      for(int i=1;i<=2*n;i++){
	if(i%2 == 0){
	  a[i] = y[s];
	  s++;
	}

	if(i%2 == 1){
	  a[i] = x[t];
	  t++;
	}
      }
    }
 
    else{

      for(int i=1;i<=k;i++) x[i] = a[i];

      for(int j=k+1;j<=2*n;j++) y[j] = a[j];

      for(int i=1;i<=2*n-k;i++) a[i] = y[k+i];

      for(int j=2*n-k+1;j<=2*n;j++) a[j] = x[j-2*n+k];
    }
  }

  for(int i=1;i<=2*n;i++) cout << a[i] << endl;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i,N){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int lb=-1,ub=N;
    vector<vector<bool>> dp(N+1,vector<bool>(K,false));
    while(ub-lb>1){
        int mid=(lb+ub)/2;
        rep(i,N+1){
            rep(j,K){
                dp[i][j]=false;
            }
        }
        dp[0][0]=true;
        rep(i,N){
            rep(j,K){
                dp[i+1][j]=dp[i+1][j]||dp[i][j];
                if (j>=a[i]&&dp[i][j-a[i]]&&i!=mid){
                    dp[i+1][j]=dp[i][j-a[i]];
                }
            }
        }
        bool b=false;
        rep(i,min(K,a[mid])){
            if (dp[N][K-1-i]){
                b=true;
                break;
            }
        }
        if (b){
            ub=mid;
        }
        else {
            lb=mid;
        }
    }
    cout << ub << endl;
}

Measured memory_bytes: 3584
n, m, x = map(int, input().split())

lis = []
for i in range(n):
  li = list(map(int, input().split()))
  lis.append(li)
  
anss = [0]*2**n
for i in range(2**n):
  rikaido = [0]*m
  for j in range(n+1):
    if str(bin(i)[-j-1]) == "1":
      anss[i] += lis[j][0]
      for k in range(m):
        rikaido[k] += lis[j][k+1]
    elif str(bin(i)[-j-1]) == "b":
      for k in range(m):
        if rikaido[k] < x:
          anss[i] = 0
      break

ans = 10**10
for i in range(2**n):
  if anss[i] > 0:
    ans = min(ans, anss[i])

if ans == 10**10:
  print(-1)
else:
  print(ans)

    

Measured memory_bytes: 9296
import java.util.Scanner;
import java.lang.Math;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x = Integer.parseInt(stdIn.next());

    if (x != 2 && x % 2 == 0) x++;
    while (true) {
      int i;
      double sqrtNum = Math.sqrt(x);
      for (i = 3; i <= sqrtNum; i += 2) {
        if (x % i == 0) break;
      }
      if (i > sqrtNum) break;
      x += 2;
    }

    System.out.println(x);
  }
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/


const int mod = 1000000007;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  // 構造体の変数は public 変数であるためアクセス可能
  ll x; // typedef long long ll;

  // コンストラクタ
  mint(ll x=0):x((x%mod+mod)%mod){}

  // 単項演算子：符号やインクリメントなどを表すものなど
  // -（マイナス）演算子との区別は引数によって行う
  mint operator-() const { return mint(-x);}

  // 複合代入演算子のオーバーロード
  // *1 戻り値の型は必ず自分自身のクラスで参照を返す
  // *2 return文には「*this」を指定する
  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 {  // メンバ変数の書き換えを防ぐために引数定義のあとに 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 pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // 素数の逆元計算にのみ有効
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

const int MAX = 1000100;
mint fac[MAX], finv[MAX], inv[MAX];
// 先にこれを行うことで O(1) で nCk を求められる
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<MAX; i++){
        fac[i] = fac[i-1]*i;
        finv[i] = finv[i-1]/i;
    }
}

mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n-k];
    // cout << COM(n,k).x << endl;
}

int main()
{
    int h, w; cin >> h >> w;
    int a[h][w];
    rep(i,h) rep(j,w){
        char moji; cin >> moji;
        if(moji == '#'){
            a[i][j] = 1;
        }else{
            a[i][j] = 0;
        }
    }
    mint dp[h][w];
    rep(i,h) rep(j,w) dp[i][j] = 0;
    rep(i,h) if(a[i][0] == 0) dp[i][0] = 1; else break;
    rep(j,w) if(a[0][j] == 0) dp[0][j] = 1; else break;

    for(int i=1; i<h; i++) for(int j=1; j<w; j++){
        if(a[i][j] == 1) continue;
        dp[i][j] = (a[i-1][j]==1 ? 0: dp[i-1][j]) + (a[i][j-1]==1 ? 0: dp[i][j-1]);
    }

    cout << dp[h-1][w-1].x << endl;
}

Measured memory_bytes: 38728
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if(a.second != b.second){
    return a.second < b.second;
  }else{
    return a.first < b.first;
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin >> n >> m;
  vector<pair<int,int>> ab(n);
  REP(i,n) cin >> ab[i].second >> ab[i].first;
  sort(ALL(ab),compare_by_b);
  ll ans = 0;
  int cnt=0;
  priority_queue<pair<int,int>> q;
  FOR(day,1,m+1){
    while(ab[cnt].second==day){
      q.push(ab[cnt]);
      cnt++;
    }
    if(!q.empty()){
      pair<int,int> p=q.top();
      ans += (ll)p.first;
      q.pop();
    }
  }
    
  cout << ans << endl;
  return 0;
}


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



int main(){
    string x;
    cin>>x;
    int a[10]={};
    if(x[0]==x[1]&&x[1]==x[2]){
        puts("Yes");
        return 0;
    }
    if(x[1]==x[2]&&x[3]==x[2]){
        puts("Yes");
        return 0;
    }
    if(x[1]==x[2]&&x[2]==x[3]&&x[0]==x[1]){
        puts("Yes");
        return 0;
    }
    
    puts("No");
    return 0;
}


Measured memory_bytes: 256
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define N (ll)(1e6+3)
#define INF (ll)(1e18+3)
#define MOD (ll)(1e9+7)

#define ll long long
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define per(i,a,n) for(ll i = n-1; i >= a; i--)

//using namespace __gnu_pbds;
using namespace std;
 
// typedef
// tree<
//     pair<ll,ll>,
//     null_type,
//     less<pair<ll,ll>>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
// ordered_set;

ll n, a[N], b[N];
void solve() {
    cin >> n;
    rep(i,0,n) cin >> a[i];
    ll j = n-1;
    rep(i,0,n) {
        b[i] = a[j];
        if ((j&1) == (n&1))
            j += 2;
        else
            j -= 2;
        if (j < 0) {
            j += 1;
            if (j < 0) j += 2;
        }
    }
    rep(i,0,n) {
        cout << b[i] << " ";
    }
    cout << endl;
}


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

Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin>>N;
    vector<int>dp(3);
    for(int i=0;i<N;i++){
        vector<int>arr(3);
        vector<int>new_dp(3,0);
        for(int j=0;j<3;j++)
            cin>>arr[j];
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    new_dp[k]=max(new_dp[k],dp[j]+arr[k]);
                }
            }
        }
        dp=new_dp;
    }
    // cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2];
    cout<<max({dp[0],dp[1],dp[2]});
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int n,ans; cin>>n; int x=n%1000;
  if(n<=1000)
  {
   ans=1000-n;
  }
  else
  {
     if(n%1000==0){ans=0;} 
     else{ans=1000-x;}
  }
  cout<<ans;
}


Measured memory_bytes: 3632
import itertools

N = int(input())
Pn = tuple(map(int, input().split()))
Qn = tuple(map(int, input().split()))

all_pattern = itertools.permutations(range(1, N + 1), N)

result_map = {}
count = 0

for p in all_pattern:
    result_map[p] = count + 1
    count += 1
print(abs(result_map[Pn] - result_map[Qn]))

Measured memory_bytes: 10472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll x, t;
    cin >> x >> t;
    cout << max(0LL, x - t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
     int w, h, x, y, r;
     cin >> w >> h >> x >> y >> r;
     if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h )
       cout << "Yes" << endl;
     else
       cout << "No" << endl;
     
  
}


Measured memory_bytes: 3092
#include<iostream>

using namespace std;

int main () {

    int n, S[100000], q, T[50000], count = 0;
    int right, left, mid, i;

    cin >> n;
    for (i = 0; i < n; i++) {

        cin >> S[i];

    }

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

        cin >> T[i];

    }

    for (i = 0; i < q; i++) {

        left = 0;
        right = n;

        while (left < right) {

            mid = (left + right) / 2;

            if (S[mid] == T[i]) {

                count++;
                break;

            } else if (S[mid] > T[i]) {

                right = mid;

            } else {

                left = mid + 1;

            }

        }

    }

    cout << count << endl;

    return 0;

}

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

#define N 30
#define X 1000000

static int p[ X + 1 ] = { 1, 1 };

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

  for ( i = 2; i * i <= X; ++i )
  {
    if ( p[ i ] ) continue ;
    for ( j = i * 2; j <= X; j += i )
      p[ j ] = 1;
  }

  for ( ; ; )
  {
    int m[ X + 1 ] = { 1 };
    int n, x;

    scanf ( "%d%d", &n, &x );
    if ( n == 0 && x == 0 ) break ;
    for ( i = 0; i < n; ++i )
    {
      int d;

      scanf ( "%d", &d );
      for ( j = 0; j + d <= X; ++j )
      {
        if ( m[ j ] )
          m[ j + d ] = 1;
      }
    }

    for ( i = x; i > 0; --i )
    {
      if ( !p[ i ] && m[ i ] )
      {
        printf ( "%d\n", i );
        break ;
      }
    }
    if ( i == 0 )
      puts ( "NA" );
  }

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 8432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc144_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  bool ok = false;
  repi(i, 1, 10) repi(j, 1, 10) {
    if (i * j == N) {
      ok = true;
      break;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;
}

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

int n, m, a, b, c, f[5000];

int main() {
    cin >> n >> m;
    memset(f, 0x3f, sizeof(f));
    f[0] = 0;
    rep(i, 1, m) {
        scanf("%d%d", &a, &b);
        int t = 0;
        rep(j, 1, b) {
            scanf("%d", &c);
            t |= (1 << (c - 1));
        }
        rep(j, 0, (1 << n) - 1) {
            f[j | t] = min(f[j | t], f[j] + a);
        }
    }
    printf("%d\n", f[(1 << n) - 1] == 0x3f3f3f3f ? -1 : f[(1 << n) - 1]);
    return 0;
}


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,a[200001],s=0;

void nhap()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        s^=a[i];
    }
    for (int i=1;i<=n;++i)
    {
        cout<<(s^a[i])<<" ";
    }
}

int main()
{
    nhap();
    return 0;
}


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

using namespace std;

int main(){

  int N, M; cin >> N >> M;

  vector <pair<int, int> > AB(N);
  for (int i = 0; i < N; i++){
    int A, B; cin >> A >> B;
    AB[i] = make_pair(A, B);
  }
  sort(AB.begin(), AB.end());

  int ans = 0, day = 1;
  priority_queue <int> que;

  for (int i = 0; i < N && AB[i].first <= M; i++){
    if(AB[i].first == day){
      que.push(AB[i].second);
    }else if(AB[i].first > day){
      while(AB[i].first > day){
        if(!que.empty()){
          int sum = que.top(); que.pop();
          ans += sum;
        }
        day++;
      }
      i--;
    }
  }
  
  for (int i = 0; i < M - day + 1; i++){
    if (!que.empty()){
      int sum = que.top(); que.pop();
      ans += sum;
    }else break;
  }
  

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


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int mat[3][3];
     for(int i=0;i<3;i++)
      for(int j=0;j<3;j++)
        cin>>mat[i][j];

         int n;
          cin>>n;

        set<int>p;
          for(int i=1;i<=n;i++)
          {
              int x;
               cin>>x;

               p.insert(x);
          }

             int count  =0;
             int g = 0;
         for(int i=0;i<3;i++)
          {
              int ele  =0;
            for(int j=0;j<3;j++)
           {
               if(p.find(mat[i][j])!=p.end())
                  ele++;

                if(i==j)
                 {
                    if(p.find(mat[i][j])!=p.end())
                     g++;
                 }
           }

               if(ele==3)
                  count++;

                ele = 0;
                for(int j=0;j<3;j++)
                {
                   if(p.find(mat[j][i])!=p.end())
                      ele++;
                }
                   if(ele==3)
                     count++;

            }

                int r =2;
                int e=0;
              for(int i=0;i<=2;i++)
              {
                 if(p.find(mat[i][r-i])!=p.end())
                   e++;
              }
                if(e==3)
                  count++;

            if(g==3 || count > 0)
             cout<<"Yes";

             else
             cout<<"No";

}


Measured memory_bytes: 256
n,m,q=map(int,input().split())
LR = [list(map(int,input().split())) for i in range(m)]
PQ = [list(map(int,input().split())) for i in range(q)]
#print(LR,PQ)

d = [[0]*n for i in range(n)]

for i in range(m):
    l = LR[i][0]-1
    r = LR[i][1]-1
    d[l][r] += 1
#print(d)

c = [[0]*n for i in range(n)]
for i in range(n):
    for j in range(n):
        if j == 0:
            c[i][j] = d[i][j]
        else:
            c[i][j] = c[i][j-1] + d[i][j]
#print(c)
for i in range(q):
    l = PQ[i][0]-1
    r = PQ[i][1]-1
    res = 0
    for j in range(l,r+1):
        if j == 0 or l == 0:
            res += c[j][r]
        else:
            res += (c[j][r]-c[j][l-1])
    print(res)

Measured memory_bytes: 116312
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::vector<bool> b(k + 1);
    // for (int i = 0; i < a[0]; i++) b[i] = 0;
    for (int i = 0; i <= k; i++) {
        bool flg = false;
        for (auto el : a) {
            if (el > i) break;
            if (!b[i - el]) {
                flg = true;
                break;
            }
        }
        b[i] = flg;
    }

    std::cout << (b[k] ? "First" : "Second") << std::endl;

    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
     input = input.split("\n");
  var n= parseInt(input[0], 10);
    var tmp = input[1].split(" ");
     var ar = [];
for (var i = 0; i < n ; i++){
  var r= parseInt(tmp[i], 10);
   ar[i] = r;}
  
 // console.log(ar);
//  console.log(n);
  if( n == 2){var z =ar[0]-ar[1];
            console.log(Math.abs(z)); 
            } else{     
  
  sum = ar.reduce((a,x) => a+=x,0);
 var total = ar[0];
  var total2 = 0;
  for(i =0;i<=n;i++){  if (total < sum /2){ var t = total;
                                            var t2 = sum -t;
                                            var total = total+ar[i+1];
                                         // console.log(total,ar[i+1]);
                                            } else{//console.log(total);
                                             var total2 = sum - total;
                                                       break;}
                    }
                    }
       //             console.log(t,t2);
       //           console.log(total,total2);
  if (n == 3){z =total - total2;
               //   console.log (z);
                  console.log(Math.abs(z));}
                  else{
             
  P = total - total2;
                   x =( total +ar[i+2]);
        //           console.log(i,ar[i]);
                   Q = t - t2; 
       //            console.log(P,Q);
                   P =Math.abs(P);
                   Q =Math.abs(Q);
                   if (P < Q){console.log(P);}else{console.log(Q);}
                                                               
                }  
 }
   //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int ans = 0;
    if (s.equals("SSS"))
      ans = 0;
    if (s.equals("SSR"))
      ans = 1;
    if (s.equals("SRS"))
      ans = 1;
    if (s.equals("SRR"))
      ans = 2;
    if (s.equals("RSS"))
      ans = 1;
    if (s.equals("RSR"))
      ans = 1;
    if (s.equals("RRS"))
      ans = 2;
    if (s.equals("RRR"))
      ans = 3;
    System.out.println(ans);
    sc.close();
  }
}


Measured memory_bytes: 35576
#初期値の挿入
list_xy = list(map(int, input().split()))
result_data = [[0 for y in range(list_xy[1]+1)] for x in range(list_xy[0]+1)] 

#表dataの入力と計算
for x in range(list_xy[0]):
    input_data = list()
    input_data = list(map(int, input().split()))
    for y in range(list_xy[1]):
        result_data[x][y] = input_data[y]
        result_data[x][list_xy[1]] += input_data[y]
        result_data[list_xy[0]][y] += input_data[y]
    result_data[list_xy[0]][list_xy[1]] += result_data[x][list_xy[1]]

#計算結果の表示
for a in result_data:
    print(*a)



Measured memory_bytes: 6212
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 998244353;

int dp[2][3005][3005];
int a[3005];
int n,k;

void add(int &a, int b)
{
    a += b;
    if (a >= mod) a %= mod;
}

int solve(bool start, int i, int sum)
{
    int &res = dp[start][i][sum];
    if (sum == k) return n - i + 2;
    if (sum > k || i > n) return 0;
    if (res != -1) return res;
    res = 0;
    add(res, solve(start, i + 1, sum));
    int num;
    if (start) num = solve(true, i + 1, sum + a[i]);
    else num = i * solve(true, i + 1, sum + a[i]);
    add(res, num);
    return res;
}

signed main()
{
    //freopen("file.inp","r",stdin);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 1, 0);
    return 0;
}


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

int n;
vector<long long> a;
long long ans = 1e18+9;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		long long t;
		cin >> t;
		a.push_back(t);
	}
	for(int i=1; i<n; ++i)
		a[i] += a[i-1];
	for(int i=0; i<n-1; ++i)
		ans = min(ans, abs(a[i] - (a[n-1] - a[i])));
	cout << ans << "\n";
}

Measured memory_bytes: 2420
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll l,r,d;cin>>l>>r>>d;
  rep(i,l,r+1)if(i%d==0)res++;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define readInt(x) scanf_s("%d", &x)
#define readStr(x) scanf_s("%s", x)
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmax(x, y) (x > (y) ? x : x = (y))
#define chmin(x, y) (x < (y) ? x : x = (y))
#define write(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1 << 29;
const int MAX = 1e5 + 10;

ll N;

int main()
{
    cin >> N;

    int limit = (to_string(N).size() - 1) / 2 + 1;
    int ans = to_string(N).size();
    int max = sqrt(N) + 5;
    for (int i = 1; i < max; i++) {
        if (N % i == 0) {
            int q = N / i;
            int val = std::max(to_string(i).size(), to_string(q).size());
            if (val < ans) {
                ans = val;
                if (ans == limit) break;
            }
        }
    }
    write(ans);
}

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

int main() {
  int N, Q;
  cin >> N >> Q;

  int time = 0;

  queue<pair<string, int>> q;

  for (int i = 0; i < N; i++) {
    pair<string, int> tmp;
    cin >> tmp.first >> tmp.second;
    q.push(tmp);
  };

  while(!q.empty()) {
    string pn = q.front().first;
    int lt = q.front().second;
    q.pop();
    if (lt <= Q) {
      time += lt;
      cout << pn << ' ' << time << endl;
    } else {
      time += Q;
      pair<string, int> lp{ pn, lt - Q };
      q.push(lp);
    }
  }
};



Measured memory_bytes: 6264
#include <stdio.h>
int main(){

  int d[6],i,blank;
  char ENSW[100];

  for(i = 0; i < 6; i++){

    scanf("%d",&d[i]);

  }

  scanf("%s",ENSW);
  
  for(i = 0; ENSW[i] != '\0'; i++){

    if(ENSW[i] == 'N'){

      blank=d[0];
      d[0]=d[1];
      d[1]=d[5];
      d[5]=d[4];
      d[4]=blank;

    }

    if(ENSW[i] == 'E'){

      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;

    }

    if(ENSW[i] == 'S'){

      blank=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=blank;

    }

    if(ENSW[i] == 'W'){

      blank=d[0];
      d[0]=d[2];
      d[2]=d[5];
      d[5]=d[3];
      d[3]=blank;

    }

  }
  
  printf("%d\n",d[0]);

  return 0;

}

Measured memory_bytes: 596
n = int(input())
s = input()

r, g, b = [0, 0, 0]

for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1

ans = r*g*b

for i in range(n):
    m = min(i, n-i-1)
    for j in range(m+1):
        if s[i] != s[i+j] and s[i] != s[i-j]:
            if s[i+j] != s[i-j]:
                ans -= 1

print(ans)

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

int main(){
  int N,c=0;
  cin >> N;
  string S;
  cin>>S;
  if(N==S.length()){
  for(int i=0; i<S.length();i++){
    if(S[i]=='A'){
      if(S[i+1]=='B'){
        if(S[i+2]=='C'){
          c++;
        }
      }
    }
  }
    cout<<c<<endl;
  }

}

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

int main(){
    int n;
    cin >> n;
    
    int a[n], i, min, max;
    long s = 0;
    
    cin >> a[0];
    min = a[0];
    max = a[0];
    s += a[0];
    
    for(i = 1; i < n; i++){
        cin >> a[i];
        if(min > a[i]) min = a[i];
        if(max < a[i]) max = a[i];
        s += a[i];
    }
    
    cout << min << " " << max << " " << s << endl;
    
    return 0;
}


Measured memory_bytes: 3144
#include<stdio.h>
#include<string.h>
#define MAXS 200
char s[MAXS];
char qs[MAXS];
void qupop(int shn,int mode,int len){
    int i;
    if(mode == 1){
        for(i = 0;i < shn;i++){
            qs[i] = s[i];
        }
        for(i = shn;i < len;i++){
            s[i-shn] = s[i];
        }
    }
    else{
        for(i = shn;i < len;i++){
            s[i-shn] = s[i];
        }
    }
}
void qupush(int shn,int len){
    int i;
    for(i = shn;i >= 0;i--){
        s[len-i] = qs[shn-i];
    }
}
int main(){
    while(1){
        scanf("%s",s);
        if(s[0] == '-'){
            break;
        }
        size_t len = strlen(s);
        int sh;
        scanf("%d",&sh);
        int i,j;
        for(i = 0;i < sh;i++){
            int shn;
            scanf("%d",&shn);
            qupop(shn,1,len);
            qupush(shn,len);
            for(j = 0;j < len;j++){
                qs[j] = 0;
            }
        }
        printf("%s\n",s);
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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 ll INF = 1e18;
// const ll MOD = 998244353;
const ll MX = 1000001;
ll MOD;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;

int N;
string S;
map<ll, ll> cnt;
ll ans;

void solve() {
    cin >> N >> MOD >> S;
    reverse(S.begin(), S.end());
    if (MOD != 2 && MOD != 5) {
		cnt[0] = 1;
		ll cur = 0;
		for (int i = 0; i < N; i++) {
			cur += modMul(modExp(10, i), S[i] - '0'); cur %= MOD;
			// cout << S[i] - '0' << " " << cur << "\n";
			ans += cnt[cur]++;
		}
	} else {
		for (int i = 0; i < N; i++) {
			if ((S[i] - '0') % MOD == 0) {
				ans += N - i;
			}
		}
	}
	cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


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

using namespace std;
#define int long long 
int n,a[200005],f[200005];
main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[max(i-2,1ll)]+abs(a[i]-a[max(i-2,1ll)]));
	}
	cout<<f[n];
}

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

int main(){
	int n, x1,y1,x2,y2, ans = 0, mmax = 1000;
	cin >> n;
	vector<vector<int>> a(2000,vector<int>(2000,0));
	for(int i = 0;i<n;i++){
		cin >> x1 >> y1 >> x2 >> y2;
		x2--;
		y2--;
		a[x1][y1]++;
		a[x1][y2+1]--;
		a[x2+1][y1]--;
		a[x2+1][y2+1]++;
	}
	for(int i = 0;i<mmax + 1;i++){
		a[0][i+1] = a[0][i] + a[0][i+1];
		if(ans < a[0][i]) ans = a[0][i];
	}
	for(int i = 1;i<mmax + 1;i++){
		for(int j = 0;j<mmax;j++){
			a[i][j+1] = a[i][j] + a[i][j+1];
			a[i][j] = a[i][j] + a[i-1][j];
			if(ans < a[i][j]) ans = a[i][j];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18748
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cassert>
#define maxn 
#define maxm 
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
//#define DEBUG
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	int max = 0, sum = 0, x;
	rep(i, 1, n) {
		scanf("%d", &x);
		if (x >= max) sum++, max = x;
	}
	printf("%d", sum);
}

Measured memory_bytes: 128
A[10000],B[10000];z(int*a,int*b){return*b-*a;}
main(n,i,j){for(;scanf("%d",&n),n;puts(i>n?"No":"Yes")){
for(i=0;i<n;i++)scanf("%d",A+i);
for(i=0;i<n;i++)scanf("%d",B+i);
for(i=qsort(A,n,4,z);i<n;A[i++]?i=n+1:1)for(j=0;j<n;j++)if(B[j])A[i]--,B[j]--;
}exit(0);}

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

int main(){
    string s;
    cin >> s;
    int flaga = 0;
    int flagb = 0;
    int flagc = 0;

    for(int i = 0; i < 3; i++){
        if(s[i] == 'a'){
            flaga++;
        }    
         if(s[i] == 'b'){
            flagb++;
        }  
         if(s[i] == 'c'){
            flagc++;
        }  
    }

    if(flaga == 1 && flagb == 1 && flagc == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const int N = 200006;
const ll INF = 1e18;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll tot = 1;
    for(int i = 1; i <= n; i++) {
        tot *= 10;
        tot %= mod;
    }

    ll sub = 1;
    for(int i = 1; i <= n; i++) {
        sub *= 9;
        sub %= mod;
    }
    sub *= 2;
    sub %= mod;
    ll add_again = 1;
    for(int i = 1; i <= n; i++) {
        add_again *= 8;
        add_again %= mod;
    }

    tot = (tot - sub + mod) % mod;
    tot = (tot + add_again) % mod;
    cout << tot << '\n';
    return 0;
}

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

int main() {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	int A = A1 + A2 + A3;
	if(A >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int p=111,xs[17],xp,x;
int main(){
	for(int i=1;i<=9;i++) xs[++xp]=p*i;
	scanf("%d",&x);
	printf("%d\n",*lower_bound(xs+1,xs+1+xp,x));
	return 0;
}

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

int main(){
  int n; cin>>n;
  double sum = 0;
  vector<double> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=1/a[i];
  }
  cout<<1/sum<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            string[] line = S.Split(' ');
            int ans = 0;
            int[] H = new int[N];
            int srh = 0;

            for(int i=0; i<N; i++)
            {
                H[i] = int.Parse(line[i]);
                if(H[i] >= srh)
                {
                    ans++;
                    srh = H[i];
                }
            }
            
            Console.WriteLine(ans);


        }
    }
}

Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void print_vector(vector<int> v){
  for(int i = 0; i < (int)v.size(); i++){
	  if (i == (int)v.size() - 1) cout << v[i];
	  else cout << v[i] << " ";  
	}
  cout << endl;	
}

void solve(){
  	map<string, int> m;
  	int q;
  	cin >> q;
  	for(int i = 0; i < q; i++){
	  int cmd ;
	  cin >> cmd;
	  if (cmd == 0){
		  string s;
		  int key;
		  cin >> s >> key;
		  m[s] = key;  
		}
	  if (cmd == 1){
		  string s;
		  cin >> s;
		  if(m.find(s) == m.end()) cout << 0 << endl;
		  else cout << m[s] << endl; 
		}
	  if (cmd == 2){
		   string s;
		   cin >> s;
		   m.erase(s);
		}	
	} 
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 25960
#include<bits/stdc++.h>
using namespace std;
int MIN=9999;
string S;
long long int MOD = 1000000007;
const int MAX = 1000001;
long long int fac[MAX],finv[MAX], inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<MAX;i++){
        fac[i] = fac[i-1]* i % MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long COM(int n,int k){
    if(n < k)return 0;
    if(n < 0 || k< 0)return 0;
    return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
}

int main(){
    long long int N,K,p[200001],sum[200002],ksum[200002];
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    for(int i=0;i<200002;i++){
        ksum[i] = 0;
        sum[i] = 0;
    }
    for(int i=0;i<N;i++){
        sum[i+1] = sum[i] + p[i];
    }
    for(int i=0;i+K<=N;i++){
        ksum[i+K] = sum[i+K] - sum[i];
    }
    long long int index,M=-999;
    for(int i=0;i+K<=N;i++){
        if(ksum[i+K] >= M){
            M = ksum[i+K];
            index = i+K;
        }
    }
    printf("%.16lf\n",(M+K)/2.0);
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll tot = a[0];
    reps(i, 1, n) tot = tot ^ a[i];
    vector<ll> ans(n);
    rep(i, n) ans[i] = tot ^ a[i];
    rep(i, n) printf("%lld%s", ans[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 6296