akhauriyash/Code-Regression huggingface dataset:
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
             ll dp[100+1][100000+1];
    int main()
    {   
         IOS;
         int n,m,i,j,k,w;
         cin>>n>>w;
         vector< pair<ll,ll> >v(n+1);
         for(i=1;i<=n;i++)
         	cin>>v[i].F>>v[i].S;
        //  sort(v.begin(),v.end());
         for(i=1;i<=n;i++)
         {
         	for(j=0;j<=w;j++)
         	{
         		if(i==0||j==0)
         			dp[i][j]=0;
         		else
         		{
         			if(v[i].F<=j)
         			{
         				dp[i][j]=max(v[i].S+dp[i-1][j-v[i].F],dp[i-1][j]);
         			}
         			else
         			{
         				dp[i][j]=dp[i-1][j];
         			}
         		}
         	}
         }
         // for(i=0;i<=n;i++)
         // {
         // 	for(j=0;j<=w;j++)
         // 		cout<<dp[i][j]<<" ";
         // 	cout<<endl;
         // }
         cout<<dp[n][w];
  
    }

Measured memory_bytes: 78336
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e18;

using namespace std;

int N;
long long ans = 0;

int main(){
  cin>>N;
  REP(i,0,N){
    int l, r;
    cin>>l>>r;
    ans += r -l + 1;
  }

  cout<<ans<<endl;

  return 0;
}


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

const int N = 100010;
const int moder = 1e9 + 7;

int powermod(int a, int exp){
	int ret = 1;
	for ( ; exp; exp >>= 1){
		if (exp & 1){
			ret = 1ll * ret * a % moder;
		}
		a = 1ll * a * a % moder;
	}
	return ret;
}

int n;
int a[N], cnt[N], fac[N], inv[N];

int comb(int n, int m){
	if (n < m || m < 0){
		return 0;
	}
	return 1ll * fac[n] * inv[m] % moder * inv[n - m] % moder;
}

int main(){
	fac[0] = 1;
	for (int i = 1; i < N; ++ i){
		fac[i] = 1ll * fac[i - 1] * i % moder;
	}
	inv[N - 1] = powermod(fac[N - 1], moder - 2);
	for (int i = N - 1; i; -- i){
		inv[i - 1] = 1ll * inv[i] * i % moder;
	}
	scanf("%d", &n);
	int gap;
	for (int i = 1; i <= n + 1; ++ i){
		scanf("%d", &a[i]);
		if (cnt[a[i]]){
			gap = i - cnt[a[i]];
		}
		cnt[a[i]] = i;
	}
	for (int i = 1; i <= n + 1; ++ i){
		int x = (comb(n - 1, i - 2) + comb(n - 1, i)) % moder;
		x = (x + 2ll * comb(n - 1, i - 1)) % moder;
		x = (x - comb(n - gap, i - 1) + moder) % moder;
		printf("%d\n", x);
	}
	return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (1)
  {
    C -= B;
    if (C <= 0)
    {
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if (A <= 0)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

long long modinv(long long a, long long m=MOD) {
    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;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}




int main(){
    int N,M;
    cin >> N >> M;
    int ans = 0;
    
    ans += max(0,(N*(N-1))/2) + max(0, M*(M-1)/2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<cstdio>

int main(){
    unsigned N, answer = 0;
    scanf("%u", &N);
    unsigned L[N];
    for(int i = 0; i < N; ++i){
        scanf("%u", L + i);
    }
    for (unsigned i = 0; i+2 < N; i++){
        for (unsigned j = i+1; j+1 < N; j++){
            for (unsigned k = j+1; k < N; k++){
                if(L[i] != L[j] && L[k] != L[j] && L[i] != L[k] && L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[k] + L[j] > L[i]) answer++;
            }
        }
    }
    printf("%u\n", answer);
	return 0;
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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


vector<int> Z(string s) {
    vector<int> z(s.size() , 0);
    int l = 0 , r = 0;
    for (int i = 1 ;i < s.size() ;i++) {
        if (i <= r)
            z[i] = min(z[i - l] , r - i + 1);

        while (i + z[i] < s.size() && s[i + z[i]] == s[z[i]])
            z[i]++;

        if (i + z[i] - 1 > r)
            l = i , r = i + z[i] - 1;
    }

    return z;
}


int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    while(SZ(s)){
        vi cur = Z(s);
        loop(i,SZ(cur))ans = max(ans , min(cur[i],i));
        s = s.substr(1);
    }


    cout << ans << endl;


    return 0;
}


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

int main() {
    
    int N;
    cin >> N;
    
    if (N % 2 == 0) {
    cout << N / 2 << endl;
    }
    
    else { cout << N / 2 + 1 << endl;
    }
    
}


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

int main()
{
	int a, b, x;
	cin >> a >> b >> x;

	double da = a;
	double db = b;
	double dx = x;

	if (x == a * a * b) {
		cout << fixed;
		cout << setprecision(10) << 0 << endl;

		return 0;
	}

	if (2 * x == a * a * b) {
		double t = db / da;
		double at = atan(t);
		double pi = 3.141592653589;
		double ret = at * 180 / pi;
		cout << setprecision(10) << ret << endl;

		return 0;
	}
	else if (2 * x > a * a * b) {
//		double t = (da * da * da) / ((2 * dx) - (da * da * db));
		double t = (2 * db / da) - (2 * dx / (da * da * da));
		double at = atan(t);
		double pi = 3.141592653589;
		double ret = at * 180 / pi;

		cout << setprecision(10) << ret << endl;

		return 0;
	}
	else {
		double t = (da * db * db) / (2 * dx) ;
		double at = atan(t);
		double pi = 3.141592653589;
		double ret = at * 180 / pi;

		cout << setprecision(10) << ret << endl;

		return 0;
	}
}

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

using namespace std;
typedef long long ll;
typedef long double ld;


int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(false);

    #ifdef DBG
        freopen("in", "r", stdin);
    #endif
    int n;
    cin>>n;
    vector<int> C(n), S(n), F(n);

    for(int i = 0 ; i < n-1; i++) cin>>C[i]>>S[i]>>F[i];

    for(int i = 0; i < n; i++){
        int t = S[i];



        for(int j = i; j < n-1; j++){
            if(S[j] < t){
                int p = ceil(t/(1.0*F[j]) - S[j]/F[j] + 1);
                t = S[j] + (p-1)*F[j];
            }
            else{
                t = S[j];
            }
            t += C[j];
        }

        cout<<t<<"\n";
    }

    return 0;
}

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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

string in;
vector<vector<pi>> alphabet;

vector<pi> initialize(){
  vector<pi> ret(26);
  REP(26){
    ret[i].first=in.size();
    ret[i].second=-1;
  }
  return ret;
}

int main(){
  cin>>in;
  cerr<<in;
  int cnt=0,full=0;
  vector<pi> workspace=initialize();
  Rev(i,in.size()){
    size_t index=in[i]-'a';
    workspace[index].first=min(workspace[index].first,i);
    workspace[index].second=max(workspace[index].second,i);
    print_pair(workspace[index]);
    cerr<<endl;
    if(workspace[index].second==i){
      cnt++;
      if(cnt>=26){
        cnt=0;
        cerr<<"cnt is full at "<<i<<endl;
        alphabet.push_back(workspace);
        workspace=initialize();
      }
    }
  }
  char tmp;
  For(i,workspace.size()){
    print_pair(workspace[i]);
    if(workspace[i].second==-1){
      tmp='a'+i;
      break;
    }
  }
  string ans="";
  ans+=tmp;
  while(alphabet.empty()!=true){
    workspace=alphabet.back();alphabet.pop_back();
    int t=ans.back()-'a';
    int e=workspace[t].first;
    char b;
    For(i,workspace.size()){
      if(workspace[i].second<=e){
        b='a'+i;
        break;
      }
    }
    ans+=b;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2308
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    int q,a,b;
    cin>>q;
    while(q--){
            cin>>a>>b;
        reverse(&v[a],&v[b]);
    }
    for(int i=0;i<n;i++){
        if(i!=0)cout<<" ";
        cout<<v[i];
    }    cout<<endl;

}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define loop(a,b)            for(ll i=a;i<=b;i++)
#define sci(n)               scanf("%d",&n)
#define scl(n)               scanf("%lld",&n)
#define scd(n)               scanf("%lf",&n)
#define srt(g)               sort(g.begin(),g.end())
#define rvs(g)               reverse(g.begin(),g.end())
#define pl                   pair<long long,long long>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define f first
#define s second
int main()
{
    int n;
    scl(n);
    int a[n+5];
    map<int,int>mp;
    ll ans=0;
    FOR(i,n)
    {
        scl(a[i]);
        mp[i+a[i]]++;
    }
    FOR(i,n)
    {
        ll k=i-a[i];
        if(1<=k && k<n && mp[k]>0)
        {
            ans=ans+mp[k];
        }
    }
    cout << ans << "\n";
}



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

int main() {
  int N;
  string S;
  cin >> N >> S;
  bool can = false;
  if (N%2==0)  {
    string tmp = S.substr(N/2);
    if ((tmp+tmp) == S) can = true;
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

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

int main() {
  int n;
  std::cin >> n;
  long long a[n];
  rep(i, n) std::cin >> a[i];

  std::map<long long, int> d1;
  // std::map<long long, int> d2;

  // rep(i, n) {
  //   long long x = (i + 1) + a[i];
  //   long long y = (i + 1) - a[i];
  //   ++d1[x];
  //   ++d2[y];
  // }
  //
  // long long sum = 0;
  // for (auto x : d1) {
  //   if (d2.find(x.first) != d2.end()) sum += x.second * d2[x.first];
  // }

  // rep(i, n) { sum += d1[(i + 1) - a[i]]; }

  rep(i, n) { d1[i + a[i]]++; }

  long long ans = 0;
  rep(j, n) { ans += d1[j - a[j]]; }

  std::cout << ans << '\n';

  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[int(2e5+5)], ans[int(2e5+5)];
vector <int> res;

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];

  for (int i = N; i >= 1; i--){
    if (ans[i] % 2 == A[i]) continue;
    res.push_back(i);
    for (int j = 1; j * j <= i; j++){
      if (i % j != 0) continue;
      ans[j]++;
      if (j * j != i) ans[i/j]++;
    }
  }

  for (int i = 1; i <= N; i++){
    if (ans[i] % 2 != A[i]){
      cout << -1 << endl;
      return 0;
    }
  }

  int M = res.size();
  cout << M << endl;
  for (int i = 0; i < M; i++){
    cout << res[i];
    if (i < M - 1) cout << " ";
    else cout << endl;
  }

  return 0;
}


Measured memory_bytes: 5268
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, k;
    cin >> n >> k;

    Ld ans = 0;

    vector<Ld> r;
    Int tem = 1, rs = 0;
    while (tem < k) {
        rs++;
        tem = tem << 1;
    }
    r.push_back(1);
    for (Int i = 1; i <= rs; i++) {
        r.push_back(r.back() / 2.0);
    }

    for (Int i = 1; i <= n; i++) {
        Int ii = i, ss = 0;
        while (ii < k) {
            ss++;
            ii = ii << 1;
        }

        ans += r[ss] / (Ld)n;
    }

    if (ans < 0) {
        ans = 0;
    } else if (1 < ans) {
        ans = 1;
    }

    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int minNum, midNum, maxNum;
    minNum = min(min(a, b), min(a, c));
    maxNum = max(max(a, b), max(a, c));
    midNum = a + b + c - minNum - maxNum;

    cout << minNum + midNum << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split
b = gets.chomp.split
n.times do |i|
    a[i] = a[i].to_i
    b[i] = b[i].to_i
end
a[n] = a[n].to_i

monsters = 0
n.times do |i|
    if a[n-i] <= b[n-i-1]
        monsters += a[n-i]
        if a[n-i-1] <= b[n-i-1] - a[n-i]
            monsters += a[n-i-1]
            a[n-i-1] = 0
        else
            monsters += b[n-i-1] - a[n-i]
            a[n-i-1] -= b[n-i-1] - a[n-i]
        end
        a[n-i] = 0
    else
        monsters += b[n-i-1]
        a[n-i] -= b[n-i-1]
    end
end

puts monsters

Measured memory_bytes: 16020
//atcoder clange
#include <stdio.h>
#include <stdlib.h>



int main(void){
  int N;
  scanf("%d", &N);
  long A[N+1];
  long B[N];
  int i = 0;
  for(i=0;i<N+1;i++){
	scanf("%ld", &A[i]);  
  }
    for(i=0;i<N;i++){
		scanf("%ld", &B[i]);
	 }
  int j=0;
  long num = 0;
  long sum = 0;
  
  for(i=0;i<N;i++){
    num = B[i] -A[i];
    if(B[i] >= A[i]){
    	sum = sum + A[i]; 
      	B[i] = B[i] - A[i];
    }else{
      sum = sum + B[i];
      B[i] = 0;
    }
    
    if(num > 0){
     	if(B[i] >= A[i+1]){
    		sum = sum + A[i+1]; 
          	A[i+1] =0;
    	}else{
     	 	sum = sum + B[i];
          	A[i+1] = A[i+1] -B[i];
    	}
    }
  }
           printf("%ld",sum);  

    
  
  
    return 0;
}

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


using namespace std;
 
int main(){

  string divide[4] = {"dream","dreamer","erase","eraser"};
  string s;

 cin >> s;

 reverse(s.begin(),s.end());
 for(int i = 0; i < 4; i++) reverse(divide[i].begin(),divide[i].end());

 bool can = true;

 for(int i = 0; i < s.size();){
   bool can2 = false;
   for(int j = 0; j < 4; j++){
     string d = divide[j];
     if(s.substr(i,d.size()) == d){
       can2 = true;
       i += d.size();
     }
   }

   if(!can2){
     can = false;
     break;
   }
 }

if(can) cout << "YES" << endl;
else cout << "NO" << endl;
 
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

int n, s1, s2, mn = 1e9, w[N];

int abs(int p) {return p > 0 ? p : -p;}

int main()
{
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", &w[i]);
		s2 += w[i];
	}
	for (i = 0; i < n; i++) {
		s1 += w[i], s2 -= w[i];
		mn = min(mn, abs(s1 - s2));
	}
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    long n = scanner.nextInt();
    System.out.println(fact(n));
  }

  private static long fact (long n) {
    if (n == 1) {
      return 1;
    }
    return n * fact (n - 1);
  }
}

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

int main()
{
    // 入力
    int n, k;
    cin >> n >> k;
    vector<int> w(n);
    for(int i = 0; i < n; i++) cin >> w[i];
    int sumw = 0;
    for(int i = 0; i < n; i++) sumw += w[i];

    // 二分探索
    int ans = 0;
    int left = 0;
    int right = sumw+1;
    while(left < right)
    {
        // 中央の値
        int mid = (left + right) / 2;

        // シミュレート
        int idx = 0;
        int sum = 0;
        int cntk = 1;
        bool flag = false;
        while(true)
        {
            if(sum+w[idx] > mid)
            {
                sum = 0;
                cntk++;
            }
            else
            {
                sum += w[idx];
                idx++;
            }

            // トラックの上限k台を越えたらアウト
            if(cntk > k)
            {
                flag = false;
                break;
            }

            // n個の荷物を全て乗せられたらOK
            if(idx >= n)
            {
                flag = true;
                break;
            }
        }

        // 範囲を更新
        if(flag == true)
        {
            right = mid;
            ans = mid;
        }
        else if(flag == false)
        {
            left = mid + 1;
        }

        //cout << "---" << endl;
        //cout << "left:" << left << endl;
        //cout << "right:" << right << endl;
    }

    // 解を出力
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3468
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  hour := n / 3600
  remain_hour := n % 3600
  minute := remain_hour / 60
  second := remain_hour % 60
  fmt.Println(strconv.Itoa(hour) + ":" + strconv.Itoa(minute) + ":" + strconv.Itoa(second))
}


func nextInt() (int) {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 1096
number = int(input())
list = []
count = 0
num = 0

for i in range(number):
  x, y = input().split()
  list.append(x)
  list.append(y)
 

for num in range(0,len(list)-1,2):
  if list[num] == list[num+1]:
    count += 1
    if count == 3:
      break
  else:
    count = 0 

if count < 3:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 9168
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

vector<double> a;
void input(){
    scan_vector(5,a);
}
void src(){
    double sum=0;double min=0.0;
    rep(i,5){
        sum += ceil(a[i]/10)*10;
        chmax(min,ceil(a[i]/10)*10-a[i]);
    }
    cout<<(int)(sum-min);
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
N,C,K=map(int, input().split())
T=[]
for i in range(N):
    t=int(input())
    T.append(t)

T=sorted(T)
ans=0
mint=T[0]
now=1
for i in range(1,N):
    t=T[i]
    if now==C:
        ans+=1
        now=1
        mint=t
    elif t-mint<=K:
        now+=1
    else:
        ans+=1
        now=1
        mint=t
    if i==N-1:
        ans+=1
print(ans)

Measured memory_bytes: 8280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
unordered_map<int,list<int> > um;
int mod=1000000007;
void solve()
{
    int r,c;
    cin>>r>>c;
    char a[r][c];
    for(int i=0; i<r; i++){
        cin>>a[i];
    }
    int dp[r][c];
    memset(dp,0,sizeof(dp));
    dp[r-1][c-1]=1;
    for(int i=r-1; i>=0; i--){
        for(int j=c-1; j>=0; j--){
            if(a[i][j]=='#'){
                continue;
            }
            if(i+1<r && a[i][j]!='#'){
                dp[i][j]+=dp[i+1][j];
                dp[i][j]=dp[i][j]%(mod);
            }
            if(j+1<c && a[i][j]!='#'){
                dp[i][j]+=dp[i][j+1];
                dp[i][j]=dp[i][j]%(mod);
            }
        }
    }
    cout<<dp[0][0];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 8528
using Training20200609.Questions;
using Training20200609.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Training20200609.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/agc007/tasks/agc007_b
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var p = inputStream.ReadIntArray().Select(i => i - 1).ToArray();

            var enumrator = Enumerable.Range(0, n).Select(i => i * 40000);
            var a = enumrator.ToArray();
            var b = enumrator.Reverse().ToArray();

            for (int i = 0; i < n; i++)
            {
                a[p[i]] += i + 1;
                b[p[i]] += i + 1;
            }

            yield return string.Join(" ", a);
            yield return string.Join(" ", b);
        }
    }
}


namespace Training20200609
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Training20200609.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Training20200609.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 20704
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int part(vector<int> &A,int p){
    int r = A.size()-1;
    int x = A[r];
    int i = p-1;
    for(int j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

int main(){
    int N;cin>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    int idx = part(A,0);
    rep(i,N){
        if(i!=idx) cout << A[i];
        else cout << "[" << A[i] << "]";

        if(i<N-1) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 5 && b == 5 && c == 7){ cout << "YES" << endl; }
	else if (a == 5 && b == 7 && c == 5){ cout << "YES" << endl; }
	else if (a == 7 && b == 5 && c == 5){ cout << "YES" << endl; }
	else{ cout << "NO" << endl; }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#include <time.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <deque>
#include <iomanip>
#include <complex>
//#include <ext/rope>

using namespace std;
//using namespace __gnu_cxx;

//defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define fast_read cin.sync_with_stdio(0)
#define PREX(number) cout << fixed << setprecision(number)
#define nul point(0, 0)
#define random srand(time(NULL))
#define rand_int abs((rand() << 15) | rand())
#define str_to_int(stroka) atoi(stroka.c_str())
#define str_to_ll(stroka) atoll(stroka.c_str())
#define str_to_double(stroka) atof(stroka.c_str())
#define what_is(x) cerr << #x << " is " << x << endl
#define solve_system int number; cin >> number; for (int i = 0; i < number; i++) solve()
#define solve_system_scanf int number; scanf("%d", &number); forn(i, 0, number) solve()

//easy functions
template< typename T >
T gcd(T a, T b) { return a ? gcd(b % a, a) : b; }
template< typename T >
T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }

//constants
const ld pi = 3.141592653589793238462643383279;
const ld log23 = 1.58496250072115618145373894394781;
const ld eps = 1e-8;
const ld zero = 0;
const ll INF = 1e18;
const int COUT = 30;
const int prost = 239;
const ll prost64 = 239;
const int two = 2;
const int thr = 3;
const ll sr = 31;
const ll MOD = 1e9 + 7;
const int BIG = 2 * 1e9 + 1;
const int alf = 26;
const int MAX_N = 1000 + 1;
const int MAX_M = 2001;
const int MAX_T = (1 << 20);
const int BLOCK = trunc(sqrt(MAX_N)) + 1;
const int MAX_LOG = 19;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int bt = 31;

// Code starts here

int n, a[two][MAX_N];

int main()
{   /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /**/
    fast_read;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[0][i];
    for (int i = 0; i < n; i++)
        cin >> a[1][i];
    for (int i = 1; i < n; i++)
        a[0][i] += a[0][i - 1];
    for (int i = n - 2; i >= 0; i--)
        a[1][i] += a[1][i + 1];
    int ans = 0;
    for (int i = 0; i < n; i++)
        ans = max(ans, a[0][i] + a[1][i]);
    cout << ans;
    return 0;
}


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

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

    

    map<map<char, long long>, long long> T;

    
    for(long long i = 0; i < n; i++){
        string s;
        cin >> s;
        map<char, long long> D;

        for(long long j = 0; j < s.size(); j++){
            if(D.find(s[j]) == D.end()){
                D[s[j]] = 1;
            }
            else{
                D[s[j]]++;
            }
        }

        if(T.find(D) == T.end()){
            T[D] = 1;
        }
        else{
            T[D]++; 
        }
    }

    long long count = 0;

    map<map<char, long long>, long long >::iterator it;

    for(it = T.begin(); it != T.end(); it++){
        if(it->second >= 2){
            count += it->second*(it->second-1)/2;
        }
    }

    cout << count << endl;

    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int A[101010],B[101010];
vector<pair<int,int>> E[101010];
int did[101010];

int dfs(int cur,int tar) {
	if(cur==tar) return 1;
	
	FORR(r,E[cur]) if(did[r.second]==0) {
		did[r.second]=1;
		return dfs(r.first,tar);
	}
	return 0;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
		
		E[A[i]].push_back({B[i],i});
		E[B[i]].push_back({A[i],i});
	}
	
	FOR(i,M) if(did[i]==0) {
		did[i]=1;
		if(dfs(A[i],B[i])==0) return _P("NO\n");
	}
	_P("YES\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main() {
	int a, b, c, num = 0, i;
	scanf("%d%d%d", &a, &b, &c);
	for (i = a; i <= b; i++)
	{
		if (i % c == 0)
		{
			num++;
		}
	}
	printf("%d", num);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int H, N;
    cin >> H >> N;
    int A;
    for(int i=0; i<N; i++){
        cin >> A;
        H-=A;
    }
    if(H>0) cout << "No" << endl;
    else cout << "Yes" << endl;
    
}

Measured memory_bytes: 256
import heapq as hq

N,M=map(int,input().split())
A=list(map(int,input().split()))

p=[]
for i in range(N):
  hq.heappush(p,-A[i])
#print(p)

for i in range(M):
  tmp=-hq.heappop(p)//2
  hq.heappush(p,-tmp)
#print(p)
p=list(map(lambda x:-x, p))
print(sum(p))

Measured memory_bytes: 14992
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


//INSERT ABOVE HERE
signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> as(n);
  for(int i=0;i<n;i++) cin>>as[i];

  vector< set<int> > L(10);
  for(int i=0;i<n;i++) L[as[i]].emplace(i);
  for(int d=0;d<10;d++) L[d].emplace(n);

  int len=n-k,pos=-1;
  while(len){
    for(int d=9;d>0;d--){
      if(*L[d].rbegin()<=pos) continue;
      int nxt=*L[d].upper_bound(pos);
      if(n-nxt>=len){
        cout<<d;
        pos=nxt;
        break;
      }
    }
    len--;
  }

  cout<<endl;
  return 0;
}



Measured memory_bytes: 12860
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> ps(N);
  int minDiff = 1000000;
  int minIndex = 0;
  if (N == 0) {
    cout << X << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> ps.at(i);
    int absDiff = abs(X - ps.at(i));
    if (minDiff > absDiff) {
      minDiff = absDiff;
      minIndex = i;
    }
  }
  int val = ps.at(minIndex);
  int cnt = 1;
  bool isLoop = true;
  int ans;
  while (isLoop) {
    auto a = find(ps.begin(), ps.end(), val + cnt);
    auto b = find(ps.begin(), ps.end(), val - cnt);
    if (a == ps.end()) {
      ans = val + cnt;
      isLoop = false;
    }
    if (b == ps.end()) {
      ans = val - cnt;
      isLoop = false;
    }
    cnt++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
using System;

namespace AtCoder.ABC096
{
    class d
    {
        static int[] list = { 3, 13,23,43 ,53 ,73 ,83 ,103 ,113 , 163
                ,173 , 193 ,223 ,233 ,263 ,283 ,293 ,313 ,353,373
                ,383 ,433 ,443,463 ,503 ,523 ,563 ,593 ,613 ,643
                ,653 ,673 ,683 ,733 ,773 ,823 ,863 ,883 ,953 ,983
                ,1013 ,1033 ,1093 ,1103 ,1123 ,1153 ,1163 ,1193 ,1213 ,1223
                ,1283 ,1303 ,1373 ,1423 ,1433};
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var N = int.Parse(line);
            for (var i = 0; i < N - 1; ++i)
            {
                Console.Write(list[i] + " ");
            }
            Console.WriteLine(list[N - 1]);
        }
    }
}


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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double pi = acos(-1);
  double res;
  if (a*a*b - x < x) {
    double space = a*a*b - x;
    double l = (2*space) / (a*a);
    double rad = atan(l/a);
    res = (rad/pi)*180.0;
  }
  else {
    double space = x;
    double l = (2*space) / (a*b);
    double rad = atan(b/l);
    res = (rad/pi)*180.0;
  }
  cout << fixed << setprecision(10);
  cout << res << endl;
}


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

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int main() {

	int K, S, count = 0;
	
	cin >> K >> S;

	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {

			if (0 <= S - x - y&&S - x - y <= K)count++;

		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i=0;i<n;i++)
    scanf("%d",&a[i]);
    int maxi=a[0];
    ll sum1=0LL;
    for (int i=1;i<n;i++)
    {
        maxi=max(maxi,a[i]);
        sum1=sum1+1LL*abs(maxi-a[i]);
    }
    printf("%lld\n",sum1);
    return 0;
}

Measured memory_bytes: 4592
#include<cstdio>
#include<algorithm>
using namespace std;
int h,w;
char s[405][405];
bool v[405][405];
long long a,b;
long long ans;
void dfs(int x,int y){
	v[x][y]=1;
	if(s[x][y]=='#')a++;
	else b++;
	if(x>1&&v[x-1][y]==0&&s[x-1][y]!=s[x][y])dfs(x-1,y);
	if(x<h&&v[x+1][y]==0&&s[x+1][y]!=s[x][y])dfs(x+1,y);
	if(y>1&&v[x][y-1]==0&&s[x][y-1]!=s[x][y])dfs(x,y-1);
	if(y<w&&v[x][y+1]==0&&s[x][y+1]!=s[x][y])dfs(x,y+1);
}
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	scanf("%s",s[i]+1);
	for(int i=1;i<=h;i++)
	for(int j=1;j<=w;j++)
	if(v[i][j]==0){
		a=b=0;
		dfs(i,j);
		ans+=a*b;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 12928
#include <stdio.h>

 int main (void) {
 int i;
 int n;
 int a[100];
   
 scanf("%d", &n);
 for (i = 0; i < n; i++) {
 scanf("%d", &a[i]);
 }

 for (i = 0; i < n; i++) {
 if (a[i] % 2 == 0 && a[i] % 3 != 0 && a[i] % 5 != 0) {
 puts("DENIED");
 return 0;
 }
 }
 puts("APPROVED");

 return 0;
 }


Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main (void){
        int A,B,C,D,ans=0;
        scanf("%d",&A);
        scanf("%d",&B);
        scanf("%d",&C);
        scanf("%d",&D);
        if (A>=B) {
                ans+=B;
        }else{
                ans+=A;
        }
        if (C>=D) {
                ans+=D;
        }else{
                ans+=C;
        }
        printf("%d\n",ans );
        return 0;

}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    ll mx = -1e9 - 150;
    // watch(mx);
    int n, k; cin>>n>>k;
    vector<ll> v(n+5), c(n+5);
    REP(i, 1, n)
    {
        int x; cin>>x;
        v[i] = x;
    }
    REP(i, 1, n)
    {
        int x; cin>>x;
        c[i] = x;
    }
    REP(i, 1, n)
    {
        vi test;
        int length = 0;
        int currind = v[i];
        ll score = c[currind];
        test.pb(c[currind]);
        length++;
        while(currind != i)
        {
            currind = v[currind];
            test.pb(c[currind]);
            score += c[currind];
            length++;
        }
        // if(i == 2) {watch(length); watch(score); }
        ll sm = 0;
        ll localmx = test[0];
        REP(j, 0, min(length,k)-1)
        {
            sm += test[j];
            localmx = max(localmx, sm);
        }
        mx = max(mx, localmx);
        if(length < k)
        {
            ll initsm = 1LL*score*(k/length);
            int left = k % length;
            ll localmx = test[0];
            ll localsm = 0;
            REP(j, 0, left-1)
            {
                localsm += test[j];
                localmx = max(localmx, localsm);
            }
            if(left == 0) localmx = 0;
            mx = max(mx, initsm+localmx);
            
            initsm = 1LL*score*(k/length - 1);
            left = length;
            localmx = test[0];
            localsm = 0;
            REP(j, 0, left-1)
            {
                localsm += test[j];
                localmx = max(localmx, localsm);
            }
            mx = max(mx, initsm + localmx);
            
            
            
        }
        
    }
    cout<<mx;
    
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t
RE: double dec, integer overflow(ll or 1LL mult)
*/





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

int main() {
	int A, B, C, D;
	int P;
	int X, Y;
	int water;
	scanf("%d%d%d%d%d", &A, &B, &C, &D, &P);
	X = A * P;
	if(P <= C){
		Y = B;
	}else{
		Y = B + D * (P - C);
	}
	water = min(X,Y);
	printf("%d\n", water);
	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H+2, vector<char>(W+2));
  for (int i=0; i<H ; i++){
    for (int j=0; j<W ; j++){
      cin >> S[i+1][j+1];
    }
  }
  for (int i=0; i<H ; i++){
    int i2=i+1;
    for (int j=0; j<W ; j++){
      int j2=j+1;
      int B=0;
      if (S[i2][j2]=='.'){
        if(S[i2-1][j2-1]=='#') B++;
        if(S[i2-1][j2]  =='#') B++;
        if(S[i2-1][j2+1]=='#') B++;
        if(S[i2]  [j2-1]=='#') B++;
        if(S[i2]  [j2+1]=='#') B++;
        if(S[i2+1][j2-1]=='#') B++;
        if(S[i2+1][j2]  =='#') B++;
        if(S[i2+1][j2+1]=='#') B++;
        cout << B;
      }else{
        cout << S[i2][j2];
      }
    }
    cout << endl;
  }
 
  return 0;
}


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

#define         ll      long long int

int main( )
{
    ll d, n, a, p;
    cin >> d >> n;
    if (d == 0)
    {
        if (n == 100)   cout << "101\n" << "\n";
        else            cout << n << "\n";
        return 0;
    }
    else if (d == 1)
    {
        if (n == 100)   cout << "10100\n";
        else            cout << 100 + (n - 1) * 100 << "\n";
        return 0;
    }
    else
    {
        if (n == 100)   cout << "1010000\n";
        else            cout << 10000 + (n - 1) * 10000 << "\n";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, k, i;
	double s[200000] = { 0 }, ans, j;
	scanf("%d %d", &n, &k);
	scanf("%lf", &j);
	j = (j + 1) / 2;
	s[0] = j;
	for (i = 1; i < n; i++) {
		scanf("%lf", &j);
		j = (j + 1) / 2;
		s[i] = j + s[i-1];
	}

	ans = s[k-1];
	for (i = 1; i <= n - k; i++) {
		if (ans < s[i + k - 1] - s[i - 1])ans = s[i + k - 1] - s[i - 1];
	}
	printf("%.10lf", ans);
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };


ll dp[50][2];

void chmax(ll &a, ll b) {
	if (a == -1)a = b;
	else if (a < b)a = b;
}


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

	memset(dp,-1,sizeof(dp));
	dp[0][0] = 0;
	rep(dgt, 0, 45)rep(isless, 0, 2) {
		if (dp[dgt][isless] == -1)continue;

		ll s = 1LL << 44 - dgt;
		ll sc0 = 0;
		ll sc1 = 0;

		rep(i, 0, n) {
			if (a[i] & s)sc0 += s;
			else sc1 += s;
		}

		if (!isless) {
			if (k & s) {
				chmax(dp[dgt+1][0],dp[dgt][isless]+sc1);
				chmax(dp[dgt+1][1],dp[dgt][isless]+sc0);
			}
			else {
				chmax(dp[dgt + 1][0],dp[dgt][isless]+sc0);
			}
		}
		else {
			chmax(dp[dgt+1][1],dp[dgt][isless] + max(sc0,sc1));
		}
	}
	
	cout << max(dp[45][0], dp[45][1]) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int n,q,count=0;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cin>>q;
    for(int i=0;i<q;i++){
        int key;
        cin>>key;
        int left=0;
        int right=n;
        while(left<right){
            int mid=(left+right)/2;
            if(a[mid]==key){
                count++;
                break;
            }else if(key<a[mid]){
                right=mid;
            }else if(key>a[mid]){
                left=mid+1;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 3476