akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i32, i64, isize, u32, u64, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
#[fastout]
fn main() {
    input! {
        n: usize
    }

    let mut ans = 0;
    for i in 1..=n {
        for j in 1..=n {
            for k in 1..=n {
                ans += gcd(gcd(i, j), k) ;
            }
        }
    }

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


Measured memory_bytes: 2156
#include <bits/stdc++.h>
#define ll long long
#define MAX 1000002
using namespace std;

int factor[MAX] = {0};

void generatePrimeFactors(){
    factor[1] = 1;

    // Initializes all the positions with their value.
    for (int i = 2; i < MAX; i++)
        factor[i] = i;

    // Initializes all multiples of 2 with 2
    for (int i = 4; i < MAX; i += 2)
        factor[i] = 2;

    // A modified version of Sieve of Eratosthenes to
    // store the smallest prime factor that divides
    // every number.
    for (int i = 3; i * i < MAX; i++) {
        // check if it has no prime factor.
        if (factor[i] == i) {
            // Initializes of j starting from i*i
            for (int j = i * i; j < MAX; j += i) {
                // if it has no prime factor before, then
                // stores the smallest prime divisor
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}

// function to calculate number of factors
int calculateNoOFactors(int n)
{
    if (n == 1)
        return 1;

    int ans = 1;

    // stores the smallest prime number
    // that divides n
    int dup = factor[n];

    // stores the count of number of times
    // a prime number divides n.
    int c = 1;

    // reduces to the next number after prime
    // factorization of n
    int j = n / factor[n];

    // false when prime factorization is done
    while (j != 1) {
        // if the same prime number is dividing n,
        // then we increase the count
        if (factor[j] == dup)
            c += 1;

        /* if its a new prime factor that is factorizing n,
           then we again set c=1 and change dup to the new
           prime factor, and apply the formula explained
           above. */
        else {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        // prime factorizes a number
        j = j / factor[j];
    }

    // for the last prime factor
    ans = ans * (c + 1);

    return ans;
}

int main(){
    int n;
    generatePrimeFactors();

    ll count = 0;
    cin >> n;

    for(int c = 1; c < n; c++){
        int temp = n-c;
        count += calculateNoOFactors(temp);
    }
    cout << count;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a*b/gcd(a, b);}

int main()
{
  int n, a, ans = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    ans += a - 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int H, W;
  while(1){
    cin >> H >> W;

    if(H == 0 && W == 0){
      break;
    }

    for(int h = 0; h < H; h++){
      for(int w = 0; w < W; w++){
        //hogehoge
        if(h == 0 || h == H-1){
          if(w == W-1) cout << "#\n";
          else cout << "#";
        } else if(w != 0 && w != W-1){
          cout << ".";
        } else if(w == 0){
          cout << "#";
        } else if(w == W-1){
          cout << "#\n";
        }
      }
    }

    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  multiset<lint, greater<lint>> st;
  REP(i, 1LL<<N) {
    lint A;
    cin >> A;
    st.insert(A);
  }
  vector<lint> vec;
  vec.push_back(*st.begin());
  st.erase(st.begin());
  REP(k, N) {
    REP(i, 1LL<<k) {
      auto itr = st.upper_bound(vec[i]);
      if(itr == st.end()) {
        cout << "No" << endl;
        return 0;
      }
      vec.push_back(*itr);
      st.erase(itr);
     }
  }
  cout << "Yes" << endl;
}

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

template <class T1> void write(T1 e)
{
    cout << e << endl;
}
template <class T1,class T2> void write(T1 e1,T2 e2)
{
    cout << e1 << " "<< e2 << endl;
}
template <class T1,class T2,class T3> void write(T1 e1,T2 e2,T3 e3)
{
    cout << e1 << " " << e2 << " " << e3 << endl;
}

#define oo          (1<<30)
#define SZ(a)       (int)a.size()
#define LL          long long int
#define ULL         unsigned long long
#define ISS         istringstream
#define OSS         ostringstream
#define VS          vector <string>
#define VI          vector <int>
#define VD          vector <double>
#define VLL         vector <long long>
#define SII         set<int>::iterator
#define SI          set<int>
#define mem(a,b)    memset(a,b,sizeof(a))
#define fs          first
#define sc          second
#define pii         pair < int , int >

#define EQ(a,b)     (fabs(a-b)<ERR)
#define all(a,b,c)  for(int I=0;I<b;I++)    a[I] = c
#define CROSS(a,b,c,d) ((b.x-a.x)*(d.y-c.y)-(d.x-c.x)*(b.y-a.y))
#define sqr(a)      ((a)*(a))
#define FORE(i,a)   for(typeof((a).begin())i=(a).begin();i!=(a).end();i++)
#define BE(a)       a.begin(),a.end()
#define RBE(a)      a.rbegin(),a.rend()
#define rev(a)      reverse(BE(a));
#define sorta(a)    sort(BE(a))
#define pb          push_back
#define popb        pop_back
#define Round(i,a)  i = ( a < 0 ) ? a - 0.5 : a + 0.5;

#define makeint(n,s)  istringstream(s)>>n
#define string_to_int(str) atoll(str.c_str());

#define LCM(A,B)    ((__gcd(A,B))/A)*B
#define GCD(A,B)     __gcd(A,B)

#define YES     write("YES")
#define Yes     write("Yes")
#define yes     write("yes")
#define NO      write("NO")
#define No      write("No")
#define no      write("no")

#define read()      freopen("test.txt","r",stdin)
#define write_file()     freopen("WA.txt", "w", stdout);
#define Faster      {ios_base::sync_with_stdio(false); cin.tie(0);}

#define PI          3.141592653589793
#define pi          2*acos(0)
#define gama        0.57721566490
#define ERR         1e-5
#define PRE         1e-8
#define MAX         1000009

#define Scan(A)         scanf("%lld", &A)
#define Scan2(A, B) 	scanf("%lld %lld",&A, &B)
#define Scan3(A, B, C) 	scanf("%lld %lld %lld",&A, &B, &C)
#define Scan4(A, B, C, D) 	scanf("%lld %lld %lld %lld",&A, &B, &C, &D)

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

bool isvowel(char ch)
{
    ch = tolower(ch);
    return ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u';
}

struct myStruct
{
    LL Sum;
    string name;
    string Party;
};

bool cmp(myStruct a, myStruct b)
{
    return a.Sum > b.Sum ? 0 : 1;
}

map <char, int> Mp;

void Method()
{
    int j = 0;
    for(char i = 'a'; i <= 'z'; i++)
    {
        char temp = (char) i;
        Mp[temp] = j;
        j++;
    }
}

LL sums__of_digits(LL N)
{
    LL sum = 0;
    while(N)
    {
        sum += N%10;
        N /= 10;
    }
    return sum;
}
int main()
{
    LL N, A, B;
    while(cin >> N >> A >> B)
    {
        write(min(N*A, B));
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,k;
  scanf("%d %d",&n,&k);
  int p[n];
  for(int i=0;i<n;i++){
  scanf("%d",&p[i]);
  }
  int tmp;
  for (int i=0; i<n; ++i) {
    for (int j=i+1; j<n; ++j) {
      if (p[i] > p[j]) {
        tmp =  p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }
  int c=0;
  
  for(int i=0;i<k;i++){
    c+=p[i];
  }
  printf("%d\n",c);
return 0;
}
    

               


Measured memory_bytes: 1720
// https://atcoder.jp/contests/abc155/tasks/abc155_d
// 2つの要素の積 二分探索　
// なぜかWA
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 200005
ll n,k,nm=0,nz=0,np=0;
ll am[MAX_N];
ll ap[MAX_N];

ll search_minus(ll t){
	// t以上の数
	ll cnt = 0;
	ll *x1,*x2,xn1,xn2;
	if(nm<np){
		x1 = am; x2 = ap;
		xn1 = nm; xn2 = np; 
	}else{
		x1 = ap; x2 = am;
		xn1 = np; xn2 = nm; 
	}
	rep(i,xn1){
		ll ng=-1,ok=xn2;
		while(ng+1<ok){
			ll c = (ng+ok)/2;
			if(x1[i]*x2[c]>=t)ok=c;
			else ng=c;
		}
		cnt += xn2-ok;
	}
	// outsp(t);outl(cnt);
	return cnt;
}
ll search_plus(ll t,ll x[],ll xn){
	// t以上の数
	ll cnt=0;
	for(ll i=0;i<xn;i++){
		ll ng = i,ok=xn;
		while(ng+1<ok){
			ll c = (ng+ok)/2;
			if(x[i]*x[c]>=t)ok=c;
			else ng=c;
		}
		cnt += xn-ok;
	}
	// rep(i,xn){
	// 	ll ng = -1,ok=xn;
	// 	while(ng+1<ok){
	// 		ll c = (ng+ok)/2;
	// 		if(x[i]*x[c]>=t)ok=c;
	// 		else ng=c;
	// 	}
	// 	cnt += xn-ok;
	// 	if(ok<i)cnt--;
	// }
	// cnt /= 2;
	return cnt;
}

int main() {
	cin>>n>>k;
	rep(i,n){
		ll a;
		cin >> a;
		if(a>0){ap[np]=a; np++;}
		else if(a<0){am[nm]=-a; nm++;}
		else nz++;
	}
	ll kall = n*(n-1)/2;
	ll km = np*nm;
	ll kz = nz*(nm+np) + nz*(nz-1)/2;
	ll kp = np*(np-1)/2 + nm*(nm-1)/2;
	sort(ap,ap+np);
	sort(am,am+nm);
	ll ans;
	if(k<=km){
		ll l=0,r=1e18+1;
		while(l+1<r){
			ll t=(l+r)/2;
			if(search_minus(t)>=k){
				l=t;
			}else r=t;
		}

		ans = -l;
	}else if(k<=km+kz){
		ans = 0;
	}else{
		ll l=-1,r=1e18+1;
		while(l+1<r){
			ll t=(l+r)/2;
			ll v = search_plus(t,am,nm)+search_plus(t,ap,np);
			if(v>=kall-k+1){
				l=t;
			}else r=t;

		}
		ans = l;
	}
	outl(ans);
    return 0;
}



Measured memory_bytes: 1664
H,W=map(int, input().split())

def div45(a,b): return int(a/b+0.5)

#縦→縦
ans1_min=H*min(div45(W,3), div45(W-div45(W,3),2), W-div45(W,3)-div45(W-div45(W,3),2))
ans1_max=H*max(div45(W,3), div45(W-div45(W,3),2), W-div45(W,3)-div45(W-div45(W,3),2))
ans1=ans1_max-ans1_min

#横→横
ans2_min=W*min(div45(H,3), div45(H-div45(H,3),2), H-div45(H,3)-div45(H-div45(H,3),2))
ans2_max=W*max(div45(H,3), div45(H-div45(H,3),2), H-div45(H,3)-div45(H-div45(H,3),2))
ans2=ans2_max-ans2_min

#縦→横
ans3_min=min(H*div45(W,3),(W-div45(W,3))*min(div45(H,2),H-div45(H,2)))
ans3_max=max(H*div45(W,3),(W-div45(W,3))*max(div45(H,2),H-div45(H,2)))
ans3=ans3_max-ans3_min

#横→縦
ans4_min=min(W*div45(H,3),(H-div45(H,3))*min(div45(W,2),W-div45(W,2)))
ans4_max=max(W*div45(H,3),(H-div45(H,3))*max(div45(W,2),W-div45(W,2)))
ans4=ans4_max-ans4_min

print(min(ans1,ans2,ans3,ans4))

Measured memory_bytes: 38352
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    int h, w;
    char x='#', y='.';
    cin >> h >> w;
    for(c=1;h!=0||w!=0;c++)
    {
    {for(b=1; b<=h/2;b++)
    {
    {
    for(a=1;a<=w/2;a++) //width (first line)
    {
        cout << x << y;
    }
    if(w%2==1)
     cout << x << endl;
    else 
    {cout << endl;}
    for(a=1; a<=w/2;a++) //width(second line)
    {
        cout << y << x;
    }
    if(w%2==1)
     cout << y << endl;
    else 
    {cout << endl;}
} //width
}
    if(h%2==1)
    {
        for(a=1;a<=w/2;a++)
        {
            cout << x << y;
        }
        if(w%2==1)
        cout << x << endl;
        else
        cout << endl;
    }
    }
    cout << endl;
    cin >> h >> w;
    }
   
   return 0;
}


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

int main()
{
    int X, A, B;
    cin >> X >> A >> B;

    if (A >= B)
    {
        cout << "delicious" << endl;
    }
    else if (B - A <= X)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "dangerous" << endl;
    }
}


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

typedef pair<int,int> P;
#define fr first
#define sc second

int main(){
	static int n;
	static int v[1<<18]={},w[1<<18]={};
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&v[i],&w[i]);
	}
	n=(1<<18)-1;
	
	const int B=10;
	vector<P> vec[1<<B];
	for(int i=(1<<(B-1));i<(1<<B);i++){
		for(int j=0;j<(1<<B);j++){
			P p=P(0,0);
			for(int k=0;k<B;k++){
				if((j>>k)&1){
					p.fr+=w[i>>k];
					p.sc+=v[i>>k];
				}
			}
			vec[i].push_back(p);
		}
		sort(vec[i].begin(),vec[i].end());
		int MAX=-1;
		vector<P> vec_;
		for(int j=0;j<vec[i].size();j++){
			if(vec[i][j].sc>MAX){
				vec_.push_back(vec[i][j]);
				MAX=vec[i][j].sc;
			}
		}
		vec[i]=vec_;
	}
	
	int Q;
	scanf("%d",&Q);
	for(;Q>0;Q--){
		int V,L;
		int ret=0;
		scanf("%d%d",&V,&L);
		if(V<(1<<(B-1))){
			for(int j=0;j<(1<<(B-1));j++){
				P p=P(0,0);
				for(int k=0;k<(B-1);k++){
					if((j>>k)&1){
						p.fr+=w[V>>k];
						p.sc+=v[V>>k];
					}
				}
				if(p.fr<=L)ret=max(ret,p.sc);
			}
		}
		else {
			for(int j=0;j<(1<<(18-B));j++){
				P p=P(0,0);
				int k=0;
				for(;;k++){
					if((V>>k)<(1<<B))break;
					if((j>>k)&1){
						p.fr+=w[V>>k];
						p.sc+=v[V>>k];
					}
				}
				if(p.fr<=L){
					ret=max(ret,p.sc+(--lower_bound(vec[V>>k].begin(),vec[V>>k].end(),P(L-p.fr+1,0)))->sc);
				}
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 9656
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, M;
  cin >> N >> M;
  map<int, int> mp;
  REP(i, N) {
    int K;
    cin >> K;
    REP(j, K) {
      int A;
      cin >> A;
      mp[A]++;
    }
  }
  int ans = 0;
  REP1(i, M) {
    if (mp[i] == N) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    *p, = map(int, input().split())
    
    c = 0
    for i in range(1, n - 1):
        if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
            c += 1
    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

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


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

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

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

void prec(){

}

const int MAXN = 2e5;

ll maxx_can[MAXN];


void solve() {

    int n;
    cin >> n;
    ll answr = 0;


    vector<ll> v;
    for (int i = 0; i < n + 1; ++i) {
        ll currc;
        cin >> currc;
        v.push_back(currc);
    }

    if (v[0] != 0) {
        if (n == 0) {
            if (v[0] == 1) {
                cout << 1;
            } else {
                cout << -1;
            }
        } else
            cout << -1;
        return;
    }
    maxx_can[0] = 1;
    ll bbb = 1e18;


    for (int i = 1; i < n + 1; ++i) {
        if (v[i] > 2 * maxx_can[i - 1]) {
            cout << -1;
            return;
        }

        maxx_can[i] = min(bbb, 2 * maxx_can[i - 1] - v[i]);
    }

    answr++;
    ll prev = 0;
    for (int i = n; i >= 1; --i) {
        auto e = v[i];

        answr += e + prev;
        prev = min(maxx_can[i - 1], prev + e);
    }

    cout << answr;
}

#else

void solve() {

}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case " << (i++) << ": ";
        solve();
        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 4804
n = int(input())

ret = list()
for ai in range(n):
    num = ai + 1
    if num % 15 == 0:
        pass
    elif num % 5 == 0:
        pass
    elif num % 3 == 0:
        pass
    else:
        ret.append(num)

print(sum(ret))

Measured memory_bytes: 30040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	for(ll i=0;i<s.size();i++){
		cout << 'x';
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int K, X;
    cin >> K >> X;
    for(int i = X - K + 1; i <= X + K - 1; i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b;
  int c;
  if((a+b)%2==0){
    c = (a+b)/2;
  }else{
    c = (a+b)/2 + 1;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
dice = list(map(int, input().split()))
com = input()
for i in range(len(com)):
    if com[i] == 'E':
        temp = dice[0]
        dice[0] = dice[3]
        dice[3] = dice[5]
        dice[5] = dice[2]
        dice[2] = temp
    elif com[i] == 'N':
        temp = dice[0]
        dice[0] = dice[1]
        dice[1] = dice[5]
        dice[5] = dice[4]
        dice[4] = temp
    elif com[i] == 'S':
        temp = dice[0]
        dice[0] = dice[4]
        dice[4] = dice[5]
        dice[5] = dice[1]
        dice[1] = temp
    else:
        temp = dice[0]
        dice[0] = dice[2]
        dice[2] = dice[5]
        dice[5] = dice[3]
        dice[3] = temp
print(dice[0])


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

int main() {

  int i , x ;

  i = 1;

  while(1) {

    cin >> x;

    if (x == 0) break;

    cout << "Case " << i << ":" << " "<< x << "\n";

    i = i + 1;

  }

  return 0;

}

Measured memory_bytes: 1160
while True:
	surface = [list(raw_input()) for _ in range(0, 8)]

	surf = []
	for i in range(0, 8):
		if "1" in surface[i]:
			surf.append(surface[i])
	
	if len(surf) == 1 : print "C"
	else:
		if len(surf) == 2:
			x = surf[0].index("1")
			y = surf[1].index("1")
			if x - y == 0    : print "A"
			elif x - y == -1 : print "E"
			elif x - y ==  1 : print "G"
		elif len(surf) == 3:
			x = surf[0].index("1")
			y = surf[1].index("1")
			if x - y ==   1 : print "D"
			elif x - y == 0 : print "F"
		elif len(surf) == 4 : print "B"
		
	try:
		raw_input()
	except EOFError:
		break

Measured memory_bytes: 6276
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(20)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    long A, B;
    cin >> N >> A >> B;
    long h[N];
    cins(h, h + N);
    long left = 0, right = 2e9; // (left, right]
    while(left + 1 < right){
        long middle = (left + right) / 2;
        long need_direct_count = 0;
        for(int i = 0; i < N; i++){
            need_direct_count += max(0l, (h[i] - middle * B + (A - B) - 1) / (A - B));
        }
        if(need_direct_count <= middle){
            right = middle;
        }else{
            left = middle;
        }
    }
    cout << right << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int n, m, t;
	while(cin >> n >> m >> t)
	{
		if(n + m >= t)  cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
int main()
{
  int n;
  cin >> n;
  cout << n/3 << endl;
    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
int main(){
	int i,j;
	int p[14][14],x,y,s;
	for(i=2;i<12;i++)for(j=2;j<12;j++)p[i][j]=0;
	while(scanf("%d,%d,%d",&x,&y,&s)!=-1){
		y+=2;x+=2;
		p[y][x]++;
		p[y+1][x]++;
		p[y-1][x]++;
		p[y][x+1]++;
		p[y][x-1]++;
		if(s>=2){
			p[y+1][x+1]++;
			p[y+1][x-1]++;
			p[y-1][x-1]++;
			p[y-1][x+1]++;
			
		}
		if(s>=3){
			p[y+2][x]++;
			p[y-2][x]++;
			p[y][x+2]++;
			p[y][x-2]++;
		}
	}
	int mx=0,no=0;
	for(i=2;i<12;i++){
		for(j=2;j<12;j++){
			if(!p[i][j])no++;
			if(p[i][j]>mx)mx=p[i][j];
		}
	}
	printf("%d\n%d\n",no,mx);
	return 0;
}

Measured memory_bytes: 0
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:break
    print('#'*w )
    print(*['#' + '.'*(w-2) + '#' 
            if i == h-3 
            else '#' + '.'*(w-2) + '#' + '\n' 
            for i in range(h-2)],
            sep='')
    print('#'*w + '\n')


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


int main() {
  string s;
  cin >> s;
  
  int sum = 0;
  int ssize = s.size();
  
  for (int i = 0; i< ssize; i++){
    sum += s.at(i) - '0';
    sum %= 9;
  }
  if (sum % 9 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3716
#include <iostream>

using namespace std;

int main()
{
   int l,a,b,c,d,e,f;
   cin>>l>>a>>b>>c>>d;
   if(a%c==0){
    e=a/c;
   }else{
   e=(a/c)+1;}
   if(b%d==0){
    f=b/d;
   }else{
   f=(b/d)+1;}
   if(e>f){
    cout<<l-e<<endl;
   }else{
   cout<<l-f<<endl;}
    return 0;
}



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

const long long INF = 1ll << 61;

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  vector<long long> dp(N + 1, 0);
  dp[0] = 1000;
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= i; j++){
      dp[i + 1] = max(dp[j] / A[j] * A[i] + dp[j] % A[j], dp[i + 1]);
    }
  }
  
  cout << dp[N] << endl;
  
  return 0;
}

Measured memory_bytes: 3560
#include <iostream>

#define INF (1000000000)
#define min(x, y) ((x) < (y) ? (x) : (y))

int main(void) {
  using namespace std;

  int n, m;

  while (cin >> n >> m, n != 0 && m != 0) {
    int cost[100][100];
    int time[100][100];

    for (int i = 0; i < m; i++) {
      for (int j = 0; j < m; j++) {
        cost[i][j] = time[i][j] = i == j ? 0 : INF;
      }
    }

    for (int i = 0; i < n; i++) {
      int a, b, c, t;
      cin >> a >> b >> c >> t;

      a--; b--;

      cost[a][b] = cost[b][a] = min(c, cost[a][b]);
      time[a][b] = time[b][a] = min(t, time[a][b]);
    }

    for (int k = 0; k < m; k++) {
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
          time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
        }
      }
    }

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int p, q, r;
      cin >> p >> q >> r;

      p--; q--;

      if (r == 0) {
        cout << cost[p][q] << endl;
      } else {
        cout << time[p][q] << endl;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1236
import sys
sys.setrecursionlimit(10**7)
def dfs(s,m):
    if len(s)==N:
        li.append(s)
        return
    for c in range(97,ord(m)+2):
        dfs(s+chr(c),max(m,chr(c)))

N=int(input())
li=[]
li.sort()
dfs('a','a')
print(*li,sep='\n')

Measured memory_bytes: 90492
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def bs(a, lo, hi, f):
    olo = lo
    ohi = hi
    while (lo + 1) < hi:
        mid = (lo + hi) // 2
        v = f(ohi, mid, olo)
        if 0 < v:
            lo = mid
        elif v < 0:
            hi = mid
        else:
            return mid
    if abs(f(ohi, lo, olo)) < abs(f(ohi, hi, olo)):
        return lo
    else:
        return hi

def solve(N: int, A: "List[int]"):

    def _g(li, ci, ri):
        a = acc[li - 1] - acc[0]
        b = acc[ci - 1] - acc[li-1]
        c = acc[ri - 1] - acc[ci - 1]
        d = acc[-1] - acc[ri - 1]
        cr = max([a, b, c, d]) - min([a, b, c, d])
        return cr

    def _f(h, m, l):
        return ((acc[h - 1] - acc[m-1]) - (acc[m - 1] - acc[l - 1]))

    acc = [0] + list(accumulate(A))

    ret = float('inf')
    for i in range(3, len(acc) - 1):
        li = bs(acc, 1, i, _f)
        ri = bs(acc, i, len(acc), _f)
        cv = _g(li, i, ri)
        ret = min(ret, cv)
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, A)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 111092
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int a, b;
    cin >> a >> b;
    if(a <= 9 && b <= 9)
        cout << a * b;
    else
        cout << -1;
    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(void){
    char a[3];
    int n,i,A=0,B=0,AB=0,O=0;
    while(scanf("%d,%s",&n,&a)!=EOF){
        if(a[0]=='A'){
            if(a[1]=='B'){
                AB++;
            }else{
                A++;
            }
        }else if(a[0]=='B'){
            B++;
        }else{
            O++;
        }
        for(i=0;i<3;i++)a[i]=0;
    }
    printf("%d\n%d\n%d\n%d\n",A,B,AB,O);
    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <complex>
#include <assert.h>
#include <limits.h>
#include <iomanip>
#include <unordered_map>
//#include <bits/stdc++.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<int,ll>pil;
typedef pair<ll,ll> pll;
//const double INF=1e20;
const int INF=0x3f3f3f3f;
//const int INF= 0x7fffffff;
//const ll INF=0x3f3f3f3f3f3f3f3fll;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
//const ll INFF=1e14+5;
const int MAX=2005;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const int MOD=1e9+7;
//const ull MOD=1e7+7;
//const ll MOD=998244353;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
//#define double long double
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
//const long double eps=-1.0;
//clock_t t1 = clock();
//fprintf(stderr, "%ld ms\n", clock() - t1);
void open()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
ll a,b,c,k;
int main()
{
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    if(k&1LL)
        printf("%lld\n",b-a);
    else printf("%lld\n",a-b);
}
/*

*/


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

int64_t gcd(int64_t A, int64_t B){  //ユークリッドの互除法による2数の最大公約数
    int64_t t;
    while(B != 0){
        t = A%B;
        A = B;
        B = t;
    }
    return A;
}

int main(){
    int64_t A, B;
    int64_t ans;
    cin >> A >> B;

    ans = A*B/gcd(A,B);

    cout << ans << endl;
}

Measured memory_bytes: 256
A,B=map(int,input().split())
M=[[] for x in range(100)]
M[0]=[str('.') for i in range(100)]
for i in range(1,99):
  if i%2==1:
    M[i]=['.']+[str('#') for a in range(99)]
  else:
    M[i]=[str('.') for a in range(99)]+['#']
M[99]=[str('#') for a in range(100)]

ch=0
for i in range(49):
  if B==1:
    break
  for j in range(1,49):
    if B==1:
      break
    M[i*2+1][j*2+1]='.'
    B-=1
for i in range(49):
  if A==1:
    break
  for j in range(1,49):
    if A==1:
      break
    M[99-(2*i+1)][j*2+1]='#'
    A-=1
print(100,100)
for i in range(100):
  ans=''.join(M[i])
  print(ans)

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

int main() {
    int n;
    string s;
    bool ans = false;
    cin >> n >> s;
    if (n % 2 == 0) {
        for (int i = 0; i < n/2; i++) {
            if (s[i] != s[i+n/2]) {
                goto END;
            }
        }
        ans = true;
    }
END:
    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce
import copy
import sys

N, M, *a_n = map(int, open(0).read().split())
a_n = list(set(a_n))
a_n = [a // 2 for a in a_n]
N = len(a_n)

def lcm_base(x, y):
    return (x * y) //  gcd(x, y)

def lcm_list(a_n):
    return reduce(lcm_base, a_n)

a_n_half = [0] * N
a_n_copy = copy.copy(a_n)
for i in range(N):
    while a_n_copy[i] % 2 == 0:
        a_n_copy[i] //= 2
        a_n_half[i] += 1
        
for i in range(N-1):
    if a_n_half[i] != a_n_half[i+1]:
        print(0)
        sys.exit()
        
print(-(-(M // lcm_list(a_n)) // 2))


Measured memory_bytes: 16148
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin>>n;
  int v[n],c[n],diff[n];
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n;i++){
    cin>>c[i];
    diff[i]=v[i]-c[i];
  }
  sort(diff,diff+n);
  for(int i=n-1;i>=0;i--){
    if(diff[i]>0){
      ans+=diff[i];
    }else{
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	bool good = false;

	int a;
	cin >> a;

//	std::to_string(123); // "123"      (int to string)

	string s = to_string(a);
	if (s[0] == s[1] && s[0] == s[2]) good = true;
	if (s[1] == s[2] && s[1] == s[3]) good = true;

	cout << ((good) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<vector<int>> A(N, vector<int>(M));
    vector<int> B(M);
    rep(i, M) cin >> B[i];
    rep(i, N) rep(j, M) cin >> A[i][j];
    
    int cnt = 0;
    rep(i, N) {
        int sum = C;
        rep(j, M) sum += A[i][j] * B[j];
        if (sum > 0) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector< pair<int , ll> > V(n, make_pair(0,0));
    REP(i, n) cin >> V[i].first >> V[i].second;
    sort(ALL(V));
    // REP(i,n) cout <<i << " "<< V[i].first << " " << V[i].second << endl;
    ll ans=0;
    REP(i,n){
        // cout << i << "にいて，もう " << m << "個かいたい．お金はまだ"<<ans << endl;
        if(m >= V[i].second ) {
            ans += V[i].first * V[i].second;
            m -= V[i].second;
        }
        else {
            ans+= V[i].first * m;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

const int INF = 1000000000;
struct NEdge {
    int to;
    int cap;
    int rev;
};

struct FlowNetwork {
    int N;
    vector<vector<NEdge>> edges;
    vector<int> level;
    vector<int> iter;

    FlowNetwork(int n) {
        N = n;
        edges.resize(N);
        level.resize(N);
        iter.resize(N);
    }
    void addEdge(int from, int to, int cap) {
        edges[from].push_back({ to, cap, (int)edges[to].size() });
        edges[to].push_back({ from, 0, (int)edges[from].size() - 1 });
    }

    int maxflow(int s, int t) {
        int flow = 0;
        while (1) {
            bfs(s);
            if (level[t] < 0)
                return flow;
            fill(iter.begin(), iter.end(), 0);
            int f;
            while ((f = dfs(s, t, INF)) > 0)
                flow += f;

        }
        return flow;
    }

    void bfs(int s) {
        fill(level.begin(), level.end(), -1);
        queue<int> q;
        level[s] = 0;
        q.push(s);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int i = 0; i < edges[v].size(); i++) {
                NEdge &e = edges[v][i];
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }
    int dfs(int v, int t, int f) {
        if (v == t)
            return f;
        for (int &i = iter[v]; i < edges[v].size(); i++) {
            NEdge &e = edges[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    edges[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
};


int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> red(n), blue(n);
    for (int i = 0; i < n; i++) {
        cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < n; i++) {
        cin >> blue[i].first >> blue[i].second;
    }

    FlowNetwork fn(2 * n + 2);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (red[i].first < blue[j].first && red[i].second < blue[j].second)
                fn.addEdge(i, n + j, 1);
        }
    }
    for (int i = 0; i < n; i++) {
        fn.addEdge(2 * n, i, 1);
        fn.addEdge(n + i, 2 * n + 1, 1);
    }
    int ans = fn.maxflow(2 * n, 2 * n + 1);
    cout << ans << endl;
    return 0;
}

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

void solve(int N)
{
    cout << fixed << setprecision(10);
    cout << (double)((N + 1) / 2) / N << endl;
}

int main()
{
    int N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3788
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))

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

A1,A2,A3 = II()

if A1+A2+A3>=22:
    print('bust')
else:
    print('win')

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];

  if (a[0] < 0)
    for (int i = 0; i < N; i++)
      a[i] *= -1;

  long long ans1 = 0, ans2 = 0, sum = 0;

  sum = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {   // positive
      sum += a[i];
      if (sum <= 0) {
        ans1 += 1 - sum;
        sum = 1;
      }
    } else {  // negative
      sum += a[i];
      if (sum >= 0) {
        ans1 += sum + 1;
        sum = -1;
      }
    }
  }

  sum = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {   // negative
      sum += a[i];
      if (sum >= 0) {
        ans2 += sum + 1;
        sum = -1;
      }
    } else {  // positive
      sum += a[i];
      if (sum <= 0) {
        ans2 += 1 - sum;
        sum = 1;
      }
    }
  }

  if (ans1 < ans2) {
    printf("%lld\n", ans1);    
  } else {
    printf("%lld\n", ans2);
  }


  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
  return 0;
}

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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}

int main()
{
	int n=read(),m=read(),gc=0,ma=0;
	for(int i=0;i<n;i++)
	{
		int k=read();
		gc=gcd(gc,k);
		ma=max(ma,k);
	}
	if(m%gc==0 && ma>=m)puts("POSSIBLE");else puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 256
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)
last_row = [0 for _ in range(c + 1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)
 
for rc in range(r+1):
    print(' '.join([str(a) for a in src[rc]]))

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

constexpr auto M = 998244353L;

int main() {
    int64_t n, s;
    cin >> n >> s;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<int64_t> dp(s + 1);
    dp[0] = 1;
    for (auto i : irange(0L, n)) {
        dp[0] *= 2;
        dp[0] %= M;
    }

    int64_t inv2 = M / 2 + 1;
    for (auto aa : a) {
        for (auto ss : irange(0L, max(0L, s - aa + 1)) | reversed) {
            dp[ss + aa] += dp[ss] * inv2 % M;
            dp[ss + aa] %= M;
        }
    }

    cout << dp[s] << endl;
}

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

int main(){

	int n, m;
	cin >> n >> m;

	int A[n][m], b[m];

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}

	for(int i = 0; i < m; i++){
		cin >> b[i];
	}

	for(int i = 0; i < n; i++){
		int sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * b[j];
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
	
	public static int eightdivisors(int n) {
		int divisors = 0;
		int output;
		
		for(int i=1; i<=n; i++) {
			if(n%i == 0) {
				divisors++;
			}
		}
		
		if(divisors != 8) {
			output = 0;
		} else {
			output = 1;
		}
		
		return output;
	}

	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		
		int amount = 0;
		
		int i = 1;		
		while(i <= N) {
			amount += eightdivisors(i);
			i += 2;
		}
		
		System.out.println(amount);
	}

}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<int,int> P;
 #include <boost/multiprecision/cpp_int.hpp>

using bint = boost::multiprecision::cpp_int;
 
vector<vector<int>> hw(800,vector<int>(800));
vector<vector<int>> visited(800,vector<int>(800));

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int ans1 = 0;
int ans2 = 0;
void dfs(P v, P p, int h, int w){
    rep(i,4){
        int nx = v.first + dx[i];
        int ny = v.second + dy[i];
        if (nx == p.first && ny == p.second) continue;
        if (nx>=0 && nx < h && ny >= 0 && ny < w && visited[nx][ny] == 0){
            if (hw[nx][ny] != hw[v.first][v.second]){
                visited[nx][ny] = 1;
                if(hw[nx][ny] == 0) ans1++;
                else ans2++;
                dfs(mp(nx,ny),v,h,w);
            }
            
        }
    }
}

int main(){
    int h,w;
    cin >> h >> w;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            if (s[j] == '.') hw[i][j] = 0;
            else hw[i][j] = 1;
        }
    }
    


    ll res = 0;
    rep(i,h)rep(j,w){
        if(hw[i][j] == 1 && visited[i][j] == 0){
            ans1 = 0;
            ans2 = 1;
            visited[i][j] = 1;
            dfs(mp(i,j),mp(-1,-1),h,w);
            res += (ll) ans1*ans2;
            
        }
    }
    cout << res;
}

Measured memory_bytes: 20352
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 4e7
#define nl "\n"
#define f first
#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define vector<int> VI;
#define vector<long long> VII;

typedef long long ll;
typedef double db;

using namespace std;

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    string s;
    cin >> s;
    for(int i=0 ; i<s.size(); i++)
    {
        s[i] = 'x';
    }
    cout << s << nl;

    ///Happily DONE
    return 0;
}


Measured memory_bytes: 3536