akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,W,Ans=0;
    int w[104],v[104];
    int r[4]={},R[4][104]={};
    cin >> N >> W;
    REP(i,N){
        cin >> w[i] >> v[i];
        R[w[i]-w[0]][r[w[i]-w[0]]]=v[i];
        r[w[i]-w[0]]++;
    }
    REP(i,4){
        sort(R[i],R[i]+r[i],greater<>());
    }
    //REP(i,4){cout << r[i] << " ";}cout << endl;
    //REP(i,4){REP(j,N){cout << R[i][j] << " ";}cout << endl;}
    REP(i,r[0]+1){
        REP(j,r[1]+1){
            REP(k,r[2]+1){
                REP(l,r[3]+1){
                    int sum=0;
                    REP(m,i){sum+=R[0][m];}
                    REP(m,j){sum+=R[1][m];}
                    REP(m,k){sum+=R[2][m];}
                    REP(m,l){sum+=R[3][m];}
                    //cout << i << " " << j << " " << k << " " <<l << " " << sum << endl;
                    if(i*w[0]+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3)<=W){
                        Ans=max(Ans,sum);
                    }
                }
            }
        }
    }
    cout << Ans << endl;
    return 0;
}   



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

ll mod = 1000000007;

signed main()
{
    string s;
    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    cin >> s;
    if (s == "zyxwvutsrqponmlkjihgfedcba")
    {
        cout << -1 << endl;
    }
    else
    {
        if (s.size() == 26)
        {
            string ss = s;
            next_permutation(all(s));
            rep(i, s.size())
            {
                if (s[i] == ss[i])
                {
                    cout << s.substr(i, 1);
                }
                else
                {
                    cout << s.substr(i, 1) << endl;
                    return 0;
                }
            }
        }
        else
        {
            vi a(26);
            rep(i, s.size())
            {
                a[s[i] - 'a']++;
            }
            cout << s;
            rep(i, a.size())
            {
                if (a[i] == 0)
                {
                    cout << alphabet.substr(i, 1) << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <list>
#include <algorithm>
#include <vector>
#include <memory>
#include <vector>
#include <numeric>

int main()
{
    size_t N;
    std::cin >> N;

    std::vector<size_t> vs(N);
    std::iota(vs.begin(), vs.end(), 1);

    std::vector<std::vector<size_t>> es(N + 1);
    std::vector<size_t> dim(N + 1, 0);
    std::vector<size_t> result(N + 1);
    for (size_t i = 0; i < N - 1; i++) {
        size_t a, b;
        std::cin >> a >> b;
        es[a].push_back(b);
        es[b].push_back(a);
        dim[a]++;
        dim[b]++;
    }

    std::vector<size_t> cs(N);
    for (size_t i = 0; i < N; i++) {
        std::cin >> cs[i];
    }
    std::sort(cs.begin(), cs.end());

    size_t sum = 0;
    for (size_t i = 0; i < N; i++) {
        size_t value = cs[i];
        std::sort(vs.begin() + i, vs.end(), [&](auto p, auto q) {
                return dim[p] < dim[q];
        });
        size_t vertex = vs[i];
        result[vertex] = value;
        size_t d = dim[vertex];
        sum += value * d;
        for (size_t u : es[vertex]) {
            dim[u]--;
        }
    }
    std::cout << sum << std::endl;
    for (size_t i = 1; i <= N; i++) {
        std::cout << result[i];
        if (i != N) {
            std::cout << ' ';
        }
    }
    std::cout << std::endl;



    return 0;
}


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

#define REP(i, n) for(int64 i = 0; i < (n); i++)

using int64 = int64_t;
constexpr int64 INF_LL = (int64)1e18;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};


int main(void) {
    int64 N, K;
    cin >> N >> K;
    vector<int64> a(N), r(K), b(K);
    vector<int64> sum_a(N+1, 0), sum_r(K+1, 0), sum_b(K+1, 0);
    REP(i, N) { cin >> a[i]; }
    REP(i, K) { cin >> r[i]; }
    REP(i, K) { cin >> b[i]; }
    sort(a.rbegin(), a.rend()); sort(r.rbegin(), r.rend()); sort(b.rbegin(), b.rend());

    REP(i, N) sum_a[i+1] = sum_a[i] + a[i];
    REP(i, K) sum_r[i+1] = sum_r[i] + r[i];
    REP(i, K) sum_b[i+1] = sum_b[i] + b[i];

    int64 all_a = sum_a.back(), all_r = sum_r.back(), all_b = sum_b.back();

    vector<vector<int64>> dp(K+2, vector<int64>(3010, INF_LL));
    dp[0][0] = 0;
    REP(i, N) {
        vector<vector<int64>> dp2(K+2, vector<int64>(3010, INF_LL));
        REP(r_p, min(K+1, i+1)) {
            REP(r_use, 3010) {
                if (r_use + a[i] <= all_r) {
                    chmin(dp2[r_p+1][r_use+a[i]], dp[r_p][r_use] + max((int64)0, a[i]-r[r_p]));
                }
                int64 b_p = i-r_p, b_use = sum_a[i]-r_use;
                if (b_use + a[i] <= all_b) {
                    chmin(dp2[r_p][r_use], dp[r_p][r_use] + max((int64)0, a[i]-b[b_p]));
                }
            }
        }
        swap(dp, dp2);
    }
    int64 res = INF_LL;
    REP(i, K+1) {
        REP(j, 3010) {
//            if (j <= 15) {
//                cout << dp[i][j] << " ";
//            }
            res = min(res, dp[i][j]);
        }
//        cout << endl;
    }
    cout << (res == INF_LL ? -1 : res) << endl;
}


Measured memory_bytes: 5948
require 'pp'
n = gets.to_i
d = gets.split.map(&:to_i)

pre = d[0]
by = 0 # 0: どっちでも受け入れる, 1: increase, 2: decrease
# p d.chunk{|x|x.odd?}.to_a

tmp = 1
p d.chunk {|x|
  ret = nil
  case by
  when 0
    if x == pre
      by = 0
    elsif x > pre
      by = 1
    elsif x < pre
      by = -1
    end
    ret = true
  when 1
    if x == pre
      by = 1
      ret = true
    elsif x > pre
      by = 1
      ret = true
    elsif x < pre
      by = 0
      ret = false
    end
  when -1
    if x == pre
      by = -1
      ret = true
    elsif x > pre
      by = 0
      ret = false
    elsif x < pre
      by = -1
      ret = true
    end
  end
  # # #
  pre = x
  tmp *= -1 unless ret
  tmp
}.to_a.size

# 2 5 3


Measured memory_bytes: 15996
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[1000001];
bool isperfectsquare(ld x)
{
    return (ceil(sqrt(x))==floor(sqrt(x)));
}
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return gcd(b%a,a);
}
ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
int main()
{
    ios_base::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll terms=b-a+1;
    ll diva=(b/c)-((a-1)/c);
    ll divb=(b/d)-((a-1)/d);
    ll divboth=(b/((c*d)/__gcd(c,d)))-((a-1)/((c*d)/__gcd(c,d)));
    ll form=diva+divb-divboth;
    show(terms-form);
    return 0;
}


Measured memory_bytes: 256
n,m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]

c = [0] * n
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
    print(c[i])



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

#include <iostream>
using namespace std;
int main()
{
    int n, k;
    long long ans;
    cin >> n >> k;
    ans = n / k;
    ans = ans * ans * ans;
    long long t;
    if (k % 2 == 0)t = (n + k / 2) / k, t = t * t * t;
    cout << ans + t;
    return 0;

    
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
using ll = long long;

const int maxn = 2e5 + 10; 
const int INF = 0x3f3f3f3f;

int main()
{
	fastIO;
	string s;
	cin >> s;
	int flag = 1;
	for(int i = 0; i < s.size() - 1; ++i){
		if(s[i] == 'h' && s[i + 1] == 'i') i++;
		else {
			flag = 0;
			break;
		}
	}	
	if(s.size() % 2) flag = 0;
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;

int a[15][15];
int c[15];

void solve(){
	int ans=INF;
	
	int n,m,x;
	cin>>n>>m>>x;
	
	rep(i,0,n){
		cin>>c[i];
		rep(j,0,m){
			cin>>a[i][j];
		}
	}
	
	rep(mask,1,(1<<n)){
		int cost=0;
		int s[15]={0};
		rep(j,0,m)s[j]=0;
		rep(i,0,n){
			if(mask>>i&1){
				cost+=c[i];
				rep(j,0,m){
					s[j]+=a[i][j];
				}
			}
		}
		bool f=1;
		rep(j,0,m){
			if(s[j]<x)f=0;
		}
		if(f){
			amin(ans,cost);
		}
	}
	
	if(ans==INF){
		ans=-1;
	}
	cout<<ans;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SEIVE
		seive();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    vector<int> A(N),B(N),C(N);
    for(int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    iota(ALL(C),1);
    int idx = 0,a,b;
    do {
        idx++;
        if(C==A) a=idx;
        if(C==B) b=idx;

    } while (next_permutation(C.begin(), C.end()));    
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	if rec(n, 0) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func rec(n, current int) bool {
	if n == current {
		return true
	} else if n < current {
		return false
	}
	return rec(n, current + 4) || rec(n, current + 7)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}

bool even(string s) {
    int l = 0;
    int m = s.size() / 2;
    while (l < m) {
        if (s[l] != s[l + m]) {
            return false;
        }
        ++l;
    }
    return true;
}

int main() {
    int task = 1;
//    cin >> task;
    while (task--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (auto& el : a) {
            cin >> el;
        }
        vector<int> b(n);
        int l = 0, r = n-1;
        for (int i = 0; i < n; ++i) {
            if (i % 2 == 0) {
                b[l] = a[n - 1 - i];
                ++l;
            } else {
                b[r] = a[n - 1 - i];
                --r;
            }
        }

        for (auto el : b) {
            cout << el << " ";
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 3712
import math

A,B,H,M = map(int,input().split())


A_kaku = 30*(H)+0.5*(M)
B_kaku = 6*M
kaku = abs(A_kaku - B_kaku)
kaku = min(kaku,360-kaku)
kaku = math.radians(kaku)
X2 = A*A + B*B - 2*A*B*math.cos(kaku)
X2 = math.sqrt(X2)
print(X2)



Measured memory_bytes: 9376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count, t;
  cin >> N;
  count = 0;
  t = N;
  for (int i=0; t > 0; i++) {
    count += t % 10;
    t /= 10;
  }
  if (N % count == 0) {
    cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl;
  }
  
}

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

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

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

  ll ans=0;
  rep(i,n){
    ans+=i;
  }
  cout << ans;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> v(q);
  rep(i, q) {
    cin >> v[i];
    v[i]--;
  }
  map<int, int> count;
  rep(i, q){
    count[v[i]]++;
  }
  for (int i = 0; i < n; i++) {
    if(k - (q - count[i]) > 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 5760
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	
	writeln(K * (K-1)^^(N-1));
	stdout.flush();
	debug readln();
}

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

int main()
{
	int a,b;
	int ans = 0;
	cin >> a >> b;
  
 	for (int i = 0; i < 20; ++i){
		if(1+i*(a-1) >= b){
          ans = i;
          goto MyErr;
		};
  	};
	
  MyErr:
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//操作によりT(S)が減ると、その設定したKではすべて0にすることができなくなる
//T(S)が減らないKの値、つまりmax(k, n-k)の内最小の値をKに設定すれば良い
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    string S;
    cin >> S;
    int n = S.size();
    int T = S.size();
    for(int i = 0; i < n-1; ++i) {
        if(S[i] != S[i+1]) 
            T = min(T, max(i+1, n - i - 1));
    }
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
using namespace std;
typedef long long LL;
const int maxn = 1e5+10;

LL n,c;
LL x[maxn],v[maxn];
LL dp1[maxn],dp2[maxn];
LL mx1[maxn],mx2[maxn];

void solve()
{
    memset(mx1,0,sizeof(mx1));
    memset(mx2,0,sizeof(mx2));
    memset(dp1,0,sizeof(dp1));
    memset(dp2,0,sizeof(dp2));
    LL ans = 0;
    for(int i=1; i<=n; i++)
    {
        dp1[i] = dp1[i-1] + x[i] - v[i] + v[i-1];
        mx1[i] = max(mx1[i-1],dp1[i]);
        ans = max(ans,dp1[i]);
    }
    for(int i=n; i>=1; i--)
    {
        dp2[i] = dp2[i+1] + x[i] - abs(v[i] - v[i+1]);
        mx2[i] = max(mx2[i+1],dp2[i]);
        ans = max(ans,dp2[i]);
    }
    for(int i=1; i<=n; i++)
    {
        ans = max(ans,dp1[i] - v[i] + mx2[i+1]);
    }
    for(int i=n; i>=1; i--)
    {
        ans = max(ans,dp2[i] - abs(c - v[i]) + mx1[i-1]);
    }
//    for(int i=0; i<=n; i++)
//    {
//        cout<<dp1[i]<<" ";
//    }
//    cout<<endl;
//    for(int i=0; i<=n; i++)
//    {
//        cout<<dp2[i]<<" ";
//    }
//    cout<<endl;
    cout<<ans<<endl;
}

int main()
{
    IO;

    while(cin>>n>>c)
    {
        x[0] = v[0] = 0;
        x[n+1] = 0;
        v[n+1] = c;
        for(int i=1; i<=n; i++)
            cin>>v[i]>>x[i];
        solve();
    }
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main() {
	
	vector<double> p(1001,0);
	for(int i=1;i<=1000;i++){
		for(int j=1;j<=i;j++){
			p[i]+=(double)(j)/(double)(i);
		}
	}
	
	int n,k;
	cin >> n >> k;
	vector<double> a(n);
	
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	
	double tot=0;
	for(int i=0;i<k;i++){
		tot+=p[a[i]];
	}
	double ans=tot;
	
	for(int i=k;i<n;i++){
		tot+=p[a[i]];
		tot-=p[a[i-k]];
		ans=max(ans,tot);
	}
	
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  string str;
  int base=0,point=0,out=0;
  int n;
  cin>>n;
  getline(cin,str);
  while(getline(cin,str)){
    if(str[0] == 'O'){
      out++;
      //cout<<out<<endl;
      if(out==3){
	n--;
	printf("%d\n",point);	
	base=0,point=0,out=0;
	if(n==0)break;
      }
    }
    else if(str[1] == 'I'){
      base ++;
      if(base>3){
	base --;
	point ++;
      }
    }
    else if(str[1] == 'O'){
      point += base + 1;
      base = 0;
    }

  }
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main() {
  int r;
  cin >> r;
  cout << 3*r*r << endl;



}



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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   int d,n;cin >> d >> n;
   string ans;
   if(d == 0){
      ans = "";
   }else if(d == 1){
      ans = "00";
   }else if(d == 2){
      ans = "0000";
   }
   if(!(n == 100)){
      cout << n << ans << endl;
   }else{
      if(d ==0)cout << 101;
      else if(d == 1)cout << 10100;
      else if(d == 2)cout << 1010000;
   }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int h3=k/60;
    int m3=k%60;
    h1+=h3;
    m1+=m3;
    h1+=m1/60;
    m1%=60;

    cout<<(h2-h1)*60+(m2-m1)<<endl;
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

void Main()
{
	std::string str;
	std::cin >> str;
	int rest = 15;
	for (auto c : str)
	{
		if (c == 'x')
		{
			--rest;
		}
	}
	if (rest >= 8)
	{
		std::cout << "YES" << std::endl;
	}
	else
	{
		std::cout << "NO" << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define inf 1000000000
 
int n,ary[N][N];
 
int prim(){
  int i,u,v,mincost,sum=0;
  int pary[N],eary[N],color[N];
 
  for(i=0;i<n;i++){
    color[i]=WHITE;
    pary[i]=inf;
  }
  pary[0]=0;
  eary[0]=-1;
 
  while(1){
    mincost=inf;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && pary[i]<mincost){
    mincost=pary[i];
    u=i;
      }
    }
    if(mincost==inf)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && ary[u][v]!=inf){
    if(ary[u][v]<pary[v]){
      pary[v]=ary[u][v];
      eary[v]=u;
      color[v]=GRAY;
    }
      }
    }
  }
  for(i=0;i<n;i++){
    if(eary[i]!=-1)sum+=ary[i][eary[i]];
  }
  return sum;
}
 
int main(){
 
  int i,j,e;
   
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      if(e==-1){
    ary[i][j]=inf;
      }
      else{
    ary[i][j]=e;
      }
    }
  }
  printf("%d\n",prim());
}


Measured memory_bytes: 2052
#!/usr/bin/env python3
import sys
import copy
line = sys.stdin.readline() 
line = line.rstrip('\r\n')
face = line.split()

line = sys.stdin.readline() 

while(True):
    line = sys.stdin.readline() 
    if not line:
        break
    line = line.rstrip('\r\n')
    tar = line.split()
    
    for i in range(5):
        if face[1] == tar[1]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[1]
        face[1] = face_old[5]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[0]
        face[5] = face_old[4]
    else:
        face_old = copy.deepcopy(face)
        face[0] = face_old[3]
        face[1] = face_old[1]
        face[2] = face_old[0]
        face[3] = face_old[5]
        face[4] = face_old[4]
        face[5] = face_old[2]
    for i in range(5):
        if face[1] == tar[1]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[1]
        face[1] = face_old[5]
        face[2] = face_old[2]
        face[3] = face_old[3]
        face[4] = face_old[0]
        face[5] = face_old[4]
    for i in range(5):
        if face[0] == tar[0]:
            break
        face_old = copy.deepcopy(face)
        face[0] = face_old[3]
        face[1] = face_old[1]
        face[2] = face_old[0]
        face[3] = face_old[5]
        face[4] = face_old[4]
        face[5] = face_old[2]
    print(face[2])



Measured memory_bytes: 6308
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    string s,t;
    cin>>s>>t;
    int lens=s.size(),lent=t.size(),cnt,minv=inf;
    for(int i=0;i<=lens-lent;i++)
    {
    	cnt=0;
    	for(int j=0;j<=lent-1;j++)
    	{
    		if(t[j]!=s[j+i])
    			cnt++;
		}
		if(cnt<minv)
			minv=cnt;
	}
	cout<<minv<<endl;
	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<int>a(n+1);
  vector<int>b(n+1);
  rep(i,n)cin>>a[i+1];
  for(int i=n;i>0;i--){
    int sum=0;
    for(int j=i*2;j<=n;j+=i){
      sum^=b[j];
    }
    b[i]=a[i]^sum;
  }
  vector<int>ans;
  rep(i,n){
    if(b[i+1])ans.push_back(i+1);
  }
  cout<<ans.size()<<endl;
  rep(i,ans.size()){
    cout<<ans[i];
    if(i+1==ans.size())cout<<endl;
    else cout<<' ';
  }
  return(0);
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int arrays[n];
    for(int i = 0;i < n;i++){
        cin >> arrays[i];
    }
    
    ll ans = 0;
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            ans += arrays[i] * arrays[j];
        }
    }
    cout << ans << endl;
}





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

using namespace std;

template <typename T>
class BIT {
  vector<T> tree_;

 public:
  BIT(int n) : tree_(n, 0) {}
  void Add(int i, T x) {
    for (i++; i <= tree_.size(); i += i & -i) {
      tree_[i - 1] += x;
    }
  }

  T Sum(int s) {
    T ans = 0;
    for (s++; s > 0; s -= s & -s) {
      ans += tree_[s - 1];
    }

    return ans;
  }

  T Sum(int l, int r) { return Sum(r) - Sum(l - 1); }
};

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

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

  vector<array<int, 3>> vq(q);
  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    vq[i][0] = r - 1;
    vq[i][1] = l - 1;
    vq[i][2] = i;
  }

  sort(vq.begin(), vq.end());

  BIT<int> bit(n);
  vector<int> vp(n, -1), ans(q);
  int prev = 0;
  for (auto &q : vq) {
    int l, r, idx;
    r = q[0];
    l = q[1];
    idx = q[2];
    for (int i = prev; i <= r; ++i) {
      int c = vc[i];
      if (vp[c] < i) {
        if (vp[c] != -1) {
          bit.Add(vp[c], -1);
        }

        bit.Add(i, 1);
        vp[c] = i;
      }

      ans[idx] = bit.Sum(l, r);
    }

    prev = r;
  }

  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 17376
import java.io.*;
import java.util.*;

public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        public FastReader(String fileName) throws FileNotFoundException{br = new BufferedReader(new FileReader(fileName));}
        String next(){while (st == null || !st.hasMoreElements()){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());}
        double nextDouble(){return Double.parseDouble(next());}
        char[][] readCharArray(int n,int m) {
            String str;
            char[][] arr = new char[n][m];
            for(int i=0;i<n;i++) {
                str=nextLine();
                for(int j=0;j<n;j++) {
                    arr[i][j]=str.charAt(j);
                }
            }
            return arr;
        }
        char[][] readCharArray(int n){
            return readCharArray(n,n);
        }
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static void printArray(int[] arr){
        for(int x:arr){
            System.out.print(x+" ");
        }
        System.out.println();
    }
    static final Random random=new Random();
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastReader st = new FastReader();
        String str = "ACL";
        int n = st.nextInt();
        while(n-- > 0) {
        	System.out.print(str);
        }
        System.out.println();
    }
}

Measured memory_bytes: 25392
#include <bits/stdc++.h>
#define ll long long
#define NMAX
using namespace std;
ll n,n2;
char s[14],s2[14];
int main()
{
    //for(int k=1; k<=n; k++)
    cin.getline(s,14);
    cin.getline(s2,14);
    n=strlen(s);
    n2=strlen(s2);
    if(n+1!=n2)
    {
        cout<<"No";
        return 0;
    }
    for(int i=0; i<n; i++)
        if(s[i]!=s2[i])
        {
            cout<<"No";
            return 0;
        }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  string S;
  cin >> S;
  
  int bucket[26]={0};//バケット
  
  for(int i=0;i<S.length();i++){
    int tmp= S[i]-'a';
    bucket[tmp]++;
  }
  
  int ans=-1;//答えを格納
  for(int i=0; i<26; i++){
    if (bucket[i]==0){
      ans=i;
      break;
    }
  }
  
  if(ans==-1){
    cout << "None" << endl;
  }else{
    printf("%c",ans+97);
  }
  
  return 0;
      
}

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

typedef long long ll;

/*
  let's try computer shogi!!!
 */

ll getd(ll a){
  ll out = 0;
  while(a >9){
    out += a % 10;
    a = a/10;
  }
  out += a;
  return out;
}

int main(){
  ll n;
  ll mv = 114514;
  cin >> n;
  for(int i=1; i<n;++i){
    ll v = getd(i) + getd(n-i);
    if(v < mv){
      mv = v;
    }
    //cerr<<v<<","<<mv<<endl;
  }
  cout<<mv<<endl;
  return 0;
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
a = ["" for _ in range(n)]
b = ["" for _ in range(m)]
for i in range(n):
    a[i] = input()
for i in range(m):
    b[i] = input()
for i in range(n - m + 1):
    for j in range(n - m + 1):
        # bの左上が(i, j)の場合
        match = True
        for k in range(m):
            # print("i:{} j:{} k:{}".format(i, j, k))
            # print(b[k])
            # print(a[i+k][j:j+m])
            # print()
            if b[k] != a[i+k][j:j+m]:
                match = False
                break
        if match:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define forn(i, n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vii;
#define sz(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()

vi combine (const vi &l, const vi &r)
{
    if (l.empty() || r.empty())
        return l.empty() ? r : l;

    vi res(sz(l) + sz(r));
    int pl = 0, pr = 0, h = 0;
    while (pl < sz(l) && pr < sz(r))
        res[h++] = (l[pl] > r[pr] ? l[pl++] : r[pr++]);
    while (pl < sz(l))
        res[h++] = l[pl++];
    while (pr < sz(r))
        res[h++] = r[pr++];
    assert(h == sz(res));

    return res;
}

vi dfs (int x, const vvi &g, vector<char> &used)
{
    used[x] = 1;
    vi res;

    for (int dest : g[x])
    if (!used[dest])
        res = combine(res, dfs(dest, g, used));

    res.insert(res.begin(), x);
    return res;
}

void solve (int n)
{
    vi a(n);
    forn (i, n) cin >> a[i];
    sort(ALL(a));

    vvi g(n);
    forn (i, n) forn (j, i)
    if (__gcd(a[i], a[j]) != 1)
    {
        g[i].pb(j);
        g[j].pb(i);
    }

    forn (i, n)
        sort(ALL(g[i]));

    vi res;
    vector<char> used(n);
    forn (i, n) if (!used[i])
        res = combine(res, dfs(i, g, used));

    forn (i, n)
        cout << a[res[i]] << " \n"[i + 1 == n];
}

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

    int n;
    while (cin >> n)
        solve(n);
}


Measured memory_bytes: 17024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

ll used[101][101];
struct edge{ll to,cost;};
struct dijkstra
{
  using P=pair<ll,ll>;
  priority_queue<P,vector<P>,greater<P>> q;
  vector<vector<edge>>ed;
  vector<ll>dist;
  ll sz;
  dijkstra(ll size){
    sz=size;
    ed.resize(size);
  }
  void reset(){
    dist.assign(sz,-1);
    q=priority_queue<P,vector<P>,greater<P>>();
  }
  void ae(ll from,ll to,ll cost){
    ed[from].push_back({to,cost});
  }
  ll cal(ll start,ll end){
    reset();
    q.push({0,start*1001});
    while(!q.empty()){
      P tp=q.top();q.pop();
      ll from=tp.second%1000;
      tp.second/=1000;
      if(dist[tp.second]!=-1&&dist[tp.second]<tp.first)continue;
      dist[tp.second]=tp.first;
      used[from][tp.second]=1;
      used[tp.second][from]=1;
      //cout<<from<<tp.second<<endl;

      for(auto nn:ed[tp.second]){
        if(dist[nn.to]!=-1)continue;
        q.push({nn.cost+tp.first,nn.to*1000+tp.second});
      }
    }
    return dist[end];
  }
  ll getd(ll end){
    return dist[end];
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  rep(i,101)rep(j,101)used[i][j]=0;
  vector<ll >a(m),b(m),c(m);
  rep(i,m){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    used[a[i]][b[i]]=2;
    used[b[i]][a[i]]=2;
  }
  dijkstra dj(n);
  rep(j,m){
    dj.ae(a[j],b[j],c[j]);
    dj.ae(b[j],a[j],c[j]);
  }
  rep(i,n){

    dj.cal(i,n-1);
  }
  ll cnt=0;
  rep(i,101)repi(j,i+1,101)if(used[i][j]==2){cnt++;}
  cout<<cnt<<endl;

  return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll a[6];
	for(int i=1;i<=5;i++){
		cin>>a[i];
		if(a[i]==0) {
			cout<<i;
			return 0;
		}
	}


    return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main{
	public static void main(String []args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);

		//a???????????????
		int a = sc.nextInt();

		//b???????????????
		int b = sc.nextInt();
		//a??????b???????????§???????????° a < b
		if(a < b){
			System.out.println("a < b");
		//a??????b??????????°????????????° a > b
		} else if( a > b){
			System.out.println("a > b");
		//a??¨b?????????????????° a == b
		} else if(a == b){
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
const int MOD = 1000000007;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

int main() {
    ll n; cin >> n;
    ll ans = LLONG_MAX;
    for(ll i = 1;i * i <= n;i++){
        
        if(n % i == 0){
            ans = min(ans,n/i+i-2);
        }
    }
    cout << ans;
}


Measured memory_bytes: 3608
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    from collections import deque
    que = deque()
    que.append(1)
    seen = [-1] * (N+1)
    seen[1] = 0
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    one_num = 0
    while que:
        v = que.popleft()
        seq.append(v)
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] ^ 1
                if seen[u]:
                    one_num += 1
                par[u] = v
                child[v].append(u)
                que.append(u)
    seq.reverse()
    two_num = N - one_num

    one = list(range(1, N+1, 3))
    two = list(range(2, N+1, 3))
    three = list(range(3, N+1, 3))
    three_num = N // 3

    ans = [0] * (N+1)
    if one_num <= three_num:
        for v in range(1, N+1):
            if seen[v]:
                ans[v] = three.pop()
            else:
                if one:
                    ans[v] = one.pop()
                elif two:
                    ans[v] = two.pop()
                else:
                    ans[v] = three.pop()
    elif two_num <= three_num:
        for v in range(1, N+1):
            if not seen[v]:
                ans[v] = three.pop()
            else:
                if one:
                    ans[v] = one.pop()
                elif two:
                    ans[v] = two.pop()
                else:
                    ans[v] = three.pop()
    else:
        for v in range(1, N+1):
            if seen[v]:
                if one:
                    ans[v] = one.pop()
                else:
                    ans[v] = three.pop()
            else:
                if two:
                    ans[v] = two.pop()
                else:
                    ans[v] = three.pop()
    print(*ans[1:])


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define mem(a, b) memset(a, b, sizeof(a))

const int MOD = 1000000007;
const int MAX = (int) 1e9;
const double PI = 3.141592653589793238462643383279502884;

template <typename T, typename U>
T max(T x, U y) {
    return x > y ? x : y;
}

template <typename T, typename U>
T min(T x, U y) {
    return x < y ? x : y;
}

template<typename T>
void debug(string msg, T t) {
	cout << msg << ": " << t << "\n";
}

int toDigit(char c) { return c - '0'; }


int n;
ll a[200000], prefixSum[200000];

int main() {

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

	prefixSum[0] = a[0];
	for(int i = 1; i < n - 1; i++) {
		prefixSum[i] = (prefixSum[i - 1] + a[i]) % MOD;
	}

	ll ans = 0;
	for(int i = 1; i < n; i++) {
		ans = (ans + (a[i] * prefixSum[i - 1] % MOD)) % MOD;
	}

	cout << ans << "\n";

	return 0;
}

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

struct inc{
  int hp;
  int pow;
};

int main()
{
  inc a,b;

  cin >> a.hp >> a.pow >> b.hp >> b.pow;

  while(a.hp>0){
    b.hp-=a.pow;
    if(b.hp<=0){
      cout << "Yes\n";
      return 0;
    }
    a.hp-=b.pow;
  }

  cout << "No\n";

  return 0;
}

Measured memory_bytes: 3628
//atcoder problems AtCoder Beginner Contest160 のB問題です。
#include <stdio.h>

signed main(){

long long i,x,go=0,hyaku,goj,j,g=0,iti,sum=0;

scanf("%lld",&x);
while(x>=500){
x-=500;
go++;
}

while(x>=5){
x-=5;
g++;
}


sum=1000*go+5*g;

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

return 0;    
}

Measured memory_bytes: 1704
#include<iostream>
using namespace std;
 
int main(){
    int n, b, f, r, v;
    int i, j, k;
    int count[4][3][10] = {0};
     
    cin >> n;
     
        for(i = 0; i < n; i++){
            cin >> b >> f >> r >> v;
            count[b -1][f - 1][r - 1] += v;
        }
         
        for(i = 0; i < 4; i++){
            for(j = 0; j < 3; j++){
                for(k = 0; k < 10; k++){
                    cout << " " << count[i][j][k];
                }
                cout << endl;
            }
            if(i < 3){
                cout << "####################" << endl;
            }
        }
 
    return 0;
}

Measured memory_bytes: 3084
N = int(input())
A = list(map(int, input().split()))


def mod10_9_7(num):
    return num % (10**9+7)


seki = A[-1]

ans = 0
for i in range(N-2, -1, -1):
    ans += A[i] * seki
    seki += A[i]
print(mod10_9_7(ans))


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

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

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int a; cin >> a;
  string s; cin >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok
//string HOGE(".!\"#&%&'()*+,-/:"); // bad
//string HOGE(";<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'"); // bad
//string HOGE("()*+,-/:;<=>?@[\\"); // bad
//string HOGE("]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\"); // bad
//string HOGE("()*+,-/:;<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*,-/:;<=>?@[\\]^_`{|}~"); // ok (no +)

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_"); // ok -5


// included '_'

string HOGE("_.!\"#&%&'()*+,-/:;<=>?"); // ? more -5

int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || c == '.' || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;}

Measured memory_bytes: 1220