akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 2e5 + 10;
int a[N];
int pre[N], suf[N];
int mx[N], mn[N];
int pos[N], len[N];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

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

  pre[1] = pos[1] == 1 ? 0 : 1;
  for (int i = 1; i <= n; i++) {
    mx[i] = max(mx[i - 1], a[i]);
  }
  for (int x = 2; x <= n; x++) {
    if (mx[pos[x]] > x) {
      pre[x] = x;
    } else {
      pre[x] = pre[x - 1];
    }
  }

  suf[n] = pos[n] == n ? 0 : 1;
  mn[n + 1] = 1e8;
  for (int i = n; i >= 1; i--) {
    mn[i] = min(mn[i + 1], a[i]);
  }

  for (int x = n - 1; x >= 1; x--) {
    if (mn[pos[x]] < x) {
      suf[x] = n - x + 1;
    } else {
      suf[x] = suf[x + 1];
    }
  }

  int ans = n;
  for (int i = 1; i < n; i++) {
    ans = min(ans, suf[i + 1] + pre[i]);
  }
  ans = min({ans, pre[n], suf[1]});

  len[n] = 1;
  for (int i = n - 1; i > 1; i--) {
    if (pos[i + 1] > pos[i]) {
      len[i] = 1 + len[i + 1];
    } else {
      len[i] = 1;
    }
    ans = min(ans, pre[i - 1] + suf[i + len[i]]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9084
#bfs
import queue

h, w = map(int, input().split())
c = [list(input()) for i in range(h)]
emp = 0
for i in range(h):
    for j in range(w):
        if c[i][j] == '.':
            emp += 1

visited = [[0 for i in range(w)] for j in range(h)]
q = queue.Queue()
q.put([0, 0, 1])
visited[0][0] = 1
dyx = [[0, 1], [1, 0], [-1, 0], [0, -1]]
flag = False
while not q.empty():
    now = q.get()
    if now[0] == h-1 and now[1] == w-1:
        flag = True
        break
    for i in range(4):
        y = now[0] + dyx[i][0]
        x = now[1] + dyx[i][1]
        z = now[2]
        if 0 <= y < h and 0 <= x < w:
            if c[y][x] != '#' and visited[y][x] == 0:
                visited[y][x] = 1
                q.put([y, x, z+1])
if flag:
    print(emp-now[2])
else:
    print(-1)

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, n, iz, der;
    cin >> x >> n;
    iz = x - 1;
    der = x + 1;
    vector<int> datos(n);
    for (int &i : datos) cin >> i;
    sort(datos.begin(), datos.end());
    if (!binary_search(datos.begin(), datos.end(), x) || !n) {
        cout << x << "\n";
        return 0;
    }
    while (1) {
        if (!binary_search(datos.begin(), datos.end(), iz)) {
            cout << iz << "\n";
            break;
        }
        if (!binary_search(datos.begin(), datos.end(), der)) {
            cout << der << "\n";
            break;
        }
        iz--;
        der++;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,M;cin>>N>>M;
	map<int,long> num;
    long sum=0,a;num[0]++;
	for(int i=1;i<=N;i++){
		cin>>a;
		sum=(sum+a)%M;
		num[sum]++;
	}long result=0;
	for(auto itr=num.begin();itr!=num.end();itr++){
		a=itr->second;
		result+=a*(a-1)/2;
	}cout<<result<<endl;
}

Measured memory_bytes: 4224
//g++  5.4.0
// Time-complexity : ( 3^n + 2^n * n * n )
#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

const int nax = 1e5+1;
int mod;
vector< int > g[nax];
vector< pii > down(nax),up(nax) ,pref[nax], suff[nax];

// first - black
// second - white

int add(int a,int b)
{
    return (a+b)%mod;
}
int mult(int a,int b)
{
    return (a*b)%mod;
}
pii work( pii a, pii b )
{
    pii res;
    res.ff = mult( a.ff , add( b.ff,b.ss) );
    res.ss = mult( a.ss , b.ss );
    return res;
}
pii work2( pii a, pii b )
{
    pii res;
    res.ff = mult( a.ff , b.ff );
    res.ss = mult( a.ss , b.ss );
    return res;
}
signed main()
{
    fast;
    int n ;
    cin >> n >> mod;
    for(int i=1 ; i<n ; i++ )
    {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    function< void(int,int) > dfs = [&](int v,int par)
    {
        pii p = {1,1};
        for( auto u: g[v] )
        {
            if( u!=par )
            {
                dfs(u,v);
                p = work(p,down[u]);
            }
            pref[v].pb(p);
        }
        down[v] = p;
        p = {1,1};
        reverse( g[v].begin() , g[v].end() );
        for( auto u : g[v] )
        {
            if( u!=par )
                p = work(p,down[u]);
            suff[v].pb(p);
        }
        reverse( g[v].begin(), g[v].end() );
        reverse( suff[v].begin() , suff[v].end() );
        return ;
    };
    dfs(1,0);
    
    function< void(int,int) > dfs_dp = [&](int v,int par)
    {
        for(int i=0 ; i<(int)(g[v].size()) ; i++ )
        {
            int u = g[v][i];
            if( u != par )
            {
                
                if( i && i!=(int)(g[v].size())-1 )
                    up[u] = work2( pref[v][i-1] , suff[v][i+1] );
                else if( i )
                    up[u] = pref[v][i-1];
                else  if( i!=(int)(g[v].size())-1 )
                    up[u] = suff[v][i+1]; 
                else
                    up[u] = {1,1};
                if( v!=1)
                    up[u] = work( up[u], up[v] );
                dfs_dp( u , v ) ;
            }
        }
    };
    
    dfs_dp(1,0);
    cout << down[1].ff << "\n";
    for(int i=2 ; i<=n ; i++ )
        cout << work( down[i] , up[i] ).ff  %mod<< "\n";
    
}





Measured memory_bytes: 33280
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#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 Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    pr(S.substr(0,3));
}

Measured memory_bytes: 3580
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=1e9+9;
const ll inf2=8e18+9;
const ll mol=1e9+7;
const int maxn=2e3+9;
const ll maxx=1e15+9;

ll n,ar[20]={1,26};

int main()
{
    for(int i=2;ar[i-1]<=maxx;i++) ar[i]=ar[i-1]*26;
    cin>>n; n--;
    int len=1;
    while(n>=ar[len]) n-=ar[len++];
    string ans;
    while(len--)
    {
        ll cnt=n/ar[len];
        n-=cnt*ar[len];
        ans+='a'+cnt;
    }
    cout<<ans<<endl;
}


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

int mod = 1000000007;

int main()
{
    int A, B;
    cin >> A >> B;
    bool x = true;
    for (int i = 0; i < 1010; i++)
    {
        if (i * 8 / 100 == A && i / 10 == B)
        {
            cout << i;
            x = false;
            break;
        }
    }
    if(x)
        cout << -1;
}

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

for i in range(M):
    if i == 0:
        l, r = map(int,input().split())
    else:
        L, R = map(int,input().split())
        if L > r:
            print(0)
            quit()
        l = max(l, L)
        r = min(r, R)
print(r - l + 1)


Measured memory_bytes: 3060
use proconio::*;
use std::*;

fn main() {
    const MOD: usize = 1000000007;
    input! {
        n: usize,
    }
    let mut x = 1;
    let mut y = 1;
    let mut z = 1;
    for _ in 0..n {
        x = x * 10 % MOD;
        y = y * 9 % MOD;
        z = z * 8 % MOD;
    }
    let ans = x - (y*2 % MOD - z);
    println!("{}", (MOD + ans) % MOD)
}


Measured memory_bytes: 2164
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

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

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

int N, M;
int A;
string S;

int main() {
    cin >> N >> M;
    cin >> S;
    M = M - 1;
    if (S[M] == 'A')S[M] = 'a';
    else if (S[M] == 'B')S[M] = 'b';
    else S[M] = 'c';
    PRI(S)
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    ll n;
    cin >> n;

    ll ans = 0;
    vector<int> p(n + 1, 1);
    for(int i = 1; i <= n; i++) {
        for(int j = 2 * i; j <= n; j += i) {
            p[j]++;
        }
    }
    for(int i = 1; i < n; i++) {
        ans += p[n - i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7128
M=998244353;N=gets.to_i;v=$<.map{|e|Complex(*e.split.map(&:to_i))};h={};r=2**N%M-N-1;N.times{|i|(i+1...N).map{|j|h[x=[i,j]]||(j+1...N).map{|k|((v[j]-v[k]).conj*(v[i]-v[k])).imag.abs<1e-9&&x<<k}&&x.size.times{|a|(a+1...x.size).map{|b|r=(r-2**(b+~a))%M;h[[x[a],x[b]]]=1}}}};p r

Measured memory_bytes: 5628
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
mint mod_pow(ll p,ll q){
    mint ret = p;
    return ret.pow(q);
}
template<class T> bool chmin(T& a,T b);
template<class T> bool chmax(T& a,T b);


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

    int n;cin >> n;
    vector<int> a(n);
    int sum = 0;
    REP(i,n){cin >> a[i];sum += a[i];}
    
    int half = (sum + 1)/2;
    vector<vector<mint> > dp1(n,vector<mint>(90010,0));
    dp1[0][0] = (mint)2;
    dp1[0][a[0]] = (mint)1;

    for(int i = 1;i < n;i++){
        for(int j = 0;j <= 90000;j++){
            dp1[i][j] += (mint)2 * dp1[i-1][j];
            if(j >= a[i])dp1[i][j] += dp1[i-1][j-a[i]]; 
        }
    }
    mint all = mod_pow(3,n);
    for(int i = half;i <= 90000;i++){
        all -= (mint)3 * dp1[n-1][i];
    }
    vector<vector<mint> > dp2(n,vector<mint>(90010,0));
    dp2[0][0] = (mint)1;
    dp2[0][a[0]] = (mint)1;
    for(int i = 1;i < n;i++){
        for(int j = 0;j <= 90000;j++){
            dp2[i][j] += dp2[i-1][j];
            if(j >= a[i])dp2[i][j] += dp2[i-1][j-a[i]];
        }
    }
    if(sum %2 == 0){
        all += (mint)3 * dp2[n-1][half];
    }
    cout << all.x << '\n';
}
///////////////////////////////////////////////////////////
template<class T> bool chmin(T& a,T b){
    if(a > b){a = b;return true;}else return false;
}
template<class T> bool chmax(T& a,T b){
    if(a < b){a = b;return true;}else return false;
}


Measured memory_bytes: 423232
#include<cstdio>

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

using namespace std;

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

struct data{
	int S;
	int x,y;
};

int n;

data next_state(int S,int x,int y){
	S|=1<<y*n+x;
	int T=0;
	rep(i,n) rep(j,n) {
		int cnt=0;
		rep(k,8){
			int yy=i+dy[k],xx=j+dx[k];
			if(0<=yy && yy<n && 0<=xx && xx<n && S&(1<<yy*n+xx)) cnt++;
		}
		if(S&(1<<i*n+j)){
			if(cnt==2 || cnt==3) T|=1<<i*n+j;
		}
		else{
			if(cnt==3) T|=1<<i*n+j;
		}
	}
	T&=~(1<<y*n+x);
	return (data){T,x,y};
}

bool dfs(data D,int t){
	if(D.S==0) return true;
	if(t==0) return false;
	rep(k,8){
		int yy=D.y+dy[k],xx=D.x+dx[k];
		if(0<=yy && yy<n && 0<=xx && xx<n && (D.S&(1<<yy*n+xx))==0){
			if(dfs(next_state(D.S,xx,yy),t-1)) return true;
		}
	}
	return false;
}

int main(){
	for(;scanf("%d",&n),n;){
		data ini={};
		rep(i,n){
			char s[6]; scanf("%s",s);
			rep(j,n){
				if(s[j]=='#') ini.S|=1<<(i*n+j);
				if(s[j]=='@') ini.x=j, ini.y=i;
			}
		}

		int ans=-1;
		rep(t,11) if(dfs(ini,t)) { ans=t; break; }
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

int main(int argc, char* argv[])
{
  std::string s;
  cin >> s;
  for (size_t i = 0; i < s.size() / 2; ++i)
  {
    // cout << "s[i] != s[s.size()/2-i-1]" << i << ", " << s.size() / 2 - i - 1
    //      << endl;
    // cout << "s[s.size()-1-i] != s[s.size()+3/2-1+i]" << s.size() - 1 - i << ", "
    //      << (s.size() + 3) / 2 - 1 + i << std::endl;

    if (s[i] != s[s.size() - 1 - i] || s[i] != s[s.size() / 2 - i - 1]
        || s[s.size() - 1 - i] != s[(s.size() + 3) / 2 - 1 + i])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
  int n,i,j,kotae=1;
  string s;
  string a[100];
  char c,d;
  cin>>n;
  cin>>s;
  a[0]=s;
  c=s[s.size()-1];
  for(i=1;i<n;i++){
    cin>>s;
    a[i]=s;
    for(j=0;j<i;j++){
      if(a[i]==a[j]){
        kotae=0;
      }
    }
    d=s[0];
    if(c!=d){
      kotae=0;
    }
    c=s[s.size()-1];
  }
  if(kotae){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}


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

int main()
{
    int A, B;
    cin >> A >> B;
    int numPlug = 1;
    int numTap = 0;
    while (numPlug < B) {
        ++numTap;
        numPlug = numPlug - 1 + A;
    }
    cout << numTap << endl;
}



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


int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        string str1 = "WA", str2 = "AC", str3 = "TLE", str4 = "RE";
        ll n;
        cin>>n;
        string str;
        ll count1=0, count2=0, count3=0, count4=0;
        while(n--){
            cin>>str;
            if(str==str1) count1++;
            if(str==str2) count2++;
            if(str==str3) count3++;
            if(str==str4) count4++;
        }
        cout<<str2<<" x "<<count2<<endl;
        cout<<str1<<" x "<<count1<<endl;
        cout<<str3<<" x "<<count3<<endl;
        cout<<str4<<" x "<<count4<<endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define RG register int
#define rep(i,a,b)	for(RG i=a;i<=b;++i)
#define per(i,a,b)	for(RG i=a;i>=b;--i)
#define ll long long
#define inf (1<<29)
using namespace std;

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

int main()
{
	ll n,m,g;
	while(~scanf("%lld%lld",&n,&m))
	{
		g=gcd(n,m);
		printf("%lld %lld\n",g,n/g*m);
	}
	return 0;
}


Measured memory_bytes: 3120
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
        n: usize,
        a: [[i32; n]; 2],
    }
    let (mut low, mut column):(usize, usize) = (0, 0);
    let mut ans = a[0][0];
    for i in 0..n{
        let mut total = 0;
        for k in 0..n{
            if k == i{
                total += a[low][k];
                low+=1;
            }
            total += a[low][k];
        }
        ans = max(ans, total);
        low = 0;
    }
    puts!("{}\n", ans);
}
fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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



int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int X;
	cin >> X;
	for (int A = -200 ; A <= 200 ; A++)
	{
		for (int B = -200 ; B <= 200 ; B++)
		{
			int A5 = A * A * A * A * A;
			int B5 = B *B *B *B *B;
			if (A5 - B5 == X)
			{
				cout<<A<<" "<<B<<endl;
				exit(0);
			}
		}
	}
}

Measured memory_bytes: 3608
n = int(input())
P = list(map(int, input().split()))
a = 0
for i in range(1,n-1):
    L = P[i-1:i+2]
    if not (P[i]==min(L) or P[i]==max(L)):
        a = a+1
    else:
        pass
print(a)

Measured memory_bytes: 2940
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

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

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int ans = 0;
	int k;
	cin >> k;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				ans += __gcd(a, __gcd(b, c));
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;


namespace atcorder2
{
    class Program
    {
        public static long Read()
        {

            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
         public static long GCM(long x,long y)
        {
            if (x < y)  GCM(y, x);


            while (y > 0)
            {
                var z = y;
                y = x % y;
                x = z;
            }
            
            return x;
        }

        



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var hw = Reads();
            var h = hw[0];
            var w = hw[1];
            var s = new char[h][];
            var x = new long[] {  -1, 0, 0, 1 };
            var y = new long[] {  0, -1, 1,  0 };
            for (int i = 0; i < h; i++)
            {
                s[i] = ReadLine().ToCharArray();
            }
            bool f = false;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    f = false;
                    if (s[i][j] == '#')
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            bool f1 = i + x[k] >= 0 && i + x[k] < h && j + y[k] >= 0 && j + y[k] < w;

                            if (f1 && s[i + x[k]][j + y[k]] == '#') f = true;

                        }

                    }
                    else f = true;
                    if (!f) break;
                }
                if (!f) break;
            }
            WriteLine(f ? "Yes":"No");
            

            






            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	string s;
	ll i,j;
	map<char, ll> mp;
	cin>>s;
	for(i=0; i<4; i++)
	mp[s[i]]++;
	
	ll kk= mp.size();
	if(kk==2 ){
	    auto it= mp.begin();
	    if(it->second == 2)
	    cout<<"Yes\n";
	    else
	    cout<<"No\n";
	}
	else
	cout<<"No\n";
    return 0;
}























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

int main()
{
    double A, B;
    int H, M;

    cin >> A >> B >> H >> M;

    //double theta = fabs((H*30+M*0.5)-(M*6));
    //double theta = fabs(fmod(H*30+M*0.5, 180)-fmod(M*6, 180));
    double H_t = H*30+M*0.5;
    double M_t = M*6;
    double theta;
    if(H_t >= M_t) {
        theta = H_t - M_t;
    } else {
        theta = M_t - H_t;
    }
    //double theta = fabs((H*30+M*0.5)-(M*6));
    //double theta = 80;
    // H : 300 - 60, 120 , 180->120
    // M : 240 - 60, 120 , 180->60

    //cout << H*30+(H*40/60*6) << endl;
    //cout << M*6 << endl;
    //cout << theta << endl;

    // a^2 = b^2 + c^2 + 2bc cosA
    cout << std::fixed << std::setprecision(15) << sqrt(pow(A, 2) + pow(B, 2) - 2*A*B*cos(theta*M_PI/180)) << endl;

    return 0;
}

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
#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 << " ";
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;

ll powmod(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

ll gcd(ll a, ll b)
{
    while (b > 0)
    {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

ll lcm(ll a, ll b)
{
    return (a / gcd(a, b)) * b;
}

ll is_prime(ll n)
{
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (ll i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}
int main()
{

    ll n;
    cin >> n;
    string s, g;
    cin >> s >> g;
    //  ll l = n - 1, r = 0;
    ll ans = 0;
    rep(i, n)
    {
        if (s.substr(i, n - i) == g.substr(0, n - i))
            ans = max(ans, n - i);
    }
    c(2 * n - ans) return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,j,ans;
  int n,m,Q,L,R;
  int train[501][501],p,q;
  int ruiseki[501][501];
  
  scanf("%d %d %d",&n,&m,&Q);
  
  /*電車テーブルを初期化*/
  for(i=0; i<=n; i++) for(j=0; j<=n; j++) train[i][j] = 0;
  
  /*累積和のテーブルを初期化*/
  for(i=0; i<=n; i++) for(j=0; j<=n; j++) ruiseki[i][j] = 0;

  /*データ読み込み*/
  for(i=0;i<m;i++){
    scanf("%d %d",&L,&R);
    //printf("LEFT->%d. RIGHT->%d\n",L,R);
    train[L][R]++;
  }
  
  /*2次元の累積和を求める*/
  for(i=1; i<=n; i++) for(j=1; j<=n; j++){
    ruiseki[i][j] = ruiseki[i-1][j] + ruiseki[i][j-1] - ruiseki[i-1][j-1] + train[i][j];
  }
  
  //クエリ処理
  for(i=0;i<Q;i++){
    scanf("%d %d",&p,&q);
    ans = ruiseki[q][q] + ruiseki[p-1][p-1] - ruiseki[q][p-1] - ruiseki[p-1][q];
    printf("%d\n",ans);
  }
  
  
  return 0;
}

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

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

using namespace std;
typedef long long ll;

int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll N, M, A;
  cin >> N >> M;
  priority_queue<ll> p;
  rep(i,N) {
    cin >> A;
    p.push(A);
  }
  ll ans, x = 0;
  rep(i,M) {
  x = p.top()/2;
  p.pop();
  p.push(x); 
  }
  rep(i,N) {
    ans += p.top();
    p.pop();
  }
  cout << ans;
}

Measured memory_bytes: 1400
#include<stdio.h>
int main(void)
{
    int i,n,k[1000],p[1000],a;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d",&k[i],&p[i]);
    }
    for(i=0;i<n;i++){
        a=k[i]%p[i];
        if(a==0) a=p[i];
        printf("%d\n",a);
    }
    return 0;
}

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

using namespace std;

int main(){
    long long A=0,B=0,C=0,D=0,N=0,ans=0;
    string S;



    vector<long long> vec(2);


    cin>>A>>B>>N;

    ans=N/A*B;

    cout<<ans<<endl;

}

Measured memory_bytes: 256
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0:
        return 1
    a = reduce(mul, range(n, n-r, -1))
    b = reduce(mul, range(1, r+1))
    return a//b

n, k = map(int, input().split())
mod = pow(10, 9) + 7

for i in range(k):
    if i > n-k:
        print(0)
    else:
        b = cmb(k-1, i)
        r = cmb(n-k+1, i+1)
        print(int((b*r)%mod))


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
        return 0;
    }
    else {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int length = String.valueOf(N).length();
        String onePoint = String.valueOf(N).substring(length - 1);

        switch (Integer.parseInt(onePoint)) {
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                System.out.println("hon");
                break;
            case 0:
            case 1:
            case 6:
            case 8:
                System.out.println("pon");
                break;
            case 3:
                System.out.println("bon");
                break;
        }
    }
}


Measured memory_bytes: 35820
#include<stdio.h>
char str[11000];
char key[10][12]={
"","\',.!?","abcABC","defDEF",
"ghiGHI","jklJKL","mnoMNO",
"pqrsPQRS","tuvTUV","wxyzWXYZ",
};
int sz[]={0,5,6,6,6,6,6,8,6,8};
int main(){
	while(~scanf("%s",str)){
		int last=0;
		int t=0;
		for(int i=0;i==0||str[i-1];i++){
			if(str[i]-'0'!=last){
				if(i&&last){
					printf("%c",key[last][(t-1)%sz[last]]);
				}
				last=str[i]-'0';
				t=1;
			}else{
				if(last==0)printf(" ");
				t++;
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 936
#include<bits/stdc++.h>
using namespace std;
inline void read(long long &x)
{
	x=0;
	long long p=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
long long n,k;
int main()
{
//	freopen(".in","r",stdin);
//	freopen("a.out","w",stdout);
	read(n);read(k);
	if(k>=(n+1)/2)return cout<<(1ll+n-k)*(n-k)/2<<endl,0;
	if(k==0)return cout<<n*n<<endl,0;
	long long ans=0;
	for(long long i=n;i>=k+1;i--)
	{
		long long block=(n/i);
		long long yu=n%i;
		ans+=block*(i-k);
		if(yu>=k)ans+=(1ll+yu-k);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int A;
  cin >> A;
  
  int B;
  cin >> B;
  
  int C;
  cin >> C;
  
  int s = C - (A - B);
  if (s<0) cout << 0;
  else cout << s;
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [0] + [(1 + p) / 2 for p in P]
P_acc = list(accumulate(P))

ans = 0
for i in range(1, N - K + 2):
    ans = max(ans, P_acc[i + K - 1] - P_acc[i - 1])

print(ans)


Measured memory_bytes: 25148
#include <iostream>
#include <cmath>

int main(void){
    long long int a(0), b(0);
    
    std::cin >> a >> b;
    
    if(a%2 != b%2){
        std::cout << "IMPOSSIBLE" << std::endl;
    }else{
        const auto k = (std::pow(a, 2) - std::pow(b, 2)) / (2*(a - b));
        std::cout << static_cast<int>(k) << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;

int S(int n){
    int out=0;
    while(n != 0){
        out += n - (n/10) * 10;
        n/=10;
    }
    return out;
}

int main(){
    int N;
    cin >> N;
    if(N%S(N)==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int ab, bc, ca;
  cin >> ab >> bc >> ca;
  cout << ab*bc/2 << endl;
}

Measured memory_bytes: 3568
N,K=map(int,input().split())
P=list(map(int,input().split()))

s=sum(P[:K])
tmp=s
k=0
for i in range(N-K):
    s=s-P[i]+P[K+i]
    
    if tmp<s:
        k=i+1
        tmp=s
ans=0
for i in range(k,k+K):
    ans+=(P[i]+1)/2

print(ans)

Measured memory_bytes: 25060
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  string s, t;
  cin >> s >> t;
  int n = SZ(s), m = SZ(t), best = INF;
  for (int i = 0; i + m <= n; ++i) {
    int cnt = 0;
    for (int j = 0; j < m; ++j) {
      cnt += s[i + j] != t[j];
    }
    best = min(best, cnt);
  }
  cout << best << '\n';
  return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, y;
    cin >> n >> y;
    for (ll i = 0; i <= y / 10000; i++)
    {
        ll temp = y - 10000 * i;
        for (ll k = 0; k <= (y - i * 10000) / 5000; k++)
        {
            ll temp2 = temp - 5000 * k;
            if (temp2 == 1000 * (n - i - k))
            {
                cout << i << " " << k << " " << n - i - k << endl;
                exit(0);
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

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

ll solve() {
    ll H, W;
    cin >> H >> W;
    map<char,int> m;
    string s;
    for ( int i = 0; i < H; i++ ) {
        cin >> s;
        for ( char c : s ) {
            m[c]++;
        }
    }
    int n1 = 0, n2 = 0, n4 = 0;
    if ( H%2==1 && W%2==1 ) n1 = 1;
    if ( H%2==1 ) n2 += W/2;
    if ( W%2==1 ) n2 += H/2;
    n4 = (H*W - n2*2 - n1) / 4;

    for ( auto& p : m ) {
        while ( n4 > 0 &&  p.second >= 4 ) {
            p.second -= 4;
            n4--;
        }
        if ( n4 == 0 ) break;
    }
    if ( n4 > 0 ) return false;
    for ( auto& p : m ) {
        while ( n2 > 0 &&  p.second >= 2 ) {
            p.second -= 2;
            n2--;
        }
        if ( n2 == 0 ) break;
    }
    if ( n2 > 0 ) return false;
    for ( auto& p : m ) {
        while ( n1 > 0 &&  p.second >= 1 ) {
            p.second -= 1;
            n1--;
        }
    }
    if ( n1 > 0 ) return false;
    return true;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int tmp = n / 11;
  if(n%11 == 0) {
    cout << tmp*2;
  } else if(n % 11 <= 6) {
    cout << tmp*2 + 1;
  } else {
    cout << tmp*2 + 2;
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double d;
const long long INF = 10000000000000;
int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  for(int i = 0;i<N;i++){
    cin >> a[i];
  }
  ll sum = 0;
  for(int i = 0;i<N;i++){
    sum += a[i];
  }
  cout << sum-N << endl;
               
}

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

using namespace std;

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

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

int main() {
  int N;
  cin >> N;
  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    m[a]++;
  }
  int ans = 0;
  for (auto itr = m.begin(); itr != m.end(); ++itr) {
    int need = itr->first;
    int n = itr->second;
    if (n < need) ans += n;
    else ans += n - need;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
#include<cstdio>

int n, a;
bool ok = true;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
      ok = false;
    }
  }
  printf("%s\n", ok ? "APPROVED" : "DENIED");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
void fff()
{
	ll n, d;
	cin >> n >> d;
	ll x, y;
	d*=d;
	ll ans = 0, cur;
	while(n--)
	{
		cin >> x >> y;
		cur = x*x+y*y;
		if(cur <= d)ans++;
	}	
	cout << ans << ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N, M;
	cin >> N >> M;
	pair<int, int> A[100000];
	rep(i, N) cin >> A[i].first >> A[i].second;
	sort(A, A + N);

	int ima = 0;
	ll kotae = 0;
	rep(i, N) {
		if (ima < M) {
			int kari = min(M - ima, A[i].second);
			ima += kari;
			kotae += (ll)kari * A[i].first;
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, t, i, j, k, sum = 0, last, x;
	cin >> n >> t;
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	x = 0; last = t;
	for (i = 0; i < n; i++) {
		if (a[i] <= last) {
			last = a[i] + t;
			if (i == n - 1) 
				sum += last - x;
		}
		else {
			sum += last - x;
			x = a[i]; last = x + t;

			if (i == n - 1)
				sum += last - x;
		}
	}
	cout << sum << "\n";

	return 0;
}


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

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

    string s;
    cin >> s;
    int n = s.size() + 1;
    vector<ll> a(n, 0);

    int k = 1, sum = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == '<') a[i + 1] = a[i] + 1;
    }

    for (int i = n - 2; i >= 0; i--) {
        if (s[i] == '>') a[i] = max(a[i+1] + 1, a[i]);
    }

    ll ans = 0;
    for (int i = 0; i < n; i++) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 7700
#include <stdio.h>
int main()
{
  int N;		/* 入力される整数 */
  int K;		/* K進数で表すと */
  int counter;	/* カウンタ */
  scanf("%d %d", &N, &K);
  
  counter = 0;
  while(N != 0){
    N /= K;
    ++counter;
  }
  printf("%d\n", counter);
  return 0;
}

Measured memory_bytes: 128