akhauriyash/Code-Regression huggingface dataset:
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

ll n; 

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n;
    if((n % 10 == 1 ) || (n % 10 == 3) || (n % 10  == 7) || (n % 10 == 9)) {
        ll x = 7;
        int ans = 1;
        while(x % n != 0) {
            ans += 1;
            x %= n;
            x *= 10;
            x += 7;
        }
        cout<<ans<<endl;
    } else {
        cout<<"-1\n";
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ss second
#define ff first
#define all(a) a.begin(), a.end()
#define All(a) a.rbegin(), a.rend()
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.precision(10), cout << fixed
//double Time=clock();
int main() {
    ios;
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a + (a - 1), b + (b - 1)});
    //cout <<endl<< clock() - Time << endl;
    return 0;
}

Measured memory_bytes: 3600
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
typedef pair<pii,pii> P;
VV(P) vv;
void foo(int a,int b){
	cout<<vv[a][b].F.F<<" "<<vv[a][b].F.S<<" "<<vv[a][b].S.F<<" "<<vv[a][b].S.S<<endl;
}
void mainmain(){
	int h,w;
	while(cin>>h>>w,h||w){
		initvv(vv,h,w,mkp(mkp(0,0),mkp(0,0)));
		vv[0][0]=mkp(mkp(1,1),mkp(0,0));
		rep(i,h){
			if(!i) continue;
			vv[i][0]=mkp(mkp(1,0),mkp(0,0));
		}
		rep(i,w){
			if(!i) continue;
			vv[0][i]=mkp(mkp(0,1),mkp(0,0));
		}
		reep(i,1,h){
			reep(j,1,w){
				vv[i][j].F.F=vv[i-1][j].F.F+vv[i-1][j].S.F;
				vv[i][j].S.F=vv[i-1][j].F.S;
				vv[i][j].F.S=vv[i][j-1].F.S+vv[i][j-1].S.S;
				vv[i][j].S.S=vv[i][j-1].F.F;
				vv[i][j].F.F%=100000;
				vv[i][j].S.F%=100000;
				vv[i][j].F.S%=100000;
				vv[i][j].S.S%=100000;
			}
		}
		// foo(1,1);
		int t=vv[h-1][w-1].F.F+vv[h-1][w-1].F.S+vv[h-1][w-1].S.F+vv[h-1][w-1].S.S;
		t%=100000;
		cout<<t<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1328
import java.util.Scanner;

class Main{
   public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int i = 1;
       int x;
       while(true){
           x=sc.nextInt();
           if( x == 0){
               break;
           }
           System.out.println("Case "+ (i++) +": "+x);
       }
   }
}


Measured memory_bytes: 41636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//





int main() {
    
    int N; cin >> N;
    vector<int> a(N), b(N), c(N);
    rep(i,N) cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(N, vector<int>(3));
    rep(i,N) {
        rep(j,3) dp[i][j] = 0;
    }
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    for (int d = 1; d < N; ++d) {
        dp[d][0] = a[d] + max(dp[d-1][1], dp[d-1][2]);
        dp[d][1] = b[d] + max(dp[d-1][0], dp[d-1][2]);
        dp[d][2] = c[d] + max(dp[d-1][0], dp[d-1][1]);
    }

    int ans = max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
    out(ans);
    
    return 0;
}






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

int main()
{
  int N,ans=0;
  cin>>N;
  vector<int> num(101);
  for(int i=2;i<=N;i++){
    int tmp=i;
    for(int j=2;j*j<=tmp;j++){
      while(tmp%j==0){
        num[j]++;
        tmp/=j;
      }
    }
    if(tmp!=1)num[tmp]++;
  }

  for(int i=2;i<=100;i++){
    if(num[i]>=74)ans++;
  }

  for(int i=2;i<=100;i++){
    for(int j=2;j<=100;j++){
      if(j!=i && num[i]>=2 && num[j]>=24)ans++;
    }
  }

  for(int i=2;i<=100;i++){
    for(int j=2;j<=100;j++){
      if(j!=i && num[i]>=4 && num[j]>=14)ans++;
    }
  }
  
  for(int i=2;i<=100;i++){
    for(int j=2;j<=100;j++){
      for(int k=2;k<j;k++){
        if(j!=i && i!=k && k!=j && num[i]>=2 && num[j]>=4 && num[k]>=4)ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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

typedef long long ll;
int n;
ll a[401],d[402][402],INIT=1e18;

ll f(int l, int r){
    if(d[l][r]!=INIT)return d[l][r];
    if(l+1==r)return d[l][r]=0;
    if(l+2>=r)return d[l][r]=a[r]-a[l];
    ll v=INIT;
    for(int i=l+1;i<r;i++){
        v=min(v, f(l, i)+f(i, r));
    }
    return d[l][r]=v+a[r]-a[l];
}

int main(void){
    cin>>n;
    a[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i=0;i<=n+1;i++){
        for(int j=0;j<=n+1;j++){
            d[i][j]=INIT;
        }
    }
    ll ans=f(0, n);
    cout<<ans<<endl;
}


Measured memory_bytes: 1536
hash = Hash.new([])
while true do
  line = gets
  break if line == nil
  line.chomp
  word, page = line.split(' ')
  hash[word] += [page.to_i]
end
arr = hash.sort
arr.each do |w|
  puts w[0]
  w[1].sort!
  puts w[1].join(' ')
end

Measured memory_bytes: 6096
require 'prime'

class Integer
  # 素数指数表現
  def prime_decomposition
    result = Hash.new(0)
    primes = Prime.each(Float::INFINITY).lazy
    num = self

    div = 1

    while num / div != 0
      div = primes.next
      count = 0
      while num % div == 0
        num /= div
        count += 1
      end
      result[div] = count unless count.zero?
    end

    result
  end
end

class Array
  def lcm
    numerator = self.inject(:*)

    result = Hash.new(0)
    num = 1

    self.each do |num|
      tmp = num.prime_decomposition

      tmp.each do |key,value|
        result[key] = [result[key],value].max
      end
    end

    result.each do |key,value|
      num *= key**value
    end

    num
  end
end

# require 'pry'


N = gets.chomp.to_i
A = gets.chomp.split(' ').map(&:to_i)


lcm = A.lcm

sum = 0
A.each do |a|
  sum += lcm / a
end


puts ans = lcm.to_f / sum
# binding.pry



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

const ll INF = 1LL << 60;
int K;
int A[100010];
ll lb, ub;

bool check(ll m, int mode) {
  for (int i = 0; i < K; i++) {
    m = (m / A[i]) * A[i];
  }
  if (!mode) return m >= 2;
  else return m <= 2;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> K;
  for (int i = 0; i < K; i++) {
    cin >> A[i];
  }
  ll ok, ng;
  ok = INF; ng = 0;
  while (ok - ng > 1) {
    ll m = (ok + ng) / 2;
    if (check(m, 0)) ok = m;
    else ng = m;
  }
  lb = ok;
  ok = lb, ng = INF;
  while (ng - ok > 1) {
    ll m = (ok + ng) / 2;
    if (check(m, 1)) ok = m;
    else ng = m;
  }
  ub = ok;
  if (lb >= ub) cout << -1 << endl;
  else cout << lb << " " << ub << endl;

  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
int bdn[105]={};
int main(void){
	scanf("%d",&n);
	rep(i,n){
		int a;
		scanf("%d",&a);
		bdn[a]++;
	}
	
	int r=0;
	irep(i,105){
		if(bdn[i]>0){
			r=i;
			break;
		}
	}
	
	bool ok=true;
	if(r==1 && n>=3)ok=false;
	reg(i,(r+1)/2,r){
		int qn=2;
		if(i*2==r)qn=1;
		if(bdn[i]<qn)ok=false;
		else bdn[i]-=qn;
	}
	if(ok){
		for(int i=0;i*2<=r+1;i++){
			if(bdn[i]>0)ok=false;
		}
	}
	printf("%s\n",ok?"Possible":"Impossible");
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll power(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=(res*a);
        a=(a*a);
        b/=2;
    }
    return res;
}
signed main()
{   
      senky_bansal
      IIIT_ALLAHABAD
      
        ll n,k;
        cin>>n>>k;
        if(k==1) cout<<"0";
  else
    cout<<n-k;
      
      

}







Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<long long int, long long int> P;


int main(void) {
	long long int n, W;
	long long int w, v;
	long long int first;
	long long int f[4], e[4];
	long long int count[4] = {};
	long long int maxi = 0;
	long long int point;
	long long int weight;

	cin >> n >> W;
	vector<P>pairs(n);

	FOR(i, 0, n-1) {
		cin >> w >> v;
		if (i == 0) {
			first = w;
		}
		pairs[i].first = w;
		pairs[i].second = v;
	}

	FOR(i, 0, 3) {
		f[i] = e[i] = -1;
	}

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

	
	FOR(i, 0, n - 1) {
		FOR(p, 0, 3) {
			if (f[p] == -1 && pairs[i].first == first + p) {
				f[p] = i;
				if (p != 0) {
					RFOR(q, p - 1, 0) {
						if (f[q] != -1) {
							e[q] = i - 1;
							break;
						}
					}
				}
				break;
			}
		}
		
	}
	FOR(i, 0, 3) {
		if (f[i] != -1 && e[i] == -1) {
			e[i] = n - 1;
			break;
		}
	}


	FOR(i, 0, 3) {
		if (f[i] == -1) {
			count[i] = 0;
		}
		else {
			count[i] = e[i] - f[i] + 1;
		}
	}


	FOR(a, 0, count[0]) {
		FOR(b, 0, count[1]) {
			FOR(c, 0, count[2]) {
				FOR(d, 0, count[3]) {
					point = 0;
					weight = 0;
					RFOR(p, e[0], e[0] - a + 1) {
						point += pairs[p].second;
						weight += pairs[p].first;
					}
					RFOR(p, e[1], e[1] - b + 1) {
						point += pairs[p].second;
						weight += pairs[p].first;
					}
					RFOR(p, e[2], e[2] - c + 1) {
						point += pairs[p].second;
						weight += pairs[p].first;
					}
					RFOR(p, e[3], e[3] - d + 1) {
						point += pairs[p].second;
						weight += pairs[p].first;
					}
					if (weight <= W&&point > maxi) {
						maxi = point;
					}
				}
			}
		}
	}

	cout << maxi << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r,c;
    cin >> r >> c;
    vector<vector <int> > table(r+1, vector<int>(c+1,0));
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> table[i][j];
            table[i][c] += table[i][j];
            table[r][j] += table[i][j];
        }
        table[r][c] += table[i][c];
    }
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            cout << table[i][j];
            if(j != c) cout  << " ";
        }
        cout << endl;
    }
}


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

void trace(vector<int> &a,int N){
  for(int i=0;i<N;i++){
    if(i){
      cout<<" ";
    }
    cout<<a[i];
  }
  cout<<endl;
  
}

int selectionsort(vector<int> &v,int N){
  int cnt=0;
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(v[j]<v[minj]){
        minj=j;
      }
    }
    if(i !=minj){
      swap(v[i],v[minj]);
      cnt++;
    }
  }
  return cnt;
}
int main() {
  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vector<int> x(N);
  vector<int> y(M);
  for(int i=0;i<N;i++){
    cin>>x.at(i);
  }
  for(int i=0;i<M;i++){
    cin>>y.at(i);
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  int maxx=x.at(N-1);
  int miny=y.at(0);
  if(maxx>=miny){
    cout<<"War"<<endl;
  }
  else{
    bool flg=false;
    for(int i=maxx+1;i<miny+1;i++){
      if(i>X &&Y>=i){
        flg=true;
        break;
      }
    }
    if(flg){
      cout<<"No War"<<endl;
    }
    else{
      cout<<"War"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(A.rbegin(),A.rend());
    ll ans = 0;
    ll t = N-1;
    int i = 0;
    while(t > 0){
        if(i == 0){
            ans += A[i];
            t--;
            i++;
            continue;
        }
        rep(j,2){
            ans += A[i];
            t--;
            if(t <= 0) break;
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using LLONG = long long;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0
        || (A + B) % 3 == 0)
    {
        cout << "Possible" << endl;
    }
    else
    {
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t W, H, N;

	scanf("%zu %zu %zu\n", &W, &H, &N);

	bool isWhite[100][100];
	for (size_t i = 0; i < W; i++) {
		for (size_t j = 0; j < H; j++) {
			isWhite[i][j] = true;
		}
	}

	for (size_t i = 0; i < N; i++) {
		size_t x, y, a;
		scanf("%zu %zu %zu", &x, &y, &a);
		if (i < N - 1) {
			scanf("\n");
		}

		if (a == 1) {
			for (size_t i = 0; i < x; i++) {
				for (size_t j = 0; j < H; j++) {
					isWhite[i][j] = false;
				}
			}
		}
		else if (a == 2) {
			for (size_t i = x; i < W; i++) {
				for (size_t j = 0; j < H; j++) {
					isWhite[i][j] = false;
				}
			}
		}
		else if (a == 3) {
			for (size_t i = 0; i < W; i++) {
				for (size_t j = 0; j < y; j++) {
					isWhite[i][j] = false;
				}
			}
		}
		else {
			for (size_t i = 0; i < W; i++) {
				for (size_t j = y; j < H; j++) {
					isWhite[i][j] = false;
				}
			}
		}
	}

	size_t count = 0;

	for (size_t i = 0; i < W; i++) {
		for (size_t j = 0; j < H; j++) {
			if (isWhite[i][j]) {
				count++;
			}
		}
	}

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

	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			String S = sc.next();
			for(int i = S.length() - 2; i >= 0; i-=2){
				if(S.substring(0, i/2).equals(S.substring(i/2, i))){
					System.out.println(i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
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 void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

vector<VI> g;
VI memo;
int dfs(int now) {
    if (memo[now] != -1)return memo[now];
    int ret = 0;
    for (int to : g[now])chmax(ret, dfs(to) + 1);
    return memo[now] = ret;
}

int main() {
    init();

    int n, m; cin >> n >> m;
    g.resize(n), memo.resize(n, -1);
    FOR(i, 0, m) {
        int x, y; cin >> x >> y;
        --x, --y;
        g[x].push_back(y);
    }

    int ans = 0;
    FOR(i, 0, n)chmax(ans, dfs(i));
    cout << ans << "\n";
}


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

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

  vector<int> vec(N);
  for (int i = 0; i < N ;i++){
    cin >> vec.at(i);
  }
  
  vector<int> wari(N);
  
  for(int i = 0; i < N; i++){
    while (vec.at(i) % 2 == 0){
      vec.at(i) = vec.at(i) /2;
      wari.at(i)++;
    }
  }
  
//  for (int i =0; i < N; i++){
//    cout << wari.at(i) <<endl;
//  }
  
  int Min = wari.at(0);
  for( int i = 0; i < N - 1; i++){
    if ( Min > wari.at(i + 1) ){
      Min = wari.at(i + 1 );
    }
  }
  cout << Min << endl;
}

Measured memory_bytes: 256
//To debug :  g++ -g file.cpp -o code
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807;
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000;
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
 
const ll val = 1<<22;
ll dp[val];
bool b[22][22];
 
int main()
{
 
	ll t,n,i,j,siz,s;
 
	
		cin>>n;
 
		rep(i,0,n)
			rep(j,0,n)
				cin>>b[i][j];
 
		siz = 1<<n;
 
 
		dp[0]=1;
 
		rep(i,1,siz)
			dp[i]=0;
 
		for(i=0;i<siz;++i)
		{
 
			 ll s=__builtin_popcount(i);
 
			 for(j=0;j<n;++j)
			 {
			 	if((i&(1<<j))==0 && b[s][j])
			 	{
			 		dp[i|(1<<j)] =(dp[i|(1<<j)] +  dp[i])%mod;
 
			 	}
			 }
		}
 
 
 
		cout<<dp[siz-1]<<"\n";
 
	
 
 
 
 
 
return 0;	
}
 

Measured memory_bytes: 18688
s = int(input())

List = []
List.append(s)

if s==1 or s==2 or s==4:
    print(4)

else:
    for i in range(1000000):
        if List[i]%2 == 0:
            List.append(List[i]/2)
        else:
            List.append(List[i]*3+1)
        if List[i+1] == 4:
            Answer=i+5
            break

    print(Answer)


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


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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int dist[10][10];



int main() {
	int h, w; cin >> h >> w;

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> dist[i][j];
		}
	}

	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}


	LL ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int a; cin >> a;

			if (a != -1) {
				ans += dist[a][1];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n))
  const a = s[0];
  const b = s[1];

  const diff = b - a;
  const bh = [...Array(diff)].map((x, i) => i + 1).reduce((a, b) => a + b);

  const ans = bh - b;
  console.log(ans);

}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> Nums;
  int now = 1;
  int cnt = 0;
  
  for(int i=0;i<N;i++){
    if(S[i]==(char)('0'+now)) cnt++;
    else{
      Nums.push_back(cnt);
      now=1-now;
      cnt=1;
    }
  }
  if(cnt!=0) Nums.push_back(cnt);
  if(Nums.size()%2==0) Nums.push_back(0);
  int Add=2*K+1;
  int ans=0;
  int left=0;
  int right=0;
  int tmp=0;
  for(int i=0;i<Nums.size();i+=2){
    int Nextleft=i;
    int Nextright=min(i+Add,(int)Nums.size());  
    while(Nextleft>left){
        tmp -= Nums[left];
        left++;
    }  
    while(Nextright>right){
        tmp += Nums[right];
        right++;
    }  

    ans=max(ans,tmp);
  }
	cout <<ans<<endl;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    REP(i,N) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = h[N-1];
    REP(i,N-K+1){
        int x = h[i+K-1] - h[i];
        ans = min(ans,x);
    }
    cout << ans << endl;
}

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

int main(){
    int w,h,a,b,r;
    cin>>w>>h>>a>>b>>r;

    if((a+r)>w || (a-r)<0 || (b+r)>h || (b-r)<0 || a<0 || b<0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;
}



Measured memory_bytes: 3116
x, n = map(int, input().split())
if n==0:
  print(x)
else:
  A = list(map(int, input().split()))
  for i in range(100):
    if not x-i in A:
      print(x-i)
      break
    elif not x+i in A:
      print(x+i)
      break


Measured memory_bytes: 9168
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"math/bits"
	"os"
	"strconv"
	"strings"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

func Test(b uint64, n uint) int {
	return int(b >> n & 1)
}
func Set(b *uint64, n uint) {
	(*b) = (*b) | 1<<n
}
func Clear(b *uint64, n uint) {
	(*b) = (*b) & (^(1 << n))
}
func Flip(b *uint64, n uint) {
	(*b) = (*b) ^ 1<<n
}
func All(b *uint64) int {
	if 64 == bits.OnesCount64(*b) {
		return 1
	} else {
		return 0
	}
}
func Any(b *uint64) int {
	if 0 < bits.OnesCount64(*b) {
		return 1
	} else {
		return 0
	}
}
func None(b *uint64) int {
	if 0 == bits.OnesCount64(*b) {
		return 1
	} else {
		return 0
	}
}

func Count(b *uint64) int {
	return bits.OnesCount64(*b)
}

func main() {
	con := NewConsole()
	defer con.Flush()

	var b uint64 = 0
	var q int
	fmt.Scanf("%d", &q)
	lines, _ := ReadLongLines(q)
	for i := range lines {
		args := strings.Split(lines[i], " ")
		command, _ := strconv.Atoi(args[0])
		switch command {
		case 0:
			n, _ := strconv.Atoi(args[1])
			con.Printf("%d\n", Test(b, uint(n)))
		case 1:
			n, _ := strconv.Atoi(args[1])
			Set(&b, uint(n))
		case 2:
			n, _ := strconv.Atoi(args[1])
			Clear(&b, uint(n))
		case 3:
			n, _ := strconv.Atoi(args[1])
			Flip(&b, uint(n))
		case 4:
			con.Printf("%d\n", All(&b))
		case 5:
			con.Printf("%d\n", Any(&b))
		case 6:
			con.Printf("%d\n", None(&b))
		case 7:
			con.Printf("%d\n", Count(&b))
		case 8:
			con.Printf("%d\n", b)
		}
	}

}



Measured memory_bytes: 9188
n=int(input())
a=list(map(int,input().split()))
l=[ int(i) for i in range(10000)]
b=set(a)
for j in b:
  l.remove(j)
cnt=0
for i in range(1,n):
  if a[i-1]==a[i]:
    a[i]=l.pop()
    cnt+=1
print(cnt)

Measured memory_bytes: 3316
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]

t = []
memo = [0 for _ in range(26)]
for i in range(d):
    scores = []
    for j in range(26):
        delta_score = 0
        delta_score += s[i][j]
        for k in range(26):
            if j == k:
                continue
            delta_score -= c[k] * (i+1 - memo[k])
        scores.append((delta_score, j))

    scores.sort(key=lambda x: -x[0])
    choice = scores[0][1]
    t.append(choice+1)
    memo[choice] = i+1

print(*t, sep='\n')

Measured memory_bytes: 9280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
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> 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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s;
  cin >> s;

  int n = s.length(), ans = 0;
  string pre = "";
  rep(i, n) {
    if (s.substr(i, 1) != pre) {
      ans++;
      pre = s.substr(i, 1);
    }
    else {
      if (i == n - 1) break;
      ans++;
      pre = s.substr(i, 2);
      i++;
    }
  }
  cout << ans << '\n';

  




  
  return 0;
}

Measured memory_bytes: 720
using System;

class main
{
    public static void Main()
    {
        bool isEnd = false;
        int caseNum = 1;
        while (isEnd == false)
        {
            string input = Console.ReadLine();
            int x = int.Parse(input);
            if (x != 0)
                Console.WriteLine("Case " + caseNum + ": " + x);
            else
                isEnd = true;
            caseNum++;
        }
    }
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = Integer.parseInt(in.nextLine());
		String s = in.nextLine();
		in.close();
		int red = 0, blue = 0;
		for (int i = 0; i < s.length(); ++i) {
			if (s.charAt(i) == 'R') {
				++red;
			} else {
				++blue;
			}
		}
		if (red > blue) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}

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

int a[4],b[4];
void search()
{
	int hit=0,blow=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			if(a[i] == b[j] && i==j)
				hit++;
			else if(a[i]==b[j])
				blow++;
		}
	}
	cout << hit << ' ' << blow << endl;
}

int main()
{
	int m,n;
	while(cin >> m && cin >> n){
		if(m==0&&n==0)
			break;
		int j=10;
		for(int i=3;i>=0;i--){
			a[i] = m%j;
			b[i] = n%j;
			m/=j;
			n/=j;
		}
		search();
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n;
ll a[111111];
ll r[111111];
const ll MOD = 1000000007;
const int MA=1000001;
bool so[MA];
vector<ll>p;
int table[MA];

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void sosu(){
    rep(i,MA)so[i]=1;
    so[2]=1;

    for(int i=2;i<MA;i++){
        if(so[i]){
            p.pb(i);
            for(int j=i*2;j<MA;j+=i)
                so[j]=0;
        }
    }
}

map<ll,ll>ta;
map<ll,ll>hoget[MA];
int cnt=0;

void soinsu(ll tmp){
    map<ll,ll>hoge=hoget[cnt];

    //hoge.clear();
    if(so[tmp]==0){
    for(int i=0;i<p.size();i++){
        if(tmp<p[i])
            break;
        while(tmp%p[i]==0){
            tmp/=p[i];
            hoge[p[i]]++;
        }
    }
    }

    hoge[tmp]++;

    for(auto itr=hoge.begin();itr!=hoge.end();++itr){
        ll x =(*itr).first,y=(*itr).second;
        ta[x]=max(ta[x],y);
    }
    cnt++;
}

ll gcd(ll a, ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    sosu();
    ll ans = 0;
    rep(i,n){
        soinsu(a[i]);
    }
    ll g =1LL;
    for(int i=0;i<p.size();i++){
        rep(j,ta[p[i]]){
            g*=p[i];
            g%=MOD;
        }
    }
    rep(i,n){
        ans%=MOD;
        ans+=g*modinv(a[i],MOD)%MOD;
        ans%=MOD;
    }

    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 56948
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
ll n, a[6];
string s;
map<char, ll> m;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  m['M'] = 1;
  m['A'] = 2;
  m['R'] = 3;
  m['C'] = 4;
  m['H'] = 5;
  cin >> n;
  FOR(i, 0, n){
    cin >> s;
    a[m[s[0]]]++;
  }
  ll ans = 0;
  FOR(i, 1, 4)FOR(j, i+1, 5)FOR(k, j+1, 6) ans += a[i] * a[j] * a[k];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n; cin >> n;
	char a, b; cin >> a;
	for (int i = 1; i < n; i++) {
		cin >> b;
		a = (a == 'T'&&b == 'F' ? 'F' : 'T');
	}
	cout << a << endl;
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long double x;
	cin >> x;
	long double d = 100;
	int cnt = 0;
	while (d < x) {
		d = d + (0.01 * d);
		d = floor(d);
		cnt++;
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>

int cnt_koisi[50];
	
int cheak_isi(int nin,int hito){
	int h;
	for(h = 0;h < nin;h++){
		if(h != hito){
			if(cnt_koisi[h] > 0)return 0;
		}
	}
	return 1;
}
	
int main(void)
{
	int n,p,i;
	int turn = 0;
	while(1){
		scanf("%d %d",&n,&p);
		if(n == 0 && p == 0)break;
		turn = 0;
		for(i = 0;i < n;i++){
			cnt_koisi[i] = 0;
		}
		while(1){
			if(p > 0){//回ってきたとき
				p--;
				cnt_koisi[turn]++;
				if(p == 0){//一つ取った時
					if(cheak_isi(n,turn)){
						printf("%d\n",turn);
						break;
					}
				}
				
			}else{//お椀の中に入ってなかった時
				p = cnt_koisi[turn];
				cnt_koisi[turn] = 0;
				
			}
		turn++;
		if(turn > n - 1)turn = 0;
		}
		
		
	}
	return 0;
}

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

int main() {
    int N, T, t, s;
    long long ans;
    scanf("%d %d", &N, &T);
    for (int i = 0; i < N; i++) {
        scanf("%d", &t);
        if (i == 0) {
            ans = T;
            s = t;
        }
        ans += min(T, t - s);
        s = t;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int n;
long long C;
struct node{
	long long x,v;
}a[maxn];
long long ans=0;
long long b[maxn];
long long Max(long long x,long long y){
	return x>y?x:y;
}
void chkmax(long long &x,long long y){
	x=x>y?x:y;
}
void solve(){
	b[0]=0;
	long long s=0;
	for(int i=1;i<=n;i++){
		s+=a[i].v;
		b[i]=Max(b[i-1],s-a[i].x*2);
	}
	s=0;
	chkmax(ans,b[n]);
	for(int i=n;i>=1;i--){
		s+=a[i].v;
		chkmax(ans,b[i-1]+s-(C-a[i].x));
	}
}
int main(){
	scanf("%d",&n);
	scanf("%lld",&C);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&a[i].x,&a[i].v);
	solve();
	for(int i=1;i<=n;i++)
		a[i].x=C-a[i].x;
	reverse(a+1,a+n+1);
	solve();
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int start = str.indexOf("A");
        int end = str.lastIndexOf("Z");
        String substr = str.substring(start, end + 1);
        System.out.println(substr.length());
    }
}


Measured memory_bytes: 26532
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

double f(int n) {
    if(n == 1)return 1;
    double ave = (n + 1.0) / n;
    return 1+ave*f(n - 1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, d, x;
    while(cin >> n >> d >> x) {
        double ans = d + (n - 0.5)*x;
        ans *= f(n);
        cout << setprecision(20) << ans << endl;
    }
}

Measured memory_bytes: 6656
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int b,n,cnt=0,*i;

	scanf("%d",&n);

	i=(int *)malloc(sizeof(int)*n);
	
	for(int a=0;a<n;a++)scanf("%d",&i[a]);

	for(int a=0;a<n;a++)
	{
		for(b=0;;b++)
		{
			if((i[a]&1)==0)i[a]/=2;
			else break;
		}
		cnt+=b;
	}

	printf("%d\n",cnt);

	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let line = parse_line::<String>();
    let mut iter = line.split_whitespace();
    (
        iter.next().unwrap().parse().ok().unwrap(),
        iter.next().unwrap().parse().ok().unwrap(),
    )
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

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

fn average(a: u32, b: u32) -> u32 {
    (a + b) >> 1
}

fn main() {
    let (a, b) = parse_pair::<u32, u32>();

    if (a ^ b) & 1 == 1 {
        println("IMPOSSIBLE");
        return;
    }

    println(average(a, b));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define ff first
#define pb push_back
#define ss second
#define debug 0
#define ff first
#define mp make_pair
 
using namespace std;
 
const ll MOD = 1000000007LL;
 


 
ll ar[2000056];
ll br[2000056];
ll cr[2000056];


const long double pi=3.1415926535897;

 
vector<int> primes,pec,vec;

vector<pair<ll,ll> > vp;

set<ll> st;

map<ll,ll> has;
map<char,char> hav,first_occr,used;

 
 
 
ll powr (ll a, ll  b)
{
    if (b == 0)
        return 1;
    long long int x = powr(a, b/2);
    if (b % 2 == 0)
        return (x*x)%MOD;
    else
        return ((x*x)%MOD*a%MOD)%MOD;
}
 
inline ll inv(ll x) {
  return powr(x, MOD - 2);
}
 
inline ll mulMod(ll a, ll b) {
  return (a%MOD * b%MOD) % MOD;
 
}
 
/*inline void process() {
  fact[0] = 1;
  power2[0] = 1;
  for(int i = 1; i < 200003; i++) {
    fact[i] = mulMod(fact[i - 1], i);
    power2[i] = mulMod(power2[i - 1], 2);
  }
  ifact[200002] = inv(fact[200002]);
  for(int i = 200002 - 1; i >= 0; i--) {
    ifact[i] = mulMod(ifact[i + 1], i + 1);
  }
}
 
inline ll ncr(ll n, ll r) {
  if(n < r) return 0;
  return mulMod(fact[n], mulMod(ifact[r], ifact[(n - r)]));
}
 
 
 
void sieve()
{
    memset(prime,true,sizeof(prime));
    prime[0]=prime[1]=false;
    
    for(ll i=2;i*i<=1000006;i++)
    {
        if(prime[i])
        {
            for(ll j=i*2;j<=1000006;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    
    for(int i=2;i<=100005;i++)
    {
    	if(prime[i])
    	primes.pb(i);
	}
}





void LeastPrimeFactor(){
	int tot=1000003;
	least_prime[1]=1;
	for (ll i = 2; i <tot; i += 2)	least_prime[i] = 2;
	for (ll i = 3; i < tot; i += 2){
		if (!visit[i]){
			least_prime[i] = i;
			for (ll j = i; (j*i) < tot; j += 2){
				if (!visit[j*i])
				{
					visit[j*i] = true;
					least_prime[j*i] = i;
				}
			}
		}
	}
}*/




string strng[100005];

 

int main() 
{
//	freopen("input4.in","r",stdin);
//	freopen("output4.out","w",stdout);
    ll m,n,t,p,q,s,c,d,e,f,g,h,res=0,u,v,i,j,l=0,k,len,tot=0,rad,w,pos=0,y,r=0,z,x,maxm=-1,mid;
	ll cycle,val,max1=0,max2=0,num=0,zero,ans=0,min1=INT_MAX,min2=INT_MAX,sum=0;
    bool flag=0;
    ll a,b,minm=INT_MAX;
    ll x1,x2;
    
    string str,ptr="",dstr,dptr;
    
    set<ll>::iterator it;
    
    cin>>n;
    
    p=sqrt(n);
    
    if(p*p==n)
    cout<<n;
    else
    {
    	q=(p)*(p);
    	cout<<q;
	}
    
 
	return 0;
    
}    

Measured memory_bytes: 1024
//abc096_d.cpp
//Sun Jul 29 09:35:41 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 100000000
using namespace std;
using ll=long long;
typedef pair<int,int> P;

bool prime (int x) {
	for (int n=2;n<=sqrt(x);n++){
		if (x%n == 0){
			return false;
		}
	}
	return true;
}

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

	int ans[n];
	int count = 0;
	int num = 11;
	while(count < n){
		if (prime(num)){
			ans[count] = num;
			count++;
		}
		num += 10;
	}

	for (int i=0;i<n-1;i++){
		cout << ans[i] << " ";
	}

	cout << ans[n-1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,d[9],i;
double s;

int main(){
	scanf("%d",&n);
	for(i=0;i<9;i++)d[i]=0;
	while(n--){
		scanf("%lf",&s);
		if(s<165.0)d[1]++;
		else if(s<170.0)d[2]++;
		else if(s<175.0)d[3]++;
		else if(s<180.0)d[4]++;
		else if(s<185.0)d[5]++;
		else d[6]++;
	}
	for(i=1;i<7;i++){
		printf("%d:",i);
		while(d[i]--)printf("*");
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 998244353;

int main() {
	int N, cnt = 0;
	cin >> N;
	for (ll A = 1;A <= 1000000;A++) {
		for (ll B = 1;B <= 1000000;B++) {
			if (A * B >= N)break;
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		
		n = n % k;
		
		long m = (k-n);
		
		System.out.println( Math.min(n, m));
		
	}
		

}


Measured memory_bytes: 21588
s = input()
p = 10 ** 9 + 7
dp = [[0 for _ in range(13)] for j in range(len(s)+1)]
dp[0][0] = 1
for cnt, i in enumerate(reversed(s)):
	if i == "?":
		for f in range(10):
			k = pow(10, cnt, 13)*f%13
			for j in range(13):
				dp[cnt+1][(j+k)%13] = (dp[cnt+1][(j+k)%13] + dp[cnt][j])%p
	else:
		targ = int(i)
		k = pow(10, cnt, 13)*targ%13
		for j in range(13):
			dp[cnt+1][(j+k)%13] = (dp[cnt+1][(j+k)%13] + dp[cnt][j])%p
#print(dp)
print(dp[len(s)][5])

Measured memory_bytes: 96252
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

struct SegmentTree{
private:
  int n;
  vector<ll> node;
public:
  SegmentTree(int sz,ll init=0){
    n=1;
    while(n<sz)n*=2;
    node.resize(2*n-1,init);
  }
  void update(int k,ll x){
    k+=n-1;
    node[k]=x;
    while(k>0){
      k=(k-1)/2;
      node[k]=max(node[2*k+1],node[2*k+2]);
    }
  }

  //[a,b)でのmaxを返す
  ll get(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b)return node[k];
    ll xl=get(a,b,2*k+1,l,(l+r)/2);
    ll xr=get(a,b,2*k+2,(l+r)/2,r);
    return max(xl,xr);
  }   
};

int main(){
  int n;
  cin >> n;
  vector<ll> h(n),a(n);
  rep(i,n){ cin >> h[i]; }
  rep(i,n){ cin >> a[i]; }
  SegmentTree sg(n+5);

  rep(i,n){
    ll ret = sg.get(0,h[i])+a[i];
    sg.update(h[i], ret);
  }
  cout << sg.get(0,n+1) << endl;
  return 0;
}

Measured memory_bytes: 7424