akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n;

void solve(vector<string> &vs) {
    rep(i,0,n) {
        rep(j,0,vs[i].length()-1) {
            if(vs[i][j] == '.' && vs[i][j+1] == '.') vs[i][j] = ' ';
            if(vs[i][j] == '.' && vs[i][j+1] != '.') vs[i][j] = '+';
        }
    }

    rep(i,0,n) {
        rep(j,0,vs[i].length()) {
            if(vs[i][j] == '+') {
                int idx = i-1;
                while(idx >= 0 && j < vs[idx].length() && vs[idx][j] == ' ') {
                    vs[idx--][j] = '|';
                }
            }
        }
    }

    rep(i,0,n) cout << vs[i] << endl;
}

signed main() {
    while(cin >> n, n) {
        vector<string> vs(n);
        rep(i,0,n) cin >> vs[i];
        solve(vs);
    }
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a を b の倍数値まで増やす
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b 以上の最小整数
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

__int128 kai(__int128 n) {
	if(n == 1) return 1;
	if(n == 0) return 1;
	else return n * kai(n - 1);
}


int main(void) {
	ll N;
	cin>>N;
	ll ans = INF;
	REP(i, (int)sqrt(N) + 1) {
		if(i && !(N % i)) {
			ll hoge = N / i;
			ll keta = 0;
			while(hoge != 0) {
				++keta;
				hoge /= 10;
			}
			ans = min(keta, ans);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
/*         
               JAI SHREE RAM    */
 
 
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
const int N = 1000001;
 
int power(int x, unsigned int y) 
{ 
    int res = 1;     
   
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = res*x; 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
 
long long maxSubArray(long long a[], int sze)
{
   long long max_so_far = 0, max_ending = 0;
   for (int i = 0; i < sze; i++)
   {
       max_ending = max_ending + a[i];
       if (max_ending < 0)
           max_ending = 0;
       else if (max_so_far < max_ending)
           max_so_far = max_ending;
   }
   return max_so_far;
}
 
 
 
ll factorialNumInverse[N + 1]; 
ll naturalNumInverse[N + 1]; 
ll fact[N + 1]; 
  
 
void InverseofNumber(ll p) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
} 
void InverseofFactorial(ll p) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
  
    
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
void factorial(ll p) 
{ 
    fact[0] = 1; 
  
    // precompute factorials 
    for (int i = 1; i <= N; i++) { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
  
ll Binomial(ll N, ll R, ll p) 
{ 
    // n C r = n!*inverse(r!)*inverse((n-r)!) 
    ll ans = ((fact[N] * factorialNumInverse[R]) 
              % p * factorialNumInverse[N - R]) 
             % p; 
    return ans; 
} 
 
 
void solve()
{
  int n,x,t;
  cin>>n>>x>>t;
  
  int c;
  if(n%x==0)
  c=n/x;
  
  else
  c=n/x+1;
  
  int ans=c*t;
  cout<<ans<<"\n";
   
}
 
int32_t main()
{ 
      
      
      int test;
      test=1;
      //cin>>test;
      while(test--)
      {
          solve();
      }
       
    
    return 0;
	}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(i, n)
    {
        int b;
        cin >> b;
        rep(y, 3) rep(x, 3)
        {
            if (a[y][x] == b)
            {
                a[y][x] = 0;
            }
        }
    }

    bool bingo = false;

    bool diag = true;
    bool backdiag = true;

    rep(i, 3)
    {
        bool lat = true;
        bool vert = true;

        diag = diag && a[i][i] == 0;
        backdiag = backdiag && a[2 - i][i] == 0;
        rep(j, 3)
        {
            lat = lat && a[i][j] == 0;
            vert = vert && a[j][i] == 0;
        }
        bingo = bingo || lat || vert;
    }

    bingo = bingo || diag || backdiag;
    string ans = bingo ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fint register int
#define h 2001
#define p 5001
#define int long long
using namespace std;
const int mods=1e9+7;
int f[p];
signed main()
{
	int n;
	cin>>n;
	f[1]=f[2]=0;
	for(fint i=3;i<=h;i++)
	f[i]=1;
	for(fint i=3;i<=h;i++)
	for(fint j=3;j<i;j++)
	if(i-j>=3)
	f[i]+=f[i-j],f[i]%=mods;
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 3568
N, K = map(int,input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)
A = []
H = sorted(H)
for i in range(N - K + 1):
    x = H[i + K - 1] - H[i]
    A.append(x)

A = sorted(A)
ans = A[0]
print(ans) 




Measured memory_bytes: 17840
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC118 {
	class ABC118_A {
		static void Main(string[] args) {
			var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var A = input[0];
			var B = input[1];
			if(B%A ==0 ) {
				Console.WriteLine(A + B);
			} else {
				Console.WriteLine(B - A);
			}
		}
	}
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int h,w;
    cin >> h >> w;
    string s;
    rep(i,h){
        cin >> s;
        cout << s << endl << s << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N;
vector<long long> A;
map<long long, int> M;

long long comfort = 0;

int zpos = 0;
void insertM(int pos){
	if(pos == 0){
		M[A[0]] = 1;
		return;
	}
	if(pos == 1){
		if(M.count(A[pos]) == 0){
			M[A[pos]] = 2;
			M[A[0]] = 0;
		}
		else{
			M[A[0]]++;
		}
		comfort += A[0];
		return;
	}
	//まずcomfortを計算しそのあと後用の処理をする。
	long long a;
	for(int i=zpos; i<pos; i++){
		a = A[i];
		if(M[a] == 0) continue;
		comfort += a;
		M[a]--;
		if(M[a] == 0){
			zpos = i;
		}
		break;
	}
	M[A[pos]] += 2;
}

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

	cin >> N;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end(), std::greater<long>()); //降順でソート

	for(int i=0; i<A.size(); i++){
		insertM(i);
	}
	printf("%lld\n", comfort);
	return 0;
}

Measured memory_bytes: 17100
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ll long long
using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> vect(h+1,vector<char>(w+1));
    for(int i=1 ; i<=h ; i++){
        for(int j=1 ; j<=w ; j++)
            cin>>vect[i][j];
    }
    vector<vector<ll>> dp(h+1,vector<ll>(w+1,0LL));
    dp[1][1]=1LL;
    for(int i=1 ; i<=h ; i++){
        for(int j=1 ; j<=w ; j++){
            if(vect[i][j]=='.'){
                dp[i][j]=max((dp[i][j-1]+dp[i-1][j])%mod,dp[i][j]);
            }
        }
    }
    cout<<dp[h][w]<<endl;
    return 0;
}

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

typedef pair<long long, long long> ii;


long long mod = 1000000007;
int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long n, k;
	cin >> n >> k;
	
	long long arr[n];
	for(int i = 0;i < n;i++) cin >> arr[i];
	
	long long ans = 0;
	
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			if(arr[i] > arr[j]){
				ans++;
			}
		}
	}
	ans %= mod;
	ans *= k;
	ans %= mod;
	
	map<long long,long long> occ;
	for(int i = 0;i < n;i++){
		if(occ.find(arr[i]) == occ.end()) occ[arr[i]] = 1;
		else occ[arr[i]]++;
	}
	
	long long pre = 0;
	long long bi = (k) * (k-1) / 2;
	bi %= mod;
	for(ii x : occ){
		ans += x.second * bi * pre;
		ans %= mod; 
		pre += x.second;
	}
	cout << ans;
	
}


Measured memory_bytes: 384
#![allow(non_snake_case,unused_imports,dead_code)]
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Reverse,Ordering};

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        D:usize,
        C:[isize;26],
        S:[[isize;26];D],
        T:[Usize1;D],
    }
    
    let mut Last = vec![0;26];

    let mut ans = 0;
    for (d,&t) in T.iter().enumerate(){
        ans += S[d][t];
        Last[t] = d as isize +1;
        for i in 0..26{
            ans -= C[i]*(d as isize +1 -Last[i]);
        }
        println!("{}",ans);
    }

}


Measured memory_bytes: 2308
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
#define pb emplace_back
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__)
#define outl(x) cout << (x) << '\n'
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int INF = 0x3f3f3f3f;

int V;
vector<pii> G[100010];
int dist[100010];

// 最遠のノード番号を返す
int bfs_mostFar(int s)
{
    queue<int> que;
    que.push(s);
    memset(dist, INF, sizeof(dist));
    dist[s] = 0;

    int maxpos = 0;
    while ( !que.empty() ) {
        int now = que.front(); que.pop();
        for (const auto &e: G[now]) {
            int nc = e.fi + dist[now];
            if ( chmin(dist[e.se], nc) ) {
                if (dist[e.se] > dist[maxpos]) maxpos = e.se;
                que.push(e.se);
            }
        }
    }
    return (maxpos);
}

int diameter()
{
    return dist[ bfs_mostFar( bfs_mostFar(0) ) ];
}

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

   cin >> V;
   rep(i, V-1) {  // 辺の数は (ノード数 - 1)
       int s, t ,w;
       cin >> s >> t >> w;
       G[s].pb(pii(w,t));
       G[t].pb(pii(w,s));
   }

   outl(diameter());
}




Measured memory_bytes: 9864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    string S;
    cin>>S;
    int n = S.size();
    vector<int> dig;
    rep(i,n){
        dig.push_back(S[i]-'0');
    }

    long long ans=0;
    rep(i,n){
        int k=0;
        for(int j=0;j<n-i;j++){
            if(j==n-i-1){
            ans=ans+(pow(10,i)*dig[j]*pow(2,n-1-i));
            }else{
            ans=ans+(pow(10,i)*dig[j]*pow(2,n-2-i));    
            }
//            cout << (pow(10,i)*dig[j]*pow(2,n-2-i)) << endl;
        }
//    cout << i << ":" << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

const int N_MAX = 100005;
int a[3 * N_MAX];


long long int A_total[N_MAX];
long long int B_total[N_MAX];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= 3 * n; i++){
        scanf("%d", &a[i]);
    }
    
    priority_queue<int, vector<int>, greater<int>> mae;
    priority_queue<int> ushiro;

    long long int ans = 0;

    A_total[0] = 0;
    for(int i = 1; i <= n; i++){
        A_total[0] += a[i];
        mae.push(a[i]);
    }
    B_total[n] = 0;
    for(int i = 2*n + 1; i <= 3*n; i++){
        B_total[n] += a[i];
        ushiro.push(a[i]);
    }

    for(int j = 1; j <= n; j++){
        A_total[j] = A_total[j-1] + a[n+j];
        mae.push(a[n+j]);
        A_total[j] -= mae.top();
        mae.pop();
    }
    for(int j = n-1; j >= 0; j--){
        B_total[j] = B_total[j+1] + a[n+j + 1];
        ushiro.push(a[n+j + 1]);
        B_total[j] -= ushiro.top();
        ushiro.pop();
    }

    ans = A_total[0] - B_total[0];
    for(int i = 1; i <= n; i++){
        ans = max(ans, A_total[i] - B_total[i]);
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
vector<int>num;
void prin(int i)
{
	cout<<num[i];
}
int main()
{
	num.push_back(1);
	num.push_back(0);
	int n,cnt=1;
	cin>>n;
	if(n<10){
		cout<<n<<endl;
		return 0;
	}
	n-=10;
	while(n--){
		int len=num.size();
		int flag=0;
		for(int i=len-1;i>=0;i--){
			if(i!=0){
				if(num[i]==9){
					num.pop_back();
					flag=1;
					continue;
				}
				if(num[i]!=num[i-1]+1){
					num[i]++;
					break;
				}else{
					num.pop_back();
					flag=1;
					continue;
				}
			}
			else{
				if(num[i]==9){
					cnt++;
					num[i]=1;
				}else{
					num[i]++;
				}
				flag=1;
			}
		}
		if(flag){
			len=num.size();
			for(int i=len;i<=cnt;i++){
				num.push_back(max(num[i-1]-1,0));
			}
		}
	}
	int len=num.size();
		for(int i=0;i<len;i++){
			prin(i);
		}
 	return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long

signed main(void){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  cout << (char)(s1[0]+'A'-'a') << (char)(s2[0]+'A'-'a') << (char)(s3[0]+'A'-'a') << "\r\n";
  return 0;
}


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

int main(void){
    int a, b[100010], n, ans=1, wa=1000000007;
    cin >> n;
    for(int i=0;i<n;++i) b[i]=0;
    for(int i=0;i<n;++i){
        cin >> a;
        ++b[a];
    }
    if(b[0]>=2){
        cout << "0" << endl;
        return 0;
    }
    for(int i=0;i<n;++i){
        if(b[i]>2){
            cout << "0" << endl;
            return 0;
        }
    }
    for(int i=0;i<n/2;++i){
        ans *= 2;
        ans %= wa;
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    rep(i,n/7+1){
        rep(j,n/4+1){
            if((7*i + 4*j) == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	int i, j, k, n, h, ma;
	vi b;
	cin >> n >> h;
	b.resize(n);
	rep(i, n) {
		cin >> j >> b[i];
		ma = max(ma,j);
	}
	sort(b.begin(), b.end());
	k = n - 1;
	j = 0;
	
	while (b[k] > ma && h>0) {
		j++;
		h -= b[k];
		k--;
	}
	
	if (h > 0) {
		if (h%ma == 0)j += h / ma;
		else j += h / ma + 1;
	}

	cout << j;
	

	return 0;
}

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

int main(){
	int diff = 9;
	int total = 0;
	int menu;
	int cnt = 0;
	rep(i, 5){
		int d;
		cin >> d;

		if(d%10 == 0){
			total += d;
			cnt++;
		}else{
			diff = min(diff, d%10);
			d+=9;
			total += (d/10)*10;
		}
	}

	if(cnt == 5) cout << total << endl;
	else cout << total-(10-diff) << endl;
	return 0;
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        n: usize,
    }
    let mut result :usize = 0;
    for d in 1..=n {
        result += d * (n/d) * (n/d + 1) / 2;
    }
    println!("{}", result);
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int64_t x;
    cin >> x;

    int64_t ans = x / 11 * 2;
    x %= 11;
    if (x > 0) {
        x -= 6;
        ans++;
    }
    if (x > 0) {
        x -= 5;
        ans++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	
	int bind=b;
	
	if(b<10)
	{
		bind+=10*a;
	}
	else if(b<100)
	{
		bind+=100*a;
	}
	else
	{
		bind+=1000*a;
	}
	
	int son=(int)sqrt((double)bind);
	if(son*son==bind)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 256
//package javaapplication2;
import java.util.*;
import java.io.*;
import static java.lang.System.out;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split("\\s");
        int A = Integer.parseInt(s[0]);
        int B = Integer.parseInt(s[1]);
        System.out.println(solve(A,B));
    }
    
    private static int solve(int A,int B){
        int low = 1,high = Integer.MAX_VALUE;
        int ans = -1;
        while(low <= high){
            int mid = low + (high - low) / 2;
            int p8 = consumptionRate(mid,8);
            int p10 = consumptionRate(mid,10);
            if(p8 == A && p10 == B){
                ans = mid;
                high = mid - 1;
            }else if(p8 <= A && p10 <= B) low = mid + 1;
            else high = mid - 1;
        }
        return ans;
    }
    
    private static int consumptionRate(long p,int percent){
        return (int)Math.floor(p * percent / 100.0);
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
long long a,b,n;
long long check(long long x)
{
	return a*x/b-a*(x/b);
}
int main()
{
	cin>>a>>b>>n;
	long long l=0,r=n,ans=0;
	while(r-l>=1000000)
	{
		long long lmid=l+(r-l)/3,rmid=r-(r-l)/3;
		if(check(lmid)<=check(rmid))
			l=lmid;
		else
			r=rmid;
	}
	while(l<=r&&l<=n)
	{
		ans=max(ans,check(l));
		l++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
 
int main( void )
{
 
        int a,i,j;
        scanf("%d",&a);
        double x[a],y[a],z[3],b=0,c=0;
        for(i=0;i<a;i++){
            scanf("%lf",&x[i]);
        }
        for(i=0;i<a;i++){
            scanf("%lf",&y[i]);
        }
        for(i=0;i<3;i++){
            for(j=0;j<a;j++){
                z[i]+=fabs(pow((x[j]-y[j]),i+1));
            }
        }
        for(i=0;i<a;i++){
            b=fabs(x[i]-y[i]);
            if(b>c)c=b;
        }
        printf("%lf\n",z[0]);
        printf("%lf\n",sqrt(z[1]));
        printf("%lf\n",pow(z[2],1.0/3.0));
        printf("%lf\n",c);
         
    return 0;
}

Measured memory_bytes: 716
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

a,b,c=MI()
if a+b==c or b+c==a or c+a==b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {

    int a, b;
    cin>>a>>b;

    for(int i=0;i<=10000;i++){
        int j = floor(i*0.08);
        int k=floor(i*0.1);
        if(a==j && b==k){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	long long num, a, b;
	cin >> num >> a >> b;
	if (num == 1) {
		if (a != b)
			printf("0\n");
		else
			printf("1\n");
	}
	else if (a > b)
		printf("0\n");
	else
		cout << (b - a) * (num - 2) + 1 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <cstdio>
using namespace std;

typedef long long ll;
const int N = (int)2e5 + 500;
const ll INF = (ll)1e18;

int n, l;
int num[2*N];
ll psum[2*N];
int lb, rb;

int main(){
	scanf("%d%d", &l, &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &num[i]);
	}
	num[0] = 0;
	n++;
	for(int i = 0; i < n; i++) num[i + n] = num[i] + l;
	
	ll res = 0;
	for(int i = 1; i < 2 * n; i++){
		psum[i] = psum[i-1] + num[i];
	}
	for(int step = (n + 1) % 2; step < n; step += 2){
		
		int m1 = n - step;
		int rem = (n - 1 - step) / 2;
		int l1 = m1 - rem, r1 = n + rem;
		ll cur_res = (num[n] - num[m1]) + 2 * ((psum[r1] - psum[n]) - (psum[m1-1] - psum[l1-1]));
		res = max(res, cur_res + max(num[l1] - num[m1], num[m1] - num[r1]));
//		printf("res : %d, m1 : %d, rem : %d, l1 : %d, r1 : %d\n", res, m1, rem, l1, r1); 
		
		m1 = n + step;
		rem = (n - 1 - step) / 2;
		l1 = n - rem, r1 = m1 + rem;
		cur_res = (num[m1] - num[n]) + 2 * ((psum[r1] - psum[m1]) - (psum[n-1] - psum[l1-1]));
		res = max(res, cur_res + max(num[l1] - num[m1], num[m1] - num[r1]));
//		printf("res : %d, m1 : %d, rem : %d, l1 : %d, r1 : %d\n", res, m1, rem, l1, r1); 
		
	}
	cout << res << endl;
	
}

Measured memory_bytes: 4992
# B - Golden Coins
# https://atcoder.jp/contests/abc160/tasks/abc160_b

# 所持金
X = int(input())

# 嬉しさ(= 残金計算時にも使用)
happy = 0

# 500円玉,5円玉の最大両替枚数
max_five_hundred = X//500
max_five = (X-(max_five_hundred*500))//5

# 各硬化の枚数をもとに嬉しさを算出
print((max_five_hundred*1000)+(max_five*5))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int d, n;
	while(cin >> d >> n, d||n){
		vector<int> a(n), e(n), r(n);
		rep(i,n){
			cin >> a[i] >> e[i] >> r[i];
		}

		const int INF = 100000;

		vector<vector<int>> dp(1000, vector<int>(1000, INF));
		dp[d][0] = 0;
		for(int i = d; i >= 0; i--){
			rep(j,101){
				rep(k,n){
					if(dp[i][j] == INF) continue;
					if(r[k] > j) continue;
					int y = max(i - a[k], 0);
					int x = min(100, j + e[k]);
					dp[y][x] = min(dp[y][x], dp[i][j] + 1);
				}
			}
		}

		int ans = INF;
		rep(i,101){
			ans = min(ans, dp[0][i]);
		}

		if(ans == INF){
			cout << "NA" << endl;
		}else{
			cout << ans << endl;
		}
	}
}



Measured memory_bytes: 6864
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
const int MOD=1e9+7;

int a[21][21];
int dp[22][1<<21];

int main(){
	int N;
	cin>>N;
	rep(i,N)rep(j,N)cin>>a[i][j];
	
	dp[0][0]=1;
	rep(i,N)rep(j,1<<N){
		if(dp[i][j]==0)continue;
		rep(k,N){
			if(!((1<<k)&j)&&a[i][k]==1)dp[i+1][j+(1<<k)]=(dp[i][j]+dp[i+1][j+(1<<k)])%MOD;
		}
	}
	cout<<dp[N][(1<<N)-1];
}

Measured memory_bytes: 162048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
long long int K,N;
int a[200002];
long long int visited[200002];
int main(){
	cin >> N >> K;
	for(long long int i=1;i<=N;i++)cin >> a[i];
	for(long long int i=1;i<=N;i++)visited[i]=-1;
	int s=1,t;
	long long int c=0;

	while(c<N){
		visited[s]=c;
		if(K==c){cout << s << endl; return 0;}
		t=a[s];
		if(s == t) {cout << s << endl; return 0;}
		c++;
		s=t;
		if(visited[t]!=-1)break;
	}
	if(K>c){
		long long int roop = c-visited[s];
		K-=visited[s];
		
		K%=roop;
		while(K>0){
			K--;
			s=a[s];
		}
	}
	cout << s << endl;
	return 0;
}

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

#define MAX_N (1<<18)

struct UF{
	int par[MAX_N];
	int rank[MAX_N];
	int si[MAX_N];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
			si[i] = 1;
		}
	}

	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
			si[y] += si[x];
		} else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
			si[x] += si[y];
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
} uf;

struct segtree{
    int n;
    P dat[2*MAX_N-1];

    void init(int n_){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2*n-1; i++) dat[i] = P(INF,0);
        for (int i = n-1; i < 2*n-1; i++) dat[i].second = i-(n-1);
    }

    void update(int k, ll a){
        k += n-1;
        dat[k].first = a;
        while(k > 0){
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }

    P query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return P(INF, 0);
        if(a <= l && r <= b) return dat[k];
        else{
            P vl = query(a,b,k*2+1,l,(l+r)/2);
            P vr = query(a,b,k*2+2,(l+r)/2,r);
            return min(vl, vr);
        }
    }
} seg;


ll n, d;
ll a[200000];
bool saw[200000];
vector<P> edge;

int main() {
    cin >> n >> d;
    uf.init(n);
    seg.init(n);
    rep(i,n) cin >> a[i];
    rep(i,n) seg.update(i, a[i]);
    ll ans = 0;
    rep(i,n) {
        P p = seg.query(0, seg.n, 0, 0, seg.n);
        if (p.second != 0 && !saw[p.second-1]) {
            ans += seg.dat[seg.n-1+p.second].first + seg.dat[seg.n-1+p.second-1].first + d;
            seg.update(p.second-1, min(seg.dat[seg.n-1+p.second].first+d, seg.dat[seg.n-1+p.second-1].first));
        }
        if (p.second != n-1 && !saw[p.second+1]) {
            ans += seg.dat[seg.n-1+p.second].first + seg.dat[seg.n-1+p.second+1].first + d;
            seg.update(p.second+1, min(seg.dat[seg.n-1+p.second].first+d, seg.dat[seg.n-1+p.second+1].first));
        }
        seg.update(p.second, INF);
        saw[p.second] = true;
    }
    cout << ans << endl;
}



Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<vector<ll>>v[2];
ll f(ll a[],ll n,ll i,ll j,ll turn){
    if(i==n || j==-1 || i>j){
        return 0;
    }
    if(v[turn][i][j]!=0){
        return v[turn][i][j];
    }
    if(turn==0){
        ll x=0,y=0;
        y=f(a,n,i+1,j,1)+a[i];
        x=f(a,n,i,j-1,1)+a[j];
        v[turn][i][j]= max(x,y);
    }
    else{
        ll x=0,y=0;
        y=f(a,n,i+1,j,0)-a[i];
        x=f(a,n,i,j-1,0)-a[j];
        v[turn][i][j]=min(x,y);
    }
    return v[turn][i][j];
}
int main() {
	ll n,i,j,k;
	cin>>n;
	ll a[n];
	vector<ll>tmp(n+1,0);
	for(i=0;i<n;i++){
	    cin>>a[i];
	    v[0].push_back(tmp);
	    v[1].push_back(tmp);
	}
	cout<<f(a,n,0,n-1,0);
	return 0;
}

Measured memory_bytes: 141440
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  string s;cin>>s;

  for(int t=0;t<s.size();t++){
    if(s[t]==s[t+1]){
      cout<<t+1<<" "<<t+2<<endl;
      return 0;
    }
  }
  for(int t=0;t<s.size()-1;t++){
    if(s[t]==s[t+2]){
      cout<<t+1<<" "<<t+3<<endl;
      return 0;
    }
  }
  cout<<-1<<" "<<-1<<endl;
  return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

typedef long long lint;
typedef complex<double> point;

template<typename Key, typename Value>
using hash_map = cc_hash_table<Key, Value>;
template<typename T, typename Cmp = less<T>>
using oset = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;

const int INF = 0x3f3f3f3f;
const lint INFL = 0x3f3f3f3f3f3f3f3fLL;
const double E = 1e-9, pi = 2 * acos(0);

template<typename T, typename U> void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if (x < y) x = y; }

const char x = 'x';

bool solve(int testNumber) {
	string S;
	if (!(cin >> S)) {
		return false;
	}
	int ans = 0;
	bool valid = true;
	for (int i = 0, j = (int)S.size() - 1; i < j and valid; ) {
		if (S[i] == S[j]) {
			i++, j--;
		} else if (S[i] == x) {
			ans++;
			i++;
		} else if (S[j] == x) {
			ans++;
			j--;
		} else {
			valid = false;
		}
	}
	printf("%d\n", valid ? ans : -1);
	return true;
}

void init(const char *in = nullptr, const char *out = nullptr) {
	if (in) freopen(in, "r", stdin);
	if (out) freopen(out, "w", stdout);
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	init();
	for (int i=1; solve(i); i++);
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3

N = int(input())


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(num2alpha(N).lower())


Measured memory_bytes: 9160
import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val A, B = sc.nextInt()
    val ans = (A - 1) * (B - 1)
    out.println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 25284
s = input()

total = 0

for i in range(len(s)):
  for j in range(len(s) - i):
    n = int(s[j:j+i+1])
    if j == 0 or j == len(s) - i - 1:
      total += n * max([(2 ** (len(s) - i - 2)), 1])
    else:
      total += n * max([(2 ** (len(s) - i - 3)), 1])
      
print(total)

Measured memory_bytes: 9192
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	n := nextInt()
	a := nextInts(n)

	cur := 1
	ans := 0

	for cur != 2 {
		if a[cur-1] != 0 {
			cur, a[cur-1] = a[cur-1], 0
			ans++
		} else {
			ans = -1
			break
		}
	}

	fmt.Fprintln(out, ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 2688
N = int(input())
A = list(map(int,input().split()))
ans = 1
state = 0
for i in range(N-1):
    #print(A[i],state,ans)
    if state == 1:
        if A[i] > A[i+1]:
            ans += 1
            state = 0
    elif state == -1:
        if A[i] < A[i+1]:
            ans += 1
            state = 0
    elif state == 0:
        if A[i] < A[i+1]:
            state = 1
        elif A[i] > A[i+1]:
            state = -1
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  N %= 10;
  if(N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
    cout << "hon" << endl;
  }
  else if(N == 3) {
    cout << "bon" << endl;
  }
  else {
    cout << "pon" << endl;
  }
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

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

    int resCandy = 0, resPeople = 0;

    for(int i = 0; i < n; i++){
        resCandy += a[i];
        if(resCandy <= x) resPeople++;
        else break;
    }
  
  	if((resPeople == n) and (resCandy != x)) resPeople--;

    cout << resPeople << endl;

    return 0;
}




Measured memory_bytes: 256
N, X, M = map(int, input().split())
table = [0]*(M+1)

pre = X
table[pre] = 0
seq = [pre]
cnt = 0
while True:
    cnt += 1
    A = pre**2%M
    if not table[A]:
        seq.append(A)
        table[A] = cnt
        pre = A
    else:
        f = table[A]
        s = cnt
        break
    
ans = 0
for i in range(f + (N-f)%(s-f)):
    ans += seq[i]
m = (N-f)//(s-f)
for i in range(f, s):
    ans += seq[i]*m

print(ans)

Measured memory_bytes: 70996
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1E9+7;
int main(){
  int n;
  cin >> n;
  int a[n],b[(n+1)/2]={};
  for(int i=0;i<n;i++){
    cin >> a[i];
    b[a[i]/2]++;
  }
  for(int i=0;i<(n+1)/2;i++){
      if(n%2){
        if(b[0]!=1){
          cout << 0 << endl;
          return 0;
        }
      }
    else{
      if(b[i]!=2){
      	cout << 0 << endl;
        return 0;
      }
    }
  }
  long long c=1;
  for(int i=1;i<=n/2;i++){
    c = 2*c%MOD;
  }
  cout << c << endl;
}


Measured memory_bytes: 768
a, b, c = map(int, [input() for _ in range(3)])
d = int(input())
e = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if d - 500 * i - 100 * j - 50 * k == 0:
                e += 1
print(e)


Measured memory_bytes: 2940
import sys;

v,e=map(int, input().split());

v_l=[0]*v;
e_b=[0]*e;
e_l=[0]*e;
result=0;

for i in range(v):
    v_l[i] = 0;
for i in range(e):
    e_b[i], e_l[i] = map(int, input().split());

def DFS(u):
    global result
    global v_l
    v_l[u] = 1
    for i in range(e):
        if(e_b[i] == u):
            if(v_l[e_l[i]] == 0):
                DFS(e_l[i])
            if(v_l[e_l[i]] == 1):
                result=1
    v_l[u] = 2
for i in range(v):
    DFS(i)
print(result)



Measured memory_bytes: 5632
//
//AtCoder Beginner Contest 143
//C - Slimes
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n;
    string s;

    cin >> n >> s;

    s.erase(unique(s.begin(), s.end()), s.end());

    cout << s.size() << endl;
    
    return 0;
}


Measured memory_bytes: 512
N = int(input())
d1 = [int(input().replace(' ',''),2) for i in range(N)]
d2 = [list(map(int,input().split())) for l in range(N)]
ans = []


for i in range(1 << 10):
    if i != 0:
        sum = 0
        for j in range(N):
            temp = 0
            a = int(d1[j])
            b = a & i
            for k in range(10):
                if ((b >> k) & 1) == 1:
                    temp += 1
            else:
                sum += d2[j][temp]
        ans.append(sum)

print(max(ans))

Measured memory_bytes: 3188
from collections import deque
h, w = map(int, input().split())
G = [list(input()) for _ in range(h)]
go = [[0,1], [1,0], [0,-1], [-1,0]]

ans = 0
# [h,w]を探索する.
for hi in range(h):
    for wi in range(w):
        # もしスタートが壁なら、各座標への距離の算出は行わない.
        if G[hi][wi] =='#':
            continue
        # BFSにより各座標への距離の算出を行う.
        ## 距離/探索したかを-1で初期化
        dist = [[-1]*w for _ in range(h)]
        ## [hi,wi]の地点の距離は0.
        dist[hi][wi] = 0
        ## 探索用のキューを初期化.
        que = deque([[hi,wi]])
        
        ## キューがなくなるまで以下を行う.
        while que:
            ### 探索する座標[nowhi,nowwi]
            nowhi, nowwi = que.pop()
            ### 探索する方向
            for dh, dw in go:
                #### 迷路からはみ出す箇所は探索しない.
                if not ((0<=nowhi+dh<=h-1) and (0<=nowwi+dw<=w-1)):
                    continue
                #### 通れない箇所は探索しない.
                if G[nowhi+dh][nowwi+dw]=='#':
                    continue
                #### 探索済みの箇所は探索しない.
                if dist[nowhi+dh][nowwi+dw]!=-1:
                    continue
                #### 探索する地点の距離は、現在の距離+1
                dist[nowhi+dh][nowwi+dw] = dist[nowhi][nowwi]+1
                #### キューに新たな探索済みの地点を追加.
                que.appendleft([nowhi+dh, nowwi+dw])
        # 答えはスタート地点を[h,w]で探索した際、最も長くなる距離.
        ans = max(ans, max([max(d) for d in dist]))
print(ans)

Measured memory_bytes: 9364
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}

class Knapsack {
    struct item {
        ll v, w;
    };

    vector<item> items;
    ll W, lv;

    ll solve_rec(size_t k, ll v, ll w) {
        if (w + items[k].w > W)
            return solve_rec(k + 1, v, w);
        ll cv = v, cw = w;
        for (size_t i = k; i < items.size(); ++i) {
            if (cw + items[i].w <= W) {
                cw += items[i].w;
                cv += items[i].v;
            }
        }
        if (lv < cv)
            lv = cv;
        double fv = v, fw = w;
        for (size_t i = k; i < items.size(); ++i) {
            if (fw + items[i].w <= W) {
                fw += items[i].w;
                fv += items[i].v;
            } else {
                fv += items[i].v * (W - fw) / items[i].w;
                break;
            }
        }
        if (fv - lv < 1 || fv < lv)
            return lv;
        solve_rec(k + 1, v + items[k].v, w + items[k].w);
        return solve_rec(k + 1, v, w);
    }

  public:
    // 価値v, 重みwのアイテムを追加
    void add_item(ll v, ll w) { items.push_back({v, w}); }

    // 重みの合計がW以下になるようにアイテムを選んだときの価値の和の最大値を返す．
    ll solve(ll W_) {
        if (items.empty())
            return 0;
        W = W_;
        sort(items.begin(), items.end(), [](const item &a, const item &b) {
            return a.v * b.w > a.w * b.v;
        });
        lv = 0;
        return solve_rec(0, 0, 0);
    };
};

int main() {
    iostream_init();
    int N, W;
    cin >> N >> W;
    Knapsack dp;
    for (int i = 0; i < N; i++) {
        int w, v;
        cin >> w >> v;
        dp.add_item(v, w);
    }

    cout << dp.solve(W) << endl;
    return 0;
}

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

int main() {
	
	int n;
	int k;
	int x;
	int y;
	
	cin >> n;
	cin >> k;
	cin >> x;
	cin >> y;
	
	int ans;
	
	if (n <= k) {
		ans = n * x;
	} else {
		ans = k * x + (n - k) * y;
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 256
<?php
$data = explode("/", trim(fgets(STDIN)) );
$check = 1556550000; //2019/04/30
$time = mktime(0, 0, 0, $data[1], $data[2], $data[0]);

$result = "TBD";
if( $time <= $check ) { $result = "Heisei"; }

echo $result;

Measured memory_bytes: 5744
N = int(input())
A = input()
B = input()
C = input()
cnt = 0
for i in range(N):
    setl = [A[i],B[i],C[i]]
    setl = len(set(setl))
    if setl == 1:
        pass
    elif setl == 2:
        cnt += 1
    elif setl == 3:
        cnt += 2
print(cnt)

Measured memory_bytes: 3064