akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long n,k;
    cin>>n>>k;

    long long a[n];
    rep(i,n)cin>>a[i];

    long long second[46];
    second[0]=1;
    long long sum[50];
    sum[0]=0;
    rep2(i,45){
        second[i]=second[i-1]*2;
        sum[i]=sum[i-1]+second[i-1];
        //cout<<sum[i]<<" ";
    }
    //cout<<endl;
    long long right=1e9;
    long long left=0;

    while(left+1<right){

        long long mid=(right+left)/2;

        long long cnt=0;
        //cout<<mid<<endl;
        rep(i,n){
            
            //if(a[i]<=mid)continue;

            //cnt+=ceil(((double)a[i]/mid))-1;
            cnt+=(a[i]+mid-1)/mid-1;
            
        }
        

        if(cnt>k){
            left=mid;
        }
        else{
            right=mid;
        }
    }
    //cout<<endl;

    cout<<right<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 5028
using System;

public class Problem_C
{
  public static void Main()
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    int N = inputs[0], M = inputs[1];
    var paths1 = new bool[N];
    var paths2 = new bool[N];

    for (var i = 0; i < M; i++)
    {
      var path = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
      int from = path[0] - 1, to = path[1] - 1;
      if (from == 0) paths1[to] = true;
      else if (to == N - 1) paths2[from] = true;
    }

    var isPossible = false;
    for (var i = 0; i < N; i++)
    {
      if (paths1[i] && paths2[i])
      {
        isPossible = true;
        break;
      }
    }
    if (isPossible) Console.WriteLine("POSSIBLE");
    else Console.WriteLine("IMPOSSIBLE");
  }
}


Measured memory_bytes: 17376
//ABC 050-C
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;


int main() {
	char c;
	cin >> c;
	if (c == 'a') cout << "vowel" << endl;
	else if (c == 'i') cout << "vowel" << endl;
	else if (c == 'u') cout << "vowel" << endl;
	else if (c == 'e') cout << "vowel" << endl;
	else if (c == 'o') cout << "vowel" << endl;
	else cout << "consonant" << endl;
	system("pause");
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
 
using namespace std;
 
using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }
 
template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
 
constexpr int INF = 1e9;
constexpr int MXB = 20;
using bin = bitset<MXB>;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());
    
    int n, k;
    while (read(n, k)) {
        ivec p(n);
        read(p);
        sort(p.begin(), p.end());
        int ans = 0;
        forn(i, k) {
            ans += p[i];
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(){
  long int A = 0;
  long int B = 0;
  long int C = 0;
  long int D = 0;
  long int K = 0;
  cin >> A >> B >> K;
  if(K<A){
      C=A-K;
      D=B;
  }else if(K<A+B){
      C=0;
      D=A+B-K;
  }else{
      C=0;
      D=0;
  }
  cout << C << " " << D;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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 ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll a, b, c, k; cin >> a >> b >> c >> k;
  int ans = 0;
  for (int i = 1; i <= k; ++i){
    if (a > 0) {ans += 1; a--;}
    else if (b > 0) {b--;}
    else {ans -= 1; c--;}
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(){
  long long n,i,a,b,p,d[100010];
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld",&d[i]);
  a=b=2;
  d[n]=1e9;
  if(d[n-1]-2)goto END;
  for(i=n;i--;){
    if(a%d[i])a+=d[i]-a%d[i];
    b+=d[i]-b%d[i]-1;
  }
  p=a;
  for(i=0;i<n;i++)p-=p%d[i];
  if(p-2)goto END;
  p=b;
  for(i=0;i<n;i++)p-=p%d[i];
  if(p-2)goto END;
  printf("%lld %lld\n",a,b);
  return 0;
 END:;
  printf("-1\n");
  return 0;
}
    


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

using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;
    int a[n];
    vector <int> cnt(n + 1);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) ++cnt[a[i]];
    int ans = 0;
    for (int i = 0; i <= n; ++i) ans += cnt[i] * (cnt[i] - 1) / 2;
    for (int i = 0; i < n; ++i) {
        cout << ans - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2 << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);

int A,B,C;
  cin>>A>>B>>C;
int counter=0;
  if(A%2==0){counter++;}
   if(B%2==0){counter++;}
   if(C%2==0){counter++;}
vector<int> vec(3);
  vec[0]=A;vec[1]=B;vec[2]=C;
  vsort(vec);
  if(counter==0||counter==3){
    cout<<(vec[2]-vec[1]+vec[2]-vec[0])/2<<endl;
  }else{
    if(counter==1){
      for(int i=0;i<3;i++){
        if(vec[i]%2==1){vec[i]++;
                       }
      } vsort(vec);
       cout<<(vec[2]-vec[1]+vec[2]-vec[0])/2+1<<endl;
    }else if(counter==2){
           for(int i=0;i<3;i++){
        if(vec[i]%2==0){vec[i]++;
                       }
      } vsort(vec);
       cout<<(vec[2]-vec[1]+vec[2]-vec[0])/2+1<<endl;
    }
    

  }
}




Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            int diff = input[0] - input[1];
            int ans = input[2] - diff;
            ans = (ans < 0) ? 0 : ans;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    REP(i, s.length())if(s[i] == '1')ans++;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
def main():
  S = input()
  acgts = ['']
  for b in range(len(S)):
    for e in range(b + 1, len(S) + 1):
      span = S[b:e]
      if not span.replace('A', '').replace('G', '').replace('C', '').replace('T', ''):
        acgts.append(span)
  print(max([len(x) for x in acgts]))


if __name__ == "__main__":
  main()


Measured memory_bytes: 3064
n = int(input())
lucas = [2,1]
if n == 0:
  print(2)
elif n == 1:
  print(1)
t = 2
while t <= n:
  next_lucas = lucas[-1] + lucas[-2]
  lucas.append(next_lucas)
  if t == n:
    print(next_lucas)
  t += 1

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int mod=998244353;
const int maxn=3010;
int n,S,a[maxn],iv2,dp[maxn][maxn];
void update(int &x,int y) { x+=y; if (x>=mod) x-=mod; }
int ksm(int x,int y) {
	int res=1;
	while (y) {
		if (y&1) res=(ll)res*x%mod;
		x=(ll)x*x%mod; y>>=1;
	} return res;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(S);
	for (int i=1;i<=n;i++) read(a[i]);
	iv2=mod-mod/2;
	dp[0][0]=ksm(2,n);
	for (int i=0;i<n;i++)
	for (int j=0;j<=S;j++) {
		if (j+a[i+1]<=S) update(dp[i+1][j+a[i+1]],(ll)dp[i][j]*iv2%mod);
		update(dp[i+1][j],dp[i][j]);
	}
	printf("%d\n",dp[n][S]);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 38948
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int a[8];
int main(){
int s;
cin>>s;
int b;
int B=0,S=0;
for(int i=0;i<s;i++){
cin>>b;
if(b>=1 && b<=399)
a[0]++;
if(b>=400 && b<=799)
a[1]++;
if(b>=800 && b<=1199)
a[2]++;
if(b>=1200 && b<=1599)
a[3]++;
if(b>=1600 && b<=1999)
a[4]++;
if(b>=2000 && b<=2399)
a[5]++;
if(b>=2400 && b<=2799)
a[6]++; 
if(b>=2800 && b<=3199)
a[7]++;
if(b>=3200)
a[8]++;
}
if(a[8]>=1)
B+=a[8];
for(int i=0;i<8;i++)
if(a[i]>0){
S++;
B++;}
if(S==0)
S++;
cout<<S<<' '<<B;
system("pause");
return 0;
}


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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
	int n; scanf("%d", &n);
	int store[n + 1];
	for1(i, n) scanf("%d", &store[i]);
	int off = 0;
	for(int i = 1; i <=n; i++) {
		if(store[i] != i)
			off++;
	}
	off == 2 || off == 0?printf("%s", "YES"):printf("%s", "NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b;
    cin>>a>>b;
    if(a>b)
        swap(a,b);
    if(b-a<=1){
        cout<<"Brown"<<endl;
    }
    else{
        cout<<"Alice"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;

int main(){
   ll N; cin >> N;
   string alpha = "abcdefghijklmnopqrstuvwxyz";


   string ans = "";
   while(N > 0){
       N--;
       ans = alpha[N%26] + ans;
       N /= 26;
   }

   cout << ans << endl; 
   
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){cout<<"vowel"<<endl;}else{cout<<"consonant"<<endl;}
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<utility>
#include<climits>

#define INF INT_MAX/2
#define EPS 1.0e-7

#define MAX_N 5005

using namespace std;

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

int N,M;

vector<int> cnt[MAX_N];

int main(){

    cin.sync_with_stdio(false);

    cin >> N >> M;

    for(int i=0;i<N+2;++i)
        cnt[i].resize(i+3);

    for(int i=0;i<M;++i){

        int x,y,l;
        cin >> x >> y >> l;

        --x;
        --y;
        ++l;

        cnt[x][y]         += 1;
        cnt[x+l+1][y+1]   += 1;
        cnt[x+l][y+l+1]   += 1;

        cnt[x][y+1]       -= 1;
        cnt[x+l][y]       -= 1;
        cnt[x+l+1][y+l+1] -= 1;

    }

    for(int i=0;i<N;++i)
        for(int j=1;j<=i;++j)
            cnt[i][j] += cnt[i][j-1];

    for(int i=0;i<N;++i)
        for(int j=1;i+j<N;++j)
            cnt[i+j][i] += cnt[i+j-1][i];

    for(int i=0;i<N;++i)
        for(int j=1;i+j<N;++j)
            cnt[i+j][j] += cnt[i+j-1][j-1];

    int ans = 0;

    for(int i=0;i<N;++i)
        for(int j=0;j<=i;++j)
            if(cnt[i][j]) 
                ++ans;

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 50300
from collections import defaultdict

n, k = map(int, input().split())
d = list(map(int, input().split()))
nums = defaultdict(int)
for i in range(len(d)):
    nums[d[i]] += 1

def judge(n, nums):
    n = str(n)
    for i in range(len(n)):
        if nums[int(n[i])] == 1:
            return False
        
    return True

while 1:
    if judge(n, nums) == True:
        print(n)
        exit()
    n += 1


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

int main(void)
{
  int n;
  cin >> n;
  long long total = 0;
  for(int i = 0; i <= n; i++)
  {
    if(i % 3 != 0 && i % 5 != 0)
      total += i;
  }
  cout << total << endl;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);

    vector<int> P(N);
    Rep(i,N){
        Scd(P[i]);
    }

    int ans = 0;
    Rep(i,N-2){
        if( P[i] < P[i+1] && P[i+1] <  P[i+2] ) ans++;
        if( P[i] > P[i+1] && P[i+1] >  P[i+2] ) ans++;
    }

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


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef int Weight;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
const int MAX_T = 6;
const int MAX_N = 12 * 12;
const int INF = 1 << 25;

Weight minimum_steiner_tree(const vector<int>& T, const Matrix& g) {
	const int n = g.size();
	const int numT = T.size();
	if (numT <= 1) return 0;

	Matrix d(g); // all-pair shortest
	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	Weight OPT[(1 << MAX_T)][MAX_N];
	for (int S = 0; S < (1 << numT); ++S)
		for (int x = 0; x < n; ++x)
			OPT[S][x] = INF;

	for (int p = 0; p < numT; ++p) // trivial case
		for (int q = 0; q < n; ++q)
			OPT[1 << p][q] = d[T[p]][q];

	for (int S = 1; S < (1 << numT); ++S) { // DP step
		if (!(S & (S - 1))) continue;
		for (int p = 0; p < n; ++p)
			for (int E = 0; E < S; ++E)
				if ((E | S) == S)
					OPT[S][p] = min(OPT[S][p], OPT[E][p] + OPT[S - E][p]);
		for (int p = 0; p < n; ++p)
			for (int q = 0; q < n; ++q)
				OPT[S][p] = min(OPT[S][p], OPT[S][q] + d[p][q]);
	}
	Weight ans = INF;
	for (int S = 0; S < (1 << numT); ++S)
		for (int q = 0; q < n; ++q)
			ans = min(ans, OPT[S][q] + OPT[((1 << numT) - 1) - S][q]);
	return ans;
}

int H, W;

int toV(int x, int y) {
	return y * W + x;
};

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

	while (cin >> H >> W , H) {
		vector<int> T;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				int b;
				cin >> b;
				if (b == 1) T.push_back(toV(j, i));
			}
		}

		Matrix g(H * W, Array(H * W, INF));
		for (int i = 0; i < H * W; i++) {
			g[i][i] = 0;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (i != H - 1) {
					g[toV(j, i)][toV(j, i + 1)] = g[toV(j, i + 1)][toV(j, i)] = 1;
				}
				if (j != W - 1) {
					g[toV(j, i)][toV(j + 1, i)] = g[toV(j + 1, i)][toV(j, i)] = 1;
				}
			}
		}

		int res = minimum_steiner_tree(T, g);
		cout << H * W - res - 1 << endl;
	}
}

Measured memory_bytes: 1428
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if (a > 0 && b > 0) Console.WriteLine("Positive");
        else if (a < 0 && b < 0)
        {
            if ((a + b) % 2 != 0) Console.WriteLine("Positive");
            else Console.WriteLine("Negative");
        }
        else Console.WriteLine("Zero");
    }
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s;
  cin >> s;
  rep(i,0,4) cout << s.at(i);
  cout << " ";
  rep(i,4,12) cout << s.at(i);
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  ll n;
  cin >> n;
  ll x=n;
  int s=0;
  while(x>0){
    s += x%10;
    x /= 10;
  }
  if(n%s==0){
    cout<< "Yes" << endl;
    return 0;
  }
  cout<< "No" << endl;
  return 0;
}

Measured memory_bytes: 256
//# define FLAG
///delet....................................
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <cstdio>
# include <cmath>
# include <ctime>
# include <set>
# include <map>
# include <queue>
# include <stack>
# include <vector>
# include <fstream>
# include <algorithm>
using namespace std;
# define eps 1e-8
# define pb push_back
# define pi acos(-1.0)
# define bug puts("H")
# define mem(a,b) memset(a,b,sizeof(a))
# define IOS ios::sync_with_stdio(false)
# define FO(i,n,a) for(int i=n; i>=a; --i)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define INF 0x3f3f3f3f
# define MOD 1000000007
///           123456789
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef unsigned long long ULL;
typedef long long LL;
inline LL Scan(){
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
///coding...................................

int main()
{
    IOS;
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif /// FLAG
    string a;
    cin>>a;
    cout<<a[0]<<a.size()-2<<a[a.size()-1]<<endl;
    return 0;
}
///delete # define FLAG......................




















Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((ll)2e5+5)
#define MOD ((ll)1e9 + 7)
#define INF ((ll)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<ll,ll>
#define mid ((l+r)/2)

ll n;
ll ct[105];
vector <ll> v;

bool prime(ll x)
{
	for (ll i = 2; i*i <= x; ++i)
		if(x%i==0)
			return false;
	return true;
}

ll rec(ll idx, ll cur)
{
	if(idx<0)
		return 0LL;

	ll ret = 0;
	for (ll i = 1; i <= min(cur, v[idx]); ++i)
	{
		if(cur == i)
			ret += 1;
		else if(cur % i == 0)
		{
			ll t = rec(idx-1, cur / i);
			ret += t;
		}
	}

	return ret;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n;

	for (ll i = 2; i < 100; ++i)
		if(prime(i))
		{
			ll t = n;
			ll c = 0;
			while(t)
			{
				t = t / i;
				c += t;
			}

			ct[i] = c;
		}

	for (ll i = 0; i < 100; ++i)
		if(ct[i])
			v.pb(ct[i]+1);

	cout << rec(v.size()-1, 75) << endl;
}

/* stuff you should look for
	* ll overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 3600
S = input()
A = ["AKIHABARA", "KIHABARA", "AKIHBARA", "AKIHABRA", "AKIHABAR", "KIHBARA", "KIHABRA", "KIHABAR", "AKIHBRA", "AKIHBAR", "AKIHABR", "KIHBRA", "KIHBAR", "KIHABR", "AKIHBR", "KIHBR"]
if S in A:
  print("YES")
else:
  print("NO")

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

const ll MOD = 1e9+7;

int main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    ll sum = 0;
    PQll pq;
    rep(i,0,n){
        cin >> a[i];
        sum += a[i];
        pq.push(a[i]);
    }

    while(1){
        if(pq.size() < 2) break;
        ll a = pq.top(); pq.pop();
        ll b = pq.top(); pq.pop();
        if((a+b) >= 0) break;
        else{
            sum += 2 * abs(a + b);
        }
    }

    cout << sum << endl;
}


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

class package
{
public:
	string word;
	int page;
	package(string _word, int _page)
	{
		word = _word;
		page = _page;
	}

};
bool compare(const package & left, const package & right)
{
	if(left.word < right.word)
	{
		return true;
	}
	if(left.word == right.word && left.page <= right.page)
	{
		return true;
	}
	return false;
}
int main()
{

	vector<package> book;
	
	while(1)
	{
		string str = "";
		int page;
		cin >> str;
		if(str == "")
		{
			break;
		}
		cin >> page;
		package index(str, page);
		book.push_back(index);
	}

	sort(book.begin(), book.end(), compare);

	string lastWord = book[0].word;
	cout << book[0].word << endl;
	cout << book[0].page;

	for(int i = 1; i < book.size(); i++)
	{
		if(lastWord == book[i].word)
		{
			cout << " " << book[i].page;
			
		}
		else
		{
			cout << endl;
			cout << book[i].word << endl;
			cout << book[i].page;
			lastWord = book[i].word;
		}
	}
	cout << endl;
	


}

Measured memory_bytes: 3144
h=[]; w=[]; i=0
loop do
  h0,w0=gets.split.map &:to_i
  h0==0&&break
  h<<h0; w<<w0
  i+=1
end
h.size.times do|i|
  h[i].times do|j|
    if j%2==0
      print "#."*(w[i]/2),"#"*(w[i]%2),"\n"
    else
      print ".#"*(w[i]/2),"."*(w[i]%2),"\n"
    end
  end
  print "\n"
end



Measured memory_bytes: 8880
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int S,h,m,s;
    cin >> S;
    h = S/3600;
    m = (S%3600)/60;
    s = (S%3600)%60;
    cout <<h<<":"<<m<<":"<<s<<endl;
    return 0;
}

Measured memory_bytes: 1164
import java.util.*;

class Main{
    static int digitsum(int n){
        int sum = 0;
        while(n > 0){
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        if(N % digitsum(N) == 0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21844
use std::error::Error;
use std::io;
use std::str::FromStr;

fn get_line() -> io::Result<String> {
	let mut buffer = String::new();
	io::stdin().read_line(&mut buffer)?;
	Ok(buffer)
}

#[allow(dead_code)]
fn get_input_number<T>() -> Result<T, Box<dyn Error + 'static>>
where
	T: FromStr,
	<T as FromStr>::Err: Error + 'static,
{
	Ok(get_line()?.trim().parse::<T>()?)
}

#[allow(dead_code)]
fn get_input_array<T>() -> Result<Vec<T>, Box<dyn Error + 'static>>
where
	T: FromStr,
	<T as FromStr>::Err: Error + 'static,
{
	Ok(get_line()?
		.split_whitespace()
		.map(|s| s.parse::<T>())
		.collect::<Result<Vec<_>, _>>()?)
}

use std::collections::HashSet;

fn main() -> Result<(), Box<dyn Error>> {
	let mut lines = get_input_number::<u32>()?;
	let mut set = HashSet::new();
	while lines > 0 {
		let item = get_line()?;
		set.insert(item.trim().to_string());
		lines -= 1
	}
	//println!("set = {:?}", set);
	println!("{}", set.len());
	Ok(())
}


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

int main(void){
    int a, b;
    long long result = 0;
    
    cin >> a >> b;
    
    if(a > b){
        rep(i, a){
            result *= 10;
            result += b;
        }
    } else {
        rep(i, b){
            result *= 10;
            result += a;
        }
    }
    
    cout << result << endl;
    
    return 0;
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 8010, M = 1010;

int n, x, y;
char s[N];
vector<int> hor, ver;
set<int> X[2], Y[2];

int main()
{
	cin >> s >> x >> y;
	n = strlen(s);
	
	for (int i = 0, t = 1; i < n; i ++ , t ^= 1)
	{
		int j = i;
		while (j < n && s[j] == 'F') j ++ ;
		if (t) hor.PB(j - i);
		else ver.PB(j - i);
		i = j;
	}
	
	int tx = 0;
	X[tx].insert(hor[0]);
	for (int i = 1; i < hor.size(); i ++ )
	{
		tx ^= 1, X[tx].clear();
		for (auto u : X[tx ^ 1])
		{
			X[tx].insert(u + hor[i]);
			X[tx].insert(u - hor[i]);
		}
	}
	
	int ty = 0;
	Y[ty].insert(0);
	for (int i = 0; i < ver.size(); i ++ )
	{
		ty ^= 1, Y[ty].clear();
		for (auto u : Y[ty ^ 1])
		{
			Y[ty].insert(u + ver[i]);
			Y[ty].insert(u - ver[i]);
		}
	}
	

	if (X[tx].count(x) && Y[ty].count(y)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 4324
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

int main()
{
    ll n, c;
    cin >> n >> c;
    vvll cnt(3, vll(c, 0));
    vvll value(c, vll(c));
    rep(i, c) rep(j, c) cin >> value[i][j];
    vvll MAP(n, vll(n));
    rep(i,n){
        rep(j,n){
            cin >> MAP[i][j];
            MAP[i][j]--;
        }
    }
    rep(i,n){
        rep(j,n){
            rep(k,c){
                cnt[(i + j) % 3][k] += value[MAP[i][j]][k];
            }
        }
    }
    ll ans = infl;
    rep(x,c){
        rep(y,c){
            rep(z,c){
                if (x!=y && y!=z && x!=z){
                    ans = min(ans, cnt[0][x] + cnt[1][y] + cnt[2][z]);
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2176
def solve():
  K, A, B = map(int, input().split())
  if B - A <= 2: return K + 1
  if K - 1 < A: return K + 1

  K -= A - 1
  mod = K % 2
  N = K // 2
  return A + (B - A) * N + mod

print(solve())


Measured memory_bytes: 2940
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

long long 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;
	}
}

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

long long ruijyo(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	ll sum = 1;
	ll i;
	REP(i, 0, k) {
		sum *= n;
		sum %= MOD;
	}
	return sum;
}

int main()
{
	ll  i, j, k, l, m,n, sum, flag, N,  M, K, H, W, B,C,D;
	sum = 0;
	flag = 0;
	ll A[7];
	
	REP(i, 0, 7) {
		cin >> A[i];
	}
	ll ans,ans1;
	ans =ans1= 0;
	if (A[0] >= 1 && A[3] >= 1 && A[4] >= 1) {
		ans += 3;
		ans += ((A[0] - 1) / 2) * 2 + (A[1]) + ((A[3] - 1) / 2) * 2 + ((A[4] - 1) / 2) * 2;
		ans1 += (A[0] / 2) * 2 + (A[1]) + (A[3] / 2) * 2 + (A[4] / 2) * 2;

		k = fmax(ans, ans1);
		output(k);
	}
	else {
		output((A[0] / 2) * 2 + (A[1]) + (A[3] / 2) * 2 + (A[4] / 2) * 2);
	}
	
	return 0;
	

	
}













Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
#include <utility>
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
typedef pair<long long int,int> pli;
#define F first
#define S second
#define PB push_back
const int N=1e5+10;
const long long int INF=1LL<<60;
int main(){
    int n,m,c,l,r,d;
    long long int ans=INF,tot=0,temp;
    pli dis[N],nxt;
    priority_queue<pli,vector<pli>,greater<pli>>pq;
    bitset<N> went;
    vector<pi> graph[N];
    scanf("%d%d%d",&n,&m,&c);
    went.reset();
    dis[1]={0,1};
    for(int i=2;i<=n;i++)dis[i]={INF,i};
    while(m--){
        scanf("%d%d%d",&l,&r,&d);
        graph[l].PB({r,d});
        graph[r].PB({l,d});
        tot+=d;
    }
    pq.push({0,1});
    while(!pq.empty()){
        nxt=pq.top();
        pq.pop();
        if(nxt.F<=dis[nxt.S].F)for(pi i:graph[nxt.S])if(dis[i.F].F>nxt.F+i.S){
            dis[i.F].F=nxt.F+i.S;
            pq.push(dis[i.F]);
        }
    }
    sort(dis+1,dis+1+n);
    for(int i=1;i<=n;i++){
        temp=dis[i].F*c;
        went[dis[i].S]=true;
        for(pi j:graph[dis[i].S])if(went[j.F])tot-=j.S;
        ans=min(ans,temp+tot);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 13532
from copy import deepcopy

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for hh in range(1 << h):
    cp = deepcopy(c)
    for hi in range(6):
        if hh >> hi & 1:
            for wi in range(w):
                cp[hi][wi] = "x"

    for ww in range(1 << w):
        cp2 = deepcopy(cp)
        for wi in range(6):
            if ww >> wi & 1:
                for hi in range(h):
                    cp2[hi][wi] = "x"

        cnt = 0
        for hi in range(h):
            for wi in range(w):
                if cp2[hi][wi] == "#":
                    cnt += 1

        if cnt == k:
            ans += 1

print(ans)



Measured memory_bytes: 72092
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
// #define first first
// #define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

int dp[1100][1100];

signed main(){
    int W;
    int cnt = 0;
    while(cin >> W, W){
        int n;
        cin >> n;
        cnt++;
        vector<int> v(n), w(n);
        rep(i, 0, n){
            char c;
            cin >> v[i] >> c >> w[i];
        }
        rep(i, 0, 1010){
            rep(j, 0, 1010){
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 0;
        rep(i, 0, n){
            rep(j, 0, W + 1){
                dp[i + 1][j] = dp[i][j];
                if(j - w[i] >= 0){
                    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
                }
            }
        }
        int ans = -1, wt;
        rep(i, 0, W + 1){
            if(dp[n][i] > ans){
                ans = dp[n][i];
                wt = i;
            }
        }
        cout << "Case " << cnt << ":" << endl;
        o(ans);
        o(wt);
    }
}

Measured memory_bytes: 11772
# Problem https://atcoder.jp/contests/abc081/tasks/abc081_b
# Ruby 3rd Try
N = gets.chomp.to_i
ValueDiv = Array.new(N,0)
Ai = gets.chomp.split(' ').map(&:to_i)

for k in 0..(Ai.length-1) do
    oddFlag = false
    number = Ai[k]
    while true
        modNumber = number % 2
        if (modNumber == 1)
            oddFlag = true
        end
        if oddFlag
            break
        else
            number = number / 2
            ValueDiv[k] = ValueDiv[k]+1
        end
    end
end
answer = 1000
for k in 0..(Ai.length-1) do
    if ValueDiv[k] < answer
        answer = ValueDiv[k]
    end
end
puts(answer)

Measured memory_bytes: 1788
n,d,a = gets.split.map(&:to_i)
monsters = readlines.map{|l| l.split.map(&:to_i)}

monsters.map!{ |xh| xh[1] = (xh[1]+a-1)/a; xh }.sort_by!{ |x,h| x }

deq = []
acc_damage = 0
ans = 0
monsters.each do |x,h|
  
  while deq.size > 0 && deq[0][0] < x do
    acc_damage -= deq[0][1]
    deq.shift
  end
  
  need = h - acc_damage
  # need = 0 if need < 0
  
  if need > 0
    acc_damage += need
    ans += need
    deq.push( [x + d*2, need] )
  end
end

puts ans

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> V(N + 1);
  rep2(i, 1, N + 1) cin >> V.at(i); // 1-indexed
  int ans = 0;
  rep(A, min(N, K) + 1) {
    rep(B, min(N, K) - A + 1) {
      priority_queue<int, vector<int>, greater<int>> q;
      rep2(i, 1, A + 1) q.push(V.at(i));
      rep2(i, 1, B + 1) q.push(V.at(N + 1 - i));
      rep2(i, 1, min(A + B, K - A - B) + 1) {
        if (q.top() >= 0) break;
        q.pop();
      }
      int temp = 0;
      while (!q.empty()) {
        temp += q.top();
        q.pop();
      }
      ans = max(ans, temp);
    }    
  }

  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int t[n];
  for(int i = 0; i < n; ++i) cin >> t[i];
  int m;
  cin >> m;
  for(int i = 0; i < m; ++i) {
    int p, x;
    cin >> p >> x;
    int tmp = t[p - 1];
    t[p - 1] = x;
    int a = 0;
    for(int j = 0; j < n; ++j) {
      a += t[j];
    }
    t[p - 1] = tmp;
    cout << a << endl;
  }
  return 0;
}


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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	ll n, k;
	cin >> n >> k;

	ll ret = 0;
	rep(i, n) {
		ll h;
		cin >> h;
		if(k <= h) ++ret;
	}

	cout << ret << endl;

	return 0;
}


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

int main() {
	long long		h,a,b,c,i,j,k,n,m,x,y;
	float			ans , maxx = 0.0;
	
	cin >> n >> k;
	vector<long long> p(n),sum(n+1);
	sum[0] = 0;
	for(i=0;i<n;i++) {
		cin >> p[i];
		sum[i+1] = sum[i] + p[i];
	}
	
	for(i=0;i<=n-k;i++) {
		ans = sum[i+k] - sum[i];
		ans = (ans + k) / 2;
		maxx = max(maxx , ans);
	}
	printf("%f\n",maxx);


}


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

int main() {
	int n, m, x, y; cin >> n >> m >> x >> y;
	int xmax = -9999, ymin = 9999;
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		if (xmax < p)xmax = p;
	}
	for (int i = 0; i < m; i++) {
		int p; cin >> p;
		if (ymin > p)ymin = p;
	}
	if (xmax < ymin) {
		for (int i = xmax+1; i <= ymin; i++) {
			if (x < i&&i <= y) {
				cout << "No War" << endl;
				return 0;
			}
		}
	}
	cout << "War" << endl;
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int x, y;
    cin >> x >> y;
    string ans = "Yes";
    if (x == 2 || y == 2)
    {
        ans = "No";
    }
    else if (y <= 6)
    {
        if ((x + y) % 2 == 1)
            ans = "No";
    }
    else if (x >= 8)
    {
        if ((x + y) % 2 == 1)
            ans = "No";
    }
    else
    {
        if ((x + y) % 2 == 0)
            ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

ll conbination(int n,int k){
    ll a=1;
    ll b=1;
    if(n<k) return 0;
    for(int i=0;i<k;++i){
        a*=(n-i);
        b*=(k-i);
    }
    return a/b;
}

int main() {
    int n;
    cin >> n;
    map<int,int> a;
    vector<int> b(n);
    for(int i=0;i<n;i++){
        int input;
        cin >> input;
        b.at(i) = input;
        a[input]++;
    }
    ll sum=0;
    for (auto i:a){
        if(i.second>=2){
            sum+=conbination(i.second,2);
        }
    }
    for (int i=0;i<n;++i){
        int now = b.at(i);
        //diff はa[now]-1と同じ
        int diff = a[now]-1;
        cout << sum - diff << endl; 
    }
    return 0;
}



Measured memory_bytes: 8320
from collections import Counter

N = int(input())
V = list(map(int,input().split()))
even = Counter(V[1::2]).most_common()+([[0, 0]])
odd = Counter(V[::2]).most_common()+([[0, 0]])
if(even[0][0] != odd[0][0]):
  print(N-even[0][1]-odd[0][1])
else:
  print(min(N-even[1][1]-odd[0][1], N-even[0][1]-odd[1][1]))


Measured memory_bytes: 20572
n, m = map(int, input().split())
am = set([int(input()) for _ in range(m)])
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
for i in range(1, n+1):
    if i in am:
        continue
    dp[i] = dp[i-2] + dp[i-1] 
    dp[i] %= mod
print(dp[-1])


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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1000000007;
const ll linf  = 1ll * inf * 5;
const int N = 1000000 + 7;
const int M = 8;
const int multipleTest = 0;

int n;
int a[N], b[N], c[N];

ll dp[N];
ll sum[N];

void solve() {
    cin >> n;
    rep(i, 1, n + 1) scanf("%d", a + i); sort(a + 1, a + n + 1);
    rep(i, 1, n + 1) scanf("%d", b + i); sort(b + 1, b + n + 1);
    rep(i, 1, n + 1) scanf("%d", c + i); sort(c + 1, c + n + 1);
    
    
    for (int i = 1; i <= n; ++i) {
        int lo = 1, hi = n, res = 0;
        while (lo <= hi) {
            int g = (lo + hi) >> 1;
            if (a[g] < b[i]) {
                res = g;
                lo = g + 1;
            } else hi = g - 1;
        }
        dp[i] = res + dp[i - 1];
    }
    
    for (int i = 1; i <= n; ++i) {
        int lo = 1, hi = n, res = 0;
        while (lo <= hi) {
            int g = (lo + hi) >> 1;
            if (b[g] < c[i]) {
                res = g;
                lo = g + 1;
            } else hi = g - 1;
        }
        sum[i] = sum[i - 1] + dp[res];
    }
    cout << sum[n];
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
    //    freopen("out.txt", "w", stdout);
#endif
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
        //        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}



Measured memory_bytes: 11264
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int res = int.MinValue;
        int curMin = int.Parse(Console.ReadLine());
        for (int i = 1; i < n; i++)
        {
            var a = int.Parse(Console.ReadLine());
            res = Max(res, a - curMin);
            curMin = Min(curMin, a);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 19984
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = Integer.parseInt(sc.next());
    int g = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    if ((10*g+b)%4==0){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21204
//AtCoder1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream> 
#include <algorithm>
#include <math.h> 
#include <vector>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
    int L;
    cin >> L;
    cout <<fixed << setprecision(20)<<pow(L / 3.0, 3) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b,c,d,e; cin >> a >> b >> c >> d >> e;
	cout << min(a*e,b+max(0,e-c)*d) << endl;
}


Measured memory_bytes: 3144