akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i*i <= x; i++) {
		if (x%i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int a, b;
char c[114][114];
signed main() {
	cout << 100 << " " << 100 << endl;
	cin >> a >> b;
	rep(i, 100)rep(j, 100) {
		if (i < 50)c[i][j] = '.';
		else c[i][j] = '#';
	}
	a--; b--;
	rep(i, a) {
		c[51 + i / 50 * 2][i % 50 * 2] = '.';
	}
	rep(i, b) {
		c[i / 50 * 2][i % 50 * 2] = '#';
	}
	rep(i, 100) {
		rep(j, 100) {
			cout << c[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define Rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)

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

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


////////////////////////////////////////////////////////////////////


int main() {
int a,b,c;
cin>>a>>b>>c;
if(a+b+c>=22){
	cout<<"bust"<<endl;
	return 0;
}
cout<<"win"<<endl;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int A, B, C, K, sum = 0, max=0,another,other;
	cin >> A >> B >> C >> K;
	max = A;
	A = 0;
	another = B;
	other = C;
	if (max < B) { 
		A = max;
		max = B;
		B = 0;
		another = A;
		if (max < C) {
			B = max;
			max = C;
			C = 0;
			other = B;
		}
	}
	else if (max < C) {
		A = max;
		max = C;
		C = 0;
		other = A;
	}
	for (int i = 0; i < K; i++) {
		max = max * 2;
	}
	sum = max + another + other;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
ans = a.inject(:+)
sa = 100000000000000
count  = 0
a.each_with_index do |i,j|
	# count += i
    # tmp = ans -  count
    # all = tmp - count
  	# if j != n - 1
    #     sa = [sa,all.abs].min
    # end
    count += i
    ans -= i
    all = ans - count
    if j != n - 1
        sa = [sa,all.abs].min
    end
end
puts sa


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

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long 

using namespace std ;

const int MAXN = 1001 * 1001   ; 

int a[MAXN] ; 


int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n ; 
	cin >> n ;
	int ans = 0 ; 
	while(ans*(ans+1)/2<n)
		ans ++ ; 
	cout << ans << '\n' ; 
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n+1)]
    for i in range(len(s)):
        pt[s[i]].append(t[i])
        if directed==False:
            pt[t[i]].append(s[i])
    return pt

N = I()
a,b = Line(N-1,2)
c = III()

if N==1:
    print(c[0])
    print(c[0])
    exit()

c.sort()
M = sum(c[:-1])

pt = edges_to_pt(a,b,N)

used = [False]*(N+1)
ans = [0]*(N+1)
used[1] = True
ans[1] = c.pop()
q = [1]
while q:
    q1 = []
    for i in q:
        for j in pt[i]:
            if used[j]==False:
                used[j] = True
                ans[j] = c.pop()
                q1.append(j)
    q = q1

print(M)
print(*ans[1:])

Measured memory_bytes: 48860
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	int x = log(n) / log(2);
	cout << pow(2,x) << endl;
}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	ll n,tot=0;cin>>n; vl a(n); repi(i,n) {cin>>a[i];tot^=a[i];}
	ll ans=0;
	repi(i,n) {
		cout<<(a[i]^tot);
	if(i+1==n) cout<<endl; else cout<<" ";
	}
	
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 4760
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n)cin >> v[i];
	vector<int> rate = { 0,4,8,12,16,20,24,28,32,100};
	vector<int> num(10, 0);
	rep(i, n) {
		int tmp = v[i] / 100;
		int t = 0;
		while (tmp >= rate[t]) {
			t++;
		}
		num[t - 1]++;
	}
	int mini = 0, maxi = 0;
	rep(i, rate.size()) {
		if (i != 8) {
			if (num[i] != 0) {
				mini++;
				maxi++;
			}
		}
		else {
			maxi += num[i];
		}
	}
	cout << max(mini,1) << " " << maxi << endl;
}


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

double z(double x)
{
  if(x>=0)
    return x;
  else
    return x*-1;
}

int main()
{
  double n,t,a,ans;
  ans=1000000;
  cin>>n>>t>>a;
  vector<double> h(n);
  for(int i=0;i<n;i++)
  {
    cin>>h.at(i);
    h.at(i)=z(a-(t-h.at(i)*0.006));
    ans=min(ans,h.at(i));
  }
  for(int i=0;i<n;i++)
  {
    if(h.at(i)==ans)
    {
      cout<<i+1;
      break;
    }
  }
}

Measured memory_bytes: 3764
#include<stdio.h>

int main(){

  int x,y,z=1;

  scanf("%d %d",&x,&y);

  if( x < y ){
    z = x;
    x = y;
    y = z;
  }

  while(1){

    if( z == 0 ) break;
    z = x % y;
    x = y;
    if( z != 0 ) y = z;
   

  }

  printf("%d\n",y);

  return 0;
}

Measured memory_bytes: 592
n=int(input())
x=list(map(int,input().split()))

result=10**18

for i in range(1,101):
    tmp=0
    for j in range(1,n+1):
        tmp+=(x[j-1]-(i))**2
    else:
        if result>tmp:
            result=tmp
            
print(result)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
	int A, B, x, y;
	cin >> A >> B;
	x = A % 2;
	y = B % 2;
	if (x == 1) {
		if (y == 1) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Debug.Trace

solve [] _ = 0
solve (x:xs) base 
  | x < base = 0 + solve xs base
  | otherwise = 1 + solve xs base

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  xs <- map read . words <$> getLine :: IO [Int]
  let
    base = ceiling $ (fromIntegral (sum xs)) / (fromIntegral (4 * m))
    res = solve xs base
  
  case compare res m of
    LT -> putStrLn "No"
    _ -> putStrLn "Yes"

Measured memory_bytes: 1020
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string str;
int pos;

int exp(void);
int term(void);
int factor(void);

int main(){
  int i,j,n,ans;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> str;
    str.erase(str.size()-1);
    pos = 0;
    ans = exp();
    cout << ans << endl;
    str.clear();
  }
  return 0;
}

int exp(void){
  int x = term();
  while(str[pos] == '+' || str[pos] == '-'){
    char op = str[pos++];
    if(op == '+') x += term();
    else if(op == '-') x -= term();
  }
  return x;
}

int term(void){
  int x = factor();
  while(str[pos] == '*' || str[pos] == '/'){
    char op = str[pos++];
    if(op == '*') x *= factor();
    else if(op == '/') x /= factor();
  }
  return x;
}

int factor(void){
  int x=0,c;
  if(str[pos] == '('){
    pos++;
    x = exp();
    pos++;
  }
  else{
    while(str[pos] >= '0' && str[pos] <= '9'){
      x *= 10;
      x += str[pos++] - '0';
    }
  }
  return x;
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}
template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int H, W, D; cin >> H >> W >> D;
    vector<pair<int, int>> pos(H*W);
    vector<long long> d(H*W);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a; cin >> a; a--;
            pos[a] = make_pair(i, j);
        }
    }

    for (int i = 0; i < D; i++) {
        for (int j = i; j < H*W-D; j += D) {
            int x0 = pos[j].first, y0 = pos[j].second;
            int x1 = pos[j+D].first, y1 = pos[j+D].second;
            d[j+D] = d[j] + abs(x0 - x1) + abs(y0 - y1);
        }
    }

    int Q; cin >> Q;
    while (Q--) {
        int l, r; cin >> l >> r;
        l--, r--;
        cout << d[r] - d[l] << '\n';
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vl a;
	a.push_back(n+m);
	a.push_back(n-m);
	a.push_back(n*m);
	puta(max(a));
	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
*a, = map(int, input().split())

ans = 0
for i in range(N-1):
    s = a[i] + a[i+1]
    if s > x:
        ans += s - x
        a[i+1] = max(0, a[i+1]-(s-x))

print(ans)

Measured memory_bytes: 20112
lines = []
while str = gets
  break if str == "." || str == ".\n"
  # [ => 1 ( => 2
  this_kakko = ""
  kakko_stack = []
  str.length.times.each do |i|
    if str[i] == "["
      this_kakko = "["
      kakko_stack.push "["
    end
    if str[i] == "("
      this_kakko = "("
      kakko_stack.push "("
    end
    if str[i] == "]"
      if kakko_stack.size == 0
        kakko_stack.push -1
        break
      end
      break if this_kakko != "["
      kakko_stack.pop
      this_kakko = kakko_stack.last
    end
    if str[i] == ")"
      if kakko_stack.size == 0
        kakko_stack.push -1
        break
      end
      break if this_kakko  != "("
      kakko_stack.pop
      this_kakko = kakko_stack.last
    end
  end
  puts kakko_stack.size == 0 ? "yes" : "no"
end

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


const int maxn = 3000 + 2;

long long dp[maxn][maxn][2];

vector<long long> a;

void solve()
{
	int n;
	cin >> n;

	a.resize(n);


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

	for (int l = 2; l <= n; l++)
	{
		for (int i = 0; i + l - 1 < n; i++)
		{
			int j = i + l - 1;

			dp[i][j][0] = max(dp[i + 1][j][1] + a[i], dp[i][j - 1][1] + a[j]);

			dp[i][j][1] = min(dp[i + 1][j][0] - a[i], dp[i][j - 1][0] - a[j]);

			//cout << i << " " << j << " " << dp[i][j][0] << "\n";
			//cout << i << " " << j << " " << dp[i][j][1] << "\n";
			//cout << "\n";
		}
	}

	cout << dp[0][n - 1][0];

}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 139648
Node = Struct.new(:key, :left, :right)

class Tree
  def initialize
    @root = nil
  end
  
  def insert(key)
    unless @root
      @root = Node.new(key)
      return
    end
    node = @root
    while node
      if key < node.key
        if node.left
          node = node.left
        else
          node.left = Node.new(key)
          break
        end
      else
        if node.right
          node = node.right
        else
          node.right = Node.new(key)
          break
        end
      end
    end
  end
  
  def search(key)
    node = @root
    while node
      if key < node.key
        node = node.left
      elsif key > node.key
        node = node.right
      else
        return node
      end
    end
    nil
  end
  
  def preorder
    traverse = ->(node) {
      if node
        yield(node.key)
        traverse.(node.left)
        traverse.(node.right)
      end
    }
    traverse.(@root)
  end
  
  def inorder
    traverse = ->(node) {
      if node
        traverse.(node.left)
        yield(node.key)
        traverse.(node.right)
      end
    }
    traverse.(@root)
  end
end

t = Tree.new

$<.gets.to_i.times do
  com, key = $<.gets.split
  case com
  when "insert" then t.insert(key.to_i)
  when "print"
    t.inorder  {|key| print " #{key}"}
    puts
    t.preorder {|key| print " #{key}"}
    puts
  when "find"
    puts t.search(key.to_i) ? "yes" : "no"
  end
end


Measured memory_bytes: 31452
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int gcd(int x, int y) {
    if(y == 0) {
        return x;
    }
    else {
        return gcd(y, x%y);
    }
}

int gcd(vector<int> a) {

    int ans = a[0];
    for(int i = 1; i < a.size(); i++) {
        ans = gcd(ans, a[i]);
    }
    return ans;
}

int main() {
    int N, X;
    cin >> N >> X;
    int x[N+1];
    rep(i, N) {
        cin >> x[i];
    }
    x[N] = X;

    sort(x, x+N+1);

    vector<int> L(N);
    rep(i, N) {
        L[i] = x[i+1] - x[i];
    }
    int ans = gcd(L);

    cout << ans;

    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<vector<ll>> A(N, vector<ll>(N));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      scanf("%lld", &A[i][j]);
    }
  }

  vector<vector<bool>> need(N, vector<bool>(N, true));
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        ll val = A[i][k] + A[k][j];
        if (A[i][j] > val) {
          printf("-1\n");
          return 0;
        }
        if (A[i][j] == val and i != k and j != k) {
          need[i][j] = false;
        }
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      if (need[i][j]) { ans += A[i][j]; }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 101;
int N, a[MAX];

int main(int argc, char ** argv) {
	int ans = (1 << 30);
	scanf("%d", &N);
	rep(i, 0, N) scanf("%d", a+i);
	REP(k, -100, 100) {
		int aux = 0;
		rep(i, 0, N) aux += abs(a[i]-k)*abs(a[i]-k);
		ans = min(ans, aux);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

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

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

char tr[128];
char str[111111111];

int main(){
	while(1){
		REP(i, 128)tr[i] = i;
		int d,n;
		cin >> d;
		if(d==0)break;
		REP(i, d){
			char s[2][2];
			scanf("%s",s[0]);
			scanf("%s",s[1]);
			tr[s[0][0]] = s[1][0];
		}
		cin >> n;
		REP(i, n){
			char t[2];
			scanf("%s", t);
			str[i] = tr[t[0]];
		}
		str[n] = 0;
		printf("%s\n", str);
	}
	return 0;
}

Measured memory_bytes: 1256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

ll cal_gcd(ll m, ll n) {
	while (m%n != 0) {
		ll c = m % n;
		m = n;
		n = c;
	}
	return n;
}



int main() {
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (z >= 0 && z <= k)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long double db;
typedef long long ll;
typedef pair<db, db> pd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define mod 1000000007
#define maxn 100005

ll n, m, q, t, k;
ll a[maxn];

int solve(ll x) {
	if (a[x] >= 0)
		return a[x];

	if (x >= 100 && solve(x - 100))
		return a[x] = 1;
	if (x >= 101 && solve(x - 101))
		return a[x] = 1;
	if (x >= 102 && solve(x - 102))
		return a[x] = 1;
	if (x >= 103 && solve(x - 103))
		return a[x] = 1;
	if (x >= 104 && solve(x - 104))
		return a[x] = 1;
	if (x >= 105 && solve(x - 105))
		return a[x] = 1;
	return a[x] = 0;
}

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

	a[0] = 1;
	for (int i = 1; i < maxn; ++i) {
		a[i] = -1;
	}

	ll x;
	cin >> x;
	cout << solve(x);

	return 0;
}


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

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

  if (N == 1)
  {
    cout << "Hello World" << endl;
  }
  else
  {
    int A, B;
    cin >> A >> B;

    cout << A + B << endl;
  }
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int x[15],y[15],z[5],f,v[5100];
int cat(int a[],int b){
	char s[10],t[10];
	int i;
	//sprintf(s,"%d%d%d%d",a[0],a[1],a[2],a[3]);
	strcpy(t,"");
	for(i=0;i<b;i++)sprintf(s,"%d",a[i]),strcat(t,s);
	return atoi(t);
}
int combi(int a,int b,int c){
	int i,j;
	for(i=1;i<=a;i++){
		for(j=0;j<c-1;j++)if(x[j]==i)break;
		if(j==c-1){
			x[c-1]=i;
			z[c-1]=y[i-1];
			if(b==c){
				//for(j=0;j<c;j++)printf("%d ",x[j]);
				//printf(":%d ",cat(z,b));
				//printf("\n");
				v[f]=cat(z,b);
				f++;
			}else{
				combi(a,b,c+1);
			}
		}
	}
}
int main(){
	int i,j,n,k,ans;
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0 && k==0)break;
		for(i=0;i<n;i++)scanf("%d",&y[i]);
		ans=f=0;
		combi(n,k,1);
		for(i=0;i<f;i++){
			for(j=0;j<i;j++)if(v[i]==v[j])break;
			if(j==i)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 436
import time
import random
d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]


def calc_score(T):
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    score = 0
    for i in range(d):
        score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        score -= C[j] * (dd - X[j])
    return score


# 各日に一番満足度の増加が大きいコンテストを開催する
T = [S[i].index(max(S[i])) for i in range(d)]
score = calc_score(T)
start = time.time()
cnt = 0
while True:
    now = time.time()
    if now - start > 1.5:
        break
    p = cnt % d
    q = cnt % 26
    memo = T[p]
    T[p] = q
    new_score = calc_score(T)
    temp = 20000 * (1 - (now - start) / 2)
    prob = 2**((new_score - score) / temp)
    if random.random() < prob:
        score = new_score
    else:
        T[p] = memo
    cnt = (cnt + 1) % (10**9 + 7)

for t in T:
    print(t + 1)


Measured memory_bytes: 78600
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  int n, m;
  cin >> n >> m;
  int s[n] = {0};
  if (n != 1) s[0] = 1;
  bool f = true;
  int c[n] = {0};
  for (int i = 0; i < m; i++){
    int ts, tc;
    cin >> ts >> tc;
    if (s[ts-1]==tc || c[ts-1]==0){
      s[ts-1]=tc;
      c[ts-1]++;
    }else{
      f = false;
      break;
    }
  }
  if (s[0] == 0 && n > 1){
    f = false;
  }
  if (f){
    for (int j=0; j<n; j++){
      cout << s[j];
    }
  }else{
    cout <<"-1";
  }
  return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  string board[110];
  for (int i = 0; i < h; i++) {
      cin >> board[i];
  }

  bool x[110] = {false};
  bool y[110] = {false};
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (board[i][j] == '#') {
        x[i] = true;
        y[j] = true;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    if (x[i]) {
      for (int j = 0; j < w; j++) {
        if (y[j]) {
          cout << board[i][j];
        }
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
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 D[100001];
int P[100001];
int to[100001], ne[100001], he[100001];
int sagasu(int A) {
	if (D[A]) return D[A];
	int ret = 1;
	for (int i = he[A]; i; i = ne[i]) {
		int u = to[i];
		int kari = sagasu(u) + 1;
		if (ret < kari) {
			ret = kari;
			P[A] = u;
		}
	}
	return D[A] = ret;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), M = getint();
	rep1(i, N + M - 1) {
		int a = getint(), b = getint();
		to[i] = a;
		ne[i] = he[b];
		he[b] = i;
	}

	rep1(i, N) {
		sagasu(i);
		putint(P[i]);
	}
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

int main()
{
    string N,ans = "No";
    
    cin >> N;
    
    for(int i = 0; i <=1; i++){
        if(N[i] == '9') ans = "Yes";
    }
    
    cout << ans << endl;
    
    return 0;
}

    

Measured memory_bytes: 256
n, m = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
if n == 1:
    for i in range(0, 10**n):
        j = str(i)
        if all(int(j[s[k][0]-1])==s[k][1] for k in range(m)):
            print(i)
            exit()
else:
    for i in range(10**(n-1), 10**n):
        j = str(i)
        if all(int(j[s[k][0]-1])==s[k][1] for k in range(m)):
            print(i)
            exit()
print(-1)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

inline char nextChar()
{
	static char c;
	while ((c = getchar()) != '+' && c != '-');

	return c;
}

template <class T>
inline void relax(T &a, const T &b)
{
	if (b > a)
		a = b;
}

const int MaxN = 100000;
const s64 INF = 0x3f3f3f3f3f3f3f3fll;

int n;

s64 f0, f1, f2;

int main()
{
	cin >> n;

	f0 = getint();
	f1 = f2 = -INF;
	for (int i = 1; i < n; ++i)
	{
		if (nextChar() == '+')
		{
			int v = getint();
			f0 += v, f2 += v;
			f1 -= v;
		}
		else
		{
			int v = getint();
			f0 -= v, f2 -= v;
			f1 += v;

			relax(f2, f1);
			relax(f1, f0);
		}

		relax(f1, f2);
		relax(f0, f1);
	}

	cout << f0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
   string s,t;cin>>s>>t;
   
   int ans=0;
   if(s[0]==t[0])ans++;
   if(s[1]==t[1])ans++;
   if(s[2]==t[2])ans++;
   cout<<ans;
}

Measured memory_bytes: 256
#include<iostream> 
using namespace std; 
int main(){ 
  int n; cin>>n; 
  int a[n]; int b[n+1]; int c[n]; 
  int j,s=0; 
  for(int i=0;i<n;i++)cin>>a[i]; 
  for(int i=0;i<n;i++)cin>>b[i+1]; 
  for(int i=0;i<n-1;i++)cin>>c[i+1];
  j=0; 
  for(int i=0;i<n;i++){ //cout<<j<<" "<<a[i]<<" "<<b[a[i]];
    if(j!=0&&j==a[i]-1){ 
      s+=c[a[i]-1]; 
    } 
    s+=b[a[i]];
    j=a[i];  //cout<<" "<<c[a[i]-1]<<endl;                 
  } cout<<s; 
  return 0; 
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m + 1);
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    for (int i = 1; i <= k; i++) {
      int t;
      cin >> t;
      a[t]++;
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    if (a[i] == n) ans++;
  }
  cout << ans << '\n';
}


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

typedef struct{
	int now;
	int b;
}data;

int main(void){
	int i,j,N;
	data a[100];
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a[i].b);
		a[i].now = i+1;
	}
	int ans[N],ok=1,k=0;
	for(i=N-1;i>=0;i--){
		ok=0;
		for(j=N-1;j>=0;j--){
			if(a[j].b==a[j].now){
				ok=1;
				ans[k++]=a[j].b;
				a[j].now = -1;
				break;
			}else{
				a[j].now--;
			}
		}
		if(!ok)break;
	}
	if(!ok)printf("-1");
	else for(i=N-1;i>=0;i--)printf("%d\n",ans[i]);
	return 0;
}

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

int divide2(int n) {
  int num = 0;
  while (n % 2 == 0) {
    n = n / 2;
    num++;
  }
  return num;
}

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

  int n;
  cin >> n;

  int tmp = 0;

  int ans = 1;

  for (int i = 2; i <= n; i = i + 2) {
    int a = divide2(i);
    if (tmp <= a) {
      ans = i;
      tmp = a;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n=int(input())
t,h=map(int,input().split())
l=list(map(int,input().split()))
diff=4647474636374
ind=0
for i in range(n):
    var=t-l[i]*0.006
    if(abs(var-h)<diff):
        diff=abs(var-h)
        ind=i+1
print(ind)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n,m,t;
    cin>>n>>m>>t;

    vector<int> v(n);
    rep(i,0,n)cin>>v[i];

    int ans=0;
    ans+=max(0,v[0]-m);
    rep(i,0,n-1){
        ans+=max(0,v[i+1]-v[i]-2*m);
    }
    ans+=max(0,t-v[n-1]-m);
    cout<<ans<<endl;
    


    
    
    return 0;
}



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

int main(){
    double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2 ;
    while( cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2 ){
    if ( min( xa2,xb2 ) < max(xa1,xb1) ||
         min( ya2,yb2 ) < max(ya1,yb1) ) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    }
}

Measured memory_bytes: 1224
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let mut a = vec![0; N];
    let mut b = vec![0; N];
    let c = (0..N).map(|i| K + 2 * N + i).collect::<Vec<_>>();
    let m = (N - 1) / 2;
    let mut j = m;
    for x in (K..(K + N)).rev() {
        a[j] = x;
        j = (j + 1) % N;
    }
    for i in 0..m { b[i] = K + N + 2 * i + 1; }
    for i in m..N { b[i] = std::cmp::min(K + N + 2 * (i - m), K + 2 * N - 1); }
    let ans = if (0..N).all(|i| a[i] + b[i] <= c[i]) {
        (0..N)
            .map(|i| format!("{} {} {}", a[i], b[i], c[i]))
            .collect::<Vec<_>>()
            .join("\n")
    } else { "-1".to_string() };

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


Measured memory_bytes: 14588
#include<stdio.h>
int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a == 1 && b == 0 && c == 0) {
		printf("Close\n");
	}
	else if (a == 0 && b == 1 && c == 0) {
		printf("Close\n");
	}
	else if (a == 1 && b == 1 && c == 0) {
		printf("Open\n");
	}
	else if (a == 0 && b == 0 && c == 1) {
		printf("Open\n");
	}
	else if (a == 0 && b == 0 && c == 0) {
		printf("Close\n");
	}
	return 0;
}

Measured memory_bytes: 584
N, M, X = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]
ans = []

for i in range(2 ** N):
    buy = []
    temp = [0]*(M+1)
    for j in range(N): 
        if ((i >> j) & 1):
            buy.append(C[j][0]) 
            for k in range(M+1):
                temp[k] += C[j][k]
    
    check = 0
    for j in range(1,M+1):
        if temp[j]<X:
            check += 1
    
    if check == 0:
        ans.append(temp[0]) 

if ans==[]:
    print("-1")
else:
    print(min(ans))


Measured memory_bytes: 9232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m,c;
    sc(n,m,c);
    int b[m];
    GET(b);
    int ans = 0;
    FOR(i,0,n){
        int a[m];
        GET(a);
        ll ret = c;
        FOR(i,0,m){
            ret += a[i]*b[i];
        }
        ans += ret > 0;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

template<typename T>
struct SegTree {
	T init_val;
	int n;
	vector<T> dat;
	
	SegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(n * 2 - 1, init_val);
	}
	
	void update(int i, T x) {
		i += n - 1;
		chmin(dat[i], x);
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	
	T query(int a, int b, int k, int l, int r) {
		if (a >= r || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return min( query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r) );
	}
	T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

int N, Q, A, B;
int x[212345];

int main() {
	cin >> N >> Q >> A >> B;
	A--; B--;
	REP(i, Q) scanf("%d", x + i + 1), x[i + 1]--;
	x[0] = A;
	
	SegTree<ll> stp(N, INF), stn(N, INF); // +i, -i
	ll add = 0; // 区間加算されている合計
	
	stp.update(B, B);
	stn.update(B, -B);
	
	FOR(i, 1, Q + 1) {
		add += abs(x[i] - x[i - 1]);
		
		ll now = INF;
		
		// x[i] ≦ jとなるjでの最小を調べる
		chmin(now, stp.query(x[i], N) - x[i]);
		// x[i] > j となるjでの最小を調べる
		chmin(now, stn.query(0, x[i] + 1) + x[i]);
		
		now -= abs(x[i] - x[i - 1]);
		
		stp.update(x[i - 1], now + x[i - 1]);
		stn.update(x[i - 1], now - x[i - 1]);
	}
	
	ll ans = INF;
	REP(i, N) chmin(ans, stp.query(i, i + 1) - i);
	ans += add;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
 
/*------------------------------------------------------------------*/
 
int main(){
    ll n; cin >> n;
    string s = to_string(n);
    int m = s.length();
    int j = 0;
    int count = 0;
    while(j < m && m > 1){
        if(s[j] != '9' && j != m - 1){
            s[j]--;
            _rep(i, j + 1, m){
                if(s[i] != '9'){
                    s[i] = '9';
                    count++;
                }
            }
            if(count == 0)s[j]++;
            break;
        }else if(s[j] != '9'){
            s[j - 1]--;
            s[j] = '9';
            break;
        }
        j++;
    }
    int ans = 0;
    rep(i, m){
        ans += s[i] - '0';
    }
    //cout << s << endl;
    cout << ans << endl;
}


Measured memory_bytes: 764
import bisect
import sys
sys.setrecursionlimit(10000)
a=[]
def f(a,bin,n):
    if bin>n:return
    if bin:a+=[bin]
    f(a,bin*10+2,n)
    f(a,bin*10+8,n)

def g(n,p):
    m=-1<<20
    x=bisect.bisect_left(a,n)
    if x!=len(a) and a[x]==n:m=1
    if a[p]**2>n:return m
    if n%a[p]==0:m=g(n//a[p],p)+1
    return max(m,g(n,p+1))

n=int(input())
if n&1:print(-1);exit()
f(a,0,n)
a=sorted(a)
b=g(n,0)
if b<0:b=-1
print(b)

Measured memory_bytes: 37464
n, m = [int(i) for i in input().split()]
ab = [0] * n
for j in range(n):
  ab[j] = [int(i) for i in input().split()]
ab.sort(key = lambda x:x[0])
k = 0
ans = 0
while True:
  if m > ab[k][1]:
    ans = ans + ab[k][0] * ab[k][1]
    m = m - ab[k][1]
  else:
    ans = ans + ab[k][0] * m
    break
  k += 1
print(ans)

Measured memory_bytes: 22752
#include <cstdio>
#include <algorithm>
#include <vector>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define mp(a, b) make_pair(a, b)

using namespace std;

int a[510][510];

int main()
{
	int H, W, h, w;
	scanf("%d%d%d%d", &H, &W, &h, &w);
	long long sum = 0;
	int tmp0 = (1e9 - 1) / (h * w - 1), tmp1 = -tmp0 * (h * w - 1) - 1;
	
	Rep(i, H) Rep(j, W){
		if (!(i % h) && !(j % w)) a[i][j] = tmp1;
		else a[i][j] = tmp0;
		sum += a[i][j];
	}
	if (sum <= 0) printf("No\n");
	else {
		printf("Yes\n");
		Rep(i, H){
			Rep(j, W) printf("%d ", a[i][j]);
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int main(){
	long long n;
	while(cin >> n){
		vector<long long> v(n+1, 1);
		vector<long long> s(n+1, 1);
		long long res = 0;
		for(int i=0;i<n;i++){
			if(i==n-1){
				res += (v[i] * n)%MOD;
			} else {
				long long sq = ((n-1) * (n-1)) % MOD;
				res += (v[i] * (sq + min(i+2LL, n-1))) %MOD;
			}
			res %= MOD;
			v[i+1] = s[i];
			if(i-1 >= 0) v[i+1] += (MOD - v[i-1]);
			v[i+1] %= MOD;
			s[i+1] = (s[i] + v[i+1])%MOD;
		}
		cout << res << endl;
	}
}



Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    map<string, int> mp;
    for(int i = 0; i < q; i++)
    {
        int com, x;
        string key;
        cin >> com;
        if(com == 0)
        {
            cin >> key >> x;
            mp[key] = x;
        }
        else if(com == 1)
        {
            cin >> key;
            auto itr = mp.find(key);
            if(itr != mp.end()) cout << itr->second << endl;
            else cout << 0 << endl;
        }
        else if(com == 2)
        {
            cin >> key;
            mp.erase(key);
        }
        if(com == 3)
        {
            string l, r;
            cin >> l >> r;
            auto left = mp.lower_bound(l);
            auto right = mp.upper_bound(r);
            while(left != right)
            {
                cout << left->first << " " << left->second << endl;
                left++;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 25944
H,W=map(int,input().split())
answers=[]
answers.append([' ',]*(W+2))
for a in range(H):
    S=input()
    T=[b for b in S]
    T.append(' ')
    T.insert(0,' ')
    answers.append(T)
answers.append([' ',]*(W+2))
lll=[]
kotae=0
for a in range(H):
    A=answers[a+1]
    for b in range(W):
        if A[b+1]=='#':
            if A[b]=='#' or A[b+2]=='#'  or answers[a][b+1]=='#' or answers[a+2][b+1]=='#':
                pass
            else:
                kotae+=100
if kotae==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064