akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
vector<int>arr(0);
int main(void)
{
	arr.push_back(2);
	arr.push_back(3);
	int N;
	cin >> N;
	int counttt = 0;
	for (int i = 3; i < 55555 && counttt<=55; i++)
	{
		if (i % 3 != 0 && i % 2 != 0)
		{
			for (int j = 0; j < arr.size(); j++)
			{
				if (i % arr[j] == 0)
				{
					break;
				}
				if (arr[j] * arr[j] > i)
				{
					arr.push_back(i);
					if (i%5==1)
					{
						counttt++;
					}
					break;
				}
				if (j == arr.size() - 1)
				{
					arr.push_back(i);
					if (i % 5 == 1)
					{
						counttt++;
					}
				}
			}
		}
	}
	int count = 0;
	for (int i = 0; i < arr.size(); i++)
	{
		if (arr[i] % 5 == 1)
		{
			count++;
			if (count == N)
			{
				cout << arr[i] << "\n";
				break;
			}
			cout << arr[i] << " ";
		}
	}
}



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

int main() {
  int N;
  cin >> N;
  int t[N];
  rep(i,N) cin >> t[i];
  int v[N];
  rep(i,N) cin >> v[i];
  
  int speed[N+1];  // speed when max_v switch
  speed[0] = speed[N] = 0;
  
  rep(i,N-1) {  // acceleration
    speed[i+1] = min(speed[i] + t[i], min(v[i], v[i+1]));  // accelerate for t[i] or max_v
  }
 
  rep(i,N-1) {  // deceleration
    speed[N-1-i] = min(speed[N-i] + t[N-1-i], speed[N-1-i]);
  }
 
  double max_v;
  double sum = 0;
 
  rep(i,N) {
    if (speed[i] == v[i] || speed[i+1] == v[i]) {
      max_v = v[i];
    }
    else if (abs(speed[i]-speed[i+1]) == t[i]) {
      max_v = max(speed[i], speed[i+1]);
    }
    else if ((v[i]-speed[i]) + (v[i]-speed[i+1]) <= t[i]) {
      max_v = v[i];
    }
    else {
      max_v = ((double)t[i] + speed[i] + speed[i+1]) / 2;
    }

    sum += max_v * t[i] - pow(max_v - speed[i], 2) / 2 - pow(max_v - speed[i+1], 2) / 2;
  }
 
  printf("%.5f\n", sum);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(int argc, char *argv[])
{
  string s;
  cin >> s;

  for (int i = 0; i < s.size()-1; i++) {
    if(s[i]=='A'&&s[i+1]=='C') {puts("Yes");return 0;}
  }

  puts("No");
  return 0;
}


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

int main(){
    int N,Y;
    int res_a = -1, res_b = -1, res_c = -1;
    
    cin >> N >> Y;
    
    for (int a = 0; a <= N; a ++){
        for (int b = 0; b + a <= N; b ++){
            int c = N - a - b;
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y){
                res_a = a;
                res_b = b;
                res_c = c;
            }
        }
    }
    cout << res_a << " " << res_b << " " << res_c << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int t;
  sd(t);
  int ac=0,wa=0,tle=0,re=0;
  rep(tt,t){
    string s;
    cin>>s;
    if(s[0]=='A') ac++;
    else if(s[0]=='W') wa++;
    else if(s[0]=='T') tle++;
    else re++;
  }
  cout<<"AC x "<<ac<<"\n";
  cout<<"WA x "<<wa<<"\n";
  cout<<"TLE x "<<tle<<"\n";
  cout<<"RE x "<<re<<"\n";
  return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long a, b, k;
    scanf("%ld %ld %ld", &a, &b, &k);

    set<long> x;
    long i;
    for(i=0; i<k; i++) {
        if(a+i<=b) x.insert(a+i);
        if(b-i>=a) x.insert(b-i);
    }
    auto it = x.begin();
    for(; it!=x.end(); ++it) {
        printf("%ld\n", (*it));
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
typedef long long ll;
#define lim 1000000000000000001
 
 
ll root(ll x,vector<ll>&v)
{
    while(v[x]!=x)
    {
        v[x]=v[v[x]];
        x=v[x];
    }
    return x;
}
 
int main()
{
     fast;
     ll n;
     cin>>n;
     vector<ll>v(n);
     for(auto &x:v)cin>>x;
     vector<ll>ans(n);
     ans[0]=0LL;
     ans[1]=abs(v[1]-v[0]);
     for(int i=2;i<n;i++)
        ans[i]=min((ans[i-1]+abs(v[i-1]-v[i])),(ans[i-2]+abs(v[i-2]-v[i])));
    cout<<ans[n-1];
 
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>

using namespace std;

string zero_padding(string s){
    int l = s.size();
    for (int i = 0; i < 6 - l; i++)
        s = "0" + s;
    return s;
}

int main() {

    int n, m;
    cin >> n; cin>> m;
    vector<int> p(m);
    vector<long> y(m);
    vector<int> prefecture(n);
    for (int i = 0; i < n; i++)
        prefecture[n] = 0;
    vector<string> res(m);

    for (int i = 0; i < m; i++){
        cin >> p[i];
        cin >> y[i];
        res[i] = zero_padding(to_string(p[i]));
    }

    vector<size_t> indices(y.size());
    iota(indices.begin(), indices.end(), 0);
    sort(indices.begin(), indices.end(), 
        [&y](size_t i1, size_t i2) { return y[i1] < y[i2]; });
    
    int tmp_i;
    int* tmp_ptr;
    for (int i = 0; i < m; i++){
        tmp_i = indices[i];
        tmp_ptr = &prefecture[p[tmp_i]];
        *tmp_ptr += 1;
        res[tmp_i] += zero_padding(to_string(*tmp_ptr));
    }

    for (int i = 0; i < m; i++){
        cout << res[i] << "\n";
    }  
}

Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;

int numOfDigit(long n) {

    int c = 0;

    while (n != 0) {
        n /= 10;
        c += 1;
    }

    return c;

}

int F(long a, long b) {
    return max(numOfDigit(a), numOfDigit(b));
}

int main() {

    long N;

    cin >> N;

    int result = 11;

    for (long i = 1; i <= sqrt(N); i++) {

        if (N % i == 0) {

            result = min(result, F(N / i, i));

        }
    }

    cout << result << "\n";

    return 0;

}

Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main()
{
	int a,b,n;
	while(cin >> a >> b >> n)
	{
		int ans = 0;
		a %= b;

		rep(i,n)
		{
			a *= 10;
			ans += (a/b);
			a %= b;
		}

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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long 
#define pb push_back
#define fo(i,N) for(int i = 0 ; i < N ; i++)
#define foo(i,x,N) for (int i = x; i < N ; i++)
#define fill(a,val) memset(a,val,sizeof(a))
#define fastio()  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define MAX 1234567
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define inf 1e14+1
#define all(a) a.begin(),a.end()
int n;
string s;
ll dp[3001][3001];

void solve()
{ 
  fill(dp,0);
  dp[n][0] = (s[n-2] == '>') ? 1 : 0;
  dp[n][1] = 1-dp[n][0];

  for(int i = n-1; i >= 2; i--)
  {
    int total = n-i+1;
    for(int j = 0 ; j <= total; j++)
    {
      if ( j == 0)
      {
         if ( s[i-2] == '<')
          continue;

        for(int k = 0; k<= total-1;k++)
        {
          dp[i][j] = (dp[i][j]+dp[i+1][k])%M;
        }
      }
      else
      {
        if ( s[i-2] == '<')
        {
          dp[i][j] = (dp[i][j-1] + dp[i+1][j-1])%M;
        }
        else
          dp[i][j] = (M+dp[i][j-1] - dp[i+1][j-1])%M;
      }
    }
  }
}


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

  ll ans = 0;
  solve();
  fo(i,n)
  {
    ans = (ans+dp[2][i])%M;
  }
  cout << ans << endl;

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n, k;
    cin >> n >> k;
    cout << (k * 2 - 1 <= n ? "YES" : "NO") << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int sum = 0;
        for (int i = 0; i < s.length(); i++) {
            sum += Integer.parseInt(String.valueOf(s.charAt(i)));
        }
        if (sum % 9 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 49748
#include<bits/stdc++.h>
using namespace std;
bool isPal(string s)
{
    int l=0;
    int h=s.length()-1;
    while (h > l) 
    { 
        if (s[l++] != s[h--]) 
        { 
                return false; 
        } 
    } 
    return true; 
}
int main()
{
    int l;
    string s;
    cin>>s;
    l=s.length();
    string t1="";
    string t2="";
    bool t=isPal(s);
    for(int i=0;i<(s.length()-1)/2;i++)
    {
        t1+=s[i];
    }
    for(int i=((s.length()+3)/2)-1;i<s.length();i++)
    {
        t2+=s[i];
    }
   
    bool e=isPal(t1);
    bool f=isPal(t2);
    
    if(e && f && t)
    cout<<"Yes";
    else
    cout<<"No";

}

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

int main(){
	ll a,b,k;
	cin>>a>>b>>k;
	if(a>=k)cout<<a-k<<' '<<b;
	else cout<<0<<' '<<max(0ll,b-(k-a));
	
	return 0;
}


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

int main() {
	string S;
	cin >> S;
	int ans = 0;
	int leng = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') leng++;
		else leng = 0;
		if (leng > ans)ans = leng;
	}
	cout << ans << endl;
	return 0;
}

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

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

  vector<int> A(N);
  for (auto i = 0; i < N; ++i) {
    cin >> A.at(i);
  }

  // 行き先
  vector<int> route;
  // 順番
  vector<int> order(N + 1, -1);
  int period = 1;
  int initial = 0;
  int tmp = 1;
  // まだ来ていないのならループ
  while (order.at(tmp) == -1) {
    order.at(tmp) = route.size();
    route.push_back(tmp);
    tmp = A.at(tmp - 1);
  }
  period = route.size() - order.at(tmp);
  initial = order.at(tmp);

  if (K < initial)
    cout << route.at(K) << endl;
  else
    cout << route.at(initial + (K - initial) % period) << endl;
}

Measured memory_bytes: 5824
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

ll x[100010],y[100010];

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

	rep(i,n) cin>>x[i];
	rep(i,m) cin>>y[i];

	ll X=0,Y=0;

	rep(i,n) {
		X += x[i]*(2*i-n+1);
		X%=MOD;
	}

	rep(i,m) {
		Y += y[i]*(2*i-m+1);
		Y%=MOD;
	}

	cout<< X*Y%MOD <<endl;

	return 0;
}

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

using namespace std;

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

#define mm 100005
#define nn 1005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define cases int t;  cin>>t;   while(t--)
#define check(a,n) forn(iiii,int(n)) cout<<ll(a[iiii])<<" "; cout<<endl
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int n;
ll a[55];

bool is(ll mid)
{
    ll b[55];
    forn(i,n) b[i]=a[i];
    while(mid>0)
    {
        int flag=0;
        sort(b,b+n);
        ll m=b[n-1]/n;
        b[n-1]%=n;
        forn(i,n-1)
        {
            b[i]+=m;
            if(b[i]>=n) flag=1;
        }
        mid-=m;
        if(flag==0&&mid>=0) return true;
    }
    return false;
}

int main()
{
    fast_io;
    cin>>n;
    int flag=1;
    forn(i,n)
    {
        cin>>a[i];
        if(a[i]>=n) flag=0;
    }
    if(flag) return cout<<0,0;
    ll l=0,r=1e18;
    while(l<r)
    {
        ll mid=(l+r)/2;
        if(is(mid))
            r=mid;
        else
            l=mid+1;
    }
    cout<<r;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<tuple>

using namespace std;

signed main(){

   while(1){
      int M, T, P, R;
      cin>> M>> T>> P>> R;
      if(!(M||T||P||R)) break;

      int hoge[T][P];
      fill((int*)hoge, (int*)hoge+T*P, 0);
      for(int i=0; i<R; i++){
         int time, team, prob, judge;
         cin>> time>> team>> prob>> judge;
         time++; team--; prob--;
         if(judge==0){
            hoge[team][prob]=0-hoge[team][prob]*20+time;
         }else{
            hoge[team][prob]--;
         }
      }
      priority_queue<tuple<int, int, int>> Q;
      for(int i=0; i<T; i++){
         int ac=0, time=0;
         for(int j=0; j<P; j++){
            ac+=(hoge[i][j]>0);
            time+=max(0, hoge[i][j]);
         }
         Q.push(make_tuple(ac, -time, i));
      }

      int s, t, u;
      s=t=u=-1;
      string answer;
      for(int i=0; i<T; i++){
         int ac, time, team;
         tie(ac, time, team)=Q.top(); Q.pop();
         if(i>0){
            if(s==ac&&t==-time) answer+="=";
            else answer+=",";
         }
         answer+=to_string(team+1);
         s=ac; t=-time; u=team;
      }

      cout<< answer<< endl;
   }

   return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  set<char> se;
  for (char c : s) se.insert(c);
  for (char c : t) if (!se.count(c)) {
    return cout << -1 << '\n', 0;
  }
  int k = s.size();
  s = "$" + s + s;
  int n = s.size(), m = t.size();

  VV<> nxt(26, V<>(n + 1, -1));
  for (int i = n - 1; i >= 0; --i) {
    for (int x = 0; x < 26; ++x) {
      nxt[x][i] = nxt[x][i + 1];
    }
    if (i + 1 < n) {
      nxt[s[i + 1] - 'a'][i] = i + 1;
    }
  }

  lint res = 0, p = 0;
  for (int i = 0; i < m; ++i) {
    int np = nxt[t[i] - 'a'][p];
    res += np - p;
    p = np;
    if (p > k) p -= k;
  }
  cout << res << '\n';
}

Measured memory_bytes: 21868
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string abc = "ABC";
    int ans = 0;
    REP(i,n-2){
        bool f = true;
        REP(j,3){
            if(s[i+j]!=abc[j]){
                f = false;
            }
        }
        if(f){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n+1) {
    int now = 0;
    rep(i,q) {
      if (A[b[i]]-A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) {
      cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int main()
{
    // 文字列の入力
    int N;
	cin >> N;
	
	int b = ((N / 1000 + 1) * 1000 - N) % 1000 ;
	
	printf("%d\n", b);
	
    return 0;
}

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

long long A, B, ans;

int main() {
	cin>>A>>B;
	
	ans = 0LL;
	while(A%4!=0) {
		ans ^= A;
		A++;
	}
	while(B%4!=3 && B>=A) {
		ans ^= B;
		B--;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

// gcd
template <class T>
T gcd(T a, T b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<ll> a(N);
    for(auto& x: a){
        cin >> x; x /= 2;
    }

    ll l = 1;
    for(int i=0; i<N; i++){
        l = lcm(l, a[i]);
        if(l > M){
            cout << 0 << endl; return 0;
        }
    }

    for(int i=0; i<N; i++){
        if((l/a[i])%2==0){
            cout << 0 << endl; return 0;
        }
    }

    cout << (M/l-1)/2+1 << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int a,b,c,N;
  scanf("%d%d%d%d",&a,&b,&c,&N);

  int ans = 0;
  for (int i = 0; i <= N/a; i++) {
    if(i*a > N) break;
    for (int j = 0; j <= N/b; j++) {
      if(i*a+j*b > N) break;
      if((N-i*a-j*b)%c == 0) ans++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

  y /= 1000;
  // 10 * i + 5 * j + k = yy
  // i + j + k = n
  // 9i + 4j = yy - n
  // 9 * i + 4 * j = yy - n
  if ( y - n < 0 ) {
    cout << "-1 -1 -1" << endl;
    return 0;
  }

  for (int i = 0; 9*i <= y-n; i++) {
    // 5000円札が j 枚
    for (int j = 0; 9*i + 4*j <= y-n; j++){
      int k = n - i - j;
      if ( k >= 0 && 9 * i + 4 * j == y - n ) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()

typedef long long li;

vector<vector<int>> e;
vector<int> par;

int nColored = 0;

void dfs(int v, int p = -1)
{
    nColored++;
    par[v] = p;
    
    for (int u: e[v])
        if (u != p)
            dfs(u, v);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    par.assign(n, -1);
    e.resize(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        
        e[a].push_back(b);
        e[b].push_back(a);
    }
    
    dfs(0);
    
    int x = n - 1;
    vector<int> path;
    while (x != -1)
    {
        path.push_back(x);
        x = par[x];
    }
    
    assert(path.size() >= 2);
    nColored = 0;
    dfs(path[path.size() / 2 - 1], path[path.size() / 2]);
    
    int nFirst = n - nColored, nSecond = nColored;
    
    cout << ((nFirst <= nSecond) ? "Snuke" : "Fennec") << endl;
    
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;
const int N=2e5+10;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()


#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
} 
int binomialCoeff(int n, int k)  
{
    if (k == 0 || k == n)  
        return 1;  

    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}  
long long power(ll a, ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%MOD;
        b/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}

vector<int>v[N];
ll sum[N];

void dfs(int n,int vis)
{
    for(int i=0;i<v[n].size();i++)
    {
        if(v[n][i]!=vis)
        {
            sum[v[n][i]]+=sum[n];
            dfs(v[n][i],n);
        }
    }
}


int main()
{
    IOS;
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    for(int i=0;i<q;i++)
    {
        int p,x;
        cin>>p>>x;
        sum[p]+=x;
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)
    {
        cout<<sum[i]<<" ";

    }
    cout<<endl;
    


}

Measured memory_bytes: 27392
#include<iostream>
#include<vector>
#include <string>
using namespace std;
vector<char> rotate(vector<char> &v){
	char a = v[v.size()-1];
	vector<char> b(v.size(),'a');
	for(int i = 0; i < v.size()-1;++i){
	    b[i+1]= v[i];
	}
	b[0]= a;
	return b;
}
int main(){
	vector<char> v;
	string s1,s2;
	cin>>s1>>s2;
	for (int i = 0; i < s1.size(); ++i)
	{
		v.push_back(s1[i]);
	}
	int counter=0;
// 	v=rotate(v);
// 	for (int i = 0; i < v.size(); i++) {
// 	    cout<<v[i];
// 	}
	
	for(int i = 0; i < v.size(); ++i){
		if(v[0]==s2[0]){
			for (int j = 0; j < v.size(); ++j)
			{
				if(v[j]==s2[j])
					counter++;
				else{
					counter=0;
					break;
				}
			}
			if(counter == v.size()){
			    cout<<"Yes";
			    break;
			}
		}
		v= rotate(v);
	//	cout<<v[0]<<endl;
	}
	if(counter !=v.size()){
	    cout<<"No";
	}
}

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

using namespace std;

int A, B;

string S, c, d;

int main() {

	cin >> A >> B >> S;

	string ans = "No";
	int last = 0;
	int pos = S.find("-");

	c = S.substr(last, pos - last);
	if (A == c.length() && all_of(c.cbegin(), c.cend(), [](char c) {return isdigit(c); }))
	{
		last = pos + 1;
		d = S.substr(last, S.length());
	}
	if (B == d.length() && all_of(d.cbegin(), d.cend(), [](char d) {return isdigit(d); }))
	{

		ans = "Yes";
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#TIME : 
import sys
from math import sqrt
input = sys.stdin.readline

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

MAX = 10**18
n = inp()
a = inlt()
if 0 in a:
    print(0)
    exit()
res = 1
for num in a:
    res*=num
    if res > MAX:
        print(-1)
        exit()
print(res)

Measured memory_bytes: 82824
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


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



const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


ll dp[2100][2100];

int main(){
    int N, M;
    ll s[2100], t[2100];
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }
    for(int i = 0; i < M; i++){
        cin >> t[i];
    }

    for(int i = 0; i <= N; i++){
        dp[i][0] = 1;
    }
    for(int i = 0; i <= M; i++){
        dp[0][i] = 1;
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            dp[i][j] = sub(add(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]);
            if(s[i-1] == t[j-1]){
                dp[i][j] = add(dp[i][j], dp[i-1][j-1]);
            }
        }
    }
//    for(int i = 0; i <= N; i++){
//        for(int j = 0; j <= M; j++){
//            cout << dp[i][j] << " ";
//        }
//        cout << endl;
//    }

    cout << dp[N][M] << endl;



    return 0;
}


Measured memory_bytes: 35072
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt ans(1), mul(x);
    while(n) {
      if(n & 1) ans *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ans;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

LL N,K;

ModInt<mod> ans = 0;

void solve(){
	//gcd(A1,..,AN)=iとなる組み合わせの個数をnum[i]とおく
	vector<ModInt<mod>> num(K+1);
	for(LL i=K;i>=1;i--){
		ModInt<mod> add = K/i;
		add = add.pow(N);
		for(LL j=2*i;j<=K;j+=i){
			add -= num[j];
		}
		num[i] = add;
		ans += ModInt<mod>(i)*num[i];
	}
}

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

    solve();

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

Measured memory_bytes: 3172
#include <iostream>
#include <cmath>
using namespace std;
const int inf=0x3f3f3f3f;
int n,k;
int h[100001];
int f[100001];

int main(){
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		cin>>h[i];
	}
	f[1]=0;
	f[2]=abs(h[2]-h[1]);
	for (int i=3;i<=n;i++){
		int min=inf;
		for (int j=1;j<=k;j++){
			if (i-j==0) break;
			if ((f[i-j]+abs(h[i]-h[i-j]))<min) min=f[i-j]+abs(h[i]-h[i-j]);
		}
		f[i]=min;
	}
	cout<<f[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Flip,Flip, and Flip......
ll N, M;
ll ans = 0;

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

    ans = abs(N-2)*abs(M-2);
    cout << ans << endl;
    return 0;
}




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

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

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

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

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }
template <typename T> T lcm(T a, T b) { return a / gcd(a,b) * b; }

int H, W;
string S[MAX_N][MAX_N];
signed main()
{
    cin >> H >> W;
    int row = 1;
    char col = 'A';
    REP(i, H) {
        REP(j, W) {
            cin >> S[i][j];
            if(S[i][j] == "snuke") {
                row += i;
                col += j;
            }
        }
    }
    printf("%c%lld\n", col, row);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define F first
#define S second
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n = 0;
  cin >> n;
  ll ar[n];
  bool ok = true;
  for (ll i = 0; i < n; ++i) {
    cin >> ar[i];
    if (ar[i] & 1 ^ 1 and (ar[i] % 3 != 0 and ar[i] % 5 != 0))
      ok = false;
  }
  if (ok) cout << "APPROVED";
  else cout << "DENIED";
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
#define vi vector<int>
#define vl vector<ll>
ll check[100100][30];
int main(){
    ll n,ans=0;
    bool flag;
    cin>>n;
    string s;
    map<string,ll>mp;
    for(int i=0;i<n;i++){
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    for(auto x:mp){
        ll num=x.second;
        ans+=(num*(num-1))/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11136
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

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


using namespace std;



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

	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

int main() {
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    rep(i, n) {
        cin >> v[i];
    }
    rep(i, n) {
        cin >> c[i];
    }

    int res = -141341234;
    for (ULL bit = 0; bit < (1 << n); bit++) {
        int x = 0;
        int y = 0;
        rep(i, n) {
            if (bit & (1 << i)) {
                x += v[i];
                y += c[i];
            }
        }
        res = max(res, x - y);
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	int n;
	int c = 0;
	int m = INT_MAX;
	int t;

	cin >> n;
	rep(i, n)
	{
		cin >> t;
		m = min(m, t);
		if (m == t)
			c++;
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        for(int i = 0; i < b; i++){
        	int total = a * (i + 1);
            if(total % b == c){
        		System.out.println("YES");
                return;
        	}
        }
        System.out.println("NO");
    }
}

Measured memory_bytes: 35828
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>
#include <queue>          // queue, priority_queue
#include <set>            // set
#include <stack>          // stack
#include <string>         // string, to_string, stoi
#include <tuple>          // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll N;
  cin >> N;
  vector<ll> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  if (*max_element(L.begin(), L.end()) <
      accumulate(L.begin(), L.end(), 0) - *max_element(L.begin(), L.end())) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
struct UnionFind
{
    vector<long long> data;

    UnionFind(long long sz)
    {
        data.assign(sz,-1);
    }

    bool unite(long long x, long long y)
    {
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) swap(x,y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    long long find(long long k)
    {
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    long long size(long long k)
    {
        return(-data[find(k)]);
    }
};

int main(){
    long long N,M;
    cin >> N >> M;
    long long A[M],B[M];
    for(long long i=0; i<M; i++){
        cin >> A[i] >> B[i];
    }
    struct UnionFind uf(N);
    long long ans[M];
    ans[M-1] = N*(N-1)/2;
    for(long long i=M-1; i>0; i--){
        long long a=A[i]-1,b=B[i]-1;
        long long sa=uf.size(a), sb=uf.size(b);
        if(!uf.unite(a,b)) ans[i-1] = ans[i];
        else ans[i-1] = ans[i] - sa*sb;
    }
    for(long long i=0; i<M; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4480
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(int argc, char const *argv[]) {
  string S;
  cin >> S;
  string year = S.substr(0, 4);
  string mon = S.substr(5, 2);
  string day = S.substr(8, 2);
  if (year < "2019") {
    cout << "Heisei" << endl;
    return 0;
  } else if ("2019" < year) {
    cout << "TBD" << endl;
  } else if (mon < "04") {
    cout << "Heisei" << endl;
    return 0;
  } else if (mon > "04") {
    cout << "TBD" << endl;
  } else if (day <= "30") {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
a,b = [int(c) for c in input().split()]
maxa = (a+1) / 0.08
maxb = (b+1) / 0.1
mina = a / 0.08
minb = b / 0.1
mmax = int(min(maxa,maxb)) - 1 if int(min(maxa,maxb))==min(maxa, maxb) else int(min(maxa,maxb))
mmin = int(max(mina,minb)) if int(max(mina,minb))==max(mina,minb) else int(max(mina,minb)) + 1
if mmin>mmax:
    print("-1")
else:
    print(mmin)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	VI p(a),q(b),r(c);
	REP(i,a) cin >> p[i];
	REP(i,b) cin >> q[i];
	REP(i,c) cin >> r[i];
	sort(ALL(p),greater<ll>());
	sort(ALL(q),greater<ll>());
	sort(ALL(r),greater<ll>());
	VI ans;
	REP(i,x) ans.push_back(p[i]);
	REP(i,y) ans.push_back(q[i]);
	sort(ALL(ans));
	ll sum=0;
	REP(i,x+y){
		if(i<c)
			sum+=max(ans[i],r[i]);
		else
			sum+=ans[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	string a;
	cin >> a;
	cout << (a[1] == a[2] && (a[0] == a[1] || a[3] == a[2]) ? "Yes" : "No") << endl;
	return 0;
}
 

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

require 'bigdecimal'

N, K = get_ints

nrate = 1 / BigDecimal(N)

i = 0
k = K
cur = N
ans = 0
loop do
  if cur >= k
    ans += (cur - k + 1) * nrate * ( BigDecimal(1) / 2 ** i)
    cur = k - 1
  end
  break if k == 1
  i += 1
  k = k / 2 + (k % 2 == 1 ? 1 : 0)
end

puts ans.to_f


Measured memory_bytes: 14516
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

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

const int INF = 1e9 + 7, V = 1e5 + 87;

vi G[V*2];
int l, r, vis[2*V];

void dfs(int u) {
	vis[u] = 1;
	for(int v:G[u])
		if(!vis[v])
			dfs(v);
	if(u < V) l++;
	else r++;
}

int main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		int x, y;
		cin >> x >> y;
		y += V;
		G[x].PB(y);
		G[y].PB(x);
	}
	ll ans = 0;
	for(int u=1;u<=V*2;u++) {
		if(!vis[u]) {
			l = r = 0;
			dfs(u);
			ans += (ll) l * r;
		}
	}
	cout << ans - n << endl;
}



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

int main()
{
    long long int a, b, q;
    long long int inf=1000000000000000000;
    cin >> a >> b >> q;
    vector<long long int> s;
    vector<long long int> t;
    s.push_back(-inf);
    t.push_back(-inf);
    long long int x;
    for (int i=0; i<a; i++){
        long long int tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    for (int i=0; i<b; i++){
        long long int tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    s.push_back(inf);
    t.push_back(inf);
    long long int questions[q];
    for(int i=0; i<q; i++){
        cin >> questions[i];
    }
    for(int i=0; i<q; i++){
        x=questions[i];
        long long int ans=inf;
        vector<long long int>::iterator iter_lowers, iter_lowert;
        
        iter_lowers=lower_bound(s.begin(), s.end(), x);
        long long int ls = distance(s.begin(), iter_lowers);
        ls--;
        iter_lowert=lower_bound(t.begin(), t.end(), x);
        long long int lt = distance(t.begin(), iter_lowert);
        lt--;
        //cout << ls << '@' << lt << '\n';
        for(long long int j=ls; j<=ls+1; j++){
            for(long long int k=lt; k<=lt+1; k++){
                long long int tmp1, tmp2, tmp;
                tmp1=abs(s[j]-x)+abs(t[k]-s[j]);
                tmp2=abs(t[k]-x)+abs(s[j]-t[k]);
                tmp=min(tmp1, tmp2);
                ans=min(ans, tmp);
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 3828
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	int k,a,b;
	cin>>k>>a>>b;
    bool ok = false;
    for(int i=a;i<=b;i++){
        if(i%k==0)
            ok = true;
    }
    cout<<(ok?"OK":"NG");
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define X first
#define Y second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define debug(x) cout << #x << " :: "<< x <<"\n";
#define debug2(x,y) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\n";
#define debug3(x,y,z) cout << #x << " :: "<< x << "\t" << #y << " :: " << y << "\t" << #z << " :: " << z << "\n";
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree< pair<ll,ll> , null_type,less< pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    boost
    ll a,b,m;
    cin >> a >> b >> m;
    ll v1[a],v2[b],x1=LLONG_MAX,y1=LLONG_MAX;
    for(ll i=0;i<a;i++) {
        cin >> v1[i];
        x1=min(x1,v1[i]);
    }
    for(ll i=0;i<b;i++) {
        cin >> v2[i];
        y1=min(y1,v2[i]);
    }
    ll ans=LLONG_MAX;
    for(ll i=0;i<m;i++) {
        ll x,y,c;
        cin >> x >> y >> c;
        ans=min(ans,max(0LL,v1[x-1]+v2[y-1]-c) );
    }
    ans=min(ans,x1+y1);
    cout << ans ;
    return 0;
}


Measured memory_bytes: 1792