akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{

    Main(){
        Scanner SC = new Scanner(System.in);

        int[] A = new int[9];
        for(int y=0;y<3;y++){
            for(int x=0;x<3;x++){
                A[y*3+x] = Integer.parseInt(SC.next());
            }
        }

        int N = Integer.parseInt(SC.next());
        boolean[] C = new boolean[9];
        for(int i=0;i<N;i++){
            int b = Integer.parseInt(SC.next());
            for(int j=0;j<9;j++){
                if(A[j] == b){
                    C[j] = true;
                }
            }
        }

        for(int y=0;y<3;y++){
            for(int x=0;x<3;x++){
                if(!C[y*3+x]) break;
                if(x == 2){
                    System.out.println("Yes");
                    return;
                }
            }
        }

        for(int x=0;x<3;x++){
            for(int y=0;y<3;y++){
                if(!C[y*3+x]) break;
                if(y == 2){
                    System.out.println("Yes");
                    return;
                }
            }
        }

        if((C[0] && C[4]) && C[8]){
            System.out.println("Yes");
            return;
        }

        if((C[2] && C[4]) && C[6]){
            System.out.println("Yes");
            return;
        }

        System.out.println("No");
    }

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


Measured memory_bytes: 21716
#include <iostream>
#include<math.h>
using namespace std;

int main()
{
  int r,c;
  cin>>r;
  cin>>c;
  int grid[r+2][c+2];//={0};
  
  for(int i=0;i<=r;i++)
		{
			
			for(int j=0;j<=c;j++)
			{
			    if(j==0||i==0){grid[i][j]=0; continue;}
				
              char ch;
              cin>>ch;
				if(ch=='.')
				{
				    if(i==1&&j==1)
				{
					grid[i][j]=1;
					continue;
				}
					grid[i][j]=(grid[i-1][j]+grid[i][j-1])%(int)(pow(10,9)+7);
				}
				else if(ch=='#')
				{
					grid[i][j]=0;
					continue;
				}
			}
		}
		
		cout<<grid[r][c];
  return 0;
			
}

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

#define FOR(i,N) for(int i=0;i<N;i++)
#define ROF(i,N) for(int i=N-1;i>=0;i--)
#define ROF1(i,a,b) for(int i=(b);i>=(a);i--)
#define FOR1(i,a,b) for(int i=(a);i<=(b);i++)
#define FORi(i,a,b,c) for(int i=(a);i<=(b);i+=(c))

#define read freopen("IN.txt","r",stdin)
#define write freopen("OT.txt","w",stdout)
#define fastread {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mem(a,b)          memset(a,b,sizeof(a))
#define EPS 1e-9
#define PI              acos(-1.0)
#define INF             2e16

#define ll              long long
#define ull             unsigned long long
#define ft              first
#define sd              second
#define bn              begin
#define en              end
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define all(x) x.begin(), x.end()


#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

int main()
{
#ifdef SunWalker
    //read;
   //write;
#endif

     int n;
     double ar[100],ans;
     cin>>n;
     FOR(i,n) cin>>ar[i];
     sort(ar,ar+n);
     FOR(i,n-1)
     {
          ar[i+1] = (ar[i]+ar[i+1])/2.0;
     }
     cout<<ar[n-1]<<"\n";


return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
#coding: utf-8

N = int(input())

def num_div(n):
    ret = 0
    for i in range(1, n+1):
        if n % i == 0:
            ret+=1
    return ret

r = 0
for i in range(1, N+1, 2):
    if num_div(i) == 8:
        r += 1

print(r)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = (int)2e5 + 5;
int n, a[N], sum[N];

void init() {
  cin >> n;
  for(int i = 1 ; i <= n ; ++i) cin >> a[i];
  sum[0] = 0;
  for(int i = 1 ; i <= n ; ++i) sum[i] = sum[i - 1] + a[i];
}
void solve() {
  int ans = 1e18;
  for(int i = 1 ; i < n ; ++i) {
    ans = min(ans, abs(sum[i] - (sum[n] - sum[i])));
  }
  cout << ans << '\n';
}

int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  init();
  solve();
}


Measured memory_bytes: 3328
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <functional>
#include <queue>
#include <iostream>
#include <cmath>
#include <map>
const int maxn=1e5+10;
const int mod=1e9+7;
const double eps=1e-15;
using namespace std;
map<long long,int>mp;
int n;
int a[11];
int ans[11]={0};
void check(){
    for(int i=n-1;i>=1;i--){
        if(ans[i]/a[i]){
            ans[i-1]+=1;
            ans[i]%=a[i];
        }
    }
}
void fi(){
    for(int i=0;i<n;i++){
        printf("%c",ans[i]+'a');
    }
    printf("\n");
}
void fuck(){
    long long tmp=0;
    int vis[11]={0};
    int cnt=1;
    for(int i=0;i<n;i++){
        if(vis[ans[i]]==0){
            vis[ans[i]]=cnt++;
        }
    }
    for(int i=0;i<n;i++){
        tmp=10*tmp+vis[ans[i]];
    }
    if(mp[tmp]==0){
        fi();
        mp[tmp]=1;
    }
    
}
int main()
{

    
    cin>>n;
    for(int i=0;i<n;i++)
        a[i]=i+1;
    while(ans[0]!=1){
      
        fuck();
        ans[n-1]+=1;
        check();
    }
    
}

Measured memory_bytes: 8704
N,M=map(int,input().split())
P=[0 for i in range(M)]
Y=[0 for i in range(M)]
for i in range(M):
    P[i],Y[i]=map(int,input().split())
X=sorted([(Y[i],P[i],i) for i in range(M)])
Z=[(0,0) for i in range(M)]
T=[0 for i in range(N)]
for i in range(M):
    T[X[i][1]-1]+=1
    Z[X[i][2]]=(X[i][1],T[X[i][1]-1])
for seq in Z:
    a=max(0,6-len(str(seq[0])))
    b=max(0,6-len(str(seq[1])))
    print("0"*a+str(seq[0])+"0"*b+str(seq[1]))


Measured memory_bytes: 34520
#include <bits/stdc++.h>
using namespace std;
int n, f, a[105];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (!(a[i] & 1) && a[i] % 5 && a[i] % 3)
        {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a+1, c-1):
    if s[i-1]==s[i]=='#':
        print('No')
        sys.exit()
for i in range(b+1, d-1):
    if s[i-1]==s[i]=='#':
        print('No')
        sys.exit()
if c<d:
    print('Yes')
else:
    for i in range(b-1, d):
        if s[i-1]==s[i]==s[i+1]=='.':
            print('Yes')
            sys.exit()
    print('No')

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

int main() {
    int n ,ac=0,wa=0,tle=0,re=0;
    cin>>n;
    vector<string> vt(n);
    REP(i,n) {
        cin>>vt.at(i);
        if(vt.at(i)=="AC") ac++;
        else if(vt.at(i)=="WA") wa++;
        else if(vt.at(i)=="TLE") tle++;
        else if(vt.at(i)=="RE") re++;
    }

    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE  x "<<re<<endl;


    

    return 0;
    
    
}

Measured memory_bytes: 6416
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int a,b,c,t=0;
	cin>>a>>b>>c;
	int ans;
	while(true){
		if(t>=1000007){
			ans=-1;
			break;
		}
		if((c+60*t)%(a+b)<=a){
			ans=c+60*t;
			break;
		}
		t++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int k;

int dfs(int n, int v){
    if(n == 0){
        return v;
    } else {
        return min(dfs(n-1, 2*v), dfs(n-1, v+k));
    }
}

int main(){
    int n;
    cin >> n >> k;
    cout << dfs(n, 1) << endl;
    return 0;
}


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

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    while (scanf("%s", s) != EOF ){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        } else if (s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        } else if (s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        } else{
            push(atoi(s));
        }
    }
    printf("%d\n",pop());

    return 0;
}



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

int main() {
	string s;
	cin >> s;
	int res = 100000;
	for (int i = 0; i + 2 <= s.size(); i++) {
		int x = stoi(s.substr(i, 3));
		res = min(res, abs(x - 753));
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m, a[3001];
vector<vector<ll>> memo;
ll solve(int l, int r) {
    if(l == r) return 0;
    if (memo[l][r] != 1ll << 60) return memo[l][r];
    return memo[l][r] = max(a[l] - solve(l + 1, r), a[r - 1] - solve(l, r - 1));
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    while(cin >> n){
        memo = vector<vector<ll>>(3001, vector<ll>(3001, 1ll << 60));
        REP(i, n) cin >> a[i];
        cout << solve(0, n) << endl;
    }
    return 0;
}


Measured memory_bytes: 72960
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

typedef long long ll;

int X, Y, A, B, C;

int main() {
	priority_queue<pair<ll, int>> pq;
	cin >> X >> Y >> A >> B >> C;
	for (int i = 0; i < A; i++) {
		ll tmp;
		cin >> tmp;
		pq.push(make_pair(tmp, 0));
	}
	for (int i = 0; i < B; i++) {
		ll tmp;
		cin >> tmp;
		pq.push(make_pair(tmp, 1));
	}
	for (int i = 0; i < C; i++) {
		ll tmp;
		cin >> tmp;
		pq.push(make_pair(tmp, 2));
	}

	int sureX = 0, sureY = 0, cnt = 0;
	ll ans = 0;
	while (cnt < X + Y) {
		auto now = pq.top();
		pq.pop();

		int color = now.second;
		ll delic = now.first;
		if (color == 2)cnt++, ans += delic;
		else {
			if (color == 1) {
				if (sureY < Y) {
					sureY++, cnt++;
					ans += delic;
				}
			}
			else if (color == 0) {
				if (sureX < X) {
					sureX++, cnt++;
					ans += delic;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10604
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>
#include <regex>
#include <queue>

using namespace std;

namespace {

}

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

	vector<vector<long long>> pay(M);

	for (int i = 0; i < N; ++i) {
		int curDay, curPay;
		cin >> curDay >> curPay;
		if (curDay <= M) {
			pay[curDay - 1].push_back(curPay);
		}
	}

	priority_queue<long long> que;
	long long sum(0);
	for (int i = 0; i < M; ++i) {
		// cout << "i = " << i << endl;
		vector<long long>& curPay(pay[i]);
		for (int j = 0; j < curPay.size(); ++j) {
			que.push(curPay[j]);
		}
		// cout << "i = " << i << endl;
		if (que.size() > 0) {
			sum += que.top();
			que.pop();
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 8352
n, m = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))
ab = sorted(ab, key=lambda x: x[0])

n_drinks = 0
ans = 0

for i in range(n):
    a_yen = ab[i][0]
    b_hon = ab[i][1]

    if (m - n_drinks) >= b_hon:
        n_drinks += b_hon
        ans += a_yen * b_hon
    else:
        n_buy = m - n_drinks
        ans += a_yen * n_buy
        break

print(ans)

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

int main(){
    
    float A,B; cin >> A >> B;
    int ans = -1;

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

        if(floor(i*0.08) == A && floor(i*0.1) == B){
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a[1000],b[1000],c[1000],n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	for(i=0;i<n;i++){
		if(a[i]*a[i]+b[i]*b[i]==c[i]*c[i] || a[i]*a[i]+c[i]*c[i]==b[i]*b[i] || b[i]*b[i]+c[i]*c[i]==a[i]*a[i]){
			printf("YES\n");
		}else printf("NO\n");
	}
	
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

template <ull M> struct modular {
  using m = modular;
  ull v;
  modular() : v(0) {}
  template <typename T> modular(T a) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  template <typename T> m& operator+=(T r) { if ((v += m(r).v) >= M) v -= M; return *this; }
  template <typename T> m& operator-=(T r) { if (v < m(r).v) v += M; v -= m(r).v; return *this; }
  template <typename T> m& operator*=(T r) { v = (v * m(r).v) % M; return *this; }
  template <typename T> m& operator/=(T r) { return *this *= power(m(r), M - 2); }
  template <typename T> m operator+(T r) { m l = *this; return l += r; }
  template <typename T> m operator-(T r) { m l = *this; return l -= r; }
  template <typename T> m operator*(T r) { m l = *this; return l *= r; }
  template <typename T> m operator/(T r) { m l = *this; return l /= r; }
  template <typename T> bool operator==(T r) { return v == m(r).v; }
  friend ostream& operator<<(ostream& os, m r) { os << r.v; return os; }
  static m power(m b, ll e) {
    if (e == 0) { return 1; }
    m x = power(b * b, e / 2);
    return (e % 2) ? b * x : x;
  }
};

constexpr ull MOD = 1000000007LL;

using mint = modular<MOD>;

mint fact[200005];

mint choose(int n, int k) {
  if (k == 0) { return 1; }
  return fact[n] / fact[n - k] / fact[k];
}

int main() {
  fact[0] = 1;
  for (int i = 1; i < 200005; i++) {
    fact[i] = fact[i - 1] * i;
  }
  int N, K; cin >> N >> K;
  mint res = 0;
  for (int i = 0; i <= min(N - 1, K); i++) {
    res += choose(N, i) * choose(N - 1, N - i - 1);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int mod = 1e9 + 7;

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

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<int>> can(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            scanf("%d", &can[i][j]);
        }
    }
    vector<int> dp(1 << n); // 2^n
    dp[0] = 1;
    //~ for(int a = 0; a < n; ++a) {
    for(int mask = 0; mask < (1 << n) - 1; ++mask) {
        int a = __builtin_popcount(mask); // the number of bits set to 1
        for(int b = 0; b < n; ++b) {
            if(can[a][b] && !(mask & (1 << b))) {
                int m2 = mask ^ (1 << b);
                //~ debug() << imie(mask) imie(m2) imie(dp[mask]);
                add_self(dp[m2], dp[mask]);
            }
        }
    }
    //~ }
    printf("%d\n", dp[(1<<n)-1]);
}

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

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

typedef unsigned long long uLL;
typedef long long int LL;
const int N = 1e5 + 5;
const int inf = 1e9;
const LL INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

int main( int argc , char const *argv[] ) {
        string s;
        cin >> s;
        for( int i = 0; i < s.size(); i++ ) {
                if( s[i] == '9' ) s[i] = '1';
                else if( s[i] == '1' ) s[i] = '9';
                cout << s[i];
        }
        return 0;
}









Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int k;
	cin>>k;
	string s;
	cin>>s;
	if(s.size()<=k){
		cout<<s;
	}
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"...";
	}
}

Measured memory_bytes: 3668
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        
        long ans=0;
        long min=0;
        long max=0;
        
        for(int i=0;i<K;i++){
            min+=i;
            max+=N-i;
        }
        
        for(int i=K;i<=N+1;i++){
            ans+=max-min+1;
            ans=ans%1000000007;
            min+=i;
            max+=N-i;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35864
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, K, ans;
std::vector<int> x, y;
std::vector<char> c;
std::vector<std::vector<int>> imos;

int main()
{
	in >> N >> K;
	x.resize(N); y.resize(N); c.resize(N);
	imos.resize(K * 6);
	rep(i, imos.size()) imos[i].resize(K * 6);
	rep(i, N) in >> x[i] >> y[i] >> c[i];
	rep(i, N)
	{
		if (c[i] == 'W') y[i] += K;
		x[i] %= K * 2;
		y[i] %= K * 2;
		rep(xx, 4)
		{
			rep(yy, 4)
			{
				if ((xx + yy) % 2 == 1)
				{
					++imos[x[i] + K * xx][y[i] + K * yy];
					--imos[x[i] + K * xx][y[i] + K * yy + K];
					--imos[x[i] + K * xx + K][y[i] + K * yy];
					++imos[x[i] + K * xx + K][y[i] + K * yy + K];
				}
			}
		}
	}
	rep(i, K * 6 - 1) rep(j, K * 6) imos[i + 1][j] += imos[i][j];
	rep(i, K * 6) rep(j, K * 6 - 1) imos[i][j + 1] += imos[i][j];
	rep(i, K * 6)
	{
		rep(j, K * 6)
		{
			ans = std::max(ans, imos[i][j]);
		}
	}
	out << ans << std::endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int res;

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m; cin >> n >> m;
    
    vector<int> obs(n);
    
    for (int i = 0; i < n; ++i)
        cin >> obs[i];
        
    vector<vector<int>> spider(n);
    
    for (int j = 0; j < m; ++j)
    {
        int go, to;
        cin >> go >> to;
        
        spider[go - 1].push_back(to);
        spider[to - 1].push_back(go);
    }
    
    for (int k = 0; k < spider.size(); ++k)
    {
        bool pass = true;
        
        for (auto item : spider[k])
        {
            if (obs[k] <= obs[item - 1])
            {
                pass = false;
                break;
            }
        }
        
        if (pass)
        {
            ++res;
        }
            
    }
    
    cout << res;
}

Measured memory_bytes: 8744
#include <cstdio>

#define fin stdin
#define fout stdout
//FILE *fin=fopen("a.in", "r"), *fout=fopen("a.out", "w");

int v[100009];

int main(){
    int n;
    fscanf(fin, "%d", &n);

    for(int i=1; i<=n; i++)
        fscanf(fin, "%d", &v[i]);

    int ans=0, p=0;
    while(p<n){
        ans++;
        p+=2;
        int tip=0;
        if(p<n){
            if(v[p-1]<v[p]) tip=1;
            else if(v[p-1]>v[p]) tip=2;

            bool ok=1;
            while((p<n)&&(ok)){
                if(((tip==1)&&(v[p]>v[p+1]))||((tip==2)&&(v[p]<v[p+1]))) ok=0;
                else{
                    p++;
                    if(v[p-1]<v[p]) tip=1;
                    else if(v[p-1]>v[p]) tip=2;
                }
            }
        }
    }

    fprintf(fout, "%d\n", ans);

    fclose(fin);
    fclose(fout);
    return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  bool dp[n+1];
  REP(i, n) dp[i] = false;

  if(n<5){
    cout << "NO" << endl;
    return 0;
  }

  if(s.substr(0, 5) == "dream") dp[4] = true;
  if(s.substr(0, 5) == "erase") dp[4] = true;
  if(s.substr(0, 7) == "dreamer") dp[6] = true;
  if(s.substr(0, 6) == "eraser") dp[5] = true;

  FOR(i, 7, n){
    if(s.substr(i-4, 5) == "dream" && dp[i-5]) dp[i] = true;
    if(s.substr(i-4, 5) == "erase" && dp[i-5]) dp[i] = true;
    if(s.substr(i-6, 7) == "dreamer" && dp[i-7]) dp[i] = true;
    if(s.substr(i-5, 6) == "eraser" && dp[i-6]) dp[i] = true;
  }

  if(dp[n-1]) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


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

bool solve(int n, int a[], int i, int m) {
    if (m == 0) {
        return true;
    }
    if (i >= n) {
        return false;
    }
    return solve(n, a, i + 1, m - a[i]) || solve(n, a, i + 1, m);
}

int main() {
    int n;
    scanf("%d", &n);
    int a[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int q;
    scanf("%d", &q);
    int m;
    for (int i = 0; i < q; i++) {
        scanf("%d", &m);
        if (solve(n, a, 0, m)) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2624
#include<bits/stdc++.h>
using namespace std;
#define re register
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,a,b,dp[102][102],ans[102][102],m,dp1[102][102],ans1[102][102];
char mp[102][102];
int main(){
	n=read();m=read();
	for(re int i=1;i<=n;++i)scanf("%s",mp[i]+1);
	for(re int i=1;i<=n;++i)for(re int j=1;j<=m;++j)ans[i][j]=ans1[i][j]=1e9;
	ans[1][1]=0;
	for(re int i=1;i<=n;++i){
		for(re int j=1;j<=m;++j){
			for(re int k=0;k<=n;++k)for(re int l=0;l<=m;++l)dp[k][l]=dp1[k][l]=1e9;
			dp[i][j]=(mp[i][j]=='#'),dp1[i][j]=(mp[i][j]=='.');
			for(re int k=i;k<=n;++k){
				for(re int l=j;l<=m;++l){
					if(k==i&&l==j)continue;
					dp[k][l]=min(dp[k][l-1],dp[k-1][l]);
					
					dp1[k][l]=min(dp1[k][l-1],dp1[k-1][l]);
					
					ans[k][l]=min(ans[k][l],ans[i][j]+dp[k][l]);
					ans[k][l]=min(ans[k][l],ans[i][j]+dp1[k][l]+1);dp1[k][l]+=(mp[k][l]=='.');dp[k][l]+=(mp[k][l]=='#');
					ans1[k][l]=min(ans1[k][l],ans[i][j]+dp[k][l]);
					ans1[k][l]=min(ans1[k][l],ans[i][j]+dp1[k][l]+1);
				}
			}
		}
	}
	printf("%d",ans1[n][m]);
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

string z;
int k;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> z >> k;
  for(char &el:z){
    int pom = 'z' - el + 1;
    if(el != 'a' && pom <= k){
      k -= pom;
      el = 'a';
    }
  }
  k %= 'z' - 'a' + 1;
  while(k){
    if(z.back() == 'z')
      z.back() = 'a';
    else
      z.back()++;
    k--;
  }
  cout << z << endl;
}


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

typedef long long ll;
// #define int ll
#define pb push_back
const int INF = 1e9;

signed main(){

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


	string s; cin>>s;

	int n = s.size();

	vector<int> dp(2019,0), next(2019,0);
	int ans = 0;
	for(int i=0;i<n;i++){
		int cur = s[i] - '0';
		next[cur] = 1;
		for(int j=0;j<2019;j++){
			next[(10*j + cur)%2019] += dp[j];
		}

		for(int j=0;j<2019;j++){
			dp[j] = next[j];
          	next[j] = 0;
        }

		ans += dp[0];

	}	
	cout<<ans;
	return 0;
}


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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
template<class T> void __print( v<T> &arr ){
    int n = arr.size() ;
    cerr << "[ " ;
    for( int i = 0 ; i < n ; i++ ) {
        cerr << arr[i] ;
        if( i != n - 1 ) cerr << ", " ;
    }
    cerr << " ]" << endl ;
}
template<class T> void __print( T arr[], int n ){ 
    cerr << "[ " ;
    for( int i = 0 ; i < n ; i++ ) {
        cerr << arr[i] ;
        if( i != n - 1 ) cerr << ", " ;
    }
    cerr << " ]" << endl ;
}
#define print(x) cerr << "{ " << #x << " : " << x << " } " ;
#define println(x) cerr << "{ " << #x << " : " << x << " }" << endl ;
// Template END
int solve( int n ){
    int cnt = 0, c = 0 ;
    for( int i = 2 ; i * i <= n ; i++ ){
        c = 0 ;
        while( n % i == 0 ){
            n /= i ;
            ++c ;
        }
        if( c >= 0 ){
            cnt += floor(( -1 + sqrt(1 + 8*c) ) * 1.0 / 2) ;
        }
    }
    if( n > 2 ) ++cnt ;
    return cnt ;
}

signed main(){
    int n ; cin >> n ;
    cout << solve(n) << endl ;
    return 0 ;   
}          

Measured memory_bytes: 3680
using System;
using System.Text;

public class Test
{
	static public void Main( )
	{
		StringBuilder output = new StringBuilder();
		while( true ) {
			int[] nm = Array.ConvertAll( Console.ReadLine().Split( ' ' ), int.Parse );
			int m = nm[0];
			int f = nm[1];
			int r = nm[2];
			
			if( -1 == m && -1 ==f && -1 == r ) { break; }
			
			var sum = m+f;
			if( -1 == m || -1 == f ) {
				output.AppendLine( "F" );
			} else if( 80 <= sum ) {
				output.AppendLine( "A" );
			} else if( 65 <= sum && sum < 80 ) {
				output.AppendLine( "B" );
			} else if( 50 <= sum && sum < 65 ) {
				output.AppendLine( "C" );
			} else if( 30 <= sum && sum < 50 ) {
				if( 50 <= r ) {
					output.AppendLine( "C" );
				} else {
					output.AppendLine( "D" );      
				}
			} else {
				output.AppendLine( "F" );
			}
		}

		Console.Write( output );
	}
}

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

int main(){
  int n,i,max=0;
  int data[101];

  for(i=0;i<=100;i++){
    data[i]=0;
  }
  
  while(scanf("%d",&n)!=EOF){
    data[n]++;
  }
  
  for(i=1;i<=100;i++){
    if(max<data[i]){
      max=data[i];
    }
  }

  for(i=1;i<=100;i++){
    if(max==data[i]){
      printf("%d\n",i);
    }
  }
  
  return(0);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define bear ryan
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define ends ' '
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void debug_out(){
   cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
   cerr << " " << to_string(H);
   debug_out(T...);
}

#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] : ", debug_out(__VA_ARGS__)
#else
#define debug(...) 917
#endif

const ll inf = 1e9;
const ll mod = 998244353;

void rmax(ll& r, ll x) { r = max(r, x); }

ll power(ll a, ll b) {
    ll r = 1, t = a;
    while(b) {
        if(b & 1)   r = r * t % mod;
        t = t * t % mod;
        b >>= 1;
    }
    return r;
}

const int maxn = 3e6 + 10;

ll n;
vector<pll> a, b;

int main(void) {
    fastio;
    ll sum = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        string s;   cin >> s;
        ll mn = 0, diff = 0;
        for(auto c : s) {
            diff += (c == '(' ? 1 : -1);
            mn = min(mn, diff);
        }
        if(diff >= 0)   a.eb(diff, mn);
        else            b.eb(diff, mn);
        sum += diff;
    }
    if(sum != 0) {
        cout << "No";
        return 0;
    }
    sort(all(a), [](pll l, pll r) {
        return l.se > r.se;
    });
    sum = 0;
    for(auto t : a) {
        ll diff = t.fi, mn = t.se;
        if(sum + mn < 0) {
            cout << "No";
            return 0;
        }
        sum += diff;
    }

    sort(all(b), [](pll l, pll r) {
        return l.fi - l.se > r.fi - r.se;
    });
    for(auto t : b) {
        ll diff = t.fi, mn = t.se;
        if(sum + mn < 0) {
            cout << "No";
            return 0;
        }
        sum += diff;
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 19020
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] a = line.Trim().Split(' ');
            var ans = getAns(a);
            Console.WriteLine(ans);
        }
    }
    static double calc (string x ,Stack<double> st)
    {
        var a1 = st.Pop();
        var a2 = st.Pop();
        if (x == "+") return a1 + a2;
        else if (x == "*") return a1 * a2;
        else if (x == "-") return a2 - a1;
        else return a2 / a1;
    }
   static  double getAns ( string[] a)
    {
        var st = new Stack<double>();
        foreach (var x in a)
        {
            int b;
            if (int.TryParse(x, out b)) st.Push(b);
            else st.Push(calc(x, st));
        }
        return st.Pop();
    }
}




Measured memory_bytes: 14308
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int c[n];
    ll t, sum = 0, com = 1;
    for (int i = 0; i < n-1; i++) com *= 2;
    for (int i = 0; i < n; i++) c[i] = s[i] - '0';
    for (int bit = 0; bit < com; bit++) {
        t = c[0];
        for (int i = 0; i < n-1; i++) {
            if (bit & (1 << i)) {
                sum += t;
                t = c[i+1];
            } else {
                t *= 10;
                t += c[i+1];
            }
        }
        sum += t;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

int n ;
int res ;

inline int div ( int n )
{
	int i ;
	int res=0;
	for ( i=1 ; i<=n ; i++ ) 
		if ( n%i==0 ) res++;
	return res ;
}

int main ()
{
	int i ;
	scanf("%d",&n);
	for ( i=1 ; i<=n ; i+=2 )
		if ( div(i)==8 ) res++;
	printf("%d\n",res);
	return 0 ;
}

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

int main(){
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n%d\n", (a+b+c+d)/60, (a+b+c+d)%60);
    return 0;
}

Measured memory_bytes: 1188
n,a,b=[int(i) for i in input().split()]

s_list=[]
for i in range(1,n+1):
    s=0
    x=i
    while True:
        if x//10!=0:
            s+=x%10
            x//=10
        else:
            s+=x%10
            break
    if a<=s<=b:
        s_list.append(i)

print(sum(s_list))  

Measured memory_bytes: 9096
def getStr(vars):
    if len(vars)==N:
        print(getPrintStr(vars))
        return
    
    vars.append(0)
    for i in range(0,max(vars)+2):
        vars[-1] = i
        #print(":", i, vars)
        getStr(vars)
    del vars[-1]
    return

def getPrintStr(vars):
    ret = ""
    for i in range(len(vars)):
        ret += "abcdefghijkl"[vars[i]]
    return ret

N = int(input())
 
getStr([0])

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  vl h(n);
  rep(i, n) {
    cin >> h[i];
  }

  reverse(all(h));

  rep(i, n-1) {
    if (h[i+1] == h[i]+1) {
      h[i+1]--;
    } else if (h[i+1] > h[i]+1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
#include<functional>
using namespace std;
const int INF=1000000009;
int n,k;
int a[100005];
int l[100005],r[100005];
int par[100005];
int root;
vector<int> edge[100005];
vector<int> order;
void getara(int x,int prev)
{
	if(a[x]!=-1)
		l[x]=r[x]=a[x];
	for(int i=0;i<edge[x].size();i++)
	{
		int y=edge[x][i];
		if(y!=prev)
		{
			getara(y,x);
			if(l[y]==-INF)
				continue;
			if(l[x]==-INF)
			{
				l[x]=l[y]-1;
				r[x]=r[y]+1;
			}
			else
			{
				if(abs(l[x]%2)==abs(l[y]%2))
				{
					cout<<"No";
					exit(0);
				}
				l[x]=max(l[x],l[y]-1);
				r[x]=min(r[x],r[y]+1);
			}
		}
	}
	if(l[x]>r[x])
	{
		cout<<"No";
		exit(0);
	}
	order.push_back(x);
	par[x]=prev;
}
void getans(int x)
{
	int y=par[x];
	l[x]=max(l[x],a[y]-1);
	r[x]=min(r[x],a[y]+1);
	a[x]=l[x];
	if(abs(a[x]%2)==abs(a[y]%2))
		a[x]++;
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	memset(a,-1,sizeof(a));
	cin>>k;
	for(int i=0;i<k;i++)
	{
		int x,v;
		cin>>x>>v;
		x--;
		root=x;
		a[x]=v;
	}
	for(int i=0;i<n;i++)
	{
		l[i]=-INF;
		r[i]=INF;
	}
	getara(root,-1);
	cout<<"Yes"<<endl;
	reverse(order.begin(),order.end());
	for(int i=0;i<order.size();i++)
	{
		int x=order[i];
		if(a[x]==-1)
			getans(x);
	}
	for(int i=0;i<n;i++)
		cout<<a[i]<<endl;
	return 0;
}


Measured memory_bytes: 14712
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int Q;
    cin >> Q;
    priority_queue<ll> tail, head;
    ll med, tail_sum = 0, head_sum = 0, bias = 0;
    ll number, a, b;
    cin >> number >> a >> b;
    med = a;
    bias += b;
    tail.push(a);
    tail_sum += a;
    for (int i = 0; i < Q - 1; i++) {
        cin >> number;
        if (number == 1) {
            cin >> a >> b;
            bias += b;
            if (a >= med) {
                // cout << "pushed to head" << endl;
                head.push(-a);
                head_sum += a;
            }
            else {
                // cout << "pushed to tail" << endl;
                tail.push(a);
                tail_sum += a;
            }
            if (ll(tail.size()) - ll(head.size()) >= 2) {
                // cout << "1 is happened" << endl;
                head.push(-med);
                head_sum += med;
                tail.pop();
                tail_sum -= med;
                med = tail.top();
            }
            else if (ll(head.size()) - ll(tail.size()) >= 1) {
                // cout << "2 is happened" << endl;
                med = -head.top();
                head.pop();
                head_sum -= med;
                tail.push(med);
                tail_sum += med;
            }
            /*
            cout << "<information>" << endl;
            cout << tail_sum << ' ' << head_sum << ' ' << med << ' ' << tail.size() << ' ' << head.size() << endl;
            */
        }
        else {
            // cout << "ans = ";
            cout << med << ' ' << head_sum - ll(head.size()) * med + ll(tail.size()) * med - tail_sum + bias << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;


int main()
{
	int x, p, y;
	while (cin >> x >> y >> p) {
		if (x == 0) break;
		int ans = 0;
		for (int i = 1; i < p; i++) {
			for (int j = 1; j < p; j++) {
				if (i * (100 + x) / 100 + j * (100 + x) / 100 == p) {
					int m = j * (100 + y) / 100 + i * (100 + y) / 100;
					ans = max(ans, m);
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3056
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N, K, Q;
int a;
int A[100010];

int main(){
	cin >> N >> K >> Q;
	for (int i = 1; i <= N; i++){
		A[i] = K - Q;
	}
	for (int i = 1; i <= Q; i++){
		cin >> a;
		A[a]++;
	}
	for (int i = 0; i < N; i++){
		if (A[i + 1] > 0){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n < 1200){
    cout << "ABC" << endl;
    return 0;
  }
  if(n < 2800){
    cout << "ARC" << endl;
    return 0;
  }
  cout << "AGC" << endl;
  return 0;
}

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

int main () {
    int a, b;
    char op;
    int ans;

    cin >> a >> op >> b;
    while (op != '?') {
        if (op == '+') ans = a+b;
        else if (op == '-') ans = a-b;
        else if (op == '*') ans = a*b;
        else if (op == '/') ans = a/b;
        cout << ans << endl;
        cin >> a >> op >> b;
    }
}


Measured memory_bytes: 3080
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int N,H[30],ans=1;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> H[i];
	for (int i = 1; i < N; i++) {
		bool can = 1;
		for (int j = 0; j < i; j++) {
			if (H[i] < H[j]) { can = 0; break; }
		}
		if (can)ans += 1;
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int a = 0 ;
  int b = 0 ;
  int c = 0 ;

  std::cin >> a >> b >> c ;

  if ( a < b && b < c )
    std::cout << "Yes" << std::endl ;
  else
    std::cout << "No" << std::endl ;

  return 0 ;
}

Measured memory_bytes: 3100
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()

scnt = 0
dlt = 0

for si in s:
    if si == 'S':
        scnt += 1
        
    if scnt > 0 and si == 'T':
        scnt -= 1
        dlt += 2
        
print(len(s)-dlt)

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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> sum(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        if (i == 0)
        {
            sum[0] = v[0];
        }
        if (i > 0)
        {
            sum[i] = sum[i-1] + v[i];
        }
    }
    int minim = 9999999;
    int index = -1;
    for (int i = 0; i < n; i++)
    {
        if (abs(sum[n-1] - 2 * sum[i]) < minim)
        {
            minim = abs(sum[n-1] - 2 * sum[i]);
        }
    }
    cout << minim;

    return 0;
}


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

using ll = long long;

constexpr int inf = 1e9;

template <typename T>
class fenwick_tree {
public:
    fenwick_tree(int n_) : n(n_), dat(n, 0) {}

    void add(int i, T value) {
        for(; i < n; i |= i + 1) {
            dat[i] += value;
        }
    }

    T sum(int i) const {
        T res = 0;
        for(; i >= 0; i = (i & (i + 1)) - 1) {
            res += dat[i];
        }
        return res;
    }
    T sum(int l, int r) const {
        return sum(r - 1) - sum(l - 1);
    }

private:
    const int n;
    std::vector<T> dat;
};

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

    const ll half = n * (n + 1) / 4 + 1;
    auto check = [&] (int x) {
        const int offset = n + 1;
        fenwick_tree<ll> bit(2 * n + 2);
        bit.add(offset, 1);
        ll sum = 0, cnt = 0;
        for(int i = 0; i < n; ++i) {
            sum += (a[i] <= x ? 1 : -1);
            cnt += bit.sum(sum + offset - 1);
            bit.add(sum + offset, 1);
        }
        return cnt >= half;
    };
    int lb = -1, ub = inf + 1;
    while(ub - lb > 1) {
        const int mid = (lb + ub) >> 1;
        (check(mid) ? ub : lb) = mid;
    }

    cout << ub << endl;
}

Measured memory_bytes: 2176
n,k=map(int,input().split())
s=list(input())

if s[k-1] == 'A':
    s[k-1]='a'
elif s[k-1] == 'B':
    s[k-1] = 'b'
else:
    s[k-1]='c'
print("".join(s))

Measured memory_bytes: 3060
def print_list():
    for i,e in enumerate(A):
        if i == N - 1:
            print(e)
        else:
            print(e, end=" ")

N = int(input())
A = [int(e) for e in input().split()]
cnt = 0
for i in range(N):
    min_index = i
    for j in range(i, N):
        if A[min_index] > A[j]:
            min_index = j
    if i != min_index:
        w = A[i]; A[i] = A[min_index]; A[min_index] = w
        cnt += 1
print_list()
print(cnt)



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

using namespace std;

int n,m,pos[100000];
bool vpos[100000],v[100000];
vector<pair<int,int> > adj[100000];

bool calc(int node) {
    int mini = 0;
    int maxi = 0;
    pos[node] = 0;
    vpos[node] = 1;
    stack<int> st;
    st.push(node);
    while (!st.empty()) {
        int t = st.top(); st.pop();
        if (v[t]) continue;
        v[t] = 1;
        for (pair<int,int> neig : adj[t]) {
            if (!vpos[neig.first]) {
                pos[neig.first] = pos[t] + neig.second;
                mini = min(mini, pos[neig.first]);
                maxi = max(maxi, pos[neig.first]);
                vpos[neig.first] = 1;
                if (!v[neig.first])
                    st.push(neig.first);
            } else if (pos[neig.first] != neig.second + pos[t])
                return 0;
        }
    }
    return maxi - mini <= 1000000000;
}

int main() {
    scanf("%d%d", &n, &m);
    while (m--) {
        int l,r,d; scanf("%d%d%d", &l, &r, &d); l--; r--;
        adj[l].push_back(make_pair(r,d));
        adj[r].push_back(make_pair(l,-d));
    }
    bool exists = 1;
    memset(vpos, 0, sizeof vpos);
    memset(v, 0, sizeof v);
    for (int i = 0; i < n && exists; i++)
        if (!v[i])
            exists = exists && calc(i);
    printf("%s\n", exists ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 9600