akhauriyash/Code-Regression huggingface dataset:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, Q = MAP()
A = [LIST() for i in range(N-1)]
P = [LIST() for i in range(Q)]

graph = defaultdict(list)
for a, b in A:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

cnt = [0] * N
ans = [0] * N

for node, point in P:
    cnt[node-1] += point

check = [False] * N
q = deque([])
q.append(0)
check[0] = True

while q:
    a = q.pop()
    for node in graph[a]:
        if check[node] == True:
            continue
        cnt[node] += cnt[a]
        check[node] = True
        q.append(node)
print(*cnt)





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

using namespace std;

int main() {
    int N, K;
    string s;
    cin >> N >> s >> K;

    string res = s;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != s[K - 1]) res[i] = '*';
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int n;
vector<int> w;
int memo[300][300];

// [l, r]
int rec(int l, int r) {
    auto& MEMO = memo[l][r];
    if (MEMO != INF) return MEMO;
    if (r <= l) return 0;
    
    int ret = 0;
    if (abs(w[l] - w[r]) <= 1 && rec(l + 1, r - 1) == (r - 1) - (l + 1) + 1) {
        chmax(ret, r - l + 1);
    }
    REPF(i, l, r) {
        chmax(ret, rec(l, i) + rec(i + 1, r));
    }
    return MEMO = ret;
}

signed main() {
    while (1) {
        cin >> n;
        if (n == 0) break;
        REP(i, 300) REP(j, 300) memo[i][j] = INF;
        w.resize(n);
        cin >> w;
        cout << rec(0, n - 1) << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,d;
    cin >> n >> d;
    d = 2*d+1;
    cout << (n+d-1)/d << endl;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
m = 0
l = 2 * c * max(x, y)
d = abs(x - y)

if c * 2 <= a + b:
    m += 2 * c * min(x, y)
    if x <= y:
        m += b * d
    else:
        m += a * d
    print(min(m, l))
else:
    m += a * x + b * y
    print(m)

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

int F(int n){
   if(n%2==0){
      return n/2;
   }
   else return n/2+1;
}


int main(){

int N;
cin >> N;
int K;
cin >> K;
int R;
cin >> R;
int S;
cin >> S;
int P;
cin >> P;
string T;
cin >> T;
long long int giveup=0;
vector<char> vec(N,0);
for(int i=0;i<N;i++){
    vec[i]=T.at(i)
;}
int counter_r=0;
int counter_p=0;
int counter_s=0;
for(int i=0;i<K;i++){
   for(int j=i+K;j<N;j+=K){
      if(vec[j-K]==vec[j]){
         if(vec[j]=='r'){
            counter_r++;
         ;}
         if(vec[j]=='p'){
            counter_p++;
         ;}
         if(vec[j]=='s'){
            counter_s++;
         ;}
      ;}
      else{
         giveup+=F(counter_r)*P+F(counter_p)*S+F(counter_s)*R;
         counter_r=0;
         counter_p=0;
         counter_s=0;
      }
   ;}
   giveup+=F(counter_r)*P+F(counter_p)*S+F(counter_s)*R;
         counter_r=0;
         counter_p=0;
         counter_s=0;
;}

long long int sum=0;
for(int i=0;i<N;i++){
   if(vec[i]=='r'){
       sum+=P
    ;}
   if(vec[i]=='p'){
      sum+=S
    ;}
   if(vec[i]=='s'){
      sum+=R
    ;}
   ;}

cout<<sum-giveup<<endl;

   return 0;
}  


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	if(n%2==1)
	{
		cout<<0;
	}
	else{
		ll ans = 0;
		ll t = 5;
		
		while((n/t)>0)
		{
			ans += n/(2*t);
			//cout<<ans<<endl;
			t = t*5;
		}
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int cnt[112345] = {};
int gen[112345] = {};
int dat[112345] = {};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int num,mod;
    cin >> num >> mod;

    for(int i=0;i<num;i++)
	{
		int z;
        cin >> z;
		cnt[z%mod]++;
		dat[z]++;
	}
	for(int i=0;i<=100000;i++)
	{
		gen[i%mod]+=dat[i]/2;
	}

    int ret = 0;
    for(int i = 0; i+i <= mod; i++){
        if(i == 0 || i+i == mod){
            ret += cnt[i] / 2;
        }else{

			if(cnt[i]<cnt[mod-i])ret+=cnt[i]+min((cnt[mod-i]-cnt[i])/2,gen[mod-i]);
			else ret+=cnt[mod-i]+min((cnt[i]-cnt[mod-i])/2,gen[i]);

        }
    }
    printf("%d\n",ret);

}


Measured memory_bytes: 1408
/**
 * File              : F - LCS .cpp
 * Author            : horcrux2301 <khajuriaharsh729@gmail.com>
 * Date              : 06.01.2019
 * Last Modified Date: 06.01.2019
 */
#include <bits/stdc++.h>
#define ll long long
#define mp(a,b)     make_pair(a,b)
#define newline     cout << endl;
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int main(){
    //clock_t tStart = clock();
    int test;
    test=1;
    //cin >> test;
    while(test--){
        string s1,s2;
        cin >> s1  >> s2;
        ll a = s1.length();
        ll b = s2.length();
        ll dp[a+1][b+1];
        for(ll i=0;i<a+1;i++){
            for(ll j=0;j<b+1;j++){
                if(i==0 || j==0) dp[i][j]=0;
                else if(s1[i-1]==s2[j-1]) dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
            }
        }
        string ans = "";
        int i = a, j = b;
        while(i>0 && j>0){
            if(s1[i-1]==s2[j-1]){
                ans+=s1[i-1];
                i--;
                j--;
            }
            else if(dp[i-1][j]>dp[i][j-1]){
                i--;
            }
            else{
                j--;
            }
        }
        reverse(ans.begin(), ans.end());
        cout << ans << endl;
    }
    //printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}



Measured memory_bytes: 70656
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;


#define REP(i,n) for(int i=0;i<(int)n;i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()


double EPS = 1e-10;

double add(double a, double b){
	if(abs(a+b) < EPS * (abs(a) + abs(b))) return 0;
	return a+b;
}

struct P{
	double x,y;
	P(){}
	P(double x, double y) : x(x), y(y){
	}
	P operator +(P p){
		return P(add(x,p.x), add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x), add(y,-p.y));
	}
	P operator *(double d){
		return P(d*x, d*y);
	}
	double dot (P p){
		return add(x*p.x, y*p.y);
	}
	double det (P p){
		return add(x*p.y, -y*p.x);
	}
	void print (){
		cout << x << " " << y <<endl;
		return;
	}
};

int intersectionCheck(P &p0, P &p1, P &p2, P &p3){
	P q0 = p1-p0;
	P q1 = p3-p2;
	if(q0.det(q1)==0){
		if((p2-p1).det(p2-p0)!=0) return 0;
		if(((p2-p0).dot(p2-p1)<=0)||((p3-p0).dot(p3-p1)<=0) || ((p1-p2).dot(p1-p3)<=0)){
			return 1;
		}else{
			return 0;
		}
	}

	P r = p0 + (p1-p0)*(q1.det(p2-p0)/q1.det(q0));
	if ((p0-r).dot(p1-r) <=0 && (p2-r).dot(p3-r) <=0){
		return 1;
	} else{
		return 0;
	}
}

int main(){
	int q;
	cin >> q;

	REP(i, q){
		P p0, p1, p2, p3;
		cin >> p0.x >> p0.y >>p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y ;
		cout << intersectionCheck(p0, p1, p2, p3) << endl;
	}
	return 0;
}

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

int main() {
long long  N,K;
    cin >> N >> K ;
long long Nmin=N;
 
    N=N%K;
    Nmin=min(N,Nmin);
    Nmin=min(K-N,Nmin);

  cout << Nmin << endl;  
}


Measured memory_bytes: 256
#!ruby -pl
xa,ya,xb,yb,xc,yc,xd,yd=$_.split(?,).map &:to_i
xab=xb-xa
yab=yb-ya
xbc=xc-xb
ybc=yc-yb
xcd=xd-xc
ycd=yd-yc
xda=xa-xd
yda=ya-yd
zabc=xab*ybc-xbc*yab
zbcd=xbc*ycd-xcd*ybc
zcda=xcd*yda-xda*ycd
zdab=xda*yab-xab*yda
$_=zabc>0&&zbcd>0&&zcda>0&&zdab>0||zabc<0&&zbcd<0&&zcda<0&&zdab<0?:YES: :NO

Measured memory_bytes: 6104
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int n,q,ans=0,chk=0;
    scanf("%d",&n);
    vector<int> s(n);
    for(auto&e:s){
        scanf("%d",&e);
    }
    sort(s.begin(),s.end());

    scanf("%d",&q);
    vector<int> t(q);
    for(auto&e:t){
        scanf("%d",&e);
    }
    sort(t.begin(),t.end());

    for(int i=0;i<q;i++){
        for(int j=chk;j<n;j++){
            if(t[i]==s[j]){
                ans++;
                break;
            }else if(t[i]<s[j]){
                break;
            }
            chk=j;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1564
#include<stdio.h>
int main(void)
{
	long w,a,b;
	scanf("%d %d %d", &w, &a, &b);
	if(abs(a-b)-w>0)
	printf("%d\n", abs(a-b)-w);
	else
	printf("0\n");
	
	return 0;
}

Measured memory_bytes: 128
N, Y = map(int, input().split())

for i in range(N+1):
    for j in range(N+1-i):
        if i*1000 + j*5000 + (N-i-j)*10000 == Y:
            print(N-i-j,j,i)
            exit(0)

print(-1,-1,-1)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    ll ans = 0;
    for(int i = 0;i < n+1;i++)cin >> a[i];
    for(int i = 0;i < n;i++)cin >> b[i];
    ll zero = 0;
    for(int i = 0;i < n;i++){
        ans += min(a[i]+a[i+1],b[i]);
        if(b[i] >= a[i]+a[i+1]){
            a[i] = 0;
            a[i+1] = 0;
        }else{
            b[i] = max(zero,(b[i]-a[i]));
            a[i+1] -= b[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  long long int start=0;
  long long int end=s.size()-1;
  bool ok=true;
  long long int ans=0;
  while(start<end){
    if(s[start]=='x'&&s[end]=='x'){
      start++;
      end--;
      continue;
    }
    if(s[start]=='x'){
      start++;
      ans++;
      continue;
    }else if(s[end]=='x'){
      ans++;
      end--;
      continue;
    }

    if(s[start]==s[end]){
      start++;
      end--;
    }else{
      ok=false;
      break;
    }
  }
  if(ok){
    cout<<ans<<endl;;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if(n==0) {
				break;
			}
			int[] score = new int[n];
			double average = 0;
			double total = 0;
			double a;
			double a2;
			for (int i = 0; i < n; i++) {
				score[i] = scanner.nextInt();
				total = total + score[i];
			}
			average = total / n;
			double totala = 0;
			for (int i = 0; i < n; i++) {
				totala = totala + Math.pow(score[i] - average, 2);
			}
			a2 = totala / (double)n;
			a = Math.sqrt(a2);
			System.out.printf("%.10f\n", a);
		}
	}

}


Measured memory_bytes: 31956
n = int(input())
h = list(map(int, input().split( )))

Stk = []
Stk.append([h[0],1])
ans = []

for i in range(1,n):
    if Stk[-1][0] <= h[i]:
        Stk.append([h[i],1])
        
    else:
        tmp = 0
        while len(Stk) > 0 and Stk[-1][0]>h[i]:
            [hei,w] = Stk.pop()#Stk.pop()[0],Stk.pop()[1]だとpop2回することになるか
            tmp+=w
            ans.append(hei*tmp)
            
        Stk.append([h[i],tmp+1])
###以上だと最後appendした後の分が欠ける
tmp = 0
while len(Stk) > 0:
    [hei,w] = Stk.pop()
    tmp+=w
    ans.append(hei*tmp)

print(max(ans))
    


Measured memory_bytes: 19340
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n, q;
Int c[1 << 19];
Int l[1 << 19];
Int r[1 << 19];
Int last_app[1 << 19];
Int ans[1 << 19];
vector<Int> queries[1 << 19];
vector<Int> rights[1 << 19];

Int seg[1 << 20];

void add(int ind)
{
    ind += 1 << 19;
    while (ind) {
        seg[ind]++;
        ind /= 2;
    }
}

int sum_of(int l, int r)
{
    l += 1 << 19;
    r += 1 << 19;
    int ans = 0;
    while (l < r) {
        if (l % 2)
            ans += seg[l++];
        if (r % 2)
            ans += seg[--r];
        l /= 2;
        r /= 2;
    }
    return ans;
}

int main()
{
    cin >> n >> q;
    for (int i = 0; i < n; i++)
        cin >> c[i];

    for (int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
        l[i]--;
        queries[l[i]].push_back(i);
    }

    fill(last_app, last_app + (n + 1), -1);
    for (int i = 0; i < n; i++) {
        if (last_app[c[i]] != -1)
            rights[last_app[c[i]]].push_back(i);
        last_app[c[i]] = i;
    }

    for (int i = n - 1; i >= 0; i--) {
        for (auto right : rights[i])
            add(right);

        for (auto q_ind : queries[i]) {
            int left = l[q_ind];
            int right = r[q_ind];
            ans[q_ind] = (right - left) - sum_of(left, right);
        }
    }

    for (int i = 0; i < q; i++)
        cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 80860
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> x(n), y(n), t(n);
    int lst = -1e9, cnt = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'o' && lst + c < i) {
            lst = i;
            cnt++;
        }
        x[i] = cnt;
    }
    lst = 1e9, cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o' && lst - c > i) {
            lst = i;
            cnt++;
        }
        y[i] = cnt;
    }
    vector<bool> ok(n, false);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'x') {
            ok[i] = false;
            continue;
        }
        int sum = 0;
        if (i - c - 1 >= 0) {
            sum += x[i - c - 1];
        }
        if (i + c + 1 < n) {
            sum += y[i + c + 1];
        }
        if (sum + 1 == k) {
            ok[i] = true;
        }
    }
    for (int i = 0; i < n; i++) {
        if (ok[i]) t[i]++;
        if (i) t[i] += t[i - 1];
    }
    debug(t);
    for (int i = 0; i < n; i++) {
        if (ok[i] == false) continue;
        if (t[min(i + c, n - 1)] - t[i] != 0) continue;
        if (t[i] - (i - c - 1 >= 0 ? t[i - c - 1] : 0) != 1) continue;
        cout << i + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
#define Re register
using namespace std;
int main(){
    string s;cin>>s;    
    bool C=0,F=0;
    int L=s.length();
    for(Re int i=0;i<L;i++){
        if(s[i]=='C'&&!C)C=1;
        if(s[i]=='F'&&!F&&C)F=1;
    if(C&&F){cout<<"Yes";return 0;}
        
    }
    cout<<"No";
    return 0;
}


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7


int main() {
  ll a,b;
  cin>>a>>b;
  str s;
  bool D=false;
  ll count=0;
  FOR(i,a,b+1){
    s=to_string(i);
    FOR(j,0,s.sz/2){
      if(s[j]!=s[s.sz-1-j]){
        D=false;
        break;
      }
      else{
        D=true;
      }
    }
    if(D) count++;
  }
  co(count);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int solve()
{
    int a, b;

    std::cin >> a >> b;

    if (a < b)
        cout << string(b, a + '0') << endl;
    else
        cout << string(a, b + '0') << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long c1 = 0;
    long long c2 = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            if (a[i] > a[j]) c1++;
        }
        for (int g = 0; g < n;g++){
            if (a[i] > a[g]) c2++;
        }
    }
    long long mod = 1000000007;
    cout << (c1*k%mod + k*(k-1)/2%mod*c2%mod)%mod << endl;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

K = int(input())
A, B = LI()

ans = "NG"
for i in range(A, B+1):
    # print(i)
    if i % K == 0:
        ans = "OK"
print(ans)

Measured memory_bytes: 10932
// Author:: MUKUL KUMAR RAI
// Institution:: Jalpaiguri Government Engineering College
//If you are not doing well now just stick to it and learn new things one day you will be...
//Compete with yourself
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
///*template{{{
#define sz(x) (ll)x.size()
#define all(x) x.begin(),x.end()
#define trav(a,x) for(auto &a:x)
#define fr(i,a,b)  for(ll i=a;i<=b;i++)
#define fr1(i,a)   for(ll i=0;i<a;i++)
#define frr(i,a,b) for(ll i=b;i>=a;i--)
#define frr1(i,a)   for(ll i=a-1;i>=0;i--)
#define sorta(a,n) sort(a,a+n)
#define sortd(a,n) sort(a,a+n,greater<ll>())
#define sorva(a) sort(a.begin(),a.end())
#define sortvd(a) sort(a.begin(),a.end(),greater<ll>())
#define tc(t) while(t--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
using vi= vector<ll>;
using vvi= vector<vi>;
using vb =vector<bool>;
using vc =vector<char>;
using vs =vector<string>;
using vld =vector<ld>;
using pii =pair<ll,ll>;
using psi =pair<string,ll>;
using pci =pair<char,ll>;
using vpii =vector<pii>;
//}}}template*/
ll const mod=1e9+7;
ll const maxn=1e5+5;
ll const inf=1e18;
ll add(ll a,ll b){
    return ((a%mod)+(b%mod))%mod;
}
ll mul(ll a,ll b){
    return ((a%mod)*(b%mod))%mod;
}
ll powm(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
    return result;
}
ll modinverse(ll a, ll m){
    return powm(a,m-2,m);
}
bool prime(ll x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++)if(x%i==0)return false;
    return true;
}
ll divisor(ll x){
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++){
        if(x%i==0){
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
vector<ll> sieve(ll n) {    
    bool prim[n+1];
    memset(prim, true, sizeof(prim));
    for (ll p=2; p*p<=n; p++) {
        if (prim[p] == true) {
            for (int i=p*p; i<=n; i += p)
                prim[i] = false;
        }
    }
    vector<ll>v;
    for(int i=2;i<=n;i++)if(prim[i])v.push_back(i);
    return v;
}
vector<pii>fun(ll x){
    vpii v;
    for(ll i=2;i*i<=x;i++){
        if(x%i!=0)continue;
        ll cnt=0;
        while(x%i==0){
            cnt++;
            x/=i;
        }
        v.pb({i,cnt});
    }
    if(x!=1)v.pb({x,1});
    return v;
}
void solve(){
    ll n;
    cin>>n;
    vi a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    sort(all(a));
    sort(all(b));
    ll x,y;
    if(n&1){
        x=a[n/2];
        y=b[n/2];
    }
    else{
        x=a[n/2-1]+a[n/2];
        y=b[n/2-1]+b[n/2];
    }
    cout<<y-x+1;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fio;
    clock_t zzzz = clock();
    ll t;
    t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    debug("Total Time: %.3f\n", (double)(clock() - zzzz) / CLOCKS_PER_SEC);
   return 0;
}



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

int main()
{
    int n,count = 0,ans = -1,flag;
    cin>>n;
    for(int i = 1;i<=n;i++)
    {
       count = 0;
       int temp = i;
        while(temp%2 == 0 && temp != 0)
        {
            count++;
            temp = temp/2;
            //cout<<"fU\n";
        }
        if(count > ans)
            flag = i;
        ans = max(count,ans);
    }
    cout<<flag<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
string a,b;
int f[100001],g[100001],i,l1,r1,l2,r2,q;
int main()
{
  //  freopen("ntu.inp","r",stdin);
  //  freopen("ntu.out","w",stdout);
    cin>>a>>b;
    a=" "+a; b=" "+b;
    for(i=1;i<a.length();i++)
        if(a[i]=='A') f[i]=(f[i-1]+2)%3;
        else f[i]=(f[i-1]+1)%3;
    for(i=1;i<b.length();i++)
        if(b[i]=='A') g[i]=(g[i-1]+2)%3;
        else g[i]=(g[i-1]+1)%3;
    cin>>q;
    while(q--)
    {
        cin>>l1>>r1>>l2>>r2;
      //  cerr<<f[r1]-f[l1-1]+3)%3<<" "<<(g[r2]-g[l2-1]+3)%3)<<'\n';
        if(abs((f[r1]-f[l1-1]+3)%3-(g[r2]-g[l2-1]+3)%3)%3==0) cout<<"YES"<<'\n'; else cout<<"NO"<<'\n';
    }
}


Measured memory_bytes: 1636
n, D = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        cnt = 0
        for d in range(D):
            cnt += (x[i][d] - x[j][d])**2
        if (cnt**0.5).is_integer():
            ans += 1
print(ans)

Measured memory_bytes: 9440
def main():
    N, A = map(int, input().split())
    X = [int(x) for x in input().split()]

    cur = dict()
    cur[X[0]-A] = 1
    for i in range(1, N):
        temp = dict()
        temp[X[i]-A] = 1
        for v in cur:
            temp[v+X[i]-A] = temp.get(v+X[i]-A, 0) + cur[v]
        for v in temp:
            cur[v] = cur.get(v, 0) + temp[v]
    return cur.get(0, 0)

if __name__ == '__main__':

    print(main())

Measured memory_bytes: 3260
#include <iostream>
#include <string>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;

  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    cout << a * b << endl;
  } else {
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i){
        if (s[i] != t[i]){
            ++ans;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3700
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	x := scanInts(n)

	left, right := min(x), max(x)

	min := math.MaxInt64
	for i := left; i <= right; i++ {
		distance := 0
		for _, v := range x {
			distance += (v - i) * (v - i)
		}
		if distance < min {
			min = distance
		}
	}

	fmt.Printf("%d", min)
}

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}

func min(array []int) int {
	min := math.MaxInt64
	for _, v := range array {
		if v < min {
			min = v
		}
	}
	return min
}

func max(array []int) int {
	max := math.MinInt64
	for _, v := range array {
		if v > max {
			max = v
		}
	}
	return max
}


Measured memory_bytes: 640
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };





signed main() {
	int n;
	vector<int>list;

	cin >> n;

	int ima = 1, cnt = 0;

	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		list.push_back(num);

		if (ima == num) {
			ima++;
			cnt++;
		}

	}

	if (cnt == 0) {
		cout << -1 << endl;
	}
	else {
		cout << n - cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#define LB(v,x) std::lower_bound(v.begin(),v.end(),x)-v.begin()+1
#define vi std::vector<int>
const int maxN = 6e5 + 10;
int arr[maxN],next[maxN];
std::map<int,int> mp;
vi BIT[maxN],required[maxN];
void update(int index,int val,int n){
	while(index<=n){
		int indexj = LB(required[index],val);
		int sz = BIT[index].size();
		while(indexj<=sz){
			BIT[index][indexj]+=1;
			indexj+=(indexj&-indexj);
		}
		index+=(index&-index);
	}
}
int query(int index,int val){
	int ret=0;
	while(index>0){
		int sz = required[index].size(), indexj = sz ;
		while(indexj>0){
			ret += BIT[index][indexj];
			indexj-=(indexj&-indexj);
		}
		indexj = LB(required[index],val)-1;
		while(indexj>0){
			ret -= BIT[index][indexj];
			indexj-=(indexj&-indexj);
		}
		index-=(index&-index);
	}
	return ret;
}
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&arr[i]);
	for(int i=n;i;i--){
		next[i] = mp.count(arr[i])?mp[arr[i]]:n+1;
		mp[arr[i]]=i;
	}
	
	for(int i=1;i<=n;i++){
		int index=i;
		while(index<=n){
			required[index].push_back(next[i]);
			index+=(index&-index);
		}
		std::sort(required[i].begin() , required[i].end());
		required[i].erase( unique( required[i].begin() , required[i].end() ) , required[i].end());
		BIT[i] = vi( required[i].size()+2,0);
	}
	
	for(int i=1;i<=n;i++)update(i,next[i],n);
		
	for(int i=1;i<=q;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		int ret=query(r,r+1)-query(l-1,r+1);
		printf("%d\n",ret);
	}
}
	


Measured memory_bytes: 105468
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

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


int main(void)
{
    ll n,ans=0;
    cin >> n;
    map<ll,ll> mp;
    rep(i,n){
        ll a;
        cin >> a;
        mp[a]++;
    }
    for(auto i:mp){
        ll tmp;
        if(i.second-i.first >= 0) tmp = i.second-i.first;
        else tmp = i.second;
        ans += min(i.second, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9540
# coding: utf-8

h = int(input())
w = int(input())
n = int(input())
count  = num = 0

higher = max(h,w)
lower = min(h,w)

for i in range(lower):
    count = higher*(i+1)
    num += 1
    if count>=n:
        print(num)
        exit()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main (void){
  string s;
  cin >> s;
  if(s[0] == s[1] && s[0] == s[2] && s[0] == s[3]){cout << "No" << endl;}
  else{
    if(s[0] == s[1] && s[2] == s[3]){cout << "Yes" << endl;}
    else if(s[0] == s[2] && s[1] == s[3]){cout << "Yes" << endl;}
    else if(s[0] == s[3] && s[1] == s[2]){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
  }
  return 0;
}
 

Measured memory_bytes: 3588
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 100000007
#define INF 1e9
/****************************/
 
const int N = 303;
int n;
ll a[N][N];
ll ans = 0;
 
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			scanf("%lld", &a[i][j]);
		}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < i; j++) {
			ll w = a[i][j] + 1;
			for (int k = 0; k < n; k++) {
				if (i == k || j == k) continue;
				w = min(w, a[i][k] + a[k][j]);
			}
			if (w < a[i][j]) {
				printf("-1\n");
				return 0;
			}
			if (w > a[i][j]) ans += a[i][j];
		}
	printf("%lld\n", ans);
 
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int can[100050];
int a[100500];

bool chmin(int &a, int b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

bool chmax(int &a, int b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W;
    cin >> W;
    for(int i = 0; i < W; i++) cin >> a[i];
    for(int i = 0; i < W; i++) can[i] = -1;
    priority_queue<i_i> que;
    for(int i = 0; i < W; i++) {
        if(a[i] == 0) {
            can[i] = 1e9;
            que.push({1e9, i});
        }
    }
    int dw[2] = {1, -1};
    while(!que.empty()) {
        i_i now = que.top();
        que.pop();
        //cerr << now.first << " " << now.second << endl;
        for(int index = 0; index <= 1; index++) {
            int neww = now.second + dw[index];
            if(neww < 0 || neww >= W) continue;
            int newcost = can[now.second] - 1;
            if(a[neww] < 0) {
                chmin(newcost, -a[neww] - 1);
            }
            if(chmax(can[neww], newcost)) {
                que.push({newcost, neww});
            }
        }
    }
    //for(int i = 0; i < W; i++) cerr << i << " " << can[i] << endl;
    int ans = 0;
    for(int i = 0; i < W; i++) {
        if(a[i] <= 0) continue;
        ans += min(a[i], can[i] + 1);
    }
    cout << ans << endl;
    return 0;
}



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

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

  vector<int> V;
  V.reserve(N);
  for (int i = 0; i < N; i++) {
    int v;
    cin >> v;
    V.emplace_back(v);
  }

  vector<int> C;
  C.reserve(N);
  for (int i = 0; i < N; i++) {
    int c;
    cin >> c;
    C.emplace_back(c);
  }

  int result = 0;
  for (int i = 0; i < N; i++) {
    result += max(0, V[i] - C[i]);
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
l.sort()

import bisect

count = 0
for i in range(n-1):
    for j in range(i+1, n):
            ab = l[i] + l[j]
            right = bisect.bisect(l, ab-1)
            left = j + 1
            count += (right - left)

print(count)

Measured memory_bytes: 9368
import scala.io.StdIn.{readInt,readLine}

object Main {
  def search(a:Array[Int],value:Int) = {
    def scan(l:Int,r:Int):Boolean = {
      val mid = (l+r)/2
      if(a(mid) == value) true
      else if(l>=r) false
      else if(a(mid)<value) scan(mid+1,r)
      else scan(l,mid-1)
    }
    scan(0,a.length-1)
  }

  def main(args:Array[String]) = {
    readInt
    val s = readLine.split(" ").map(_.toInt).toArray
    readInt
    val t = readLine.split(" ").map(_.toInt).toArray
    println(t.count(i=> search(s,i) ))
  }
}

Measured memory_bytes: 72048
#include <stdio.h>
int main (void){
long long int  a[10000],max,min,sum=0;
int n,i;
scanf("%d",&n);

for(i=0;i<n;i++){
scanf("%lld",&a[i]);
}

for(i=0;i<n;i++){
 sum+=a[i];
}
max=a[0];
for(i=1;i<n;i++){
if(max<a[i]){
max=a[i];
}
}
min=a[0];
for(i=1;i<n;i++){
if(min>a[i]){
min=a[i];
}}


printf("%lld %lld %lld\n",min,max,sum) ;
return 0 ;
}

Measured memory_bytes: 676
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

  string str;cin >> str;
  cout << ((str[0] == str[1] && str[1] == str[2]) ? "No" : "Yes") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int> > c(h, vector<int>(w));
  rep(i, h) rep(j, w) { char c_; cin >> c_; c[i][j] = (c_ == '#'); }

  int ans = 0;
  rep(i, 1 << h) rep(j, 1 << w) {
    vector<vector<int> > c2 = c;
    rep(l, h) {
      if (i & (1 << l)) {
        rep(m, w) c2[l][m] = 0;
      }
    }
    rep(l, w) {
      if (j & (1 << l)) {
        rep(m, h) c2[m][l] = 0;
      }
    }
    int cnt = 0;
    rep(l, h) rep(m, w) cnt += c2[l][m];
    ans += (cnt == k);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main() {
    int A, B;
    scanf("%d %d", &A, &B);
    int resultA, resultB, resultC;
    resultA = A + B;
    resultB = A - B;
    resultC = A * B;
    if(resultA > resultB){
        if(resultA > resultC){
            printf("%d", resultA);
        }else{
            printf("%d", resultC);
        }
    }else{
        if(resultB > resultC){
            printf("%d", resultB);
        }else{
            printf("%d", resultC);
        }
    }
    return 0;
}



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

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

    string ans = string(S.size(), char('z' + 1)); 
    for (int i = 0; i + T.size() <= S.size(); i++) {
        string S2 = S;
        for (int j = 0; j < T.size(); j++) {
            if (S2[i + j] == '?') S2[i + j] = T[j];
        }
        if (S2.substr(i, T.size()) != T) continue;
        // 残りをa埋め
        for (int j = 0; j < S2.size(); j++) {
            if (S2[j] == '?') S2[j] = 'a';
        }
        ans = min(ans, S2);
    }
    if (ans[0] == char('z' + 1)) cout << "UNRESTORABLE" << endl;
    else cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
object Main{
  def main(args:Array[String]) = {
    val list = scala.io.StdIn.readLine.split(" ").map(_.toLong).toList;
    val ans = Math.min(Math.min(list(0) + list(1), list(0) + list(2)), list(1) + list(2))
    println(ans)
  }
}

Measured memory_bytes: 25416
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr long long LINF=334ll<<53; constexpr int INF=15<<26; constexpr long long MOD=1E9+7;
void fail(){cout << "NO" <<"\n"; exit(0);}
void ok(){cout << "YES" <<"\n"; exit(0);}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,odd=0,even=0;
    cin >> n;
    for(int i=0; i<n; ++i){
        int tmp;
        cin >> tmp;
        if(tmp%2==0)even++;
        else odd++;
    }
    if(odd%2!=0)fail();
    ok();


    return 0;
}



Measured memory_bytes: 256