akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int N,K;
	cin >> N >> K;
	if (N % K == 0){
		cout << 0 <<endl;
	}
	else{
		cout << 1 <<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int t,s,f,n,i,g=0,a;
	0<=t<=22;
	1<=n<=10;
	6<=s;
	f<=22;
	while(1){
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for(i=1;i<=n;i++){
			scanf("%d %d",&s,&f);
			g=g+(f-s);
		}
		if(g<t){
			a=t-g;
			printf("%d\n",a);
		}
		else{
			printf("OK\n");
		}
		g=0;
	}
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main()
{
  int n;
  cin >> n;
  std::vector<int> a(n);
  REP(i,n) cin >> a[i];
  std::vector<int> b(n);
  REP(i,n) cin >> b[i];
  std::vector<int> c(n-1);
  REP(i,n-1) cin >> c[i];


  lint happiness = 0;
  REP(i,n){
    happiness += b[a[i]-1];
    if(i!=n-1 && a[i+1]-a[i] == 1){
      happiness += c[a[i]-1];
    }
  }

  cout << happiness << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int A, B, C, K;

    cin >> A >> B >> C >> K;
    REP(i, K) {
        if(A >= B) {
            B *= 2;
        }
        else if(B >= C) {
            C *= 2;
        }
    }

    if(A < B && B < C) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 50;
int main(){
ll N,M,L; cin >> N >> M >> L;
  
  vector<vector<ll>> dist(N,vector<ll>(N,INF));
  for(ll i = 0; i < N; i++){ dist[i][i] = 0;}
  for(ll i = 0; i < M; i++){
    ll a,b,c; cin >> a >> b >> c; a--; b--;
    dist[a][b] = c; dist[b][a] = c;
  }
  
  for(ll k = 0; k < N; k++){
    for(ll i = 0; i < N; i++){
      for(ll j = 0; j < N; j++){
        dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
      }
    }
  }
                         
 
  vector<vector<ll>> dist2(N,vector<ll>(N,INF));
  
  for(ll i = 0; i < N; i++){
    for(ll j = 0; j < N; j++){
      if( i == j){ dist2[i][j] = 0;}
      else{
      if( dist[i][j] <= L){
        dist2[i][j] = 1;
      }
      } 
    }
  }
  
  for(ll k = 0; k < N; k++){
    for(ll i = 0; i < N; i++){
      for(ll j = 0; j < N; j++){
        dist2[i][j] = min(dist2[i][j],dist2[i][k]+dist2[k][j]);
      }
    }
  }

  ll Q; cin >> Q;
  for(ll i = 0; i < Q; i++){
    ll s,t; cin >> s >> t;
    s--; t--;
    if(dist2[s][t] == INF){ cout << -1 << endl;}
    else{
      cout<< dist2[s][t]-1 << endl; 
    }
    
  }
  
  return 0;
}
  
  

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;
int A[500][500] = {};

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

    int c = 0;
    for (int i = 1; i < 500; i++) {
        if ((i*i + i)/2 == N)
            c = i;
    }

    if (c == 0) {cout << "No" << endl; return 0;}

    int now = 1;
    for (int i = 0; i <= c; i++) {
        for (int j = 0; j < c-i; j++) {
            A[i][i+j] = now;
            A[i+j+1][i] = now;
            now++;
        }
    }

    cout << "Yes" << endl;
    cout << c+1 << endl;
    for (int i = 0; i <= c; i++) {
        cout << c << ' ';
        for (int j = 0; j < c; j++) {
            if (j != c-1) {cout << A[i][j] << ' ';}
            else {cout << A[i][j] << endl;}
        }
    }
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define ll long long
#define pw (ll)pow 
#define MAX 1000005
using namespace std;

int main()	
{
	int n;
	cin >> n;
	int a[n];
	vector<int> b(MAX,0);
	for(int i=0; i<n; i++)	{
		cin >> a[i];
		b[a[i]]++;
	}
	sort(a,a+n);
	int m=a[n-1];
	vector<bool> dp(m+1,true);
	for(int i=0; i<n; i++)	{
		for(int j=2*a[i]; j<=m; j+=a[i])	{
			if(dp[j])	dp[j]=0;
		}
	}
	int c=0;
	for(int i=1; i<=m; i++)	{
		if(dp[i] && b[i]==1)	c++;
	}
	cout << c << endl;
	return 0;
}

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

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

	if(A != 1 && B != 1)cout << "1" << endl;
	if(A != 2 && B != 2)cout << "2" << endl;
	if(A != 3 && B != 3)cout << "3" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main { //クラス名はMain
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
        int[] h=new int[n];
        ArrayList<Integer> a=new ArrayList<>();
        int o=0;
        for (int i=0;i<n;i++){
        	h[i]=sc.nextInt();
            if(i>0 && h[i-1]<h[i]){
            	a.add(i);
            }
        } 
        int l=a.size();
        if(l>0){
            o=a.get(0)-1;
            for (int i=1;i<l;i++){
                int d=a.get(i)-a.get(i-1)-1;
                if(o<d)o=d;
            }
            int d_last=n-1-a.get(l-1);
            if(o<d_last)o=d_last;
        }  else{
        	o=n-1;
        }
        System.out.println(o);
    }
}

Measured memory_bytes: 60708
N, L = map(int,input().split())
Apples = list(L+i-1 for i in range(1,N+1))
APP = list(abs(Apples[i])for i in range(N))
if min(APP) in Apples:
    ans = sum(Apples[i]for i in range(N))-min(APP) 
else:
    ans = sum(Apples[i]for i in range(N))+min(APP)
print(ans)

Measured memory_bytes: 3060
(defun solve (sx sy tx ty)
  (let ((dx (- tx sx))
        (dy (- ty sy)))
    (with-output-to-string (*standard-output*)
      (dotimes (_ dy)
        (write-char #\U))
      (dotimes (_ dx)
        (write-char #\R))
      (dotimes (_ dy)
        (write-char #\D))
      (dotimes (_ dx)
        (write-char #\L))
      (write-char #\L)
      (dotimes (_ (1+ dy))
        (write-char #\U))
      (dotimes (_ (1+ dx))
        (write-char #\R))
      (write-char #\D)
      (write-char #\R)
      (dotimes (_ (1+ dy))
        (write-char #\D))
      (dotimes (_ (1+ dx))
        (write-char #\L))
      (write-char #\U))))

#-swank
(let* ((sx (read))
       (sy (read))
       (tx (read))
       (ty (read)))
  (format t "~A~%" (solve sx sy tx ty)))


Measured memory_bytes: 15840
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int d = n / i;
    ans += i * d * (d + 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n%111 == 0)
    cout << n << endl;
  else
    cout << (n/111+1)*111 << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n,sum=0,t;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        sum+=t;
    }
    cout<<(sum-n)<<endl;
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n,0);
  int k;
  int all = 0;
  for(int i = 0; i<n;++i){
    cin >> k;
    all = all ^ k;
    a[i] = k;
  }
  for(int i = 0; i<n-1;++i){
    a[i] = all ^ a[i];
    cout << a[i] << " ";
  }
  a[n-1] = all ^ a[n-1];
  cout << a[n-1] << endl;
 
}


Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <unordered_map>
using namespace std;

long long fuct(long long n) {
	if (n == 0) {
		return 1;
	}
	else {
		return n * fuct(n - 1) % 1000000007;
	}
}

int main()
{
	int n;
	cin >> n;
	cout << fuct(n) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    // int x,y,z;
    // cin>>x>>y>>z;
    // swap(x,y);
    // swap(x,z);
    // cout<<x<<" "<<y<<" "<<z<<endl;
    int n,m;
    cin>>n>>m;
    vi v(n);
    rep(i,n)cin>>v[i];
    int sum=0;
    rep(i,n)sum+=v[i];
    int ans=0;
    rep(i,n){
        if((double)sum/4.0/m>v[i])continue;
        ans++;
    }
    if(ans>=m)fin("Yes");
    else fin("No");
}



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

using namespace std;

long long kaijou(int n){
  long long ans=1;
  for(int i=1;i<n+1;i++) ans *= i;
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(2));
  for(int i = 0; i < n; i++) {
    cin >> a.at(i).at(0);
    cin >> a.at(i).at(1);
  }
  
  double ans=0;
  vector<int> b(n);
  for(int i = 0; i < n; i++) {
    b[i]=i+1;
  }
  do {
    double sum=0;
    for(int i = 0; i < n-1; i++) {
      sum += sqrt((a.at(b[i]-1).at(0)-a.at(b[i+1]-1).at(0))*(a.at(b[i]-1).at(0)-a.at(b[i+1]-1).at(0))+(a.at(b[i]-1).at(1)-a.at(b[i+1]-1).at(1))*(a.at(b[i]-1).at(1)-a.at(b[i+1]-1).at(1)));
    }
    ans += sum;
  }while (next_permutation(b.begin(),b.end()));  

  cout << fixed << setprecision(10);
  cout << ans/kaijou(n) << endl;
  return 0;
}

Measured memory_bytes: 3748
#include<iostream>
using namespace std;
int a,b,c,d,x,y;
int main()
{
    while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
    {
        if(c > b || a > d)
        {
            printf("0\n");
            continue;
        }
        if(a > c)
            x = a;
        else
            x = c;
        if(b > d)
            y = d;
        else
            y = b;
        printf("%d\n",y-x);
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




















 
int main(){
    ll n, k;
    cin >> n >> k;
    if(k == 1){
        cout << 0 << endl;
    }
    else{
        cout << n - k << endl;
    }
}

Measured memory_bytes: 892
import java.util.Scanner ;
public class Main {

	public static void main(String[] args) {
	Scanner stdin = new Scanner( System.in ) ;
	int a,b,c;
	a = stdin.nextInt();
	b = stdin.nextInt();
	c = stdin.nextInt();
	if(a<=c){
		if(c<=b){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}else{
		System.out.println("No");


		}
	}


}



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

char c[55][55]; int H, W, cnt;

int main(){
  cin >> H >> W;
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++) cin >> c[i][j];
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++){
      if (c[i][j] == '#' && c[i][j-1] != '#' && c[i-1][j] != '#' && c[i][j+1] != '#' && c[i+1][j] != '#') cnt++;
    }
  }
  if(cnt == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
A1 = set(A)
AN = {}
for a in A:
    if not a in AN:
        AN[a] = 0
    AN[a] += 1
AN = sorted(AN.items(), key=lambda x: x[1])
ans = 0
K1 = len(A1) - K
if K1 > 0:
    for k in range(K1):
        ans += AN[k][1]
    print(ans)
else:
    print('0')


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

int main() {
    int n;
    cin >> n;
    map<int, int> A;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        A[tmp]++;
    }

    int cnt = 0;
    for (auto x : A) {
        if (x.second % 2 != 0) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 8060
#include <stdio.h>
#define MAX 100000
#define INFTY 1000000000

typedef struct{
  char mark;
  int num;
}Data;

int Partition(Data[], int, int);
void QuickSort(Data[], int, int);
int isStable(Data[] ,Data[],int);
void Merge(Data[], int, int, int);
void MergeSort(Data[], int, int);

int count = 0;
int main(){
  int i, n, judge;
  Data A[MAX],B[MAX];

  scanf("%d%*c",&n);
  for(i=0;i<n;i++){
    scanf("%c %d%*c",&A[i].mark, &A[i].num);
  }
  
  for(i=0;i<n;i++){
    B[i] = A[i];
  }
  /*
  while(flag!=0){ //BubbleSort
    
    flag = 0;
    
    for(j = n-1 ;0 < j ;j--){
      
      if(A[j].num < A[j-1].num){
	tmp = A[j];
	A[j] = A[j-1]; 
	A[j-1] = tmp;

	flag = 1;	
      }
    }
  }
 */
  MergeSort(A, 0, n);
  QuickSort(B,0,n-1);

  judge = isStable(A,B,n);

  if(judge==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n", B[i].mark, B[i].num);
  }
  
  return 0;
}

void QuickSort(Data *A, int p, int r){
  int q;
  if(p < r){
    q = Partition(A, p, r);
    QuickSort(A, p, q-1);
    QuickSort(A, q+1, r);
  }
}
int Partition(Data *A, int p, int r){
  int x, i, j;
  Data tmp;
  
  x = A[r].num;
  i = p - 1;

  for(j=p;j<r;j++){
    if(A[j].num<= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  
  return i+1;
}

int isStable(Data A[],Data B[],int n){
  int i;

  for(i=0;i<n;i++){
    if(A[i].mark != B[i].mark) return 0;
  }
  return 1;
}
/*
int isStable(Data in[],Data out[],int n){ //??????????????????isStable
  int i,j,a,b;

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if(in[i].num == in[j].num
	     && in[i].mark==out[b].mark && in[i].num==out[b].num
	     && in[j].mark==out[a].mark && in[j].num==out[a].num){
	    return 0; //false
	  }
	}
      }
    }
  }
  return 1; //true
}
*/
void MergeSort(Data *A, int left, int right){
  int mid;

  // printf("left: %d, right: %d\n",left,right);
  
  if(left+1 < right){
    mid = (left + right)/2;
    
    // printf("%d\n\n",mid);
    
    //printf("L-M\n");
    MergeSort(A, left, mid);

    //printf("M-R\n");
    MergeSort(A, mid, right);

    //printf("Merge\n");
    Merge(A, left, mid, right);
  }
}

void Merge(Data *A, int left, int mid, int right){
  int i,j,k;
  int n1, n2;
  Data L[MAX];
  Data R[MAX];
  n1 = mid - left;
  n2 = right - mid;

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

  L[n1].num = INFTY;
  R[n2].num = INFTY;

  i=0;
  j=0;
  
  for(k = left ; k < right ; k++){
    
    count++;
    if(L[i].num <= R[j].num){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

Measured memory_bytes: 2956
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <string>
using namespace std;
 
int main (){
 
//変数宣言
 
    int i=0,j=0;
    string temp;
 
    getline(cin,temp);
  
    for(i=0;i<temp.size();i++){
	if (islower(temp[i])){
	    temp[i] = toupper(temp[i]);
	}else{
	    temp[i] = tolower(temp[i]);
	}
    }
    
//出力
    cout << temp << endl;
    return 0;
}

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

int main()
{
  int sum=0,n,nn;
  vector<int> num(9);

  cin>>n;
  nn=n;
  for(int i=0;i<10;i++)
  {
    sum=nn%10+sum;
    nn=nn/10;
  }

  if(n%sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n, m;
  cin >> n >> m;
  if (n * 2 <= m ) {
	m -= n * 2;
	cout << n + m / 4 << endl;
	return 0;
  }
  else {
	cout << m / 2 << endl;
	return 0;
  }
  
  return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin>>s;
  if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

int n;

int main()
{
    int s=0,maxim=0,x;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        maxim=max(maxim,x);
        s+=x;
    }


    cout<<(maxim<s-maxim ? "Yes":"No");
    return 0;
}


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

#define LEN 101

int main(void){
    int N, i, match;
    char s[LEN], t[LEN];
    
    scanf("%ld", &N);
    scanf("%s", s);
    scanf("%s", t);
    
    for(match = N; match >=0; match--){
        if(strncmp(&(s[N - match]), t, match) == 0) break;
    }
    
    printf("%ld\n", 2 * N - match);
    
    return 0;
}

Measured memory_bytes: 128
S = input()

if S == 'SAT':
    print(1)
elif S == 'FRI':
    print(2)
elif S == 'THU':
    print(3)
elif S == 'WED':
    print(4)
elif S == 'TUE':
    print(5)
elif S == 'MON':
    print(6)
elif S == 'SUN':
    print(7)

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

const static int MAX = 100000;

std::vector<int> G[MAX];
int N;
std::vector<bool> visited(MAX);
std::vector<int> prenum(MAX), parent(MAX), lowest(MAX);
int timer;

void dfs(int current, int prev){
    prenum[current] = lowest[current] = timer;
    timer++;

    visited[current] = true;

    int next;

    for(int i = 0; i < G[current].size(); i++){
        next = G[current][i];
        if(!visited[next]){
            parent[next] = current;
            dfs(next, current);

            lowest[current] = std::min(lowest[current], lowest[next]);
        }else if(next != prev){
            lowest[current] = std::min(lowest[current], prenum[next]);
        }
    }
}

void art_points(){
    for(int i = 0; i < N; i++) visited[i] = false;
    timer = 1;

    dfs(0, -1);

    std::set<int> ap;
    int np = 0;
    for(int i = 1; i < N; i++){
        int p = parent[i];
        // std::cout << p << std::endl;
        if(p == 0) np++;
        else if(prenum[p] <= lowest[i]) ap.insert(p);
    }

    if(np > 1) ap.insert(0);
    for(std::set<int>::iterator it = ap.begin(); it != ap.end(); it++ ){
        std::cout << *it << std::endl;
    }
        
}
    
int main(void){
    int m;
    std::cin >> N >> m;

    for(int i = 0; i < m; i++){
        int s, t;
        std::cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    art_points();

    return 0;
}


Measured memory_bytes: 7872
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N, K;
	int[] p;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		K = Integer.parseInt(tokens[1]);
		tokens = in.readLine().split(" ");
		p = new int[N];
		for (int i = 0; i < N; ++i) {
			p[i] = Integer.parseInt(tokens[i]);
		}
		Arrays.sort(p);
		int sum = 0;
		for (int i = 0; i < K; ++i) {
			sum += p[i];
		}
		System.out.println(sum);
	}

	void calc() {
	}

	void showResult() {
	}
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin>>n;
  vector<int> b(n-1); 
  vector<int> a(n);
  rep(i,n-1) cin>>b.at(i);
  for(int i=1;i<n-1;i++) a.at(i)=min(b.at(i-1),b.at(i));
  a.at(0)=b.at(0);
  a.at(n-1)=b.at(n-2);
  int ans=0;  
  rep(i,n) ans+=a.at(i);
  cout<<ans<<endl;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin>>A>>B;
  int cnt=0;
  
  for (int i=A;i<=B;i++){
    if(to_string(i)[0]==to_string(i)[4] && to_string(i)[1]==to_string(i)[3]){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}

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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    int a = n / 2;
    int mod = n % 2;
    int how_many = a + mod;
    if(how_many >= k){
        puts("YES");
    }else{
        puts("NO");
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

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

    ll N = (A * X) + (B * Y);
    ll M = C * (2 * max(X, Y));

    ll P = X < Y ? B : A;
    ll L = C * (2 * min(X, Y)) + P * abs(X - Y);

    cout << min(N, min(M, L)) << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
constexpr int M = 1e9 + 7;
constexpr int INF = 1e9;
 
int main() {
    string S, T;
    cin >> S >> T;
    vector<string> cand;
    for(int i = (int)S.size() - (int)T.size(); i >= 0; --i) {
        bool check = true;
        for(int j = 0; j < T.size(); ++j) {
            check &= S[i + j] == '?' || S[i + j] == T[j];
        }
        if(check) {
            string res;
            for(int j = 0; j < i; ++j) {
                res += (S[j] == '?' ? 'a' : S[j]);
            }
            res += T;
            for(int j = i + T.size(); j < S.size(); ++j) {
                res += (S[j] == '?' ? 'a' : S[j]);
            }
            cand.push_back(move(res));
        }
    }
    if(cand.size() == 0) {
        cout << "UNRESTORABLE" << endl;
    } else {
        sort(cand.begin(), cand.end());
        cout << cand[0] << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	string s, t; 
	int ans= -1;
	cin>>s>>t;

	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());

	int length= min(s.length(),t.length());

	for(int i=0; i<length; i++){
		if(s[i]<t[i]){
			ans= 1;
			break;
		}
		else if(s[i]>t[i]){
			ans=0;
			break;
		}
	}

	if(ans==-1){
		if(s.length()< t.length()){
			ans=1;
		}
		else{
			ans=0;
		}
	}

	if(ans==1){
		cout<<"Yes"<<endl;
	}
	if(ans==0){
		cout<<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
signed main() {
	ll a, b, c, d, e, f, g;
	cin >> a >> b >> c >> d >> e >> f >> g;
	if (a == 1 && d == 1 && e == 1)cout << 3 + b << endl;
	else if (a < 2 && d < 2 && e < 2)cout << b << endl;
	else if ((a % 2 == 1 && d % 2 == 1 && e % 2 == 1) || (a % 2 == 0 && d % 2 == 0 && e % 2 == 0))cout << a + b + d + e << endl;
	else cout << a + b + d + e - 1 << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    int n,ans;
int main(){
    cin >> n;
    vector<long long> a={},b={};
    long long suma=0,sumb=0;
    for(int i=0;i<n;i++){
        long long aa;
        cin >> aa;
        a.push_back(aa);
        suma += aa;
    }
    for(int i=0;i<n;i++){
        long long bb;
        cin >> bb;
        b.push_back(bb);
        sumb += bb;
    }

    //cerr << suma << " " << sumb <<endl;

    if(suma < sumb){
        cout << -1<<endl;
        return 0;
    }
    ans = 0;
    vector<long long> ok={};
    long long sumng=0;
    for(int i=0;i<n;i++){
        if(a[i] > b[i]){
            ok.push_back(a[i] - b[i]);
        }else if(a[i] < b[i]){
            sumng += b[i]-a[i];
            ans++;
        }
    }
    //cerr << ans <<endl;
    if(sumng==0){
        cout << 0<<endl;
        return 0;
    }

    for(int i =0;i<ok.size();i++){
        //cerr << ok[i] <<" ";
    }
    //cerr <<endl;

    sort(ok.begin(),ok.end(),std::greater<long long>());
    long long sumok = 0;

    for(int i =0;i<n;i++){
        sumok += ok[i];
        ans++;
        if(sumok>=sumng){
            break;
        }
    }


    cout << ans<<endl;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    
    int mi = n + 1;
    int cnt = 0;
    rep(i, n) {
        if (mi >= p[i]) {
            cnt++;
        }
        mi = min(mi, p[i]);
    }

    put(cnt);
    return 0;
}

Measured memory_bytes: 3988
# -*- coding: utf-8 -*-

s = raw_input()

Heisei = "Heisei"
TBD = "TBD"
ans = Heisei

l = s.split("/")

if int(l[0]) > 2019:
    ans = TBD
elif int(l[0]) < 2019:
    ans = Heisei
else:
    if int(l[1]) > 4:
        ans = TBD
    else:
        ans = Heisei

print ans


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, A; cin >> N;
    A = LLINF;
    rep(i, 5){
        ll temp; cin >> temp;
        A = min(A, temp);
    }
    ll ans = (N+(A-1))/A;
    cout << ans+4 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] ab = new int[n][3];
        int[][] cd = new int[m][2];
        
        for (int i = 0; i < n; i ++) {
            ab[i][0] = sc.nextInt();
            ab[i][1] = sc.nextInt();
        }
        
        for (int i = 0; i < m; i++) {
            cd[i][0] = sc.nextInt();
            cd[i][1] = sc.nextInt();
        }
        
        for (int i = 0; i < n; i++) {
            ab[i][2] = 0;
            int man = Math.abs(ab[i][0] - cd[0][0]) + Math.abs(ab[i][1] - cd[0][1]);
            for (int j = 1; j < m; j++) {
                int x = Math.abs(ab[i][0] - cd[j][0]);
                int y = Math.abs(ab[i][1] - cd[j][1]);
                if (x + y < man) {
                    ab[i][2] = j;
                    man = x + y;
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            System.out.println(ab[i][2] + 1);
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll sum = 1;
	ll i, j;
	ll ret = 0;

    cin >> n >> m;

    while(m>sum) {
    	sum += (n-1);
        ret++;
    }
    
    cout << ret <<endl;

	return 0;
}

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

inline bool chmin(double &a, double b){
	if (a - 1e-8 > b){
		a = b;
		return true;
	}
	return false;
}

const int M = 256;
int N;
int I[257], R[257], O[257];
int cnt[257];

double calc(int s, int a, int c)
{
	R[0] = s;
	for (int i = 1; i <= N; i++){
		R[i] = (a * R[i - 1] + c) % M;
	}
	memset(cnt, 0, sizeof cnt);
	for (int i = 1; i <= N; i++){
		O[i] = (I[i] + R[i]) % M;
		cnt[O[i]]++;
	}
	double H = 0;
	for (int i = 0; i < M; i++){
		if (!cnt[i]) continue;
		H -= double(cnt[i]) / N * log(double(cnt[i]) / N);
	}
	return H;
}

int main()
{
	while (scanf("%d", &N), N){
		for (int i = 1; i <= N; i++) scanf("%d", I + i);
		
		double mini = 1e9;
		int ress, resa, resc;
		for (int s = 0; s < 16; s++)
			for (int a = 0; a < 16; a++)
				for (int c = 0; c < 16; c++)
					if (chmin(mini, calc(s, a, c))){
						ress = s;
						resa = a;
						resc = c;
					}
		printf("%d %d %d\n", ress, resa, resc);
	}
}

Measured memory_bytes: 1232
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let K: usize = sc.get();
    let mut A: Vec<i64> = sc.vec(N);
    for _ in 0..K {
        let mut bright = vec![0; N+2];
        for i in 0..N {
            let begin = max(0, i as i64 - A[i]) as usize;
            let end = min(N as i64+1, i as i64 + A[i] + 1) as usize;
            bright[begin] += 1;
            bright[end] -= 1;
        }
        for i in 0..N {
            bright[i+1] += bright[i];
        }
        let mut end = true;
        for i in 0..N {
            if A[i] != bright[i] {
                A[i] = bright[i];
                end = false;
            }
        }
        if end {
            break;
        }
    }
    for &ai in &A {
        println!("{}", ai);
    }
}


Measured memory_bytes: 5204
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b,ll m) {ll res=1;a%=m;for(;b;b>>=1){if(b&1)res=res*a%m;a=a*a%m;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); }
ll dp[200005]; 
vector<ll>grp[200005];
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n,k;
		cin>>n>>k;
		zero(dp);
		for(ll i=1;i<=k;i++){
			for(ll j=2*i;j<=k;j+=i){
				grp[i].pb(j);
			}
		}
		for(int i=1;i<=k;i++){
			ll num=k/i;
			dp[i]=modpow(num,n,MOD);
			// cout<<"i= "<<i<<" dp= "<<dp[i]<<endl;
		}
		for(ll i=k;i>=1;i--){
			for(ll j=0;j<grp[i].size();j++){
				ll m=grp[i][j];
				// cout<<i<<" "<<grp[i][j]<<endl;
				dp[i]=(dp[i]-dp[m]+MOD)%MOD;
			}
		}
		ll res=0;
		// cout<<"After DP"<<endl;
		for(ll i=1;i<=k;i++){
			// cout<<i<<" "<<dp[i]<<endl;
			res=(res+(dp[i]*i)%MOD)%MOD;
			// cout<<"i= "<<i<<" dp = "<<dp[i]<<endl;
		}
		cout<<res<<endl;
	}	
}


Measured memory_bytes: 20520
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    vector<int> dp(n+1, INF);
    dp[1] = 0;
    int cnt = 2;
    while (cnt <= k+1 && cnt < n+1) {
        dp[cnt] = abs(h[cnt-1]-h[0]);
        cnt++;
    }

    for (int i=1; i<n; i++) {
        cnt = 1;
        while (cnt <= k && i+cnt < n+1) {
            dp[i+cnt] = min(dp[i]+abs(h[i+cnt-1]-h[i-1]), dp[i+cnt]);
            cnt++;
        }
    }

    cout << dp[n] << endl;

}




Measured memory_bytes: 1024
#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 ALL(v) v.begin(), v.end()

int main() {
  //std::cout << std::fixed << std::setprecision(20);
  int64_t N, K;
  cin >> N >> K;

  int64_t i = 1;
  int64_t n = 0;
  while(N >= i){
    i *= K;
    n++;
  }
  cout << n << endl;
}

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

int main()
{
	int a[10]={0};
	int n,k;
	int ans=0,flag=0;
	int x;
	cin>>n>>k;
	
	for(int i=0;i<k;i++)
	{
		cin>>x;
		a[x]++;
	}
	
	for(int i=n; i<1000000; i++)
	{
		int t=i;
		flag=0;
		while(t)
		{
			int p=t%10;
			if(a[p]!=0)
			{
				flag=1;
				break;
			}
			t/=10;
		}
		if(flag==1)
			continue;
		else
		{
			ans=i;
			break;
		}
	}
	
	cout<<ans<< endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    
    int max = 0, min = 1000000000;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(sc.next());
      max = n > max ? n : max;
      min = n < min ? n : min;
    }
    
    System.out.println(max - min);
  }
}

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

int main(){
  string N,M,s;
  getline(cin,N);
  getline(cin,M);
  int  len = N.size();
  for(int i = 0;i < len;i++){
    if(N.compare(M) == 0){
      cout << "Yes" << "\n";
      return 0;
    }
    for(int j = len; j >= 0; --j) {
      s[0] = N[len];
      N[j+1] = N[j];
    }
    N[0] = s[0];
  }
  cout << "No" << "\n";
  return 0;
}

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;

int arr[100010];
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    
    int N; cin >> N;

    REP(i, N) cin >> arr[i];

    ll ans = 0;
    int P = 0;

    for(int i=0; i<N; ++i){
        if(P == 0){
            ans += arr[i]-1;
            P=1; 
        }else if(arr[i] == P+1){
            P++;
        }else if(arr[i] > P+1){
            ans += (arr[i]-1)/(P+1);
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 640
#include<cstdio>
#define MOD 1000000
using namespace std;
int dp[107][6];
int n,m;

int solve(){
  dp[0][0]=1;
  dp[0][1]=1;
  dp[0][2]=1;
  dp[0][3]=1;
  dp[0][4]=0;
  for(int i=1;i<n;i++){
    dp[i][0]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][4])%MOD;
    dp[i][1]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2])%MOD;
    dp[i][2]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][2]+dp[i-1][3])%MOD;
    dp[i][3]=(dp[i-1][0]+dp[i-1][3])%MOD;
    dp[i][4]=(dp[i-1][2]+dp[i-1][4])%MOD;
  }
  int res=0;
  for(int i=0;i<4;i++) res=(res+dp[n-1][i])%MOD;
  printf("%d\n",res);
}

int main(){
  scanf("%d%d",&n,&m);
  int co=1;
  if(m==1){
    for(int i=0;i<n;i++) co=(co*2)%MOD;
    printf("%d\n",co);
  }else{

    solve();
  }

  return 0;

}

Measured memory_bytes: 1028
p = [int(input()) for _ in range(5)]

maxIndex = 0;
v = 10;
for i in range(5):
  div = p[i]%10
  if div != 0 and v > div:
    v = div
    maxIndex = i

ans = 0
for i in range(5):
  if i != maxIndex:
    ans += p[i]
    if ans%10 != 0:
      ans += (10-p[i]%10)
print(ans+p[maxIndex])

Measured memory_bytes: 3064
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MAX = 510000;
const ll MOD = 1000000007;


ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,k;
cin >> n >> k;
ll ans = 0;
ll odd = 0,even = 0;
for(ll i = 1;i <= n; i++) {
    if(k % 2 == 0){
        if(i % k == 0)
            odd++;
        else if ( i % k == k / 2)
            even++;
    }
    else if(k % 2 != 0){
        if(i % k == 0)
            odd++;
    }
}
ans = even * even * even + odd * odd * odd;
cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string s,t;
  cin>>s>>t;
  bool flag = false;
  rep(i,s.size()) {
    char tmp = s[s.size() - 1];
    
    for(int i = s.size() - 2; i >= 0; i--)
    {
      s[i+1] = s[i];
    }
    s[0] = tmp;
    if(s == t) {
      flag = true;
    }
   }
   if(flag) {
     cout << "Yes" << endl;
   } else {
     cout << "No" << endl;
   }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vvi;
typedef vector<vector<double> > vvd;

int main(){

    ll N, H;
    cin >> N >> H;

    vector<ll> vec_a(N);
    vector<ll> vec_b(N);

    while(N--){
        ll a, b;
        cin >> a >> b;
        vec_a[N] = a;
        vec_b[N] = b;
    }

    sort( vec_a.begin(), vec_a.end() );
    ll max_a = vec_a.back();

    sort( vec_b.begin(), vec_b.end(), std::greater<ll>() );
    ll sum_b=0; ll count=0;
    for( auto b : vec_b ){
        if( b > max_a ) { sum_b+=b; count++; }
        if( sum_b >= H ) { cout << count << endl; return 0; }
    }

    H -= sum_b;
    count += H/max_a;
    if( H%max_a > 0 ) count++;

    cout << count << endl;

    return 0;

}

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

const ll INF = 1LL << 60;

ll n;
vector<ll> a;

const int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    cin >> n;
    a.resize(n + 1);
    rep(i, n + 1) cin >> a[i];

    // 1種類の数字だけ重複がある
    combination comb(1e6);

    // 2項ある数を求める
    map<int, int> mp;
    int left = -1, right = -1;
    rep(i, n + 1) {
        if (mp.count(a[i])) {
            left = mp[a[i]];
            right = i;
            break;
        }
        mp[a[i]] = i;
    }
    // cout << left << " " << right << endl;


    for (int i = 1; i <= n + 1; i++) {
        mint ans = comb(n + 1, i);
        if (i == 1) {
            ans -= 1;
        } else if (i != n + 1) {
            // 重複を取り除く
            mint tmp = comb(left + n - right, i - 1);
            ans -= tmp;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 24224