akhauriyash/Code-Regression huggingface dataset:
var
  n,i,j,k,ans:longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    k:=0;
    for j:=1 to i do
     if i mod j=0 then inc(k);
    if (k=8)and odd(i) then inc(ans);
  end;
  writeln(ans);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    int n, k, a, m, ans = 0;
    cin >> n >> k;
    cout << (n + k - 3) / (k - 1) << endl;
}

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

int main(){

  int n, p;
  vector<int> s, t;

  cin >> n;

  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    s.push_back(a);
  }
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(), s.end()), s.end()); 
  cin >> p;

  for(int i = 0; i < p; i++){
    int a;
    cin >> a;
    t.push_back(a);
  }

  int cnt = 0;

  for(int i = 0; i < (int)s.size(); i++){
    for(int j = 0; j < (int)t.size(); j++){
      if(s[i] == t[j]){
	cnt++;
	//	cout << s[i] << " " << t[j] << endl;
      }
    }
  }

  cout << cnt << endl;

}

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

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

    long long a[n+1];
    long long b[n+1];
    for(long long i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = 0;
    }

    
    long long count = 0;

    for(long long i = n; i >= 1; i--){
        long long j = i;
        long long sum = 0;
        while(j <= n){
            sum = sum + b[j];
            j = j + i;
        }
        
        if((sum+a[i])%2 == 1){
            b[i] = 1;
            count++;
        }
    
    }

    printf("%lld\n", count);

    if(count >= 1){
        for(long long i = n; i >= 1; i--){
            if(b[i] == 1){
                printf("%lld ", i);
            }
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 3968
import re
def main():
    S = input()
    S = input()
    l = len(S)
    cnt = 0


    for i in range(10):
        iti = 0
        iti = S.find(str(i))
        if iti == -1 :
            continue
        for j in range(10):
            s = S[iti+1:]
            itj = s.find(str(j))
            if itj == -1 :
                continue
            for k in range(10):
                t = s[itj+1:]
                itk = t.find(str(k))
                if itk != -1 :
                    cnt += 1

    print(cnt)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;

////////////////////////// templates

template<class U>
void PRINT(std::vector<U> &x) {
    for (int i=0;i<x.size();++i) {
        cout << x[i];
    }
}

template<class U>
void PRINTLN(std::vector<U> &x) {
    PRINT<U>(x);
    cout << endl;
}

////////////////////////// functions


////////////////////////// main

int main() {
    ll N;
    cin >> N;
    vector<int> P(N+1,-1), Q(N+1,-1);
    for (int i=1;i<=N;++i){
        cin >> P[i];
    }
    for (int i=1;i<=N;++i){
        cin >> Q[i];
    }
    vector<int> R(N+1,-1);
    for (int i=1;i<=N;++i) {
        R[i] = i;
    }
    
    int c=1;
    int a = 0, b = 0;
    do {
        if (P == R) a = c;
        if (Q == R) b = c;
        ++c;
    } while(next_permutation(R.begin()+1, R.end()));

    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        String str=sc.nextLine();
         
        char[] c=str.toCharArray();
        for(int i=0;i<c.length;i++){
            if('a'<=c[i] &&c[i]<='z'){
                c[i]=(char)(c[i]-'a'+'A');
            }else if('A'<=c[i] &&c[i]<='Z'){
                c[i]=(char)(c[i]-'A'+'a');
            }
        }
        ln(String.copyValueOf(c));
    }
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 26344
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	int n;
    cin>>n;
    vector<int> w(n);
    cin>>w[0];
    for(int i=1;i<n;i++)
    {
        cin>>w[i];
        w[i]+=w[i-1];
    }
    
    int ans=INF;
    for(int i=0;i<n-1;i++)
    {
        ans=min(ans,abs(w[i]-(w[n-1]-w[i])));
    }
    cout<<ans<<endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll k;
ll a[200005];
void solve() {
    cin >> n >> k;
    rep(i, n) cin >> a[i];

    sort(a, a + n);

    ll l = -ll(1e18) - 1, r = ll(1e18) + 1;
    while (r - l > 1) {
        ll x = (l + r) / 2;
        ll res = 0;
        rep(i, n) {
            if (a[i] < 0) {
                int ll = -1, rr = n;
                while (rr - ll > 1) {
                    int mid = (ll + rr) / 2;
                    if (a[i] * a[mid] < x) rr = mid; else ll = mid;
                }
                res += n - rr;
            }
            else {
                int ll = -1, rr = n;
                while (rr - ll > 1) {
                    int mid = (ll + rr) / 2;
                    if (a[i] * a[mid] < x) ll = mid; else rr = mid;
                }
                res += rr;
            }
            if (a[i] * a[i] < x) res--;
        }
        if (res / 2 < k) l = x; else r = x;
    }
    cout << l << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e6

void fun(){
    int n;
    cin>>n;
    int a[n];
    fi(0,n) cin>>a[i];
    int g=a[0];
    fi(1,n){
        g=__gcd(g,a[i]);
    }
    if(g!=1){
        cout<<"not coprime";
        return ;
    }
    map<int,bool> mp;
    fj(0,n){
      if(a[j]!=1&&mp[a[j]]){
        cout<<"setwise coprime\n";
        return ;
      }
      mp[a[j]]=1;
        for(ll i=2;i*i<=a[j];i++){
            if(a[j]%i==0){
                if(mp[i]!=0||mp[a[j]/i]!=0){
                    cout<<"setwise coprime\n";
                    return ;
                }
                mp[i]=1;
                mp[a[j]/i]=1;
            }
        }
    }
    cout<<"pairwise coprime";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}


Measured memory_bytes: 7604
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=5005,M=205;

typedef long long LL;

int n,m,b[M][N],Top,d[N],le[N],ri[N];

LL f[N][N],a[N],ans;

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<n;i++)
	{
		scanf("%d",&a[i]); a[i]+=a[i-1];
	}
	for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) scanf("%d",&b[j][i]);
	for (int j=1;j<=m;j++)
	{
		Top=d[0]=0;
		for (int i=1;i<=n;i++)
		{
			for (;Top>0 && b[j][d[Top]]<b[j][i];Top--);
			le[i]=d[Top]+1;
			d[++Top]=i;
		}
		Top=0; d[0]=n+1;
		for (int i=n;i;i--)
		{
			for (;Top>0 && b[j][d[Top]]<=b[j][i];Top--);
			ri[i]=d[Top]-1;
			d[++Top]=i;
			f[le[i]][i]+=b[j][i];
			f[le[i]][ri[i]+1]-=b[j][i];
			f[i+1][i]-=b[j][i];
			f[i+1][ri[i]+1]+=b[j][i];
		}
	}
	ans=-1e16;
	for (int i=1;i<=n;i++) for (int j=1;j<=n;j++)
	{
		f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
		if (i<=j) ans=max(ans,f[i][j]-a[j-1]+a[i-1]);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

const int maxn = 100010;
int N, M;
vector<int> aft[maxn];
vector<int> bef[maxn];
int dp[maxn];
int outdeg[maxn];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> M;
	int x, y;	
	for (int i = 0; i < M; i++) {
		cin >> x >> y;
		aft[x].push_back(y);
		outdeg[x]++;
		bef[y].push_back(x);
	}
	queue<int> q;
	for (int i = 1; i <= N; i++) {
		if (outdeg[i] == 0) {
			q.push(i);
		}
	}
	while (q.size()) {
		int v = q.front(); q.pop();
		for (int u : aft[v]) {
			dp[v] = max(dp[v], dp[u]+1);
		}

		for (int u : bef[v]) {
			outdeg[u]--;
			if (outdeg[u] == 0) q.push(u);
		}
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12032
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))





N=input1()
A=input_array()
flag=True
for x in A:
	if x%2==0:
		if x%3==0 or x%5==0:
			continue
		else:
			flag=False
			break
if flag:
	print("APPROVED")
else:
	print("DENIED")

Measured memory_bytes: 3060
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int N, M, C;
    cin >> N >> M >> C;

    vec<int> B(M);
    vvec<int> A(N, vec<int>(M));

    for (auto &e : B)
    {
        cin >> e;
    }
    for (auto &v : A)
        for (auto &e : v)
        {
            cin >> e;
        }

    int count{};

    for (auto& v : A)
    {
        int sum{};
        for (int i = 0; i < M; ++i)
        {
            sum += v[i] * B[i];
        }
        sum += C;

        if (sum > 0)
            ++count;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k;cin>>n>>k;
    map<int,int>m;
    vector<int> key;
    vector<int> value;
    for(int i=0;i<n;i++)
    {
        int t;cin>>t;
        m[t]+=1;
        key.push_back(t);
        
    }
    sort(key.begin(),key.end());
    
    key.erase(unique(key.begin(), key.end()), key.end());
    int keynum=key.size();
    int lastk=keynum-k;
    if(lastk <=0){cout<<0<<'\n';return 0;}
    for(int x:key)
    {
        value.push_back(m[x]);
        
    }
    sort(value.begin(),value.end());
    int sum=0;
    for(int i=0;i<lastk;i++)
    {
        sum+=value[i];
        
    }
    cout<<sum<<'\n';
    return 0;
    
}


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

const int INF = 1000000;

int main() {
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];

    int res = INF;

    rep(i, N) {
        int count = 0;
        while (A[i]%2 == 0) {
            A[i] /= 2;
            ++count;
        }
        if (res > count) res = count;
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 3588
/*---------------------------*\
____________Mari000____________         
________Mostafa  Shehab________    
\*---------------------------*/

#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
typedef long long ll;
typedef long double ld;
//template <class Type>

ll power(ll x,ll y,ll p);
int Bit(ll x);
 
inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}

const int N=1e5 + 5;
int arr[N];
int n,m,cnt;
int a,b,c,d;
unordered_map<int,int> mp;
bool flage[101];

int main(){
	scanf("%d",&n);

	printf("%d",48-n);
		

}










ll power(ll x,ll y,ll p){ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0){ 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;
    }
    return res; 
}


int Bit(ll x){
	if(!x)
		return 0;
	return 1+Bit(x>>1);
}


















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, Q, S[200010], T[200010], X[200010], D[200010];
multiset<ll> st;
vector<pll> L, R;

signed main(){
    cin >> N >> Q;
    REP(i, N){
        cin >> S[i] >> T[i] >> X[i];
        L.push_back(pll(S[i] - X[i], X[i]));
        R.push_back(pll(T[i] - X[i], X[i]));
    }
    sort(ALL(L));
    sort(ALL(R));
    REP(i, Q) cin >> D[i];
    ll l = 0, r = 0;
    REP(i, Q){
        while(l < N && L[l].first <= D[i]){
            st.insert(L[l].second);
            l++;
        }
        while(r < N && R[r].first <= D[i]){
            auto itr = st.find(R[r].second);
            if(itr != st.end()) st.erase(itr);
            r++;
        }
        if(st.empty()) PRINT("-1");
        else PRINT(*st.begin());
    }
    return 0;
}

Measured memory_bytes: 24856
// Green Bin
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    map<string, long long> m;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        int tmp = m[s];
        tmp++;
        m[s] = tmp;
    }
    
    long long cnt = 0;
    for (auto it = m.begin(); it != m.end(); ++it) {
        long long value = it->second;
        if (value > 1) {
            cnt += ((value * (value - 1)) / 2);
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool com(ld a,ld b){
	return (fabsl(a - b) <= LDBL_EPSILON * fmaxl(1.L, fmaxl(fabsl(a), fabsl(b))));
}

bool solve(){
	ll a,b;cin>>a>>b;
	cout<<a*b<<endl;
	return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 3652
import sys

dic = {}
for line in sys.stdin:
    s, p = line.rstrip().split(' ')
    if not s in dic:
        dic[s] = [p]
    else:
        dic[s].append(p)
else:
    for k, v in sorted(dic.items()):
        v.sort(key=int)
        print k
        print ' '.join(v)

Measured memory_bytes: 4200
import math
from collections import Counter
N, A, B = map(int, input().split())
V = sorted(Counter(list(map(int, input().split()))).items(), key=lambda x: x[0], reverse=True)
if A <= V[0][1]:
    print(V[0][0])
    x = min(V[0][1], B)
    num = 0
    for i in range(A, x + 1):
        num += math.factorial(V[0][1]) // (math.factorial(V[0][1] - i) * math.factorial(i))
    print(num)
    exit()
l = []
num = 0
for v, n in V:
    if n >= A:
        l.extend([v] * A)
        num = math.factorial(n) // (math.factorial(n - A) * math.factorial(A))
        break
    else:
        l.extend([v] * n)
        A -= n
        B -= n
print(sum(l) / len(l))
print(num)


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

int main()
{
    int a[200000];
    int n;
    int maxv=-2000000000;

    cin>>n;
    for (int i=0;i<n;i++)
        cin>>a[i];

    int minv=a[0];
    for(int j=1;j<n;j++)
    {
        maxv=max(maxv,a[j]-minv);
        minv=min(minv,a[j]);
    }
    cout<<maxv<<endl;
    return 0;

}

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

f = [0] * (n+1)

for i in range(1, n+1):
    for j in range(i, n+1, i):
        # print(i, j)
        f[j] += 1

res = 0
for i in range(1, n+1):
    res += i * f[i]

print(res)

Measured memory_bytes: 151712
import sys
input = sys.stdin.buffer.readline # 入出力高速化

def main():
    N, Q = map(int, input().split())
    tl = [] # イベントタイムライン
    for _ in range(N):
        S, T, X = map(int, input().split())
        tl.append((S-X, 1, X)) # insert
        tl.append((T-X, 0, X)) # erase
    for _ in range(Q):
        D = int(input())
        tl.append((D, 2, 0)) # min
    tl.sort()
    working = set() # 工事中
    wcur = 0 # 工事中の区域の数
    curmin = -1
    flag = False
    for t, c, x in tl:
        if c == 0: # erase
            wcur -= 1
            working.remove(x)
            if x <= curmin:
                curmin = x
                flag = True
        elif c == 1: # insert
            wcur += 1
            working.add(x)
            if curmin < 0 or curmin >= x:
                curmin = x
                flag = False
        else: # min
            if wcur == 0:
                curmin = -1
                flag = False
            elif flag:
                curmin = min(working)
                flag = False
            print(curmin)
    return
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 88904
#include<stdio.h>
#include<string.h>
int dp[1505000];
int main(){
	int n,m,i,j,b,k;
	scanf("%d %d",&n,&m);
	memset(dp,0,sizeof(dp));
    for (i=0;i<=n;i++)
      for (j=0;j<=m;j++){
      	b=i*m+(n-i)*j-i*j;
      	dp[b]=1;
      }
      scanf("%d",&k);
      if (dp[k]==1)  printf("Yes\n");else printf("No\n");
}

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

#define int long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >

const int N = 3007;
const int INF = 1e18 + 7;

int dp[N][N][2];
int a[N];
int n;

int rec (int l, int r, int t){
    if (l > r)
        return 0;
    if (dp[l][r][t] != 0)
        return dp[l][r][t];
    if (t == 0){
        dp[l][r][t] = -INF;
        dp[l][r][t] = max(dp[l][r][t], rec(l, r - 1, t ^ 1) + a[r]);
        dp[l][r][t] = max(dp[l][r][t], rec(l + 1, r, t ^ 1) + a[l]);
    }
    else {
        dp[l][r][t] = INF;
        dp[l][r][t] = min(dp[l][r][t], rec(l, r - 1, t ^ 1) - a[r]);
        dp[l][r][t] = min(dp[l][r][t], rec(l + 1, r, t ^ 1) - a[l]);
    }
    return dp[l][r][t];
}

main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    cout << rec(1, n, 0);
}


Measured memory_bytes: 141696
// atcoder/abc142/F/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

const int N = 1000 + 5;

vector<int> g[N];
bool vis[N];
stack<int> S;
stack<int> T;
bool rec(int curr, int prev)
{
  vis[curr] = true;
  S.push(curr);

  int cnt = 0;
  each (next, g[curr]) {
    cnt += vis[next];
  }
  if (cnt == 1) {
    throw "";
  }
  if (cnt == 0) {
    each (next, g[curr]) {
      if (next == prev) continue;
      if (vis[next]) continue;
      rec(next, curr);
    }
  }

  S.pop();
  vis[curr] = false;
  return false;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {
    fill(g, g + N, vector<int>());
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
    }

    T = stack<int>();
    for (int i = 0; i < n+1; ++i) {
      T.push(i);
    }

    bool f = false;
    fill(vis, vis + N, false);
    for (int i = 0; i < n; ++i) {
      try {
        S = stack<int>();
        rec(i, -1);
      } catch (const char* e) {
        fill(vis, vis + N, false);
        f = true;
        if (S.size() < T.size()) T = S;
      }
    }

    if (n < T.size()) cout << -1 << endl;
    else {
      cout << T.size() << endl;
      while (T.size()) {
        cout << T.top() + 1 << endl;
        T.pop();
      }
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
int main()
{
	int n,x,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		while(x%2==0)
		{
			x/=2;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){

    int a,b;
    cin >> a >> b;
    int ma = max(a,b);
    int mi = min(a,b);
    rep(i,ma){
        cout << mi ;
    }cout << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //input
            int N = Convert.ToInt32(Console.ReadLine());
            var inputs = Console.ReadLine().Split(' ');

            int[] nums = new int[N];
            int x = 0;
            int result = 0;
            for (int i = 0; i < N; i++)
            {
                nums[i] = Convert.ToInt32(inputs[i]);
                if (i == 0) continue;
                if (nums[i] <= nums[i - 1])
                {
                    x++;
                }
                else
                {
                    result = Math.Max(x, result);
                    x = 0;
                }
            }
            result = Math.Max(x, result);
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 23004
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

void print(const vector<int>& num) {
    int n = num.size();
    for (int i = 0; i < n; ++i) {
        cout << num[i];
        if (i != n - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}

void swap(int& a, int& b) {
    int tmp = a;
    a = b;
    b = tmp;
}

void insertion_sort(vector<int>& a) {
    int n = a.size();

    for (int i = 1; i < n; ++i) {
        // この状態では，[0, i - 1]はソートされている．
        int x = a[i];
        int j = i - 1;
        // a[i]より大きいものがあれば，ずらしていく．
        while (j >= 0 && a[j] > x) {
            a[j + 1] = a[j];
            --j;
        }
        a[j + 1] = x;
    }
}

void bubble_sort(vector<int>& a) {
    int n = a.size();
    bool flag = true;
    while (flag) {
        flag = false;
        // 配列の後ろから，隣接する要素を交換していく．
        for (int i = n - 1; i >= 0; --i) {
            if (a[i - 1] > a[i]) {
                swap(a[i - 1], a[i]);
                flag = true;
            }
        }
    }
}

void selection_sort(vector<int>& a) {
    int n = a.size();
    for (int i = 0; i < n; ++i) {
        // a[i]からa[n - 1]までの最小値をa[i]と交換する．
        int mini = i;
        for (int j = i; j < n; ++j) {
            if (a[j] < a[mini]) { mini = j; }
        }
        swap(a[i], a[mini]);
    }
}

int merge(vector<int>& a, int left, int mid, int right) {
    // [left, mid)と[mid, right)までは，それぞれソート済み．
    int n1 = mid - left, n2 = right - mid;

    vector<int> l(n1 + 1), r(n2 + 1);
    for (int i = 0; i < n1; ++i) { l[i] = a[i + left]; }
    for (int i = 0; i < n2; ++i) { r[i] = a[i + mid]; }

    l[n1] = INT_MAX;
    r[n2] = INT_MAX;

    int i = 0, j = 0;
    for (int k = left; k < right; ++k) {
        // l[i]とr[j]のうち小さい方をa[k]に代入する．
        if (l[i] <= r[j]) {
            a[k] = l[i++];
        } else {
            a[k] = r[j++];
        }
    }
    return right - left;
}

int merge_sort(vector<int>& a, int left, int right) {
    int sum = 0;
    // [left, right)をソートする．
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        // 分割して，それぞれソートする．
        sum += merge_sort(a, left, mid);
        sum += merge_sort(a, mid, right);
        // 部分問題の解を統合する．
        sum += merge(a, left, mid, right);
    }
    return sum;
}

int partition(vector<int>& a, int left, int right) {
    // [left, right)をa[right - 1]を基準に分割する．
    int center = a[right - 1];
    int i = left;
    for (int j = left; j < right - 1; ++j) {
        if (a[j] <= center) {
            swap(a[i], a[j]);
            ++i;
        }
    }
    swap(a[i], a[right - 1]);
    return i;
}

void quick_sort(vector<int>& a, int left, int right) {
    if (left < right) {
        int center = partition(a, left, right);
        quick_sort(a, left, center);
        quick_sort(a, center + 1, right);
    }
}

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

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

    vector<int> b = a;
    int sum = merge_sort(b, 0, n);
    quick_sort(a, 0, n);
    print(a);
    cout << sum << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



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

Measured memory_bytes: 256
import std.stdio,std.conv,std.string,std.algorithm;
void main(){
  auto nab = readln.chomp.split.map!(to!int);
  int n=nab[0],a=nab[1],b=nab[2];
  
  if(n*a<b) writeln(n*a);
  else writeln(b);
}

Measured memory_bytes: 256
S=input()

for i in range(len(S)):
  if i%2==0 and S[i]!="h":
    print("No")
    exit()
  elif i%2==1 and S[i]!="i":
    print("No")
    exit()

if len(S)%2==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
#include <numeric>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	ll a[100] = {};
	ll b[100] = {};
	ll c[100] = {};
	ll d[100] = {};

	//ll v[3] = {};
	//ll *c, *s, *n;
	string S,T,U[52];
	ll count = 10;
	ll count2 = 0;
	ll sum = 0;
	ll min = 100000000000000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	int flag = 0;
	char temp,head;
	//int is = 0;
	
	
	//char p;


	

	

	//cin >> S;
	
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	
	cin >> A >>B;
	

	
	cout << A + B/2 << endl;
	
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	

	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	return 0;

}

ll gcd(ll a, ll b) {
	
	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y/b*x;
}



Measured memory_bytes: 764
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BAtCoderAlloy {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    ll h, w;
	    in >> n >> h >> w;
	    ll a, b;
	    int res = 0;
	    for(int i=0; i<n; i++){
	        in >> a >> b;
	        if(h <= a && w <= b) res++;
	    }

	    out << res << endl;
	}
};


int main() {
	BAtCoderAlloy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import string

N = int(input()) - 1
smap = dict(enumerate(string.ascii_lowercase))

res = []
while True:
    d, m = divmod(N, 26)
    res.append(m)
    if d-1 > 25:
        N = d-1
    else:
        if d == 0:
            break
        else:
            res.append(d-1)
            break

print("".join(smap[i] for i in reversed(res)))

Measured memory_bytes: 10016
#include <stdio.h>

int main(void){
	char a[9+1]; int i;
	
	while(~scanf("%s",a)){
		for(i=0; i<3; i++){
			if(a[i*3]!='s' && a[i*3]==a[i*3+1] && a[i*3+1]==a[i*3+2]){
				printf("%c\n",a[i*3]);
				goto end;
			}else if(a[i]!='s' && a[i]==a[i+3] && a[i+3]==a[i+6]){
				printf("%c\n",a[i]);
				goto end;
			}
		}
		if(a[0]!='s' && a[0]==a[4] && a[4]==a[8]){
			printf("%c\n",a[0]);
			goto end;
		}else if(a[2]!='s' && a[2]==a[4] && a[4]==a[6]){
			printf("%c\n",a[2]);
			goto end;
		}
	
		printf("d\n");
		
		end:;
	}
	
	return 0;
}

Measured memory_bytes: 0
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    r, d, x = MI()
    for i in range(1, 11):
        x = r * x - d
        print(x)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5524
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int x[200000];
int main(){
	int n,m;cin>>n>>m;
	rep(i,m){
		scanf("%d",&x[i]);
	}
	sort(x,x+m);
	int sum=x[m-1]-x[0];
	vector<int>v;
	rep(i,m-1){
		v.push_back(x[i+1]-x[i]);
	}
	sort(v.begin(),v.end(),greater<>());
	rep(i,n-1){
		if(i>=v.size())break;
		sum-=v[i];
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 1276
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var d = new int[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = int.Parse(Console.ReadLine());
        }
        Array.Sort(d);

        var x = d[0];
        var ans = 1;
        for (int i = 1; i < n; i++)
        {
            if (x < d[i])
            {
                x = d[i];
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define VI vector<int>
#define VL vector<long long>
#define VII vector<PII>
#define VLL vector<PLL>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
 
template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=2e6+5;
LL t,n,m,q,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

string s;
LL f[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>s;
	l=s.size();
	repd(i,l-1,0){
		if(ca==0&&s[i]=='S')ans++;
		else if(s[i]=='T')ca++;
		else if(s[i]=='S')ca--;
	}
	cout<<ans*2<<endl;
	return 0;
}

Measured memory_bytes: 720
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,A,B = map(int,input().split())
    INF = 10**10
    dp = np.full((N+1,10*N+1,10*N+1),INF)
    dp[0][0][0] = 0
    
    for i in range(N):
        a,b,c = map(int,input().split())
        dp[i+1][a:,b:] = np.minimum(dp[i][a:,b:],dp[i][:10*N+1-a,:10*N+1-b]+c)
        dp[i+1] = np.minimum(dp[i],dp[i+1])
    
    ans = INF
    x,y = A,B
    while x < 10*N+1 and y < 10*N+1:
        ans = min(ans,dp[N][x][y])
        x += A
        y += B
        
    print(int(ans) if ans != INF else -1)

if __name__ == "__main__":
    main()


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

int main(){
	int H, h[11][6];
	
	while(1){
		int count, ans = 0, t, t2;
		cin>>H;
	
		if(H == 0) break;

		for(int i = 0; i < H; i++){
			for(int j = 0; j < 5; j++){
				cin>>h[i][j];
			}
		}
		
		while(1){
			count = 0;
			for(int i = 0; i < H; i++){
				for(int j = 0; j < 3;j++){
					if(h[i][j] == h[i][j + 1] && h[i][j] == h[i][j + 2] && h[i][j] < 10  && h[i][j] != 0){
						count++;
						if(j < 2 && h[i][j] == h[i][j + 3]){
							if(j < 1 && h[i][j] == h[i][j + 4]){
								h[i][j] *= 10;
								h[i][j + 1] *= 10;
								h[i][j + 2] *= 10;
								h[i][j + 3] *= 10;
								h[i][j + 4] *= 10;
							} else{
								h[i][j] *= 10;
								h[i][j + 1] *= 10;
								h[i][j + 2] *= 10;
								h[i][j + 3] *= 10;

							}
						} else {
							h[i][j] *= 10;
							h[i][j + 1] *= 10;
							h[i][j + 2] *= 10;
						}
						
					}
						
					
					
				}
			}
			if(count == 0) break;

			for(int i = 0; i  < H; i++){
				t = 0;
				for(int j = 0; j < 5; j++){
					if(h[i][j] >= 10){
						t++;
					}
				}
				if(t != 0) ans += h[i][2] * t * 0.1;
				
			}
			for(int i = H - 1; i > 0;){
				t2 = 0;
				for(int j = 0; j < 5; j++){
					if(h[i][j] >= 10) {
						t2++;
						for(int k = i; k > 0 ; k--){
							h[k][j] = h[k - 1][j];
						}
						h[0][j] = 0;
					}
				}
				if(t2 == 0) i--;
				
			}
		
		}

		
		cout<<ans<<endl;
	}

	return 0;
}



Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
using namespace std;
int x[150000], y[150000], n; long long sum, maxn;
int main() {
	while (true) {
		sum = 0; maxn = 0;
		cin >> n;
		if (!n) { break; }
		for (int i = 0; i < n; i++) {
			cin >> x[i]; sum += x[i];
		}
		for (int i = 0; i < n - 1; i++) {
			cin >> y[i]; sum += y[i];
		}
		sort(y, y + n - 1);
		maxn = sum;
		for (int i = 0; i < n - 1; i++) {
			sum -= y[i];
			maxn = max(maxn, sum*(i + 2));
		}
		cout << maxn << endl;
	}
}

Measured memory_bytes: 1684
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (a, b, c) = read!(i32, i32, i32);

    // a,b | c
    // a,c | b
    // b,c | a の3パターンの分け方
    if a + b == c || a + c == b || b + c == a {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdbool.h>

/* define */
#define STR_LENGTH_MAX (1000)
#define ORDER_LENGTH_MAX (100)

#define STR_print "print"
#define STR_replace "replace"
#define STR_reverse "reverse"

//debug用
//#define DEBUG_BUILD

#ifdef DEBUG_BUILD
# define DEBUG_PRINT(fmt, ...)  printf(fmt, ## __VA_ARGS__)
# define DEBUG_F_PRINT(fp,fmt, ...)  fprintf(fp,fmt, ## __VA_ARGS__)
#else
# define DEBUG_PRINT(fmt, ...)
# define DEBUG_F_PRINT(fmt, ...)
#endif

#ifdef DEBUG_BUILD
FILE *fp;
#endif

/* struct */

/* func prototype */
void DoOrder(void);
void Print(int a,int b);
void reverse(int a,int b);
void replace(int a,int b,char p[]);

/* global field */
static char input[STR_LENGTH_MAX+1]={0};

int main(void) {
#ifdef DEBUG_BUILD
	fp=fopen("output.txt","w");
#endif
	int qNum=0;

	scanf("%s",input);
	scanf("%d",&qNum);
	for(int i=0;i<qNum;i++){
		DoOrder();
	}
#ifdef DEBUG_BUILD
	fclose(fp);
#endif
	return 0;
}

void DoOrder(void){
	char q[STR_LENGTH_MAX]={0};
	char p[ORDER_LENGTH_MAX+1]={0};
	scanf("\n%s",q);
	if(strcmp(q,STR_print)==0){
		int a=0,b=0;
		scanf("%d",&a);
		scanf("%d",&b);
		Print(a,b);

	}
	else if(strcmp(q,STR_reverse)==0){
		int a=0,b=0;
		scanf("%d",&a);
		scanf("%d",&b);
		reverse(a,b);
	}
	else if(strcmp(q,STR_replace)==0){
		int a=0,b=0;
		memset(p,0,sizeof(p));
		scanf("%d",&a);
		scanf("%d",&b);
		scanf("\n%s",p);
		replace(a,b,p);
	}
}

void Print(int a,int b){
	for(int i=a;i<=b;i++){
		printf("%c",input[i]);
	}
	puts("");
}

void reverse(int a,int b){
	for(int i=0;i<=(b-a)/2;i++){
		DEBUG_PRINT("[%d] [%d]\n",a+i,b-i);
		int temp =input[a+i];
		input[a+i]=input[b-i];
		input[b-i]=temp;
	}
}
void replace(int a,int b,char p[]){
	for(int i=0;i<=(b-a);i++){
		input[a+i]=p[i];
	}
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int n, k;
    char s[51];
    cin >> n >> k;
    cin >> s;

    if(s[k-1] == 'A'){
        s[k-1] = 'a';
    }
    if(s[k-1] == 'B'){
        s[k-1] = 'b';
    }
    if(s[k-1] == 'C'){
        s[k-1] = 'c';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include<numeric>

using namespace std;

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

    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    int max = *max_element(l.begin(),l.end());
    int sum= accumulate(l.begin(),l.end(),0);
    bool result;
    result = (sum-max) > max;
    if(result){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int a, b;
  int d, r;
  double f;

  cin >> a >> b;

  // d : a を b で割った商
  d = a / b;
  // r : a を b で割った余り
  r = a - b * d;
  // f : a ÷ b の値 (不動小数点)
  f = (double)a / b;

  printf("%d %d %.5f\n", d, r, f);
}



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

int main() {
  int x = 0;
  int s;
  cin >> s;
  if(s/100 == 1){
    x++;
  }
  if(s/10 == 1 || s/10 == 11){
    x++;
  }
  if(s%2 == 1){
    x++;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int yr, A,B;
  int ans = 0;

  cin >> yr;
  if(yr == 2){
    cin >> A;
    cin >> B;

    cout << A + B << endl;
  }else{
    cout << "Hello World" << endl;
  }

}


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

typedef struct {
	int from,to,tak;
} Box;
int compare(const void *a,const void *b){
	Box x=*(Box *)a,y=*(Box *)b;
	int X=x.tak,Y=y.tak;
	return Y-X;
}
int main(){
	int n,m,a,h,p,q,now,pre,hei;
	Box box[2000];
	while(cin>>n>>m>>a,n||m||a){
		for(int i=0;i<m;i++){
			cin>>h>>p>>q;
			box[i].from=p;
			box[i].to=q;
			box[i].tak=h;
			box[i+m].from=q;
			box[i+m].to=p;
			box[i+m].tak=h;
		}
		qsort(box,m*2,sizeof(Box),compare);
		now=a;
		pre=2*m-1;
		hei=1000;
		
			for(int j=0;j<=pre;j++){
				if(box[j].from==now&&hei!=box[j].tak){
					now=box[j].to;
				
					hei=box[j].tak;
				}
			}
		cout<<now<<endl;
	}
	return 0;
}

Measured memory_bytes: 1032