akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main()
{
    int h, w;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) { break; }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << '[' << *it << " = " << a << "]  ";
    err(++it, args...);
}

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<lli, lli> tii;
typedef tuple<lli, lli, lli> tiii;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;


void solve(){
	vector<vi> a(3, vi(3,0));
	rep(i,3)rep(j,3) cin>>a[i][j];
	vi b(101,0);
	int n,h; cin>>n;
	rep(i,n){
		cin>>h;
		b[h]++;
	}
	bool ans=false;
	int a3=0,a4=0;
	rep(i,3){
		int k=0;
		rep(j,3){
			if(b[a[i][j]]) k++;
		}
		if(k==3) ans=true;
		k=0;
		rep(j,3){
			if(b[a[j][i]]) k++;
		}
		if(k==3) ans=true;
		if(ans) break;
	}
	rep(i,3){
		if(b[a[i][i]]) a3++;
		if(b[a[i][2-i]]) a4++;
	}
	if(ans or a3==3 or a4==3) cout<<"Yes";
	else cout<<"No";
}

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

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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int N;
  ll Tall, Aall;
  cin >> N;
  
  cin >> Tall >> Aall;
  for (int i = 1; i < N; i++)
    {
      ll Ti, Ai;
      cin >> Ti >> Ai;
      ll n = max(Tall/Ti,Aall/Ai);
      while (Ti * n < Tall || Ai * n < Aall) 
	{
	  n++;
	}
      Tall = Ti*n;
      Aall = Ai*n;
    }
  cout << Tall + Aall << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int Cin()
{
    int n;
    cin >> n;
    return n;
}

class MaxFlowCalc
{
private:
    // 辺を表す構造体
    struct Edge
    {
        int To;     // 行き先
        int Cap;    // 容量
        int Rev;    // 逆辺
    };
    int INF = 1000000000;
    vector<vector<Edge>> m_graph;
    vector<bool> m_usedFlags;

    const int DFS(const int v, const int t, const int f)
    {
        if (v == t) return f;
        m_usedFlags[v] = true;
        for (Edge &edge : m_graph[v])
        {
            if (!m_usedFlags[edge.To] && edge.Cap > 0)
            {
                const int d = DFS(edge.To, t, min(f, edge.Cap));
                if (d > 0)
                {
                    edge.Cap -= d;
                    m_graph[edge.To][edge.Rev].Cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    MaxFlowCalc(const int N)
    {
        m_graph = vector<vector<Edge>>(N);
        m_usedFlags = vector<bool>(N);
    }

    void AddEdge(const int from, const int to, const int capacity)
    {
        Edge F, T;
        F.To = to;
        F.Cap = capacity;
        F.Rev = m_graph[to].size();
        m_graph[from].push_back(F);
        T.To = from;
        T.Cap = 0;
        T.Rev = m_graph[from].size() - 1;
        m_graph[to].push_back(T);
    }

    const int MaxFlow(const int source, const int target)
    {
        int flow = 0;
        for (;;)
        {
            for (auto itr = m_usedFlags.begin(); itr != m_usedFlags.end(); ++itr) *itr = false;
            int f = DFS(source, target, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }
};

int main()
{
    // 二部グラフの最大マッチング問題
    // 最大流問題として解く
    int N = Cin();
    vector<int> as(N), bs(N), cs(N), ds(N);
    for (int i = 0; i < N; ++i) cin >> as[i] >> bs[i];
    for (int i = 0; i < N; ++i) cin >> cs[i] >> ds[i];
    // Flow Networkを構築：ソース→赤→青→ターゲットとつなぐ
    MaxFlowCalc mfc(2 * N + 2);
    for (int r = 0; r < N; ++r) mfc.AddEdge(0, r + 1, 1);
    for (int b = 0; b < N; ++b) mfc.AddEdge(N + b + 1, 2 * N + 1, 1);
    for (int r = 0; r < N; ++r)
    {
        for (int b = 0; b < N; ++b)
        {
            if (as[r] < cs[b] && bs[r] < ds[b])
            {
                mfc.AddEdge(r + 1, N + b + 1, 1);
            }
        }
    }
    // 最大流＝最大マッチング数
    cout << mfc.MaxFlow(0, 2 * N + 1) << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#include<ctype.h>
int main() {
	string S;
	cin >> S;
	if (S.length()!=6)
		cout << "No" << endl;
	else {
		for(int i=0;i<6;i++){
			if(S[i]<97 && S[i]>122){
				cout << "No" << endl;
				return 0;
			}
		}
		if (S[2]==S[3] && S[4]==S[5]){
			cout << "Yes" << endl;
		}
		else 
			cout << "No" << endl;
		
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

char a[2005][2005];
int b[4][2005][2005];

int main()
{
	IO_OP;
	
	int h, w;
	cin >> h >> w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin >> a[i][j];
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++) {
			if(a[i][j] == '.') {
				b[0][i][j] = b[0][i][j-1]+1;
			}
		}
	for(int i=1;i<=h;i++)
		for(int j=w;j>=1;j--) {
			if(a[i][j] == '.') {
				b[1][i][j] = b[1][i][j+1]+1;
			}
		}
	for(int j=1;j<=w;j++)
		for(int i=1;i<=h;i++) {
			if(a[i][j] == '.') {
				b[2][i][j] = b[2][i-1][j]+1;
			}
		}
	
	for(int j=1;j<=w;j++)
		for(int i=h;i>=1;i--) {
			if(a[i][j] == '.') {
				b[3][i][j] = b[3][i+1][j]+1;
			}
		}
	int ans = 0;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			ans = max(ans, b[0][i][j] + b[1][i][j] + b[2][i][j] + b[3][i][j] - 3);
	cout << ans << endl;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    int n = s.size();
    ll bc = 0, ans = 0;
    RREP(i, n){
        if(s[i] == 'A'){
            ans += bc;
        }else if(s[i] == 'B'){
            bc = 0;
        }else{
            if(i > 0 && s[i-1] == 'B'){
                bc++;
                i--;
            }else{
                bc = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int A[1000000],n;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	int q, k, sum = 0;
	cin >> q;
	for (int i = 0; i < q; i++){
		scanf("%d", &k);
		if (*lower_bound(A, A + n,k) == k)sum++;
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;
#define INF 1000000001


void solve(const int &i,
        const vector<vector<int> > &hapiness,
        vector<vector<int> > &dp){
    if(i == 0){
        for(int j = 0;j < 3;j++) dp[i][j] = hapiness[i][j];
    }else{
        solve(i-1,hapiness,dp);
        dp[i][0] = max(dp[i-1][1] + hapiness[i][0], dp[i-1][2]+ hapiness[i][0]);
        dp[i][1] = max(dp[i-1][0] + hapiness[i][1], dp[i-1][2]+ hapiness[i][1]);
        dp[i][2] = max(dp[i-1][0] + hapiness[i][2], dp[i-1][1]+ hapiness[i][2]);
    }
}

int main()
{
    int N;
    cin >> N ;
    vector<vector<int> > hapiness(N,vector<int>(3,0));
    vector<vector<int> > dp(N,vector<int>(3,0));
    for(int i = 0 ;i < N;i++){
        cin >> hapiness[i][0] >> hapiness[i][1] >> hapiness[i][2];
    }
    solve(N-1,hapiness,dp); // dp[i][j] : i日目にj番目の行動をしたときの最大幸福度
    int ans = 0;
    for(int i = 0;i < 3;i++){
        ans = max(dp[N-1][i],ans);
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 15872
#include <iostream>
#include <cstdlib>
#include <array>
#include <list>
#include <vector>
#include <math.h>
using namespace std;

/* 
素因数分解
AOJ NTL_1_A Accepted
*/

// global var
const int max_n = 1000000000;
const long d = 1000000007;
const int array_size = (int)(sqrt(max_n)) + 1;
const int check_p = (int)(sqrt(sqrt(max_n))) + 1;
array <int, array_size> is_prime;
list <int> prime_number;
vector<int> fact;

// Sieve of Eratosthenes
void eratosthenes ()
{
    // init
    for (int i=0; i<array_size; ++i){
        if(i < 2 || (i % 2 == 0 && i != 2) || (i % 3 == 0 && i != 3)){
            is_prime[i] = 0;
        }
        else  {
            is_prime[i] = 1;
        }
    }
    int itr = 0;
    while(itr <= check_p){
        if(is_prime[itr]){
            prime_number.push_back(itr);
            for (int i=2; itr*i<=array_size; ++i){
                is_prime[itr*i] = 0;
            }
        }
        itr++;
    }
    for(int i=itr; i<array_size; ++i){
        if(is_prime[i]){
            prime_number.push_back(i);
        }
    }
    /*
    int j=0;
    for(auto itr=prime_number.begin(); itr!=prime_number.end(); ++itr){
        cout << ++j << ":" << *itr << endl;
    }
    */
}

void factorize(int n){
    int num;
    num = n;
    for(auto itr = prime_number.begin(); itr != prime_number.end(); ++itr){
        while(num % *itr == 0){
            num = num / *itr;
            fact[*itr]++;
        }
    }
    if(num != 1){
        fact[num]++;
    }
}

long count_fact(){
    long answer;
    answer = 1;
    for (int i=0; i<1000; ++i){
        answer = (long)((answer * fact[i]) % (long)(d));
    }
    return answer;
}

int main()
{
    eratosthenes();
    int n;
    cin >> n;
    if(n != 1){
        fact.resize(1000);
        for(int i=0; i<1000; ++i){
            fact[i] = 1;
        }
        for (int i=2; i<=n; ++i){
            factorize(i);
        }
        cout << count_fact() << endl;
    }
    else {
        cout << "1" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I=ll(A);I<ll(B);++I)

const int Xx = 'x'-'X';
const int xX = 'X'-'x';

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

	map<char,int> ma;
	FOR(i,0,26)ma['a'+i]=1;
	string s;
	while(cin>>s){
		for(auto c:s){
			if(c<='Z'&&c>='A')c += 'a'-'A';
			ma[c]++;
		}
	}
	for(auto x:ma){
		if(x.first>='a'&&x.first<='z'){
			cout << x.first << " : " << x.second-1 << endl;
		}
	}
}


Measured memory_bytes: 3200
#include <vector>
#include <iostream>
#include <algorithm>
#include<map>
using namespace std;
#define MOD 1000000007
map<long long,long long>m;
int main() {
    long long n,a[100005],i,t,x,count=0;
    char s[100];
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
    {
        if(a[a[i]]==i)
            count++;
    }
    count/=2;
    cout<<count;
    
  return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { //Partition babyyyyyyyyy
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		ArrayList<Long> can = new ArrayList<Long>();
		ArrayList<Long> must = new ArrayList<Long>();
		for (int i = 0; i < N; i++) can.add(I.nextLong());
		int M = I.nextInt();
		for (int i = 0; i < M; i++) must.add(I.nextLong());
		Collections.sort(can);
		Collections.sort(must);
		int req = 0; //Pointer of requirement array-list
		for (int i = 0; i < N; i++) {
			//O.pln(can.get(i)+" "+must.get(req));
			long x = can.get(i);
			long y = must.get(req); //Have to instantiate elements as long or integer before
			//comparison since Collections data structures can't compare through get or peek
			//methods (BIZARRE)
			if (x==y) req++;
			if (req==M) break;
		}
		O.pln(req==M?"YES":"NO");
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 71248
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
using namespace std;

int main() {
    int N;
    std::string S;
    cin >> N;
    cin >> S;
    for(auto i = 0; i < S.size(); ++i) {
        char c = S[i] + N;
        if (c > 'Z') {
            c -= 26;
        }
        cout << c;
    }
    cout << endl;
    return 0;
}

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

int main(){
  
    int a,b;
    string op;
    cin>>a;
    
  while(1){
   cin>>op;

    if(op == "=") break;
    cin>>b;
    if(op == "+") a = a + b;
    if(op == "-") a = a - b;
    if(op == "*") a = a * b;
    if(op == "/") a = a / b;

  }
    cout<<a<<endl;

 
    return 0;

}


Measured memory_bytes: 3148
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

struct P {
  int a, b, c;
  bool operator<(const P &b) const {
    return c < b.c;
  }
};

P edge[200000];

int main() {
  int n;
  while(cin>>n) {
    REP(i,n-1) {
      int a, b, c;
      cin >> a >> b >> c;
      edge[i] = (P){a,b,c};
    }
    sort(edge,edge+n-1);
    UnionFind uf(n);
    ll ans = 0;
    REP(i,n-1) {
      int a = edge[i].a;
      int b = edge[i].b;
      int c = edge[i].c;
      ans += (ll) uf.size(a) * uf.size(b) * c;
      uf.unionSet(a,b);
      // cout << i << " " << ans << endl;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 4172
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

struct Mod {
    static uint64_t PRIME;
    struct LocalPrime {
        uint64_t backup;
        LocalPrime(uint64_t prime) { backup = exchange(Mod::PRIME, prime); }
        ~LocalPrime() { Mod::PRIME = backup; }
    };
    uint64_t value = 0;
    Mod()
    : value(0) {}
    Mod(ll v) {
        if (v >= 0) {
            value = v % PRIME;
        } else {
            value = PRIME - (-v) % PRIME;
        }
    }
    Mod operator+(const Mod& rhs) const { return Mod(*this) += rhs; }
    Mod& operator+=(const Mod& rhs) {
        value += rhs.value;
        if (value >= PRIME) {
            value -= PRIME;
        }
        return *this;
    }
    Mod operator-(const Mod& rhs) const { return Mod(*this) -= rhs; }
    Mod& operator-=(const Mod& rhs) {
        if (value < rhs.value) {
            value += PRIME;
        }
        value -= rhs.value;
        return *this;
    }
    Mod operator*(const Mod& rhs) const { return Mod(*this) *= rhs; }
    Mod& operator*=(const Mod& rhs) {
        value = (value * rhs.value) % PRIME;
        return *this;
    }
    Mod inv() const { return power(*this, PRIME - 2); }
    Mod operator/(const Mod& rhs) const { return Mod(*this) /= rhs; }
    Mod& operator/=(const Mod& rhs) {
        *this *= rhs.inv();
        return *this;
    }
    static Mod power(Mod rhs, ll exp) {
        Mod ans = 1;
        while (exp > 0) {
            if (exp % 2) {
                ans *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return ans;
    }
};
uint64_t Mod::PRIME = 1000000007;

int main() {
    ll N, K;
    cin >> N >> K;
    Mod ans = 0;
    rep(k,K,N+2) {
        ll mn = (k * (k-1)) / 2;
        ll mx = (k * (2 * N - (k - 1))) / 2;
        ll cnt = mx - mn + 1;
        ans += cnt;
    }
    cout << ans.value << endl;
}


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

using namespace std;

int n,m,a[100000];
vector<int> adj[100000],frs[100000];
bool vis[100000];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%d", a + i);
    while (m--) {
        int x,y; scanf("%d%d", &x, &y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    memset(vis, 0, sizeof vis);
    int nfrs = 0;
    vector<int> total;
    long long sum = 0LL;
    for (int i = 0; i < n; i++)
        if (!vis[i]) {
            stack<int> st; st.push(i);
            vector<int> tmp;
            while (!st.empty()) {
                int t = st.top(); st.pop();
                if (vis[t]) continue;
                vis[t] = 1;
                tmp.push_back(a[t]);
                for (int x : adj[t])
                    st.push(x);
            }
            sort(tmp.begin(), tmp.end());
            sum += tmp[0];
            for (int i = 1; i < tmp.size(); i++)
                total.push_back(tmp[i]);
            nfrs++;
        }

    if (nfrs == 1) {
        printf("0\n");
        return 0;
    }
    
    if (total.size() < (nfrs-2)) {
        printf("Impossible\n");
        return 0;
    }
    sort(total.begin(), total.end());
    for (int i = 0; i < nfrs - 2; i++)
        sum += total[i];
    printf("%lld\n", sum);

    return 0;
}

Measured memory_bytes: 9724
#include<iostream>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
const int ha=1e9+7;

inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}

int n,k,a[2005],ans;

inline int qz(int x){ return (x*(ll)(x+1)>>1)%ha;} 

int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	
	for(int i=0;i<n;i++)
	    for(int j=i+1;j<n;j++)
	        if(a[i]>a[j]) ADD(ans,qz(k));
	        else if(a[i]<a[j]) ADD(ans,qz(k-1));
	    
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return vec<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec


using namespace std;

bool solve() {
    auto a = make_v<ll>(0, 3, 3);
    auto bingo = make_v<bool>(false, 3, 3);
    for (auto &&v : a) for (auto &&e : v) cin >> e;
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        ll b;
        cin >> b;
        for (ll j = 0; j < 3; j++) for (ll k = 0; k < 3; k++) if (a[j][k] == b) bingo[j][k] = true;
    }

    for (ll i = 0; i < 3; i++) {
        bool ok = true;
        for (ll j = 0; j < 3; j++) if (!bingo[i][j]) ok = false;
        if (ok) return true;
    }
    for (ll i = 0; i < 3; i++) {
        bool ok = true;
        for (ll j = 0; j < 3; j++) if (!bingo[j][i]) ok = false;
        if (ok) return true;
    }
    if (bingo[1][1]) {
        if (bingo[0][0] && bingo[2][2]) return true;
        if (bingo[0][2] && bingo[2][0]) return true;
    }
    return false;
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


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

void fnInput(int &a_riLoadingCnt, int &a_riTrackCnt, vector<int> &a_rviLoading)
{
  cin >> a_riLoadingCnt >> a_riTrackCnt;

  a_rviLoading.resize(a_riLoadingCnt);
  for (int i = 0; i < a_riLoadingCnt; i++)
    cin >> a_rviLoading[i];
}

int fnSimuAlloc(const vector<int> &a_cnrviLoading, int a_iTrackCnt, int a_iMinLoading)
{
  int iCurLoading;
  int iTrackCnt = 0;

  for (int i = 0; i < a_cnrviLoading.size();    )
  {
    if (a_cnrviLoading[i] > a_iMinLoading  ||
        ++iTrackCnt       > a_iTrackCnt      ) return 0;

    iCurLoading = 0;
    while (i < a_cnrviLoading.size())
    {
      iCurLoading += a_cnrviLoading[i];
      if (iCurLoading > a_iMinLoading)  break;

      i++;
    }
  }
  return 1;
}

void fnAllocation(const vector<int> &a_cnrviLoading, int a_iTrackCnt, int &a_riMinLoading)
{
  const int cniMinLoading = 0;
  const int cniMaxLoading = 1000000000;

  int iLow  = cniMinLoading;
  int iHigh = cniMaxLoading;
  a_riMinLoading = cniMaxLoading;

  while (iLow < iHigh)
  {
    int iMid = (iLow + iHigh) / 2;
    if (fnSimuAlloc(a_cnrviLoading, a_iTrackCnt, iMid))
    {
      a_riMinLoading = min(a_riMinLoading, iMid);
      iHigh = iMid;
    }
    else
      iLow = iMid + 1;
  }
}

void fnResultOut(int a_iMinLoading)
{
  cout << a_iMinLoading << endl;
}

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

  int iLoadingCnt, iTrackCnt;
  vector<int> viLoading;
  int iMinLoading = 0;

  fnInput(iLoadingCnt, iTrackCnt, viLoading);
  fnAllocation(viLoading, iTrackCnt, iMinLoading);
  fnResultOut(iMinLoading);

  return 0;
}

Measured memory_bytes: 1524
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll a,b; cin >> a >> b;
    if(a*b <= 0) return "Zero";
    if(a >= 1) return "Positive";
    if((b-a+1)%2==0) return "Positive";
    else return "Negative";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
a = input()
b = input()
la = len(a)
lb = len(b)

def B():
    if la > lb:
        return "GREATER"
    elif la < lb:
        return "LESS"
    else:
        for i in range(la):
            ai = int(a[i])
            bi = int(b[i])
            if ai > bi:
                return "GREATER"
            elif ai < bi:
                return "LESS"
        return "EQUAL"

print(B())

Measured memory_bytes: 3060
A, B, C, X, Y = map(int, input().split())

if C*2 < A+B:
    if X < Y:
        print(min(C*2*X + (Y-X)*B, C*2*Y))
    else:
        print(min(C*2*Y + (X-Y)*A, C*2*X))
else:
    print(A*X+B*Y)




Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(void){
    
    int a,b;
    cin >> a >> b;
    if(a%3 == 0 || b % 3 == 0 || (a+b)%3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let (a,b,c) = (v[0], v[1], v[2]);
    println!("{}",
        (a..b+1).filter(|i| c % i == 0).count()
    );
}



Measured memory_bytes: 5036
// inputに入力データ全体が入る
function Main(input) {
	input = input.split(" ");
	var max = Number(input[0]);
	var sum = Number(input[1]);
	var result = 0;
	var average = Math.ceil(sum/3);
	var remain = 0;
	for (var i = 0; i <=average; i++) {
		remain = sum - i;
		for (var j = i; j <= max; j++) {
			var k = remain - j;
			if (j <= k && k <= max) {
				if (i === j && i === k) {
					result++;
				} else if (i === j || i === k || k === j ) {
					result = result + 3;
				} else {
					result = result + 6;
				}
			}
 
		}
	}
	console.log(result);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <stdio.h>

int main( int argc, char *argv[] )
{
int A;
int B;

	// A B を取得
	scanf( "%d", &A );
	if( A < 0 || A > 23 ) return 0;

	scanf( "%d", &B );
	if( A < 0 || A > 23 ) return 0;


	// 出力
	printf( "%d", ( A + B ) % 24 );

	return 0;
}

Measured memory_bytes: 128
//O(N)
#include<stdio.h>

long long sum(long long n){return n*(n+1)/2;}
int main(){
	int n;
	scanf("%d",&n);
	long long ans=0;
	for(int i=1;i<=n;i++)ans+=sum(n/i)*i;
	printf("%lld\n",ans);
}


Measured memory_bytes: 1736
#include<stdio.h>
int count = 0;
int L[500000];
int R[500000];

void merge(int *A,int left ,int mid ,int right){
int n1,n2,i,j,k;

n1 = mid - left;
n2 = right - mid;

for(i=0;i < n1; i++){
L[i] = A[left + i];
}
for(i=0;i < n2; i++){
R[i] = A[mid + i];
}

L[n1] = 1000000000;
R[n2] = 1000000000;

i=0;
j=0;

for(k = left ; k < right ; k++){

if(L[i]<= R[j]){
A[k]=L[i];
i = i+1;
count++;
}
else{
    A[k]=R[j];
    j=j+1;
count++;
}

}
}

void mergeSort(int *A,int left ,int right){
    int mid;
if((left + 1) < right){
 mid = (left + right) / 2;
  mergeSort(A,left,mid);
  mergeSort(A,mid,right);
  merge(A,left,mid ,right);

}

}
int main(){

int n,i,left,right;
int S[500000];

scanf("%d",&n);

for(i = 0;i < n;i++){

    scanf("%d",&S[i]);
}
left = 0;
right = n;

mergeSort(S,left,right);


for(i = 0;i < n;i++){

printf("%d",S[i]);

if(i+1 != n)
printf(" ");
}
printf("\n%d\n",count);
return 0;
}


Measured memory_bytes: 5604
#include<iostream>
#include<cstring>
using namespace std;
#define MAX 1000
#define temp 85
int main(){
	int x,A[MAX],B[MAX],al,bl,sum[MAX],pre,now;
	char a[MAX],b[MAX];
	cin>>x;
	while(x-->0){
		for(int i=0;i<MAX;i++){
			A[i]=0;
			B[i]=0;
			sum[i]=0;
		}
		cin>>a;
		cin>>b;
		al=strlen(a);
		bl=strlen(b);
		for(int i=0;i<al;i++)
		A[i]=a[al-1-i]-'0';
		for(int i=0;i<bl;i++)
		B[i]=b[bl-1-i]-'0';
		if(al>bl)
		bl=al;
		pre=0;
		for(int i=0;i<=bl;i++){
			if(A[i]+B[i]+pre>9)
				now=1;
			else now=0;
			sum[i]=(A[i]+B[i]+pre)%10;
			pre=now;
		}
		if(sum[bl]!=0){
			if(bl>=80){
				cout<<"overflow"<<endl;
				continue;
			}
		for(int i=bl;i>=0;i--)
		cout<<sum[i];
		}
		else {
			if(bl-1>=80){
				cout<<"overflow"<<endl;;
				continue;
			}
		for(int i=bl-1;i>=0;i--)
		cout<<sum[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int getSum(int _num) {
	int sum = 0;
	while (1) {
		if (_num >= 10) {
			sum += _num % 10;
			_num /= 10;
		}
		else {
			sum += _num;
			break;
		}
	}
	return sum;
}

int main() {
	ll N;
	cin >> N;
	int f_N = getSum(N);
	if (N%f_N == 0) cout << "Yes";
	else cout << "No";
	system("pause");
	return 0;
}

Measured memory_bytes: 504
/*
  AOJ 1276
  Title:Prime Gap
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

char prime_flag[65536];

int prime256[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,
67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,
157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,
241,251};

make_furui()
{
        int i,j,num;
        memset(prime_flag,-1,65536);
        
        prime_flag[0]=prime_flag[1]=0;

        for(i=0;prime256[i];i++)
                for(j=2;(num=prime256[i]*j)<65536;j++)
                        prime_flag[num]=0;
}
int isprime32(unsigned int n)
{
        int i;
        for(i=2;i<65536;i++)
                if(prime_flag[i] && 0==(n % i) && (n > i))
                        return(0);
        return(1);
}

main()
{
  int n,m;
  make_furui();
  while(scanf("%d",&n) && n)
    {
      if(isprime32(n))
	{
	  printf("0\n");
	  continue;
	}
      m=n;
      while(!isprime32(n))
	n++;
      while(!isprime32(m))
	m--;
      printf("%d\n",n-m);
    }
  return(0);
}

Measured memory_bytes: 684
import sys
rr = lambda: sys.stdin.readline().strip()
ri = lambda: int(rr())
rs = lambda: [int(_) for _ in rr().split()]

from operator import itemgetter

N, M = rs()
p = [tuple(rs()) for _ in range(N)]

p = sorted(p, key=itemgetter(0))

ans = 0
m = 0

for pi in p:
	m += pi[1]
	ans += pi[0] * pi[1]
	if m >= M:
		ans -= (m - M) * pi[0]
		break

print(ans)

Measured memory_bytes: 18992
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	sum := 0
	odd := 0
	even := 0
	A := make([]int, N)
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		A[i] = a
		sum += a
		if (i+1)%2 == 0 {
			even += a
		} else {
			odd += a
		}
	}
	for i := 0; i < N; i++ {
		idx := i + 1
		if idx%2 == 0 {
			fmt.Print(sum - 2*odd)
			odd += A[i]
			even -= A[i]
		} else {
			fmt.Print(sum - 2*even)
			odd -= A[i]
			even += A[i]
		}
		fmt.Print(" ")
	}
	fmt.Println(" ")

}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
using namespace std;
int  main()

{
    int n;
    cin>>n;
    int a=0, b=0 , c=0, d=0;
    for(int i =1 ; i<=n ; i++)
    {
        string s;
        cin>>s;

        if(s=="AC") a++;
        else if( s == "WA" ) b++;
        else if  (s == "TLE") c++;
        else d++;
    }


    cout<<"AC x "<<a<<endl<<"WA x "<<b<<endl<<"TLE x "<<c<<endl<<"RE x "<<d<<endl;


}


Measured memory_bytes: 3548
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H,W=map(int,input().split())
    a=[[] for _ in range(H+2)]
    a[0]=a[H+1]='#'*(W+2)
    for i in range(1,H+1):
        a[i]='#'+input()+'#'
    dp=[[0]*(W+2) for _ in range(H+2)]
    for column in range(1,H+1):
        for row in range(1,W+1):
            if column==row==1:
                dp[column][row]=1
            elif a[column][row]=='.':
                dp[column][row]=(dp[column-1][row]+dp[column][row-1])%MOD
    print(dp[H][W])

if __name__ == '__main__':
    main()


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

int main() {
    int h, w;
  cin>>h>>w;
    vector<vector<char> > a(h, vector<char>(w));
    vector<vector<int> > t(h, vector<int>(w, -1));
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
            if(a[i][j] == 'c') {
                rep(u, w - j) t[i][u + j] = u;
            }
        }
    }
    rep(i, h) {
        rep(j, w) {
            if(j != w- 1)
                cout << t[i][j] << " ";
            else
                cout << t[i][j] << endl;
        }
    }
}



Measured memory_bytes: 3216
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
using namespace std;
typedef pair<int, int> P;
typedef long long LL;

#define _CRT_SECURE_NO_WARNINGS
int N,a,b;
int main() {
	scanf("%d %d %d",&N,&a,&b);
	int c = b - a;
	if (c%2==0) {
		printf("Alice\n" );
	}
	else {
		printf("Borys\n");
	}
	return 0;
}

Measured memory_bytes: 128
using System;

namespace Factorization
{
    class Program
    {
        static void Main(string[] args)
        {
            const int FromD = -119;
            const int ToD = 211;

            long ans;
            long PicD = int.Parse(System.Console.ReadLine());
            for(int i = FromD; i < ToD; i++)
            {
                int flg = 0;
                for (int j = FromD; j < i; j++)
                {

                        ans = (long)System.Math.Pow(i, 5)-(long)System.Math.Pow(j,5);

                        if (ans == PicD)
                        {
                        System.Console.WriteLine(i.ToString() + " " + j.ToString());
                        flg = 1;
                        break;
                        }
 
                }

                if (flg == 1) break;
            }

           
            
        }
    }
}


Measured memory_bytes: 27880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin >> n;
    vector<ll> power(5);
    ll minpower_station = -1;
    ll minpower = 10000000000000000;
    for(int i=0;i<5;i++){
        cin >> power.at(i);
        if(minpower > power.at(i)){
            minpower = power.at(i);
            minpower_station = i;
        }
    }

    ll time = minpower_station;
    ll time_until_zero;
    if(n % minpower != 0)time_until_zero = n / minpower;
    else time_until_zero = n / minpower  -1;
    time = time + time_until_zero + (5 - minpower_station);
    cout << time << endl;   

}

Measured memory_bytes: 3584
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, k;
    double ans = 0;

    cin >> n >> k;

    for (int i = 1; i <= n; i++)
    {
        int res = i;
        double p = 1.0 / n;

        while (res < k)
        {
            res *= 2;
            p /= 2;
        }

        ans += p;
    }

    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
a = int(input())
i = 0
b = []
for i in range(a):
    b.append(input().split())

money_bit_all = 0
money_all = 0

for i in range(a):
    money_bit = 0
    if 'BTC' in b[i]:
        money_bit = 380000.0 * float(b[i][0])
        money_bit_all = money_bit_all + money_bit

    else:
        money_all = money_all + float(b[i][0])

print(money_all + money_bit_all)

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

long long dp[3000][3000][4];
int arr[3000][3000];

long long rec(int i, int j, int p)
{
  if(dp[i][j][p]!=-1) return dp[i][j][p];
  if(i==0 && j == 0 && p!=0) return dp[i][j][p] = arr[i][j];
  else if(i==0 && j==0) return dp[i][j][p]=0;

  long long m1 = 0, m2 = 0, m3 = 0;
  if(j> 0){
    if(p>0)
      if(arr[i][j]!=0)
        m1 = rec(i, j-1, p-1)+arr[i][j];
      m2 = rec(i, j-1, p);
  }
  if(i>0){
    m3 = max(rec(i-1, j, 3), max(rec(i-1, j, 2), max(rec(i-1, j, 1), rec(i-1, j, 0))));
    if(p!=0)
      m3 += arr[i][j];

  }

  return dp[i][j][p] = max(m1, max(m2, m3));
}

int main()
{
    int i, j, r, c, k;
    cin >> r>> c>> k;
    for(i=0;i<3000; i++)
      for(j=0;j<3000; j++)
        for(int c1=0;c1<4;c1++)
          dp[i][j][c1]=-1;
    for(i=0;i<k;i++)
    {
      int a,b,c;
      cin >>a>>b>>c;
      arr[a-1][b-1] =c;
    }
    long long ans = rec(r-1, c-1, 3);
    ans = max(ans, rec(r-1, c-1, 2));
    ans = max(ans, rec(r-1, c-1, 1));
    ans = max(ans, rec(r-1, c-1, 0));

    cout<<dp[r-1][c-1][3]<<endl;
}


Measured memory_bytes: 320644
#include<bits/stdc++.h>
int main()
{
    int num,a,b;
    scanf("%d",&num);
    a=num/100;
    b=num%100;

   if( (a== 0 || a > 12) && b>=1 && b<=12)
    printf("YYMM\n");
  else if ((1 <= a && a <= 12) && (b == 0 || b > 12))
   printf("MMYY\n");
  else  if ((a== 0 || a > 12) && (b== 0 || b > 12))
    printf("NA\n");
  else if(a>0 && a<=12 && b>0 && b<=12)
   printf("AMBIGUOUS\n");
}


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

for i in range(N, -1, -1):
    for j in range(N-i, -1, -1):
        k = N - i - j
        if k >= 0 and 10000 * i + 5000 * j + 1000 * k == Y:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 3060
s = input()

first = int(s[:2])
second = int(s[2:])

if 1 <= first <= 12 and 1 <= second <= 12:
    print('AMBIGUOUS')
elif 1 <= first <= 12:
    print('MMYY')
elif 1 <= second <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n,i,min,max,A;
  int *R;
  while(1){
  scanf("%d",&n);
  if(n>=2 && n<=200000)break;
  }
  R = (int*)malloc(sizeof(int)*n);
  for(i=0 ; i<n ; i++){
    while(1){
      scanf("%d",&R[i]);
      if(R[i]>=1 && R[i]<=1000000000)break;
    }
  }
  min=R[0];
  max=R[1]-min;
  for(i=1 ; i<n ; i++){
    if(max<R[i]-min)max=R[i]-min;
    if(min>R[i])min=R[i];
  }
  printf("%d\n",max);
  free(R);
  return 0;
}


Measured memory_bytes: 2332
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

int m, d;

int main(void){
	cin >> m >> d;
	int ans = 0;
	for(int i=1;i<=m;i++){
		for(int j=10;j<=d;j++){
			if (i == (j/10)*(j%10) && j/10 >= 2 && j%10 >= 2){
				// cerr << i << " " << j << endl;
				ans++;
			}
		}
	}
	cout << ans << endl;


    return 0;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


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

	int k;
	cin >> k;
	string s;
	cin >> s;

	if (s.size() <= k)
	{
		cout << s;
		return 0;
	}
	else
	{
		cout << s.substr(0, k) << "...";
		return 0;
	}


	return 0;
}

Measured memory_bytes: 3600
n = gets.to_i

t = 0
x = 0
y = 0
tt = 0
xx = 0
yy = 0
result = 'Yes'
n.times do
  t, x, y = gets.split.map(&:to_i)
  t -= tt
  x -= xx
  y -= yy
  z = x.abs + y.abs
  if z == t || (t % 2 == 0 && z < t && z % 2 == 0) || (t % 2 != 0 && z < t && z % 2 != 0)
    tt = t
    xx = x
    yy = y
  else
    result = 'No'
    break
  end
end
puts result


Measured memory_bytes: 1788