akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 998244353
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
ll fact[200003];
ll invfact[200003];
ll power(ll x,ll y){
  if(y<=0) return 1;
  ll z=power(x,y/2);
  if(y%2) return ((z*z)%mod)*x%mod;
  return (z*z)%mod;
}
ll Cr(ll x, ll y){
  return (((fact[x]*invfact[x-y])%mod)*invfact[y])%mod;
}
void make_fact(int n){
  fact[0]=1;
  rep(i,1,n+1) fact[i]=(i*fact[i-1])%mod;
  invfact[0]=1;
  rep(i,1,n+1) invfact[i]=(power(i,mod-2)*invfact[i-1])%mod;
}
void solve(){
  int n,m,k;
  cin>>n>>m>>k;

  make_fact(n);

  ll ans=0;
  rep(i,0,k+1) {
    ans+=(((Cr(n-1,i)*m)%mod)*power(m-1,n-1-i))%mod;
    ans%=mod;
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    {
      solve();
    }
}


Measured memory_bytes: 6708
#include <iostream>
#include <unordered_map>
#include<vector>
using namespace std;
using ll = long long;

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

	unordered_map<string, ll> combi;
	for (auto p = cnt.begin(); p != cnt.end(); ++p) {
		ll v = p->second;
		combi[p->first] = v * (v-1) / 2;
	}

	ll sum = 0;
	for (auto p:combi) sum += p.second;
	for (int i = 0; i < n; ++i) {
		ll temp = 0;
		if (cnt[a[i]] >= 3) temp = (cnt[a[i]]-1) * (cnt[a[i]]-2) / 2;
		cout << sum - combi[a[i]] + temp << endl;
	}
}

Measured memory_bytes: 30408
a,b,c,x,y=map(lambda x: int(x), input().split())
ans=0

# A, B両方のピザの購入
if a+b<2*c:
    ans+=min(x,y)*(a+b)
else:
    ans+=min(x,y)*2*c

# A又はBの残りのピザを購入
if x>y:
    ans+=min(a,2*c)*(x-y)
else:
    ans+=min(b,2*c)*(y-x)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  double a,b,c;
  string S;
  cin >> a >> b;
  double d = a/b;

  cout << d;


  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# define MAX_N 100

int n;
unsigned long long dp[MAX_N][21];
int a[MAX_N];

int main(){
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];
	
	dp[0][a[0]] = 1;

	for (int i = 1; i < n-1; ++i){
		for (int j = 0; j <= 20; ++j){
			if (j + a[i] <= 20)
				dp[i][j] += dp[i-1][j + a[i]];
			if (j - a[i] >= 0)
				dp[i][j] += dp[i-1][j - a[i]];
		}
	}

	std::cout << dp[n - 2][a[n - 1]]<<std::endl;
	return 0;
}

Measured memory_bytes: 1172
R,G,B,N = map(int,input().split())
dp = [[0,0,0] for i in range(N + 1)]

for i in range(N + 1):
  if i % R == 0:
    dp[i][0] = 1

for i in range(N + 1):
  if dp[i][0] != 0:
    for j in range(i,N + 1,G):
      dp[j][1] += dp[i][0]
for i in range(N + 1):
  if dp[i][1] != 0:
    for j in range(i,N + 1,B):
      dp[j][2] += dp[i][1]
print(dp[-1][2])


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

signed main(){
	vector<int> vals(10001, 0);
	for (int x=1; x<=100; ++x){
		for (int y=1; y<=100; ++y){
			for (int z=1; z<=100; ++z){
				int ex = x*x + y*y + z*z + x*y + y*z + z*x;
				if (ex > 10000) continue;
				vals[ex]++;
			}
		}
	}
	int n; cin >> n;
	for (int i=1; i<=n; ++i)
		cout << vals[i] << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s, t;
  cin >> s >> t;
  rep(i,s.size()) {
    s = s[s.size() - 1] + s.substr(0, s.size() - 1);
    if (s == t) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N, maxv,minv;
	vector<LL>R;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		R.pb(x);

	}

	maxv = -1 * INF;
	minv = R[0];
	for (LL i = 1; i < N; i++) {
		maxv = max(maxv,R[i]-minv);
		minv = min(minv,R[i]);
	}

	cout << maxv << endl;

	return 0;

}


Measured memory_bytes: 4960
#include<stdio.h>
int main (void)
{
	int s,h,m,S;
	scanf("%d",&S);
	
	s=S%3600%60;
	m=S%3600/60;
	h=S/3600;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
	
	
	
	
}

Measured memory_bytes: 592
#include <stdio.h>

int main() {
  int H, W;

  // 0なら削除対象
  int row_flags[100];
  int col_flags[100];

  int squares[100][100];
  int i, j;
  char str[100];

  scanf("%d %d", &H, &W);

  for (i = 0; i < H; i++) {
    scanf("%s", str);
    for (j = 0; j < W; j++) {
      squares[i][j] = str[j];
      if (str[j] == '#') {
        row_flags[i] = 1;
        col_flags[j] = 1;
      }
    }
  }
  for (i = 0; i < H; i++) {
    if (row_flags[i] == 1) {
      for (j = 0; j < W; j++) {
        if (col_flags[j] == 1) {
          printf("%c", squares[i][j]);
        }
      }
      printf("\n");
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = LONG_MAX;
const int N = 1e3 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;

	while (tc--) {

		ll n, m, k, i, j;
		ll x, y;

		ld a, v;
		ld b, w;
		ld t;
		cin >> a >> v;
		cin >> b >> w;
		cin >> t;

		if (b != a and v == w) {
			cout << "NO" << endl;
			continue;

		}


		if (v < w) {
			cout << "NO" << endl;
			continue;
		}
		ld ans = (abs(b - a)) / (v - w);


		// cout << ans << endl;

		if (ans <= t) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}




	}

}

Measured memory_bytes: 3744
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template<class _T> static void getint(_T& a) {
	if (sizeof(_T) > sizeof(int)) {
		scanf("%lld", &a);
	}
	else {
		scanf("%d", &a);
	}
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	get(N);

	std::string s1, s2;
	get(s1, s2);

	LLONG ans = 3;
	int bfr = 0;
	for (int i = 0; i < N; i++) {
		if (s1[i] != s2[i]) {
			i++;
			if (bfr == 1 || bfr == 0) {
				ans = ans * 2LL % MOD_NUM;
			}
			else {
				ans = ans * 3LL % MOD_NUM;
			}
			bfr = 2;
		}
		else {
			if (bfr == 1) {
				ans = ans * 2LL % MOD_NUM;
			}
			bfr = 1;
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3724
//C
#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 <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#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 <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	vector<string>W(N);
	for (int i = 0; i < N; i++) {
		cin >> W[i];
	}
	map<string, int>mp;
	mp[W[0]]++;
	for (int i = 1; i < N; i++) {
		if (W[i - 1][W[i - 1].size() - 1] != W[i][0]) {
			cout << "No" << endl;
			return 0;
		}
		mp[W[i]]++;
	}
	if (mp.size() != N) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

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

	string s; cin >> s;
	int curr = 0, res = 0;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == 'R')
		{
			curr++;
			res = max(res, curr);
		}
		else
			curr = 0;
	}
	cout << res << '\n';

	return 0;
}

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

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

int main(){
  
  vector<vector<int>>bingo(3,vector<int>(3));
  vector<vector<int>>ans(3,vector<int>(3));
  rep(tate,3)
    rep(yoko,3)
      cin >> bingo[tate][yoko];
      
  int n;
  cin >> n;
  
  vector<int> b(n);
  rep(i, n) cin >> b[i];
  
  
  for(int c = 0; c < n; c++)
    for(int c1 = 0; c1 < 3; c1++)
      for (int c2 = 0; c2 < 3; c2++) {
        if(b[c] == bingo[c1][c2])
          ans[c1][c2] = 1;
    }
  
  rep(a1, 3){
    if(ans[a1][0] == 1 && ans[a1][1] == 1 && ans[a1][2] == 1){
      cout << "Yes";
      return 0;
    }
    
    if(ans[0][a1] == 1 && ans[1][a1] == 1 && ans[2][a1] == 1){
      cout << "Yes";
      return 0;
    }
  }
  if(ans[0][0] == 1 && ans[1][1] == 1 && ans[2][2] == 1){
    cout << "Yes";
    return 0;
  }
  else if (ans[0][2] == 1 && ans[1][1] == 1 && ans[2][0] == 1) {
    cout << "Yes";
    return 0;
  }
  
  else
    cout << "No";
    return 0;
}

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

int main(){
  int x;
  cin >> x;
  if(x < 1200) puts("ABC");
  else puts("ARC"); 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    string s;
    cin >> s;
    int count = 0;
    
    if((s[0] == s[1]  && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	return b ? gcd(b,a%b) : a;
}



/*最小公倍数*/

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


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    string s;
    cin>>s;
    vector<ll>c(s.size(),0);
    ll x=0,y=0,o;
    while(s.find("RL",y)!=-1){
        x=s.find("RL",y);
        o=s.find("LR",y);
        if(o==-1){
            o=s.size()-1;
        }
        //cout<<x<<endl;
        //cout<<o<<endl;
        c[x]=(o-y+1)/2;
        c[x+1]=(o-y+1)/2;
        if((o-y+1)%2!=0){
            if((x-y)%2==0){
                c[x]++;
            }
            else{
                c[x+1]++;
            }
        }
        y=o+1;
        //cout<<y<<endl;
               
    }
    rep(i,0,s.size()){
        cout<<c[i]<<" ";
    }
    cout<<endl;
    
    
    
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int H, W;
	cin >> H >> W;
	string a[100];
	vector<char>w;
	for (int i = 0; i < H; i++){
		cin >> a[i];
	}
	for (int i = 0; i < W+1; i++){
		cout << '#';
	}
	cout << '#' << endl;
	for (int j = 0; j < H; j++){
		cout << '#' << a[j] << '#' << endl;
	}
	for (int i = 0; i < W+1; i++){
		cout << '#';
	}
	cout << '#' << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        final String[] varS = sc.next().split("", 0);
        final String[] varT = sc.next().split("", 0);
        sc.close();
        int varSlen = varS.length;
        int varTlen = varT.length;
        int result = 0;
        int cnt = 0;
        //  変換文字列分比較をする
        for (int j = 0; j <= (varSlen - varTlen); j++) {
            cnt = 0;
            for (int i = 0; i < varTlen; i++) {
                if (varT[i].equals(varS[i + j])) {
                    cnt++;
                }
            }
            if (result < cnt) {
                result = cnt;
            }
        }
        result = varTlen - result;
        System.out.println(result);
    }
}

Measured memory_bytes: 36844
#include <stdio.h>

int main(void){
    int h,max,min,t = 0,ave,i,sc;
    while (scanf("%d",&h),h != 0){
        t = 0;
        for(i = 1;i <= h; i++){
            scanf("%d",&sc);
            t = t + sc;
            if (i == 1){
                max = sc;
                min = sc;
            }
            else if (max < sc) {
                max = sc;
            }
            else if (min > sc){
                min = sc;
            }
        }
    t = t - min - max;
    h = h - 2;
    ave = t / h;
    printf("%d\n",ave);
    }

    return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  
  int x=1;
  for (int i; i<n; i++){
    if (x*2<=x+k){
      x*=2;
    }
    else{
      x+=k;
    }
  }
  cout << x << endl;
}

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

#define MAX_N (100000)

int main(int argc, char *argv[]) {
  // read inputs
  int N, L, as[MAX_N];
  scanf("%d %d", &N, &L);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // solve
  int i_last = -1;
  for (int i = 0; i < N - 1; i++) {
    if (as[i] + as[i + 1] >= L) {
      i_last = i;
    }
  }

  if (i_last < 0) {
    printf("Impossible\n");
  } else {
    printf("Possible\n");
    for (int i = 0; i < i_last; i++) {
      printf("%d\n", i + 1);
    }
    for (int i = N - 2; i > i_last; i--) {
      printf("%d\n", i + 1);
    }
    printf("%d\n", i_last + 1);
  }
  
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,a,b;

int main(void){
	scanf("%d%d%d",&n,&a,&b);
	printf("%d\n",min(a*n,b));
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n-1);
  rep(i, n) cin >> a.at(i);
  rep(i, n) cin >> b.at(i);
  rep(i, n-1) cin >> c.at(i);
  int sum = 0;
  rep(i, n) sum += b.at(i);
  rep(i, n-1) {
    if(a.at(i+1) - a.at(i) == 1) sum += c.at(a.at(i) - 1);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <stack>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;

#define MAX_N 100100
typedef pair<int, int> P;
typedef pair<ll, ll> llP;

class UnionFindTree{
private:
    int par[MAX_N];
    int urank[MAX_N];
    int size[MAX_N];
public:
    int init(int n);
    int find(int x);
    int unite(int x, int y);
    int same(int x, int y);
    int parnum(int x){return par[x];}
    int ranknum(int x){return urank[x];}
    int sizenum(int x){return size[find(x)];}
};

int UnionFindTree::init(int n){
    REP(i, n){
        par[i] = i;
        urank[i] = 0;
        size[i] = 1;
    }
    return 0;
}

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

int UnionFindTree::unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return 0;
    if(urank[x] < urank[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(urank[x] == urank[y])urank[x] ++;
    }
    return 0;
}

int UnionFindTree::same(int x, int y){
    return find(x) == find(y);
}


int bit[100100];
int S[100100];
int sum(int i){
    int s = 0;
    while(i  > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
int a[100100];

int main(){
    ll N, K;
    cin >> N >> K;
    if(K %2 == 0){
        K /= 2;
        ll kazu = N / K;
        if(kazu % 2 == 0){
            kazu /= 2;
            printf("%lld\n", 2 * kazu * kazu * kazu);
        }else{
            ll a = (kazu + 1) / 2;
            ll b = (kazu - 1) / 2;
            printf("%lld\n", a * a * a + b * b * b);
        }
    }else{
        ll kazu = N / K;
        printf("%lld\n", kazu * kazu * kazu);
    }
}


Measured memory_bytes: 888
#include<stdio.h>

int main(){
    char weather[6];

    scanf("%s", &weather);

    if(weather[0] == 'S'){
        printf("Cloudy\n");
    }

    if(weather[0] == 'C'){
        printf("Rainy\n");
    }

    if(weather[0] == 'R'){
        printf("Sunny\n");
    }


    return 0;
}

Measured memory_bytes: 128
# どうせすぐにみつかる
n = int(input())

def gen_sequence(seed):
    yield seed
    last = seed
    while True:
        if last&1:
            last = last*3 + 1
        else:
            last = last//2
        yield last

mem = set([])
for i,x in enumerate(gen_sequence(n), 1):
    if x in mem:
        print(i)
        exit()
    mem.add(x)

Measured memory_bytes: 9088
#include<stdio.h>
int main(void){
  int sx,sy,tx,ty,i,x,y;
  scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
  x=tx-sx;
  y=ty-sy;
  for(i=1;i<=y;i++){
    printf("U");//一回目行きy
  }
  for(i=1;i<=x;i++){
  printf("R");//一回目行きx
}
for(i=1;i<=y;i++){
  printf("D");//一回目帰りy
}
for(i=1;i<=x;i++){
  printf("L");//一回目帰りx
}
//二回目行き
printf("L");
 for(i=1;i<=y+1;i++){
    printf("U");//二回目行きy
  }
 for(i=1;i<=x+1;i++){
    printf("R");//二回目行きx
  }
printf("D");
//二回目帰り
printf("R");
 for(i=1;i<=y+1;i++){
    printf("D");//二回目帰りy
  }
   for(i=1;i<=x+1;i++){
    printf("L");//二回目帰りx
  }
printf("U\n");
return 0;
}
    
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define int ll



int t, n,a[300010];
ll k;
bool v[200010];

int32_t main(){
INIT
cin>>n>>k;

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



int p=1;
while(!v[p] && k>0){
    v[p]=true; p=a[p]; k--;
}

if(k<=0){cout<<p; return 0;}

int l=1;
int o=a[p];
while(o!=p){
    o=a[o]; l++;
}

k%=l;

while(k>0){
    p=a[p]; k--;
}


cout<<p;


return 0;
}



Measured memory_bytes: 5380
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;
int n,k;
int x[100005];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin >> n >> k;
	int ans = 0x3f3f3f3f;
	for(int i = 1;i <= n;++i)cin >> x[i];
	for(int l = 1;l <= n - k + 1;++l){
		int r = l + k - 1;
		if(x[r] < 0)ans = min(-x[l],ans);
		else if(x[l] > 0)ans = min(x[r],ans);
		else ans = min(ans,min(2*x[r] - x[l],x[r] - 2*x[l]));
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 640
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int q = readint;

    int[] v;
    for (int i = 0; i < q; i++) {
        auto xs = readints;

        switch (xs[0]) {
            case 0: v ~= xs[1]; break;
            case 1: writeln(v[xs[1]]); break;
            case 2: v = v[0..$ - 1]; break;
            default: break;
        }
    }
}



Measured memory_bytes: 7088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    long long a,b,c;
    cin >> a >> b >> c;

    if(a*a+b*b+c*c-2*a*c-2*a*b-2*b*c>0 && c>a+b){
        cout << "Yes" << endl; 
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1116
#define mod 998244353

int n,x[N],y[N],e[N],ans;

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++)
		x[i]=read(),y[i]=read();
	for (int i=e[0]=1;i<=n;i++)
		e[i]=e[i-1]*2%mod;
	ans=e[n]-1-n;
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++){
			int t=0;
			for (int k=j+1;k<=n;k++)
				t+=((x[j]-x[i])*(y[k]-y[i])==(x[k]-x[i])*(y[j]-y[i]));
			ans=(ans-e[t])%mod;
		}
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
t={'\\'=>-1,'/'=>1,'_'=>0}
a=[0]
gets.chomp.each_char{|c|a<<(a.last+t[c])}
ma=a.max

#left=a.index(ma)
right=a.rindex(ma)
depth=nil
amount=0

water1=[]
0.upto(right-1){|i|
	if !depth
		if a[i]>a[i+1]
			depth=a[i]
		end
	end
	if depth
		amount+=(depth-a[i])+(depth-a[i+1])
	end
	if a[i+1]==depth
		depth=nil
		raise if amount%2>0
		water1<<amount/2
		amount=0
	end
}
raise if depth || amount>0

water2=[]
(a.size-1).downto(right+1){|i|
	if !depth
		if a[i]>a[i-1]
			depth=a[i]
		end
	end
	if depth
		amount+=(depth-a[i])+(depth-a[i-1])
	end
	if a[i-1]==depth
		depth=nil
		raise if amount%2>0
		water2<<amount/2
		amount=0
	end
}
raise if depth || amount>0

water=water1+water2.reverse
p water.reduce(0,:+)
puts [water.size,*water]*' '

Measured memory_bytes: 9232
INF = float('inf')
N,Ma,Mb = map(int,input().split())
abc = [list(map(int,input().split())) for _ in range(N)]
dp = [[[INF]*(10*N+11) for _ in range(10*N+11)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for a1 in range(10*N+1):
        for b1 in range(10*N+1):
            a,b,c = abc[i]
            dp[i+1][a1][b1] = min(dp[i][a1][b1],dp[i][a1-a][b1-b]+c)

ans = INF
for a1 in range(1,10*N+1):
    for b1 in range(1,10*N+1):
        if a1*Mb == b1*Ma:
            ans = min(ans,dp[N][a1][b1])

if ans == INF:
    ans = -1

print(ans)

Measured memory_bytes: 128776
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int N;
	cin >> N;
	vector<ll> h(N);
	for(int i = 0; i < N; i++) cin >> h[i];
	stack<int> stka, stkb;
	vector<int> memo(N), memo2(N);
	for(int i = 0; i < N; i++){
		while(!stka.empty() && h[stka.top()] >= h[i]) stka.pop();
		memo[i] = (stka.empty() ? 0 : stka.top() + 1);
		stka.push(i);
	}
	for(int i = N - 1; i >= 0; i--){
		while(!stkb.empty() && h[stkb.top()] >= h[i]) stkb.pop();
		memo2[i] = (stkb.empty() ? N : stkb.top());
		stkb.push(i);
	}
	ll res = 0;
	for(int i = 0; i < N; i++) res = max(res, h[i] * (ll)(memo2[i] - memo[i]));
	cout << res << endl;
	return 0;
}



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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 1;
    char prev = s[0];
    for(int i=1; i<n; i++){
        if(prev!=s[i]){
            ans++;
            prev = s[i];
        }else{
            continue;
        }
    }

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

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

using namespace std;

class help
{
    public:
     int a,b,k;
     
     help(int x,int y,int z){a=x; b=y; k=z;}
     
};


bool xsort(help &a,help&b)
{
   
         return a.a<b.a;
     
}
bool ysort(help &a,help&b)
{
   
         return a.b<b.b;
     
}



 int p[200000],sz[200000];
int find(int v){return (v==p[v])?v:p[v]=find(p[v]);}
void merge(int a,int b){
	a=find(a),b=find(b);
	if(a==b)return;
	if(sz[a]<sz[b])swap(a,b);
	p[b]=a,sz[a]+=sz[b];
}
        
int main() {
    
    
    
    int n;
    cin>>n;
    
    for(int i=0;i<n;i++)p[i]=i;
    vector<help>arr;
    for(int i=0;i<n;i++)
    {
        int a,b;cin>>a>>b;a--;b--;
        arr.push_back(help(a,b,i));
    }
    sort(arr.begin(),arr.end(),xsort);
    
    set<int> set;
    unordered_map<int,int> tmap;
    
    for(int i=0;i<n;i++)
    {
        int val=-1*arr[i].b;
        auto it=set.upper_bound(val);
        if(it!=set.end())
        {
            int in=arr[tmap[*it]].k;
            merge(in,arr[i].k);
        }
        set.insert(val);
        tmap[val]=i;
    }
    
    set.clear(); tmap.clear();
    for(int i=n-1;i>=0;i--)
    {
        int val=arr[i].b;
        auto it=set.upper_bound(val);
        if(it!=set.end())
        {
            int in=arr[tmap[*it]].k;
            merge(in,arr[i].k);
        }
        set.insert(val);
        tmap[val]=i;  
    }
    
    
    sort(arr.begin(),arr.end(),ysort);
    
     set.clear();
     tmap.clear();
    
    for(int i=0;i<n;i++)
    {
        int val=-1*arr[i].a;
        auto it=set.upper_bound(val);
        if(it!=set.end())
        {
            int in=arr[tmap[*it]].k;
            merge(in,arr[i].k);
        }
        set.insert(val);
        tmap[val]=i;
    }
    
    set.clear(); tmap.clear();
    for(int i=n-1;i>=0;i--)
    {
        int val=arr[i].a;
        auto it=set.upper_bound(val);
        if(it!=set.end())
        {
            int in=arr[tmap[*it]].k;
            merge(in,arr[i].k);
        }
        set.insert(val);
        tmap[val]=i;  
    }
    tmap.clear();
    for(int i=0;i<n;i++)
    {
        tmap[find(i)]++;
    }
    for(int i=0;i<n;i++)
    cout<<tmap[find(i)]<<endl;
    
}

Measured memory_bytes: 24704
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s, t;
  s.push_back(-1e18), t.push_back(-1e18);
  for (int i = 0; i < a; ++i)
  {
    ll c;
    cin >> c;
    s.push_back(c);
  }
  for (int i = 0; i < b; ++i)
  {
    ll c;
    cin >> c;
    t.push_back(c);
  }
  s.push_back(1e18), t.push_back(1e18);
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  for (int i = 0; i < q; ++i)
  {
    ll x;
    cin >> x;

    int ng = -1;
    int sok = s.size();
    while (abs(sok - ng) > 1)
    {
      int mid = (sok + ng) / 2;
      if (s[mid] >= x)
        sok = mid;
      else
        ng = mid;
    }
    ll sr = s[sok] - x, sl = x - s[sok - 1];

    ng = -1;
    ll tok = t.size();
    while (abs(tok - ng) > 1)
    {
      int mid = (tok + ng) / 2;
      if (t[mid] >= x)
        tok = mid;
      else
        ng = mid;
    }
    ll tr = t[tok] - x, tl = x - t[tok - 1];

    cout << min({max(tl, sl), max(sr, tr), 2 * sl + tr, 2 * sr + tl, 2 * tl + sr, 2 * tr + sl}) << endl;
  }

  return 0;
}


Measured memory_bytes: 3060
use std::vec::Vec;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let mut ok = false;
    if n % 10 == 7 {
      ok = true;
    } else if (n / 10) % 10 == 7 {
      ok = true;
    } else if (n / 100) % 10 == 7 {
      ok = true;
    }

    if ok {
      println!("Yes");
    } else {
      println!("No");
    }
}


Measured memory_bytes: 2112
#include<stdio.h>
#define MAX 101
typedef struct {
  int i1;//行
  int j1;//列
  int w;//重み
} Cnt;
int n;//n:入力, i,j:繰り返し用
int S[MAX][MAX];//入力
int tag[MAX];//tag付け用

void tagging(int x,int y){
    int k,i;
    k = tag[x];
    for(i=0;i<n;i++){
        if(tag[i]==k) tag[i]=tag[y];
    }            
}

void Kruskal(){
    int s=0,t=1,cost=0,i,j;
    Cnt C[4900],tmp;
    //Cに辺の情報を記録
    for(i=0;i<n-1;i++){
        for(j=t;j<n;j++){
            if(S[i][j]!=-1){
                C[s].i1 = i;
                C[s].j1 = j;
                C[s].w = S[i][j];
                s++;
            }
        }
        t++;
    }
    //昇順ソート
    for(i=0; i<s; ++i) {
        for(j=i+1; j<s; ++j) {
            if(C[i].w > C[j].w) {
                tmp = C[i];
                C[i] = C[j];
                C[j] = tmp;
            }
        }
    }
    //tag初期化
    for(i=0;i<MAX;i++) tag[i]=i;
    //tag付け、重み総和計算
    for(i=0,t=0; t<n-1; i++){
        if(tag[C[i].i1]!=tag[C[i].j1]){
            cost+=C[i].w;
            if(tag[C[i].i1] >= tag[C[i].j1]) tagging(C[i].i1,C[i].j1);                          
            else                             tagging(C[i].j1,C[i].i1);
            t++;
        }
    }
    printf("%d\n", cost);
}

int main(void){
    int m,i,j;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        for(j=0; j<n; j++){
            scanf("%d",&m);
            S[i][j] = m;
        }
    }
    Kruskal();
    return 0;
}


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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      ans += j;
    }
  }
  cout << ans << '\n';
  return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}


int n;
ll a[3005];
ll s[405];
ll dp[405][405]; // dp[i][j]:=[i,j)の最小値

ll rec(int i, int j){
  if(dp[i][j]!=LINF) return dp[i][j];
  if(j-i==1) return dp[i][j];
  
  for(int m=i+1; m<j; m++){
    chmin(dp[i][j], rec(i,m)+rec(m,j));
  }
  dp[i][j]+=s[j]-s[i];
  return dp[i][j];
}

int main(){
  cin>>n;
  rep(i,n){
    cin>>a[i];
    s[i+1]=s[i]+a[i];
  }
  rep(i,n+1) rep(j,n+1) dp[i][j]=LINF;
  rep(i,n) dp[i][i+1]=a[i];
  
  cout<<rec(0,n)-(s[n]-s[0])<<endl;
}

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

int main() {
  int n;cin>>n;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  rep(i,n-1){
    if(s[i][s[i].size()-1]!=s[i+1][0]){
      cout<<"No"<<endl;
      return 0;
    }
  }
    rep(i,n)for(int j=i+1;j<n;j++){
      if(s[i]==s[j]){
        cout<<"No"<<endl;
        return 0;
      }
      }
    cout<<"Yes"<<endl;
}

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

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

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#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 100010

ll lis(const vector<ll>& v) {
    ll ret = 0;
    // 増加部分列の長さが i のとき、一番右に来る数字の最小値(dp 内の値は単調増加になる)
    vector<ll> dp(v.size(), LLINF);
    for(int i = 0; i < v.size(); ++i) {
        auto it = upper_bound(dp.begin(), dp.end(), v[i]);
        //auto it = lower_bound(dp.begin(), dp.end(), v[i]);  // 同じ数を含まないようにする場合
        *it = v[i];
        ret = max(ret, static_cast<ll>(it - dp.begin()));
    }
    // LLINF でない最大のインデックス + 1 が LIS になる
    return ret + 1;
}
ll lds(const vector<ll>& v) {
    vector<ll> minus_v;
    for(auto& val : v) { minus_v.push_back(-val); }
    return lis(minus_v);
}

ll N;
vector<ll> A;

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

    cin >> N;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
    }

    auto tmp = lds(A);

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

    return 0;
}


Measured memory_bytes: 2676
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = Array(N) { readLine()!!.toLong() }

    var res = 0L
    for (i in A.indices) {
        res += A[i] / 2L
        A[i] %= 2L

        if (A[i] > 0L && i + 1 < N && A[i + 1] > 0L) {
            A[i + 1] -= 1L
            A[i] -= 1L
            res++
        }
    }

    println(res)
}


Measured memory_bytes: 40572
def check(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i
n,k=map(int,input().split())
w=[int(input())for _ in[0]*n]
l=0;r=n*100000
while r-l>1:
 m=(l+r)//2
 if check(m)>=n:r=m
 else:l=m
print(r)


Measured memory_bytes: 10348
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	FIO
	
	int x;
	cin >> x;
	int ans = 0;
	ans += (x / 500) * 1000;
	x %= 500;
	ans += (x / 5) * 5;
	cout << ans;
	return 0; 
}


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

ll power(ll num, ll times) {
  ll tmp = num;
  for(ll i = 0; i < times-1; ++i) {
    tmp *= num;
  }
  return tmp;
}

int main() {
  ll h; cin >> h;
  ll i = 2, times = 1;
  while(true) {
    if(h < i) break;
    i *= 2;
    times++;
  }
  cout << power(2, times) - 1 << endl;

  return 0;
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
	int n = ri();
	UPTO(i,n,1000) {
		if (i%10 == i/10%10 && i/10%10 == i/100) {
			cout << i << endl;
			return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let n: usize = n.trim().parse().unwrap();

    let mut ta = String::new();
    stdin().read_line(&mut ta).unwrap();
    let ta: Vec<isize> = ta.trim().split_whitespace().flat_map(str::parse).collect();
    let (t, a) = (ta[0] * 1000, ta[1] * 1000);


    let mut harr = String::new();
    stdin().read_line(&mut harr).unwrap();
    let harr: Vec<_> = harr.trim().split_whitespace().flat_map(str::parse::<isize>).map(|h| {
        let t = t - a - h * 6;
        if t >= 0 { t } else { -t }
    }).collect();
    let mut result = None;
    for (i, &h) in harr.iter().enumerate() {
        if result == None {
            result = Some((i, h));
        } else if let Some((_, oh)) = result {
            if oh > h {
                result = Some((i, h));
            }
        }
    }
    if let Some((i, _)) = result {
        println!("{}", i + 1);
    }
}

Measured memory_bytes: 4352
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		var x = ss.Next<int>();
		var y = ss.Next<int>();
		if (x > y)
		{
			Console.WriteLine("a > b");
		}
		else if (x < y)
		{
			Console.WriteLine("a < b");
		}
		else
		{
			Console.WriteLine("a == b");
		}
		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}
}

public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9792
def calc(a,b):
  return [a+b, a-b, a*b]

K, X = [int(i) for i in input().split()]

hidari = X + 1 - K
migi = X + K
l = []
for i in range(hidari,migi):
    l.append(i)

print(" ".join(map(str, l)))

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

#define ln "\n"
#define SORT(X) sort(X.begin(), X.end())
#define SORTi(X) sort(X.begin(), X.end(), greater<ll>())
#define REP(x, a, b) for (auto x = a; x <= b; x++)
#define REPi(x, b, a) for (auto x = b; x >= a; x--)
#define REPit(x, A) for (auto x = A.begin(); x != A.end(); x++)
#define REPr(x, A) for (auto x : A)
#define ll long long
#define ull unsigned long long
#define PB push_back
#define EB emplace_back
#define UMP unordered_map
#define UST unordered_set

using namespace std;

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

    int N , T, sum = 0;
    cin >> N >> T;
    vector <int> A(N);
    REP(i, 0, N-1)
    {
        cin>>A[i];
    }
    int tmp = 0;
    REP(i, 0, N-2)
    {
        tmp = (A[i+1] - A[i]);
        if(tmp < T)
        {
            sum = sum + tmp;
        }
        else if (tmp >= T)
        {
            sum = sum + T;
        }
    }
    sum = sum + T;
    cout<<sum<<ln;
    return 0;
}

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

using namespace std;

template<class T> inline T sqr(const T& a) {
  return a * a;
}

template<class T> inline int len(const T &c) {
  return static_cast<int>(c.size());
}

template<class T> inline bool maximize(T &r, const T c) {
  if (r < c) {
    r = c;
    return true;
  }
  return false;
}

template<class T> inline bool minimize(T &r, const T c) {
  if (r > c) {
    r = c;
    return true;
  }
  return false;
}

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const ld EPS = 1e-9;
const ld PI = 2 * acos(0.0);
const int N = 100;

int main() {
  int n, c, k;
  scanf("%d%d%d", &n, &c, &k);
  vector<int> t(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &t[i]);
  }
  sort(t.begin(), t.end());
  int ans = 0;
  for (int i = 0; i < n; ) {
    int j = i + 1;
    while (j < n && j - i + 1 <= c && t[j] <= t[i] + k) {
      ++j;
    }
    ++ans;
    i = j;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    char a;
    cin >> a;
    if (isupper(a))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main() {
  int num;
  long long int sum = 0;
  scanf("%d", &num);

  for(int i = 1; i <= num; i++) {
    if(i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 1732