akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p=1e9+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,h,x,y,n,m,k,t1,t2,t3;
    ll a,b,c;
    cin>>n>>k;
    ll arr[n+1],cnt[n+1]={0};
    for(i=1;i<=n;i++)
    cin>>arr[i];
    vector<ll>ans;
    ans.pb(1);
    ll cur=1;
    cnt[1]=1;
    ll ind;
    while(1)
    {
        ll temp=arr[cur];
        if(cnt[arr[cur]]==0)
        {
            cnt[arr[cur]]=1;
            ans.pb(arr[cur]);
            cur=arr[cur];
        }
        else
        {
            ind=arr[cur];
            break;
            
        }
        
    }
    if(ans.size()-1>=k)
    cout<<ans[k];
    else
    {
        for(i=0;i<ans.size();i++)
        {
            
            if(ans[i]==ind)
            {
                k%=(ans.size()-i);
                
            }
            
            if(k<=0)
            {
                cout<<ans[i];
                return 0;
            }
            k--;
        }
    }
    
    
    
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  int ans = 0;
  for (auto it = cnt.begin(); it != cnt.end(); it++) {
    int a = it->first;
    int b = it->second;
    if (a > b)
      ans += b;
    else
      ans += (b - a);
  }

  cout << ans << endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define MAXN 2000005
using namespace std;
using namespace __gnu_pbds;  

string s;

bool check(string s)
{
	int n=s.size();
	for(int i=0;i<n/2;i++)
	{
		if(s[i]!=s[n-1-i]) return false;
	}
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	int n=s.size();
	bool a = check(s);
	bool b = check(s.substr(0,(n-1)/2));
	bool c = check(s.substr((n+1)/2,(n-1)/2));
	if(a && b && c) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A.at(i).first;
    A.at(i).second = i + 1;
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; ++i) {
    cout << A.at(i).second << endl;
  }
}


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

int main(){
  string S;
  cin >> S;
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }
  else if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

std::string v[100000];
int main() {
  int N, K; std::cin >> N >> K;
  int R, S, P; std::cin >> R >> S >> P;

  for (int i = 0; i < N; ++i) {
    char c; std::cin >> c;
    switch (c) {
      case 'r': v[i%K] += 'p'; break;
      case 's': v[i%K] += 'r'; break;
      case 'p': v[i%K] += 's'; break;
    }
  }

  LL score = 0;
  for (int i = 0; i < K; ++i) {
    for (int j = 1; j < v[i].size(); ++j) {
      if (v[i][j-1] == v[i][j]) v[i][j] = 'x';
    }
    for (char c : v[i]) {
      switch(c) {
        case 'r': score += R; break;
        case 's': score += S; break;
        case 'p': score += P; break;
      }
    }
//    std::cout << v[i] << std::endl;
  }
  std::cout << score << std::endl;
}


Measured memory_bytes: 5120
#include <stdio.h>
using namespace std;
static const int MAX_ARRAY_SIZE = 100;

void trace(int A[], int N) {
    for (int i=0; i<N; i++){
        if (i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertion_sort(int A[], int N){
    int j, i, v;
    for (i=1; i<N; i++) {
        v = A[i];
        j = i-1;
        while (j>=0 && A[j]>v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main() {
    int N, A[MAX_ARRAY_SIZE];

    scanf("%d", &N);
    for (int i=0; i<N; i++) scanf("%d", &A[i]);

    trace(A, N);
    insertion_sort(A, N);

    return 0;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


ll xorsum(ll a){
    ll res = 0;
    ll keta = 0;
    for(ll i=0; i<40; i++){
        ll num1 = 0, mod = (1LL << (keta+1));
        num1 += ((a+1)/mod)*(mod/2);
        if(((a+1)%mod) > mod/2) num1 += ((a+1)%mod) - mod/2;
        res |= ((num1%2)<<keta);
        keta++;
    }
    return res;
}

void solve(){
    ll a, b;
    cin >> a>> b;
    cout << (xorsum(b)^xorsum(a-1)) <<endl;
}

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

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

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


struct yo
{
	ll g;
	int a, n;
	bool operator<(const yo&rhs) const
	{
		return a<rhs.a;
	}
};


void max_u(ll&m, ll v)
{
	if(m<v) m=v;
}


void dump(vvll&dp)
{
	for(auto&mdp:dp)
	{
		for(auto&mmdp:mdp) printf("%2lld ", mmdp);
		printf("\n");
	}
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vector<yo> yoji(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d", &yoji[i].a);
			yoji[i].n=i;
		}
		sort(yoji.rbegin(), yoji.rend());

		vvll dp(n+1);
		for(int i=0;i<=n;i++)
		{
			dp[i].resize(n-i+1);
		}

		for(int i=0;i<n;i++)
		{
			auto&x=yoji[i];
			for(int s=0;s<=i;s++)
			{
				int t=i-s;
				int l=n-1-t;
				max_u(dp[s+1][t  ], dp[s][t]+(ll)abs(x.n-s)*x.a);
				max_u(dp[s  ][t+1], dp[s][t]+(ll)abs(x.n-l)*x.a);
			}
		}
//		dump(dp);

		ll ans=0;
		for(int i=0;i<=n;i++)
		{
			max_u(ans, dp[i][n-i]);
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 18980
#include<iostream>
#include<cmath>
using namespace std;
int a[100010],dp[100010];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=1001010100;
        for(int j=1;j<=k;j++)
        {
            if(i-j<=0)break;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    	
		cout<<dp[n]<<endl;
	
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Teleporter | diff Teleporter.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Teleporter.cpp && ./a.out

/*
 
 5/10/2020
 
 5:12-5:33 AC
 
 https://atcoder.jp/contests/abc167/submissions/13041089
 
 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;
LL K;

int nex[MAX_N][64];
void solve_doubling() {
  REP(i,N) nex[i][0]=A[i];
  REP(x,63)REP(i,N) nex[i][x+1]=nex[nex[i][x]][x];
  
  int res=0;
  REP(i,61)if((K>>i)&1) res=nex[res][i];
  cout<<res+1<<endl;
}

void solve() {
  int pos=0,step=0;
  VI viz(N,-1);
  viz[pos]=0;
  while(K--) {
    pos=A[pos];
    ++step;
    if(viz[pos]==-1) {
      viz[pos]=step;
    } else {
      int cycle=step-viz[pos];
      K%=cycle;
    }
  }
  cout<<pos+1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K;
  REP(i,N) cin>>A[i],A[i]--;
  solve();
  
  return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <string>
int main(int argc, char const *argv[]) {
  std::string S;
  int N,x = 0, max = 0;
  std::cin >> N >> S;
  for (size_t i = 0; i < N; i++) {
    if(S[i] == 'I') x++;
    else x--;
    if(max < x) max = x;
  }
  std::cout << max << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	for(char c : s) {
		if(c == 'R') ++ans;
	}
	int r = ans;
	ans = min(ans, n - ans);
	int ans1 = 0;
	for(int i = 0; i < r; ++i) {
		if(s[i] == 'W') ++ans1;
	}
	cout << min(ans, ans1) << '\n';
	return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int N, T,S;
int A[3000];
int B[3000];
int dp[3001][3001];
int ans = 0;
int main()
{
	scanf("%d%d%d", &N, &T, &S);
	for (int i = 0; i < N; i++)scanf("%d%d", &A[i], &B[i]);
	for (int i = 1; i <= N; i++){
		for (int j = 0; j <= T; j++){
			if (j <= S&&j >= B[i - 1]){
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - B[i - 1]] + A[i - 1]);
			}
			else if (j - B[i - 1] >= S){
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - B[i - 1]] + A[i - 1]);
			}
			else if(j<B[i-1])dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i][j - 1],dp[i-1][j]);
		}
	}
	/*
	for (int i = 1; i <= N; i++){
		for (int j = 0; j <= T; j++){
			printf("%02d ", dp[i][j]);
		}
		printf("\n");
	}*/
	printf("%d\n", dp[N][T]);
	return 0;
}

Measured memory_bytes: 36384
#include<iostream>
#include<string>
#include<map>
#include<algorithm>

using namespace std;

int RepeatString(map<string, string>, const string, const string, int);
void ChangeString(const string, const string, string&);

int main(){
  int i, n, count;
  string a, b, x, y;
  map<string, string> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> a >> b;
      data.insert(make_pair(a, b));
    }
    cin >> x >> y;

    count = RepeatString(data, x, y, 0);
    cout << count << endl;
    data.clear();
  }
  return 0;
}

int RepeatString(map<string, string> data, const string x, const string y, int count){
  if(x == y) return count;
  if(x.size() >= y.size()) return -1;

  int _count, __count;
  string _x;
  map<string, string>::iterator i;

  ++count;
  for(_count=-1, i=data.begin(); i!=data.end(); ++i){
    if(x.find(i->first, 0) != string::npos){
      _x = x;
      ChangeString(i->first, i->second, _x);
      __count = RepeatString(data, _x, y, count);
      if(__count != -1 && (_count == -1 || _count > __count))
	_count = __count;
    }
  }
  return _count;
}

void ChangeString(const string substr1, const string substr2, string& str){
  int i = 0;
  while(1){
    i = str.find(substr1, i);
    if(i == string::npos) return;
    str.erase(i, substr1.size());
    str.insert(i, substr2);
    i += substr2.size();
  }
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

int main()
{
    jaldi
    string s;
    cin>>s;
    string tmp(s.rbegin(),s.rend());
    if(s==tmp)
    {
        string a=s.substr(0,(s.length()-1)/2);
        string b=s.substr(s.length()/2+1);
        string aa(a.rbegin(),a.rend());
        string bb(b.rbegin(),b.rend());
        if(a==aa && b==bb) cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cerr<<#x<<" -> "<<x<<'\n'
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

using ordered_set = tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
struct CMP {
	bool operator() (const T& lhs, const T& rhs) const{
		return lhs < rhs;
	}
};

template <typename T>
T power(T a, T n){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a);
		a = (a * a);
		n >>= 1;
	}
	
	return res;
}

template <typename T>
T power(T a, T n, long long mm){
	T res = 1;
	while(n > 0){
		if(n & 1) res = (res * a) % mm;
		a = (a * a) % mm;
		n >>= 1;
	}
	
	return res;
}

const ll N = 2e5+7;
const ll MOD = 1e9+7;
const ll INF = 2e14+7;


int can[22][22];
ll dp[22][1 << 22];


int alldone, n;

ll solve(int pos, int group){
	if(pos == n){
		if(group == alldone) return 1;
		return 0;
	}
	
	if(dp[pos][group] != -1) return dp[pos][group];
	
	ll ans = 0;
	
	for(int i = 0; i < n; i++){
		if(!((1 << i) & group) && can[pos][i]){
			ans = (ans + solve(pos + 1, (1 << i) | group)) % MOD;
		}
	}
	
	return dp[pos][group] = ans;
}

void testcase(){
	cin>>n;
	alldone = (1 << n) - 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin>>can[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));
	ll ans = solve(0, 0);
	
	cout<<ans<<'\n';
	
}

signed main(){
	fast;
	
	int t = 1;
	//cin>>t;
	while(t--){
		testcase();
	}
	
	return 0;
}


Measured memory_bytes: 721152
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int main(){
    int A;
    int B;
    int T;
    int i=1;
    int out=0;
    cin >> A >> B >> T;
    while(A*i<T+0.5){
        out+=B;
        i++;
    }
    cout << out;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int main(void){
    int N;
    unsigned long long int H[100000];
    cin >> N;

    H[0]=0;

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

    for (int i = 1; i <= N; ++i) {
        int d = H[i]-H[i-1];

        if (d>=1) {
            --H[i];
        }else if(d==0){
            ;
        }else{
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}


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


int main(void){
    // Your code here!
    ll A,B,C,D;
    cin>>A>>B>>C;
    D=C-(A-B);
    if(D>0){
        cout<<D<<endl;
    }else cout<<0<<endl;
}


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

using ll = long long;
#define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(int);

/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  int bars[n];
  ll total = 0;
  REP(i, n) {
    cin >> bars[i];
    total += bars[i];
  }
  ll tmp = 0;
  int index = 0;
  REP(i, n) {
    tmp += bars[i];
    if(2*(tmp+bars[i+1]) >= total) {index = i+1;break;}
  }
  ll anothertmp = total - tmp;
  if(2*(tmp+bars[index]) == total) {
    cout << 0 << endl;
    return 0;
  }
  
  int over = anothertmp - tmp;
  if(over > bars[index]) {
    tmp += bars[index];
    anothertmp -= bars[index];
    over = tmp - anothertmp;
  }
  cout << abs(over);


  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}


Measured memory_bytes: 1792
#include<iostream>
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  string a, b ;
  cin >> a >> b ;
  
  bool cond = 0 ;
  if(a!=b){
  for(int i=0;i<a.size()-1;i++){
   char tmp = a.at(a.size()-1) ;
   a.pop_back() ;
   string tmp2 = tmp + a ;
   if(tmp2==b){
     cond = 1 ;
     break ;
   }
   a = tmp2 ;
  }
  }else{
  cond = 1 ;
  }
   
  if(cond)
   cout << "Yes" << endl ;
  else 
   cout << "No" << endl ;    
  
   return 0;
}


Measured memory_bytes: 256
use proconio::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        ca: [(usize, [usize; m]); n]
    }

    let mut ans = std::usize::MAX;
    for i in 0..(1 << n) {
        let mut up = vec![0; m];
        let mut cost = 0;
        for j in 0..n {
            let (c, a) = &ca[j];
            if (i >> j & 1) > 0 {
                for k in 0..m {
                    up[k] += a[k];
                }
                cost += c;
            }
        }
        let mut ok = true;
        for j in 0..m {
            if up[j] < x {
                ok = false;
                break;
            }
        }
        if ok {
            ans = std::cmp::min(ans, cost);
        }
    }
    if ans == std::usize::MAX {
        println!("-1");
        return;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2164
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////

int main(){

    ll n,k;
    L2(n,k);
    ll ar[n+2];
    for(int i=1;i<=n;i++)L(ar[i]);
    sort(ar+1, ar+n+1);
    ll res = 0;
    for(int i = 1;i<=n-k;i++)res+=ar[i];

    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
  char input[256];
  int n, m, x;
  fgets(input, 255, stdin);
  sscanf(input, "%d", &n);
  while(n > 1000)n = n-1000;
  m = 1000 - n;
  printf("%d", m);
  return 0;
}

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

int main()
{
  // 入力受け取り
  int N;
  int d[100];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> d[i];

  long long ans=0;
  for (int i=0; i< N; i++) {
      for (int j=0; j<N; j++) {
          if (i<j) ans += d[i] * d[j];
      }
  }

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


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i, j, N, A[100], mini, temp, cnt = 0, flag;
  
  scanf("%d", &N);
  
  for(i = 0; i < N; i++)
    scanf("%d", &A[i]);
  
  for(i = 0; i < N - 1; i++){
    mini = i;
    flag = 0;
    for(j = i; j < N; j++){
      if(A[j] < A[mini]){
	mini = j;
	flag = 1;
      }
    }
    temp = A[i];
    A[i] = A[mini];
    A[mini] = temp;
    if(flag == 1)   cnt++;
  }

  for(i = 0; i < N; i++){
    if(0 < i)   printf(" %d", A[i]);
    else        printf("%d", A[i]);
  }
  printf("\n%d\n", cnt);
  
  return 0;
}

Measured memory_bytes: 600
import bisect

n = int(input())
ListL = [int(i) for i in input().split()]

ListL.sort()
ans = 0

for i in reversed(range(2, n)):
	a = ListL[i]
	b = ListL[i-1]
	c = a - b + 1
	indexb = i - 1
	indexc = bisect.bisect_left(ListL, c)
	while(indexb > indexc):
		if (ListL[indexb] + ListL[indexc] > a):
			ans += indexb - indexc
			indexb -= 1
		else:
			b = ListL[indexb]
			c = a - b + 1
			indexc = bisect.bisect_left(ListL, c)

print(ans)

Measured memory_bytes: 3316
# coding=utf-8

N = int(input())

l = [(0,0,0)]
for _ in range(N):
    line = input().split(" ")
    t = int(line[0])
    x = int(line[1])
    y = int(line[2])
    l.append((t, x, y))

def judge(s1, s2):
    t = abs(s1[1]-s2[1])
    t += abs(s1[2]-s2[2])
    diff = (s2[0]-s1[0]) - t

    if diff==0:
        return True
    elif diff<0:
        return False
    else:
        return diff%2==0

for i in range(len(l)-1):
    s1 = l[i]
    s2 = l[i+1]
    if not judge(s1,s2):
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 17384
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), A = sc.nextInt();
		System.out.println((N*N)-A);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35692
N, X, Y = map(int, input().strip().split())
# dist=[[0]*N for _ in range(N)]
X-=1
Y-=1
ans=[0]*(N-1)
for i in range(N):
    for j in range(i):
        # if i==j:
        #     continue
        # dist[i][j]=min(abs(i-j),abs(i-X)+1+abs(j-Y))
        dist=min(abs(i-j),abs(i-Y)+1+abs(j-X))
        ans[dist-1]+=1
# print(dist)
# output
[print(v) for v in ans]

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

int main()
{
	ll n;
	cin>>n;
	ll a[n][3],dp[n][3],i;
	for(i=0;i<n;i++)
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(i=1;i<n;i++)
	{
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
	}
	cout<<max({dp[n-1][0],dp[n-1][2],dp[n-1][1]});
} 

Measured memory_bytes: 4992
#include<stdio.h>
#include<string.h>
#define debug system("PAUSE")

void sort(int [], int);

int main()
{
    int n, i;
    scanf("%d", &n);

    int num[n];
    for (i = 0; i < n; i++)
        scanf("%d", &num[i]);

    sort(num, n);

    int a = 0, b = 0;
    for (i = 0; i < n; i++)
    {
        if (i % 2 == 0)
            a += num[i];
        else
            b += num[i];
    }
    printf("%d\n", abs(a - b));
}


void sort(int a[], int len)
{
    int i, j, temp;

    for (i = 0; i < len - 1; i++)
        for (j = 0; j < len - 1 - i; j++)
            if (a[j] > a[j + 1])
            {
                temp = a[j];
                a[j] = a[j + 1];
                a[j + 1] = temp;
            }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int main(int argc, char *argv[]){
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int x = tx - sx;
    int y = ty - sy;
    rep(i, y) cout << "U";
    rep(i, x) cout << "R";
    rep(i, y) cout << "D";
    rep(i, x) cout << "L";
    cout << "L";
    rep(i, y + 1) cout << "U";
    rep(i, x + 1) cout << "R";
    cout << "DR";
    rep(i, y + 1) cout << "D";
    rep(i, x + 1) cout << "L";
    cout << "U" << endl;
    return 0;
}

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

int main(){
  ll a,b,c,k;cin>>a>>b>>c>>k;
  ll ans=0;
  ll count=k;
  if(a>0) {
    if(a>=count) {
      ans+=count;
      cout <<ans;
      return 0;
    }
    if(a<count) {
      ans+=a;
      count-=a;
    }
  }
  if(b>0) {
    if(b>=count) {
      cout <<ans;
      return 0;
    }
    if(b<count) {
      count-=b;
    }
  }
  if(c>0) {
    ans-=count;
    cout <<ans;
    return 0;
  }
}


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

int main()
{
double a,b,h,m;
cin>>a>>b>>h>>m;
double A=0.5*(h*60+m);
double B=(m/60.0)*360;
double C=abs(B-A);
C=C*(3.14159265358979323846/180.0);
double ans;
ans=pow(a,2)+pow(b,2)-2*a*b*cos(C);
printf("%0.18f", sqrt(ans));
}


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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

vector<vector<int>> g;
vector<char> vis;
vector<int> topsort;

void dfs(int u)
{
    if (vis[u])
        return;
    vis[u] = true;
    for (auto v : g[u])
    {
        dfs(v);
    }
    topsort.PB(u);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    g.resize(n);
    vis.resize(n);
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].PB(v);
    }
    for (int u = 0; u < n; u++)
    {
        dfs(u);
    }
    vector<int> dp(n);
    int ans = 0;
    for (auto u : topsort)
    {
        dp[u] = 0;
        for (auto v : g[u])
        {
            dp[u] = max(dp[u], dp[v] + 1);
        }
        ans = max(ans, dp[u]);
    }
    cout << ans;
    return 0;
}

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

char GetNext(char c) {
    if (c == 'z') {
        return 'a';
    }
    return c + 1;
}

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

    string s;
    cin >> s;

    int n = s.length();

    int k;
    cin >> k;

    for (int i = 0; i < n; ++i) {
        if (s[i] == 'a') {
            continue;
        }
        int dist = 'z' - s[i] + 1;

        if (dist <= k) {
            k -= dist;
            s[i] = 'a';
        } else {
            continue;
        }
    }

    k %= 26;
    while (k > 0) {
        s.back() = GetNext(s.back());
        --k;
    }

    cout << s << endl;

    return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s[0] == '9' || s[1] == '9') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
};


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main(){
  ll n, m;
  cin >> n >> m;
  ll ans;
  if (2*n >= m){
    ans = m / 2;
  } else {
    ans = n;
    m -= 2 * n;
    ans += m / 4;
  }
  cout << ans << endl;
}

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

int main() {
	int n, a[110], cnt = 0;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 1; i < n; ) {
		if (a[i - 1] == a[i]) {
			cnt++;
			i += 2;
		}
		else if (a[i] == a[i + 1]) {
			cnt++;
			i += 3;
		}
		else i++;
	}

	cout << cnt << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

// 1-indexed
class BinaryIndexedTree{
    public:
    ll size;
    vector<ll> bit;

    BinaryIndexedTree(ll n){
        size = n;
        bit = vector<ll>(size + 1, 0LL);
    }

    // Get a_1 + ... + a_idx
    ll getSum(ll idx){
        ll acc = 0;
        while(idx > 0){
            acc += bit[idx];
            idx -= (idx & -idx);
        }
        return acc;
    }

    void add(ll idx, ll x){
        while(idx <= size){
            bit[idx] += x;
            idx += (idx & -idx);
        }
    }
};

// DSL_2_B: verified
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, q; cin >> n >> q;
    BinaryIndexedTree bit(n);
    vector<ll> ans;
    for(ll i=0;i<q;i++){
        ll com, x, y; cin >> com >> x >> y;
        if(com == 0){
            bit.add(x, y);
        }else{
            if(x == 1) ans.push_back(bit.getSum(y));
            else ans.push_back(bit.getSum(y) - bit.getSum(x - 1));
        }
    }
    for(ll a: ans) cout << a << endl;
}


Measured memory_bytes: 4208
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a = INT()
s = input()

print("red" if a < 3200 else s)


Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double w,h,x,y;
  cin>>w>>h>>x>>y;
  double v = (w*h)*0.5;
  int a = 0;
    if ((w - x) == x && (h-y) ==y) a=1;
    cout << v<<" "<<a<<endl;
}

Measured memory_bytes: 384
N = int(input())
A = sorted(list(map(int,input().split())))
B = (10**6+1)*[0]

for a in A:
  B[a]+=1
  if B[a]==1:
    for n in range(2*a,10**6+1,a):
      B[n]+=2

print(B.count(1))

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

int main()
{
    int n, m;

    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 1; i <= m; i++){
        for (int j = 0; j < n - 1; j++){
            if (a[j + 1] % i < a[j] % i) swap(a[j + 1], a[j]);
        }
    }

    for (int i = 0; i < n; i++) cout << a[i] << endl;

    return 0;
}

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


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

    int N;
    cin >> N;
    int result = 0;
    for(int i = 1; i <= N; i++)
    {
	int num;
	cin >> num;

	result += (i%2 && num%2);
    }

    std::cout << result << "\n";
    
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

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

  double ans = 0;
  for (int i = 1; i <= n; i++) {
    double p = 1;
    int x = i;
    while (x < k) {
      p *= 0.5;
      x *= 2;
    }
    ans += p / n;
  }

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

  return 0;
}

Measured memory_bytes: 3176
import java.util.Scanner;
     
    class Main{
    	public static void main(String arg[]) {
    		Scanner sc = new Scanner(System.in);
    		int N = sc.nextInt();
    		sc.nextLine();
    		String s = sc.nextLine();
    		String[]S = s.split("");
    		sc.close();
    		int count = 0;
    		
    		for(int i = 1; i < N; i++) {
    			if(S[i].equals("E")) {
    				count++;
    			}
    		}

    		int min = count;
    		for(int i = 1; i < N; i++) {
				if(S[i-1].equals("W")) {
    				count++;
				}
				if(S[i].equals("E")) {
    				count--;
				}
    			min = Math.min(min, count);
    		}
    		System.out.println(min);
    	}
    }

Measured memory_bytes: 52988
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    int x;
    cin >> x;
    for(ll i=360;i<=360000000000LL;i+=360){
        if(i%x==0){
            cout << i/x << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3192
import sys
a=input()
b=input()
for i in reversed(range(len(a)-len(b)+1)):
  t=True
  for j in range(len(b)):
    if not(a[i+j]=="?") and not(a[i+j]==b[j]):
      t=False
      break
  if t:
    for p in range(i):
      if a[p]=="?":
        print("a",end="")
      else:
        print(a[p],end="")
    print(b,end="")
    for w in range(i+len(b),len(a)):
      if a[w]=="?":
        print("a",end="")
      else:
        print(a[w],end="")
    sys.exit()
print("UNRESTORABLE")


Measured memory_bytes: 3064
letterlist = ['M', 'A', 'R', 'C', 'H']
countlist = [0, 0, 0, 0, 0]
N = int(input())
for i in range(0, N):
	S = input()
	for j in range(0, 5):
		if S[0] == letterlist[j]:
			countlist[j] += 1
sum = 0
for i in range(0, 5):
	for j in range(i+1, 5):
		for k in range(j+1, 5):
			sum += countlist[i]*countlist[j]*countlist[k]
print(sum)

Measured memory_bytes: 45784
import bisect

n = int(input())
ll = list(map(int, input().split()))
ll.sort()

ans = 0
for i in range(n-2):
    e1 = ll[i]
    for j in range(i+1, n-1):
        e2 = ll[j]
        ans += bisect.bisect_left(ll[j+1:], e1+e2)

print(ans)

Measured memory_bytes: 52444
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,d;
   int m,r;
   cin>>a>>b>>c>>d;
   if(a>b)
   {
      m=b*c;
      r=(a-b)*d;
      cout<<m+r;
   }
   else if(b>a)
   {
       m=a*c;
       cout<<m;
   }
   else if(a==b)
   {
       m=b*c;
       cout<<m;
   }

    return 0;
}


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

using namespace std;

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

typedef long long ll;

void solve() {
  int n, t; cin >> n >> t;
  set<int> st;
  vector<int> vt(n);
  for (int i = 0; i < n; i++) {
    cin >> vt[i];
    st.insert(vt[i]);
  }
  int mx = 0, cnt = 0;
  for (int i = 0; i + 1 < n; i++) {
    st.erase(vt[i]);
    int v = *st.rbegin();
    if (vt[i] < v) {
      if (mx < v - vt[i])
        mx = v - vt[i], cnt = 1;
      else if (mx == v - vt[i])
        cnt++;
    }
  }
  cout << cnt;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 8336
#include <bits/stdc++.h>
#define mx 100035
int a[mx],n,l,t,x,cnt;

int main(){
    scanf("%d%d%d",&n,&l,&t);
    for (int i=1; i<=n; i++){
        scanf("%d%d",&a[i],&x);
        if(x==1)
        	a[i]+=t;
        else
        	a[i]-=t;
        cnt += a[i]/l;
        if(a[i]%l<0) cnt--;//就是这里细节的处理
        a[i]=((a[i]%l)+l)%l;
    }
    std::sort(a+1,a+n+1);
    cnt=((cnt%n)+n)%n;
	for(int i=cnt+1; i<=n; i++)
		printf("%d\n",a[i]);
    for(int i=1; i<=cnt; i++)
		printf("%d\n",a[i]);
    return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
long long int dp[300020] = {};
int main() {
	long long int a, b;
	cin >> a >> b;
	int keta = 0;
	long long int c = b;
	while (c > 0) {
		c = c / 2;
		keta++;
	}
	long long int  d = 1;
	long long int  e = 2;
	long long int ans = 0;
	for (int i = 0; i < keta; i++) {
		long long int sum1 = 0;
		long long int sum2 = 0;
		sum1 = a / e * d;
		if (a % e - d > 0) {
			sum1 = sum1 + a % e - d;
		}
		sum2 = (b+1) / e * d;
		if ((b+1) % e - d > 0) {
			sum2 = sum2 + (b+1) % e - d;
		}
		ans = ans + d * ((sum2 - sum1)%2);
		d = d * 2;
		e = e * 2;
	}
	cout << ans;
}

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



const double eps = 1e-10;
int sgn(double x) {
    if(fabs(x) < eps) return 0;
    return x < 0 ? -1 : 1;
}
struct Point {
    double x, y;
    Point(double xp=0, double yp=0): x(xp), y(yp) { }
    Point operator + (const Point& rhs) const { return Point(x+rhs.x, y+rhs.y); }
    Point operator - (const Point& rhs) const { return Point(x-rhs.x, y-rhs.y); }
    Point operator * (const double& k) const { return Point(x*k, y*k); }
    Point operator / (const double& k) const { return Point(x/k, y/k); }
    bool operator < (const Point& rhs) const {
        return x < rhs.x || (x==rhs.x && y<rhs.y);
    }
};

double dot(Point x, Point y) { return x.x*y.x + x.y*y.y; }
double length(Point x) { return sqrt(dot(x, x)); }
double cross(Point A, Point B) { return A.x*B.y - A.y*B.x; }


Point LineProjection(Point P, Point A, Point B) {
    Point v = B - A;
    return A + v * (dot(P-A, v) / dot(v, v));
}

Point LineReflection(Point P, Point A, Point B) {
    Point proj = LineProjection(P, A, B);
    return proj + proj - P;
}

int main() {
    Point a, b, p, ans;
    scanf("%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y);
    int q; scanf("%d", &q);
    while(q--) {
        scanf("%lf%lf", &p.x, &p.y);
        ans = LineReflection(p, a, b);
        printf("%.12f %.12f\n", ans.x, ans.y);
    }
    
    return 0;
}


Measured memory_bytes: 3232
#include <iostream>

using namespace std;

int main(){
    string N;
    cin >> N;
    if(N[0] == N[1] && N[1] == N[2]){
        cout << "Yes" << endl;
    }
    else if(N[1] == N[2] && N[2] == N[3]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
function main(arg) {
	arg = arg.trim().split(' ');
  	arg = arg.map(str => parseInt(str, 10));
  	var a = arg[0], b = arg[1] * 2;
  	if (a <= b) {
    	console.log(0);
    } else {
    	console.log(a-b);
    } 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        int ans = 0;
        for (int i = 0; i < N; i++) {
            int x = sc.nextInt();

            if (x <= (int) Math.abs(x - K)) {
                ans += x * 2;
            } else {
                ans += (int) Math.abs(x - K) * 2;
            }
        }

        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 36100
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run(){
		for(;;){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m) == 0){
				break;
			}
			
			int a[] = new int[21];
			int b[] = new int[21];
			 
			
			int sum = 0;
			for(int i = 0; i < n; i++){
				int z =  sc.nextInt();
				a[z]++;
				sum+=z;
			}
			
			for(int i = 0; i < m ; i++)
			{
				int z =  sc.nextInt();
				b[z]++;
				sum+=z;
			}
			
			for(int i = 0; i < 21;i++){
				sum -= Math.min(a[i], b[i])*i;
			}
			
			
			System.out.println(sum);
			
		}
	}
	
	public static void main(String[] a) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 0