akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
/*
	Source: AtCoder Beginner Contest 054
	Author: fts2001 (the_silliest)
 */
using namespace std;
int a,b;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b;
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b)cout<<"Alice\n";
    else if(a<b)cout<<"Bob\n";
    else cout<<"Draw\n";
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int cnt = 0;

    rep(i, n){
        if((i+1)%2 == 1 && a.at(i)%2 == 1){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string>
#include<iostream>
using  namespace  std;
int  main ()
{
  string  s ;
  cin>>s ;
  if  ( s.size() == 2) cout<<s<<endl ;
else  cout<<s [ 2 ]<<s [ 1 ]<<s [ 0 ]<<endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }

int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for(ll& i : a) cin >> i;
    for(ll& i : b) cin >> i;
    ll at = 0, sum = 0, cnt = 0;
    while(at < n && sum + a[at] <= k){
        cnt++;
        sum += a[at];
        at++;
    }
    ll ans = cnt;
    for(ll i : b){
        cnt++;
        sum += i;
        while(at && sum > k){
            at--;
            sum -= a[at];
            cnt--;
        }
        if(sum > k) break;
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6356
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define F first
#define S second
typedef pair<int,int> pii;
typedef long long ll;

int main(){
	int n,m,ans=0; cin>>n>>m;
	vector<int> B[m];
	int arr[m];
	for(int i=0; i<m; i++){
		int t; cin>>t;
		for(int j=0; j<t; j++){
			int x; cin>>x;
			B[i].push_back(x);
		}
	}
	for(int i=0; i<m; i++){
		cin>>arr[i];
	}
	for(int mask=0; mask<(1<<n); mask++){
		bool pass=true;
		for(int i=0; i<m; i++){
			int cnt=0;
			for(auto x: B[i]){
				x--;
				if((mask>>x) & 1)cnt++;
			}
			if(cnt%2 != arr[i])pass=0;
		}
		if(pass)ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3604
/*
 *  author: chw0501
 *  reference: 
 *  created: 18.04.2020 11:07:35(UTC)
*/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int h[200000];
ll a[200000];

int s=1;
ll seg[800000];

void update(int pos,ll val){
	pos+=s;
	while(pos>0){
		seg[pos]=max(seg[pos],val);
		pos/=2;
	}
}

ll query(int l,int r){
	l+=s; r+=s;
	ll ret=0;
	while(l<=r){
		if(l%2==1) ret=max(ret,seg[l++]);
		if(r%2==0) ret=max(ret,seg[r--]);
		l/=2; r/=2;
	}
	return ret;
}

//dp[i]: i번째 꽃까지 이용해서 얻을 수 있는 최대 뷰티
ll dp[200000];

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",h+i);
		h[i]--;
	}
	for(int i=0;i<n;i++){
		scanf("%lld",a+i);
	}
	while(s<n) s*=2;
	for(int i=0;i<n;i++){
		dp[i]=query(0,h[i]-1)+a[i];
		update(h[i],dp[i]);
	}
	cout<<*max_element(dp,dp+n);
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
using P = pair<int,int>;

int main()
{
    map<int,int> m;
    int N,ans=0;
    cin>>N;
    rep(i,N){
        int d;cin>>d;
        if(m[d]==0){
            m[d]=1;
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;

int n,m,d[25][25],Ans;
char s[25][25];
const int dx[]={-1,1,0,0},dy[]={0,0,-1,1};

void BFS(int sx,int sy)
{
    memset(d,0,sizeof d);
    std::queue<int> qx,qy;
    qx.push(sx),qy.push(sy);
    d[sx][sy]=1;
    while(!qx.empty())
    {
        int nx=qx.front(),ny=qy.front();
        qx.pop(),qy.pop();
        for(int i=0;i<4;++i)
        {
            int wx=nx+dx[i],wy=ny+dy[i];
            if(wx<1||wx>n||wy<1||wy>m||s[wx][wy]=='#')continue;
            if(!d[wx][wy])d[wx][wy]=d[nx][ny]+1,qx.push(wx),qy.push(wy);
        }
    }
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            if(d[i][j])
                Ans=std::max(Ans,d[i][j]-1);
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            if(s[i][j]=='.')
                BFS(i,j);
    printf("%d\n",Ans);
    return 0;
}


Measured memory_bytes: 256
N,L = map(int,input().split())

taste = [L+i-1 for i in range(1,N+1)]
n_applepie = sum(taste)

for i in range(len(taste)):
    taste[i] = n_applepie - taste[i]

ans_index = 0
for i in range(len(taste)):
    if abs(taste[i]-n_applepie) < abs(taste[ans_index]-n_applepie):
        ans_index = i

print(taste[ans_index])

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

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    for (int i=0; i<n; i++) cin>>a[i];
    vector<int> id(n);
    iota(id.begin(), id.end(),0);
    sort(id.begin(), id.end(), [&](int i, int j){
        return a[i] > a[j];});   
    for (int i=0; i<n; i++){
        if (a[i]==a[id[0]]) cout<<a[id[1]]<<endl;
        else cout<<a[id[0]]<<endl;
    }
}


Measured memory_bytes: 5560
n = int(input())
s = str(n)
l = len(s)
ans = 0
for i in range(1, l + 1):
    if i % 2 == 1:
        ans += (10 ** i) - (10 ** (i - 1))
        if i == l:
            ans -= (10 ** i) - n - 1
print(ans)


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> t(n);
    int tot=0;
    rep(i,n){
        cin>>t[i];
        tot+=t[i];
    }
    int m;cin>>m;
    rep(i,m){
        int x,y;cin>>x>>y;x--;
        int buf=t[x]-y;
        cout<<tot-buf<<endl;
    }
}


Measured memory_bytes: 3596
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int n = in.nextInt();
		int[][] a = new int[2][n];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = in.nextInt();
			}
		}
		
		int best = 0;
		for (int i = 0; i < n; i++) {
			int ans = 0;
			for (int j = 0; j <= i; j++) {
				ans += a[0][j];
			}
			for (int j = i; j < n; j++) {
				ans += a[1][j];
			}
			best = Math.max(best, ans);
		}
		out.println(best);
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


Measured memory_bytes: 21332
import math
n, k = [int(item) for item in input().split()]
max_n_k = max(n,k)
tk = k

logs = [0] * (max_n_k+1)
cnt = 0
while tk > 1:
    tk /= 2.0
    cnt += 1
    logs[int(math.ceil(tk))] = cnt 

cur = 0
for i in range(k+1):
    if logs[i] == 0 and i != k:
        logs[i] = cur
    if i == k:
        logs[i] = 0
        cur = 0
    else:
        cur = logs[i]

ans = 0
for i in range(1, n+1):
    ans += 1.0 / n * pow(0.5, logs[i])
print(ans)


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

int main(){
    int n;  cin >> n;
    n *= 3;

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

    sort(a.begin(), a.end(), greater<ll>());

    ll ans(0);
    for(int i=0;i<n/3;i++){
        ans += a[2*i+1];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5520
import numpy as np
N,L = list(map(int, input().split()))
l_num = np.arange(L,(L+N))
wa = np.sum(l_num)
if any(l_num<0):
	print(wa + np.min(np.abs(l_num)))
else:
	print(wa-np.min(np.abs(l_num)))


Measured memory_bytes: 12484
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{		
		GetString();
		string str = GetString();
		GetString();
		Console.WriteLine("A" + str[0].ToString() + "C");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
import math
H,W=map(int,input().split())
if W==1:
    print(1)
else:
    if H==1:
        print(1)
    else:
        if H % 2 == 0:
            a = math.ceil(W / 2)
            b = math.floor(W / 2)
            c = H / 2
            print(int(a * c + b * c))
        else:
            a = math.ceil(W / 2)
            b = math.floor(W / 2)
            c = math.ceil(H / 2)
            d = math.floor(H / 2)
            print(int((a * c + b * d)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  string s;
  cin >> s;
  i64 cnt[3] = {};
  for (i64 i = 0; i < s.size(); i++)
    cnt[s[i] - 'a']++;
  if (1 < max({cnt[0], cnt[1], cnt[2]}) - min({cnt[0], cnt[1], cnt[2]}))
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

int main() {
    ll r, g, b, n; cin >> r >> g >> b >> n;
    ll cnt = 0;
    REP (x, n + 1) {
        REP (y, n + 1) {
            ll z = (n - x * r - y * g) / b;
            cnt += (z >= 0 and x * r + y * g + z * b == n);
        }
    }
    cout << cnt << endl;
    return 0;
}


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

#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif

//{{{
using namespace std;
typedef long long LL;
typedef vector<int> VI;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x; while
(getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}

int a[22][22];
int n;

LL dp[1 << 16];
LL val[1 << 16];

LL dfs(int st)
{
    if (dp[st] != -1) return dp[st];

    if (__builtin_popcount(st) == 1) return dp[st] = 0;

    LL ret = val[st];
    for (int i = st; i; i = (i - 1) & st)
    {
        if (i == st) continue;
        int st1 = i;
        int st2 = st ^ i;

        LL v = dfs(st1) + dfs(st2);
        if (v > ret) ret = v;
    }
    return dp[st] = ret;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
// freopen("out", "w", stdout);
#endif

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

        int lim = (1 << n) - 1;
        for (int st = 0; st <= lim; st++)
        {
            LL v = 0;
            for (int i = 0; i < n; i++)
            {
                if ((st & (1 << i)) == 0) continue;
                for (int j = i + 1; j < n; j++)
                {
                    if ((st & (1 << j)) == 0) continue;
                    v += a[i][j];
                }
            }
            val[st] = v;
        }

        clr(dp, -1);
        dp[0] = 0;
        LL ans = dfs(lim);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 4596
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int OK =0;
    for (int i =A; i<=B; i++) {
      if (i % K == 0) {
        OK++;
        break;
      }
    }
    if (OK == 1) {
      System.out.println("OK");
    } else {
      System.out.println("NG");
    }
  }
}

Measured memory_bytes: 27008
n = int(input())
H = list(map(int, input().split()))
for i in reversed(range(1, n)):
    if H[i-1] - H[i] > 1:
        print("No")
        exit()
    else:
        if H[i-1] - H[i] == 1:
            H[i-1] -= 1
print("Yes")


Measured memory_bytes: 14396
#include <stdio.h>

int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	if (a > b)
		printf("%d\n", 2 * a - 1);
	else if (a == b)
		printf("%d\n", 2 * a);
	else
		printf("%d\n", 2 * b - 1);

	return 0;
}


Measured memory_bytes: 128
import math
N = int(input())
monsters = list(map(int, input().split()))
aaaa = list(map(int, input().split()))
totalMonsters=sum(monsters)
aliveMonsters = monsters[0]
for i in range(N):
    monsters[i], aaaa[i] = max(monsters[i]-aaaa[i], 0), max(aaaa[i] - monsters[i], 0)
    monsters[i+1] = max(monsters[i+1]-aaaa[i], 0)
print(totalMonsters-sum(monsters))



Measured memory_bytes: 19244
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    ll A[N+2]={0};
    FORI(i,1,N+1)
    {
        cin>>A[i];
    }
    ll dp1[N+2]={0};
    ll dp2[N+2]={0};
    FORI(i,1,N+1)
    {
        dp1[i]=__gcd(A[i],dp1[i-1]);
    }
    FORD(i,N,0)
    {
        dp2[i]=__gcd(A[i],dp2[i+1]);
    }
    ll ans=1;
    FORI(i,1,N+1)
    {
        ans=max(ans,__gcd(dp1[i-1],dp2[i+1]));
    }
    cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


  
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  int ans = 0;
  string bef,now;

  for(int i = 0;i < S.size();i++) {
    now.push_back(S.at(i));
    if(now != bef) {
      bef = now;
      now.clear();
      ans++;
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 640
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<ll, vector<ll>, greater<ll>> A;
    rep(i, N) {
        ll a;
        cin >> a;
        A.push(a);
    }

    vector<pair<ll, ll>> B;
    rep(i, M) {
        ll b, c;
        cin >> b >> c;
        B.push_back({b, c});
    }

    sort(all(B),
         [](pair<ll, ll> a, pair<ll, ll> b) { return a.second > b.second; });

    ll res = 0;
    for (auto b : B) {
        rep(j, b.first) {
            ll a = A.top();
            if (a < b.second) {
                A.pop();
                A.push(b.second);
            } else {
                while (!A.empty()) {
                    res += A.top();
                    A.pop();
                }
                cout << res << endl;
                return 0;
            }
        }
    }

    while (!A.empty()) {
        res += A.top();
        A.pop();
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3188
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 505;
int n , col[N];
char g[N][N];

int main(){
  scanf("%d",&n);
  rep(i,0,n) scanf("%s",g[i]);
  rep(i,0,n) rep(j,0,n) col[j] += g[i][j] == '#';
  if(*max_element(col,col+n)==0) {
    puts("-1");
    return 0;
  }
  int remaincol = 0;
  rep(i,0,n) remaincol += col[i] != n;
  int mn = N;
  rep(i,0,n) {
    int white = 0;
    rep(j,0,n) white += g[i][j] == '.';
    mn = min(mn , white + (col[i] == 0));
  }
  printf("%d\n",mn + remaincol);
  return 0;
}


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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)

//library----------------------------------------------


int main(){
  int a,b,c; cin>>a>>b>>c;
  int area = a*b/2;
  printf("%d\n",area);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
/*.....................................................................................................................*/
 
    const ll mod=998244353;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=200005,inf=1e14;

/*......................................................................................................................*/

signed main()
{
    fast;
    ll n;
    cin>>n;
    cout<<n*n*n<<endl;
} 

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  int t=1,a=1;
  for(int i=0;i<N;i++){
    int T,A;
    cin>>T>>A;
    int j=max((t+T-1)/T,(a+A-1)/A);
    t=j*T;
    a=j*A;
  }
  cout<<t+a<<endl;
}

Measured memory_bytes: 3596
function Main(input){
	var inputSeparated = input.split(' ');
  	var int = inputSeparated.map(i => parseInt(i));
	if(int[0] < int[1]){
      console.log(0);
    }else{
    	console.log(10);
    } 
}



Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
s = int(input())

xl = int(s ** 0.5) + 1
if (xl - 1) * (xl - 1) >= s:
  xl -= 1
  yl = xl
elif (xl - 1) * xl >= s:
  yl = xl - 1
else:
  yl = xl

diff = xl * yl - s
print(*[0, 0, xl, diff, 1, yl])

Measured memory_bytes: 3060
import itertools
import sys
N, M, Q = map(int, input().split())
abcd = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

num_list = [i for i in range(1, M + 1)]
A_cand = list(itertools.combinations_with_replacement(num_list, N))

best_score = 0
for A in A_cand:
    d_sum = 0
    for i in range(Q):
        a = abcd[i][0] - 1
        b = abcd[i][1] - 1
        c = abcd[i][2]
        d = abcd[i][3]
        if A[b] - A[a] == c:
            d_sum += d
    if best_score < d_sum:
        best_score = d_sum

print(best_score)

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

int main() {
    int a[4];
    for (int i = 0;i < 4;++i) cin >> a[i];
    int sum = 0,ans = 100000;
    for (int i = 0;i < 4;++i) sum += a[i];
    for (int i = 0;i < 4;++i) for (int j = i+1;j < 4;++j) ans = min(ans,abs(sum-(a[i]+a[j])*2));
    cout << ans << endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li res[100100];

inline li fastexp(li x, li n) {
    li res = 1;
    if (n == 0)return 1;
    if (n == 1)return x;
    li x2 = x * x % MOD;
    return (n % 2 > 0 ? x : 1ll) * fastexp(x2, n / 2) % MOD;
}

int main() {
    li n, k;
    cin >> n >> k;
    li ans = 0;
    for (li i = k; i >= 1; i--) {
        li tmp = fastexp(k / i, n);
        for (li j = i * 2; j <= k; j += i) {
            tmp = (tmp - res[j] + MOD) % MOD;
        }
        res[i] = tmp;
        ans = (ans + tmp * i % MOD) % MOD;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  cin >>N;
  int even=N/2;
  int odd=0;
  if(N%2==0) {
 odd +=(N/2);
  }
  else {
 odd +=(N/2) +1;
  }
  int x=odd*even;
  cout << x << endl;
  }


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

int main() {
    int a,b;
    cin >> a;
    cin >> b;
    if (a > b)
        cout << "a > b" << endl;
    else if(a < b)
        cout << "a < b" << endl;
    else
        cout << "a == b" << endl;
}

Measured memory_bytes: 1156
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



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

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

int main(void)
{
    ll N, M;
    cin >> N >> M;
    using P = pair<ll, ll>;
    vector<P> AB(N);
    REP(i, N) {
        ll A, B;
        cin >> A >> B;
        AB[i] = P(A, B);
    }
    sort(all(AB));
    ll result = 0;
    REP(i, N) {
        ll A = AB[i].first;
        ll B = AB[i].second;
        PRINT(A);
        PRINT(B);
        int x = min(M, B);
        PRINT(x);
        result += A * x;
        M -= x;
        if (M == 0) {
            break;
        }
    }
    cout << result << endl;

    return 0;
}



Measured memory_bytes: 1792
#include<stdio.h>

int main(){
	int i, j;
	
	for(i = 1; i <= 9; i++)
	{
		for(j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	
    return 0;
}

Measured memory_bytes: 920
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

int main() {
  std::string in1, in2;

  std::cin >> in1;
  std::cin >> in2;

  for (int i = 0; i < in1.size(); i++) {
    if (in1[i] != in2[i]) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }

  std::cout << "Yes" << std::endl;

  return 0;

}

Measured memory_bytes: 3596
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	long long ret=0;
	int at=0;
	for(int i=0;i<a;i++){
		ret+=ABS(p[i]-at);
		at=p[i];
	}
	ret+=ABS(at);
	for(int i=0;i<a;i++){
		int pr=0;
		if(i)pr=p[i-1];
		int nx=0;
		if(i<a-1)nx=p[i+1];
		if(min(pr,nx)<=p[i]&&p[i]<=max(pr,nx))printf("%lld\n",ret);
		else if(min(pr,nx)>p[i])printf("%lld\n",ret-2*(min(pr,nx)-p[i]));
		else printf("%lld\n",ret-2*(p[i]-max(pr,nx)));
	}
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A( N );
    for( auto &x : A )
    {
        cin >> x;
    }
    map<int,int> mp;
    for( auto &x : A )
    {
        mp[ x ]++;
        mp[ x + 1 ]++;
        mp[ x - 1 ]++;
    }
    int res{};
    for( auto x : mp )
    {
        res = max( res, x.second );
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5120
s = input()
k = int(input())
s_len = len(s)
if s_len == 1:
    print(k//2)
    exit()
if s.count(s[0]) == s_len:
    print((k*s_len)//2)
    exit()
cnt = 0
ans = 0
flag = "off"
while cnt <= s_len-2:
    if s[cnt] == s[cnt+1]:
        if cnt == s_len-2:
            flag = "on"
        ans += 1
        cnt += 1
    cnt += 1
dum = s[0]
check1 = 0
for i in s:
    if dum == i:
        check1 += 1
    else:
        break
dum = s[-1]
check2 = 0
for i in s[::-1]:
    if dum == i:
        check2 += 1
    else:
        break
if (check1+check2)%2 == 0 and s[0] == s[-1]:
    print(ans*k+(k-1))
else:
    print(ans*k)


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

#define f first
#define s second
#define mp make_pair
#define pb push_back

using namespace std;

int n,k;

vector<pair<int,int>> v;

int main(){
     cin >> n >> k;
     if(k > (n - 1) * (n - 2) / 2){
     	cout << -1;
     	return 0;
     }
     for(int i = 2; i <= n; i++){
     	v.pb(mp(1,i));
     }
     int x = (n - 1) * (n - 2) / 2,cur = 2;
     while(x > k){
     	for(int i = cur + 1; i <= n; i++){
     		if(x == k) break;
     		x--;
     		v.pb(mp(cur,i));	
     	}
     	cur++;
     }
     cout << v.size() << endl;
     for(auto u : v) cout << u.f << " " << u.s << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
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); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


ll mod_pow(ll x, ll p, ll M = MOD) {
  ll a = 1;
  while (p) {
    if (p % 2)
      a = a*x%M;
    x = x*x%M;
    p /= 2;
  }
  return a;
}


signed main() {
  fio();
  int n;
  cin >> n;
  vi d(n);
  rep (i, n) cin >> d[i];
  if (d[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  rep1 (i, n - 1) {
    if (d[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  vl num(n);
  rep (i, n) {
    num[d[i]]++;
  }
  while (num.back() == 0) num.pop_back();

  //DEBUG_VEC(num);
  
  ll ans = 1;
  rep1 (i, n - 1) {
    (ans *= mod_pow(num[i - 1], num[i])) %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i64,
        l: i64,
    }

    let r = l + n - 1;
    let eat = if r <= 0 {
        r
    } else if l >= 0 {
        l
    } else {
        0
    };
    let ans = (r + l) * (r - l + 1) / 2 - eat;

    println!("{}", ans);
}


Measured memory_bytes: 2184
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ipair pair<int,int>
int dp[100001];
int fun(int arr[],int n)
{  if(dp[n]!=-1)
    {
        return dp[n];
    }

    if(n==2)
    {
        return abs(arr[2]-arr[1]);
    }
    if(n==0||n==1)
        return 0;

    dp[n]= min((abs(arr[n]-arr[n-1])+fun(arr,n-1)),(abs(arr[n]-arr[n-2])+fun(arr,n-2)));
    return dp[n];
}
signed main()
{ memset(dp,-1,sizeof(dp));
     int n;
     cin>>n;
     int arr[n];
     for(int i=1;i<=n;i++)
     {
         cin>>arr[i];
     }
     cout<<fun(arr,n)<<endl;
    return 0;


}


Measured memory_bytes: 4864
#include <stdio.h>
#include <string.h>
int a[510][510], b[510][510];
int main(void)
{
    int n;
    while (1) {
        int w, h, i, j, s, t, res;
        scanf("%d", &n);
        if (n==0) break;

        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
        scanf("%d%d", &w, &h);
        while (n--) {
            int x, y;
            scanf("%d%d", &x, &y);
            a[y][x]=1;
        }
        scanf("%d%d", &s, &t);

        for(i=1;i<=h;++i) {
            for(j=1;j<=w;++j)
                b[i][j]=b[i][j-1]+a[i][j];
        }
        for(i=1;i<=h;++i) {
            for(j=1;j<=w;++j)
                b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+a[i][j];
        }

#define max(x, y) ((x)>(y)?(x):(y))
        res=0;
        for(i=t;i<=h;++i)
            for(j=s;j<=w;++j)
                res=max(res, b[i][j]-b[i][j-s]-b[i-t][j]+b[i-t][j-s]);
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 2640
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    string S;
    bool number[30];
    cin >> S;
    for (int i = 0; i < S.length(); i++)
    {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
        {
            number[i] = true;
        }
        else
        {
            number[i] = false;
        }
    }
    res = 0;
    int tmp = 0;
    bool flag = false;
    for (int i = 0; i < S.length(); i++)
    {
        if (number[i] == true && flag == false)
        {
            flag = true;
            tmp++;
            if (res < tmp)
            {
                res = tmp;
            }
        }
        else if (number[i] == true && flag == true)
        {
            tmp++;
            if (res < tmp)
            {
                res = tmp;
            }
        }
        else if (number[i] == false && flag == true)
        {
            if (res < tmp)
            {
                res = tmp;
            }
            flag = false;
            tmp = 0;
        }
    }
    cout << res << endl;
    return 0;
}

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

const int INF = 1<<29;

int main(){
    int n, cost[9999], dum[2][10010];
    int* dp[2];
    dp[0] = dum[0]+5005;
    dp[1] = dum[1]+5005;
    scanf("%d", &n);
    for(int x = 0; x < n-1; x++){
        scanf("%d", cost+x);
    }
    fill(dum[0], dum[0]+10010, INF);
    fill(dum[1], dum[1]+10010, INF);
    dp[0][1] = 0;
    for(int x = 0; x < n-1; x++){
        for(int y = -n/2; y <= n/2; y++){
            if(dp[x%2][y] < INF){
                if(y+1 <= n/2){
                    dp[(x+1)%2][y+1] = min(dp[(x+1)%2][y+1],
                                           dp[x%2][y]);
                }
                dp[(x+1)%2][-y+1] = min(dp[(x+1)%2][-y+1],
                                        dp[x%2][y] + cost[x]);
            }
            dp[x%2][y] = INF;
        }
    }
    printf("%d\n", dp[(n-1)%2][0]);
    return 0;
}

Measured memory_bytes: 1144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace ABC156D
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] nav = ReadLong();
            long n = nav[0];
            long a = nav[1];
            long b = nav[2];

            long mod = 1000000000 + 7;

            //long[] pow = new long[64];
            //pow[0] = 1;
            //pow[1] = 2;
            //for (int i = 2; i < pow.Length; i++)
            //{
            //    pow[i] = (pow[i - 1] * pow[i - 1]) % mod;
            //}

            //long all = 0;
            //for (int i = 0; i < pow.Length; i++)
            //{
            //    var shift = n >> i;
            //    if (shift % 2 == 1) all = (all + pow[i + 1]) % mod;
            //}
            long all = Calc.ModPow(2, n, mod);

            long nCa = Calc.nCk(n, a, mod);
            long nCb = Calc.nCk(n, b, mod);

            long ans = (all - 1 - nCa - nCb) % mod;
            if (ans < 0) ans += mod;

            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }

    static class Calc
    {

        /// <summary>
        /// a^n (mod p)
        /// nが非常に大きい時に有効
        /// </summary>
        /// <param name="a"></param>
        /// <param name="n"></param>
        /// <param name="mod"></param>
        /// <returns></returns>
        public static long ModPow(long a, long n, long p)
        {
            if (n == 1) return a % p;
            if (n % 2 == 1) return (a * ModPow(a, n - 1, p)) % p;

            long t = ModPow(a, n / 2, p);
            return (t * t) % p;
        }

        /// <summary>
        /// 組み合わせ個数
        /// </summary>
        /// <param name="n"></param>
        /// <param name="k"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static long nCk(long n, long k, long p)
        {
            long ans = 1;
            k = Math.Min(k, n - k);
            for (long i = n; i > n - k; i--)
            {
                ans = (ans * i) % p;
            }

            for (long i = 1; i <= k; i++)
            {
                ans = (ans * ModPow(i, p - 2, p)) % p;
            }

            return ans;
        }
    }
}


Measured memory_bytes: 13396
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String aStr = Integer.toString(a);
    int b = sc.nextInt();
    String bStr = Integer.toString(b);

    StringBuilder aResult = new StringBuilder();
    for (int i = 0; i < b; i++) {
      aResult.append(aStr);
    }

    StringBuilder bResult = new StringBuilder();
    for (int i = 0; i < a; i++) {
      bResult.append(bStr);
    }

    List<String> list = new ArrayList<>();
    list.add(aResult.toString());
    list.add(bResult.toString());
    List<String> sortedList = list.stream().sorted().collect(Collectors.toList());

    System.out.println(sortedList.get(0));
  }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define gc getchar
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define fastIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define ao(a)        \
    for (auto i : a) \
        cout << i << " ";
#define lc 2 * x // if tree index id 0 based
#define lr 2 * x + 1
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 1e6 + 6;
/*

bool comp(string a, string b)
{
    return a.size() < b.size();
}
*/

ll a[10005], tree[100005], ans[10005];
void build(ll l, ll r, ll x)
{
    if (l == r)
        tree[x] = a[l];
    else
    {
        ll mid = (l + r) >> 1;
        build(l, mid, lc);
        build(mid + 1, r, lr);
        tree[x] = tree[lc] & tree[lr];
    }
}
ll query(ll lx, ll ly, ll l, ll r, ll x)
{
    if (l > r || lx > r || ly < l)
        return 1122343442;
    if (lx <= l && r <= ly)
        return tree[x];
    ll mid = (l + r) >> 1;
    ll ans;
    ans = query(lx, ly, l, mid, lc);
    ans &= query(lx, ly, mid + 1, r, lr);
    return ans;
}
int main()
{
  ll a,b;
  cin>>a>>b;
  cout<<max(0LL,a-2*b);

}

Measured memory_bytes: 256