akhauriyash/Code-Regression huggingface dataset:
/// Bismillahir Rahmanir Rahim
/// S. M. Shakir Ahsan Romeo

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

const double PI = acos(-1.0);

typedef long long lng;
typedef unsigned long long ulng;
typedef double db;
typedef pair < int, int >  pii;
typedef vector < pii >  vpii;
//typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

inline int getint()
{
    int x;
    scanf("%d", &x);
    return x;
}
#define II getint()

inline long long getlng()
{
    long long x;
    scanf("%lld", &x);
    return x;
}
#define LL getlng()

int dx4[] = {-1, 0, 1, 0};
int dy4[] = {0, 1, 0, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


void solve();
#define theromeo421 main()
#define segtree int lft = node << 1, rgt = lft | 1, mid = (b + e) >> 1;
#define mem(x, y) memset((x), (y), sizeof (x));
#define sz(x) ((int)x.size())
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define pr1(x) cout << x << endl
#define pr2(x,y) cout << x << ' ' << y << endl
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep1(i, n) for(int i = 1; i <= n; ++i)
#define repstl(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define forcon(pp , qq) for(const auto& pp : qq)
#define all(x) (x).begin(), (x).end()
#define Unique(x) sort(all(x)); x.erase(unique(all(x)), x.end()); /// x needs to be sorted first
#define pb push_back
#define wait system("pause")
#define xx first
#define yy second
#define dbg(x) cerr << #x << "=" << x << endl;
#define dbg2(x, y) cerr << #x << "=" << x << ", " << #y << "=" << y << endl;
#define read(a) freopen(a, "r", stdin);
#define write(a) freopen(a, "w", stdout);
#define prv(v) rep(i, sz(v)) cout << v[i] << " \n"[i + 1 == v.size()];
#define Case int T; scanf("%d", &T); for(int cas = 1; cas <= T; ++cas)
#define pf printf
#define sf scanf
#define MP make_pair
#define endl '\n'
const double eps = (double)1e-9;


int theromeo421
{
    /// PLEASE HACK my code, I am error prone.
    /// Your hack can save me from the cruel hand of system testing. :) :P ;)
    solve();
#ifdef romeo
    cerr << "\nElapsed time: " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif // romeo
    return 0;
}


void solve()
{
    lng a, b; cin >> a >> b; lng c = a * b;
    if(c % 2 == 0) cout << "Even"; else cout << "Odd"; cout << endl;
}


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

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

/*-------------------------------------------*/

int n;

int main(){
    cin>>n;
    rep(i,n+1){
        if(i*108/100==n){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":(\n";
}

Measured memory_bytes: 256
# imos解
n,d,a=map(int,input().split())
xh=[]
for i in range(n):
  xx,hh=map(int,input().split())
  xh.append([xx,hh])
xh.sort(key=lambda x:x[0])
xl=[x for x,h in xh]
# print(xh)
from math import ceil
from bisect import bisect_right

ans=0
damage=[0]*(n+1)

for i in range(n):
  x,h=xh[i]
  if damage[i]<h:
    need=ceil((h-damage[i])/a)
    right=x+2*d
    # 爆発に巻き込まれる範囲の右端のindexを取得する
    r_idx=bisect_right(xl,right)
    # imosしながら爆発させる
    damage[i]+=need*a
    damage[r_idx]-=need*a
    ans+=need
  # imosの累積和を取る
  damage[i+1]+=damage[i]
print(ans)


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

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

	vector<int> dp(n + 1);
	vector<int> h(n + 1);
	h[0] = 0;
	for (int i = 1; i < n+1; i++) {
		cin >> h[i];
	}
	dp[1] = 0;
	for (int i = 2; i < n + 1; i++) {
		dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
		for (int j = 1; j <= k; j++) {
			if (i - j >= 1 && dp[i] > dp[i - j] + abs(h[i - j] - h[i])) {
				dp[i] = dp[i - j] + abs(h[i - j] - h[i]);
			}
		}
	}
	int ans = dp[n];
	cout << ans << endl;
}

Measured memory_bytes: 4056
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))


ll n;
ll a[5];
int main(){
	scanf("%lld",&n);
	rep(i,0,n){
		char s[99];
		scanf("%s",s);
		switch(s[0]){
			case 'M':a[0]++;break;
			case 'A':a[1]++;break;
			case 'R':a[2]++;break;
			case 'C':a[3]++;break;
			case 'H':a[4]++;break;
		}
	}
	ll ans=0;
	rep(i,0,5)rep(j,i+1,5)rep(k,j+1,5)ans+=a[i]*a[j]*a[k];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;


int main(void) {

  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++) cin >> d[i];
  map<int, int> mp;
  for(int i=0; i<n; i++){
    mp[ d[i] ]++;
  }

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

  for(int i=0; i<m; i++){
    if( mp[ t[i] ] == 0 ){
      cout << "NO" << endl;
      return 0;
    }else{
      mp[t[i]]--;
    }
  }
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 11264
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

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

int N, Q, Score[int(2e5 + 5)];
bool visited[int(2e5 + 5)];
vector <int> Graph[int(2e5 + 5)];

int main(){
  scanf("%d%d", &N, &Q);
  for (int i = 0; i < N - 1; i++){
    int A, B; scanf("%d%d", &A, &B);
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }
  for (int i = 0; i < Q; i++){
    int P, X; scanf("%d%d", &P, &X);
    Score[P] += X;
  }
  
  queue <int> que;
  que.push(1); visited[1] = true;

  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int i = 0; i < Graph[Q].size(); i++){
      int next = Graph[Q][i];
      if (visited[next]) continue;
      visited[next] = true;
      Score[next] += Score[Q];
      que.push(next);
    }
  }
  
  for (int i = 1; i <= N; i++){
    cout << Score[i];
    if (i == N) cout << endl;
    else cout << " ";
  }
  
  return 0;
}


Measured memory_bytes: 15732
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define _USE_MATH_DEFINES
# define M_PI 3.14159265358979323846
# define MOD 1000000007
#define ll long long int
#define pii pair<ll, ll>
#define pb push_back
#define MIN -9,223,372,036,854,775
#define N 100005
void solve(){
    ll i,j,k,n,x,y,f,c=0;
    cin>>n;
    vector<ll> v(n);
    map<ll, ll> m;
    for(i=0;i<n;i++){
        cin>>v[i];
        m[v[i]]++;
    }

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

    v.erase(unique(v.begin(),v.end()),v.end());
    n=v.size();
    for(i=0;i<n-2;i<i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                if( v[k]<v[i]+v[j] ){
                    c += m[v[i]] * m[v[j]] * m[v[k]];

                }
            }
        }
    }
    cout<<c;
}

int main() {
    ll t;
	//cin>>t;
	t=1;
	while( t-- ){
	    solve();
	    cout<<"\n";
	}

	return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N,M,Q;
  while(cin >> N >> M >> Q){
    vector<string> s(N); cin >> s;

    vector<vector<int>> v(N+1, vector<int>(M+1));
    REP(i,N) REP(j,M) v[i+1][j+1] = s[i][j]-'0';

    REPE(i,N) REP(j,M) v[i][j+1] += v[i][j];
    REPE(j,M) REP(i,N) v[i+1][j] += v[i][j];

    vector<vector<int>> e(N+1, vector<int>(M+1));
    vector<vector<int>> e_hor(N+1, vector<int>(M+1));
    vector<vector<int>> e_ver(N+1, vector<int>(M+1));
    
    REP(i,N) REP(j,M){
      if(i<N-1 and s[i][j]=='1' and s[i+1][j]=='1'){
	++e[i+1][j+1];
	++e_hor[i+1][j+1];
      }
      if(j<M-1 and s[i][j]=='1' and s[i][j+1]=='1'){
	++e[i+1][j+1];
	++e_ver[i+1][j+1];
      }
    }
    
    REPE(i,N) REP(j,M) e[i][j+1] += e[i][j];
    REPE(j,M) REP(i,N) e[i+1][j] += e[i][j];

    REPE(i,N) REP(j,M) e_hor[i][j+1] += e_hor[i][j];
    REPE(j,M) REP(i,N) e_ver[i+1][j] += e_ver[i][j];
    
    REP(i,Q){
      int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;

      int cnt_v = v[x2][y2]-v[x1-1][y2]-v[x2][y1-1]+v[x1-1][y1-1];

      int cnt_e = e[x2][y2]-e[x1-1][y2]-e[x2][y1-1]+e[x1-1][y1-1] - (e_hor[x2][y2]-e_hor[x2][y1-1]) - (e_ver[x2][y2]-e_ver[x1-1][y2]);

      int ans = cnt_v - cnt_e;
      cout << ans << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
int a;
int main() 
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='+') a++;
        else if (s[i]=='-') a--;
    }
    cout<<a<<endl;
   return 0;
}

Measured memory_bytes: 256
//  amiD
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000
#define int_inf 1000000000
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define se second
#define fi first
using namespace std;
ll a[33];
int main(){
    ll mx=0, k;
    for(int i=0;i<3;i++)cin>>a[i];
    sort(a,a+3);
    cin>>k;
    ll amid=0;
    while(k--){
        a[2]*=2;
    }
    for(int i=0;i<3;i++)amid+=a[i];
    cout<<amid<<endl;
}


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

int main(){
    int dp[1000005][2];
    string s; cin>>s;
    reverse(s.begin(),s.end());
    s += '0';
    int n = s.size();
    rep(i,n+1)rep(j,2) dp[i][j] = 1e9;
    dp[0][0] = 0;
    rep(i,n)rep(j,2){
        int x = (s[i] - '0') + j;
        if(x<10) chmin(dp[i+1][0], dp[i][j] + x);
        if(x>0) chmin(dp[i+1][1], dp[i][j]+(10-x));
    }
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 12072
#include <vector>
#include <map>
#include <iostream>
#define M make_pair
#define F first
#define S second
using namespace std;
typedef vector<pair<
	pair<
		pair<int,int>,
		pair<int,int>
	>,string
> >links;
main(){
	int N,n,x,y,X,Y,cur;
	string s,t;
	for(;cin>>N>>x>>y;){
		map<string,links>m;
		vector<string>visit;
		for(cur=-1;N;N--){
			links v;
			for(cin>>s>>n;n;n--)cin>>x>>y>>X>>Y>>t,v.push_back(M(M(M(x,X),M(y,Y)),t));
			if(m[s]=v,cur==-1)visit.push_back(s),cur=0;
		}
		for(cin>>N;N;N--){
			if(cin>>s,s=="show")cout<<visit[cur]<<endl;
			if(s=="back"&&cur>0)cur--;
			if(s=="forward"&&cur<visit.size()-1)cur++;
			if(s=="click"){
				cin>>x>>y;
				links v=m[visit[cur]];
				for(n=0;n<v.size();n++){
					if(v[n].F.F.F<=x&&x<=v[n].F.F.S && v[n].F.S.F<=y&&y<=v[n].F.S.S){
						for(;cur<visit.size()-1;)visit.erase(visit.begin()+cur+1);
						visit.push_back(v[n].S);cur++;
					}
				}
			}
		}
	}
}

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

int main() {
    int n,k;
    cin >> n >> k;
    
    vector<int> p(n);
    for (int i = 0; i < n; i++){
        cin >> p.at(i);
    }

    vector<long long> p_sum(n);
    p_sum[0]=p[0];
    for (int i = 1; i < n; i++){
        p_sum[i]=p_sum[i-1]+p[i];
    }

    long long maxp_sum=p_sum[k-1];
    for (int i = 0; i < n-k; i++){
        maxp_sum=max(maxp_sum,p_sum[k+i]-p_sum[i]);
    }
    double ans=0.5*(double)k+(double)maxp_sum/2.0;

    cout << fixed << setprecision(13) << ans << endl;
}


Measured memory_bytes: 5636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int N, M;
int A[100];
int main(void){
    cin >> N >> M;
    double c = 0;
    REP(i,N) {
        cin >> A[i];
        c+= A[i];
    }
    int count = 0;
    REP(i,N){
        if (A[i] >= c/double(4*M)) count++;
    }
    if(count >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

int main(){
    string s;
    string t;
    cin >> s;
    cin >> t;
    int N = t.length();
    string t2 = t+t;
    for(int i = 0; i < N; ++i ){
        int result = s.compare(t2.substr(i, N));
        if (result == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 888
#include <stdio.h>
int main(void){
    int n,i,sum=0;
    scanf("%d",&n);
    int a[n],b[n],c[n-1];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) scanf("%d",&b[i]);
    for(i=0;i<n-1;i++) scanf("%d",&c[i]);
    for(i=0;i<n;i++){
        sum+=b[a[i]-1];
        if(a[i]+1==a[i+1]) sum+=c[a[i]-1];
    }
    printf("%d",sum);
    return 0;
}

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

ll n;
vector<ll>a;
map<ll,ll>s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
        s[a[i]]++;
        }
    sort(all(a));
    ll mx=a[n-1];
    ll res=0;
    set<ll>se;
    rep(i,n){
        if(s[1]>1){
            cout<<0<<endl;
            return 0;
        }
        if(s[1]==1){
            cout<<1<<endl;
            return 0;
        }
        if(se.count(a[i])!=0)continue;
        for(ll cur=a[i];cur<=mx;cur+=a[i]){  
            se.insert(cur);
        }
           if(s[a[i]]==1) res++;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 55680
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		vector<long long> xs(n);
		for(int i=1;i<n;i++){
			int x; cin>>x;
			xs[i]=xs[i-1]+x;
		}
		long long res=0;
		int cur=0;
		for(int i=0;i<m;i++){
			int x; cin>>x;
			res+=abs(xs[cur+x]-xs[cur]);
			cur+=x;
		}
		cout<<res%100000<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll 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] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////



int main() {
	ll a, v, b, w;
	ll t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	if (v <= w) {
		cout << "NO" << endl;
	}
	else {
		if (a - b < 0) {
			ll dim = b - a;
			if (dim<=t*(v-w))cout << "YES" << endl;
			else cout << "NO" << endl;
		}
		else {
			ll dim = a - b;
			if (dim<=(v - w)*t)cout << "YES" << endl;
			else cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3700
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

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

        int sum = accumulate(a.begin(), a.end(), 0);
        int k = 1;
        while(k * (k+1) / 2 < sum)
            ++ k;
        if(k * (k+1) / 2 != sum){
            cout << -1 << endl;
            continue;
        }

        vector<int> goal(k);
        for(int i=0; i<k; ++i)
            goal[i] = i + 1;

        int ret = -1;
        for(int t=0; t<=10000; ++t){
            if(a == goal){
                ret = t;
                break;
            }

            vector<int> b;
            for(unsigned i=0; i<a.size(); ++i){
                if(a[i] > 1)
                    b.push_back(a[i] - 1);
            }
            b.push_back(a.size());

            a.swap(b);
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 1256
import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


if __name__ == "__main__":
    n, k = LI()
    X = LI()
    l_count = sum((x <= 0 for x in X))
    r_count = n - l_count

    if l_count == 0:
        print(X[k-1])
    elif r_count == 0:
        print(abs(X[-k]))
    else:
        times = []
        for i in range(l_count):
            try:
                left = X[l_count - i - 1]
                right = X[l_count + k - i - 2]
                times.append(abs(2 * left) + abs(right))
                times.append(abs(left) + abs(2 * right))
            except:
                continue
        print(min(times))


Measured memory_bytes: 14660
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
ans=0
for i in range(n-1):
  if a[i]<x:
    ans+=1
    x-=a[i]
  elif a[i]==x:
    x=0
    ans+=1
    break
  else:
    x=-1
    break
if a[n-1]==x:
  ans+=1
print(ans)

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	inline int ts(char *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 103;

int n,m;char s[_];
lint tim;
vector<int> got;

int main()
{
	n=ts(s+1),tim=ty();
	for(int i=2,cnt=1;i<=n+1;i++){if(s[i]==s[i-1])cnt++;else got.emplace_back(cnt),cnt=1;}
	
	m=got.size();
	if(m<=1)
	{
		printf("%lld\n",tim*got[0]/2);
		return 0;
	}
	if(s[1]==s[n])
	{
		lint sum=0;
		for(int i=1;i<m-1;i++)sum+=got[i]/2;
		printf("%lld\n",got[0]/2+sum*tim+got[m-1]/2+(got[0]+got[m-1])/2*(tim-1));
		return 0;
	}
	lint sum=0;
	for(int i=0;i<m;i++)sum+=got[i]/2;
	printf("%lld\n",sum*tim);

	return 0;
}


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

const int MN = 200010;

int N, K;
string S;
int chk[MN];

void print(int pos, int Xor) {
    for(int i = 0; i < N; i++) {
        cout << (((S[pos] == 'A') ^ Xor ^ chk[pos])? 'A' : 'B');
        pos = (pos + 1) % N;
    }
    cout << endl;
}

int main() {
    std::ios::sync_with_stdio(false);

    cin >> N >> K >> S;

    if(S[0] == 'A') S[0] = 'B', K--;

    int pos = 0;
    int Xor = 0;
    for(int i = 0; i < N; i++) {
        if(!K) break;

        //print(pos, Xor);

        K--;
        if(K && (S[ (pos + 1) % N ] == 'A') ^ Xor ^ 1) {
            chk[ (pos + 1) % N ] = 1;
            K--;
        }
        pos = (pos + 1) % N;
        Xor ^= 1;
    }

    if(!K) {
        print(pos, Xor);
        return 0;
    }

    int tot = 0;
    for(int i = 0; i < N; i++) {
        if(!K) break;

        //print(pos, Xor);

        K--;
        tot++;
        if(K &&(S[ (pos + 1) % N ] == 'A') ^ Xor ^ 1 ^ chk[ (pos + 1) % N ]) {
            chk[ (pos + 1) % N ] ^= 1;
            K--;
            tot++;
        }
        pos = (pos + 1) % N;
        Xor ^= 1;
    }

    K %= tot;
    for(int i = 0; i < N; i++) {
        if(!K) break;

        //print(pos, Xor);

        K--;
        if(K &&(S[ (pos + 1) % N ] == 'A') ^ Xor ^ 1 ^ chk[ (pos + 1) % N ]) {
            chk[ (pos + 1) % N ] ^= 1;
            K--;
        }
        pos = (pos + 1) % N;
        Xor ^= 1;
    }

    print(pos, Xor);
}


Measured memory_bytes: 1560
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        int m=sc.nextInt();
        int f=sc.nextInt();
        int r=sc.nextInt();
        int p=(m+f);
        if(m==-1&f==-1&r==-1) {
            break;
        }
        if(30>p) {
            System.out.println("F");
        }
        else if(m==-1) {
            System.out.println("F");
        }
        else if(f==-1) {
            System.out.println("F");
        }
        else if(50>p&p>=30&r>=50) {
                System.out.println("C");
        }
        else if(65>p&p>=50) {
            System.out.println("C");
        }
        else if(50>p&p>=30) {
            System.out.println("D");
        }
        else if(80>p&p>=65) {
            System.out.println("B");
        }
        else if(p>=80){
            System.out.println("A");
        }
        else {
        }
 
        }
    }
}


Measured memory_bytes: 26364
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n, m;

void solve(){
    cin >> n;
    ll arr[n];
    unordered_map<ll, ll> m;
    for(auto &i : arr){
        cin >> i;
        m[i]++;
    }
    ll occr[n + 1], prefix[n + 1];
    occr[0] = 0;
    prefix[0] = 0;
    for(ll i = 1; i <= n; i++){
        ll _occr = m[i];
        occr[i] = (_occr * (_occr - 1)) / 2;
    }
    for(ll i = 1; i <= n; i++)
        prefix[i] = prefix[i - 1] + occr[i];
    for(ll k = 1; k <= n; k++){
        ll num = arr[k - 1];
        ll _occr = m[num] - 1;
        if(_occr < 0)
            _occr = 1;
        ll curr = (_occr * (_occr - 1)) / 2;
        // trace(curr);
        cout << prefix[num - 1] + (prefix[n] - prefix[num]) + curr << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 15560
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  ll n ;cin >>n;
  ll ans=1000000000001;
  for(int i=1;i<1000001;i++){
    if(n%i==0) ans =min(ans,i-1+n/i-1);
  }
  cout<<ans<<endl;
  
}
  

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

string s;

int main(){
	while(getline(cin,s)){
		rep(i,s.size()){
			if(s[i]=='@'){
				rep(j,s[i+1]-'0') cout<<s[i+2];
				i+=2;
			}
			else cout<<s[i];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 999999999
using namespace std;



int main(){
	int n, a = 0, b = 0, c = 0,i, j, k;
	int p[999][3] = { 0 };
	int ans[999] = { 0 };
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> p[i][0] >> p[i][1] >> p[i][2];
	}
	for (i = 0; i < 3; i++) {
		for (j = 0; j < n; j++) {
			int count = 0;
			for (k = 0; k < n; k++) {
				if (p[j][i] == p[k][i]) count++;
			}
			if (count == 1) ans[j] += p[j][i];
		}
	}
	for (i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Map <Long,Long> mapA = new HashMap<Long,Long> ();
		Map <Long,Long> mapB = new TreeMap<Long,Long> ();
 
		Scanner sc = new Scanner(System.in);
			// 整数の入力
			long n,a,a2,b,d,r,m,max,num1,num2,num3,index,index2,time;
			long result1,result2;
			String result;
			
			n = sc.nextLong();
			for(index=0;index<n;index++) {
				a = sc.nextLong();
				b = sc.nextLong();				
				mapA.put(index, a);
				if(mapB.containsKey(b)){
					index2=mapB.get(b);
					a2=mapA.get(index2);
					mapA.put(index2, a+a2);
				}
				else{
					mapB.put(b, index);
				}
			}
			sc.close();
			result="Yes";
			time=0;
			for(long key : mapB.keySet()) {
				index=mapB.get(key);
				a=mapA.get(index);
				time=time+a;
				if(time>key) {
					result="No";
					break;
					}
				}
			
			System.out.println(result);
			
 
			// 出力
 
	}
}

Measured memory_bytes: 164216
#include <bits/stdc++.h>
using namespace std;
long long n,test,black,res,k,h,w;
char s[10][10];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);


    //cin>>test;
    test=1;
    res=0;
    while (test--)
    {
        cin>>h>>w>>k;
        for (int i=0;i<h;i++)
        for (int j=0;j<w;j++) cin>>s[i][j];
        //cout<<s[1][2]<<endl;
        for (int r=0;r<(1<<h);r++)
        for (int c=0;c<(1<<w);c++)
        {
            black=0;
            for (int i=0;i<h;i++)
            for (int j=0;j<w;j++)
            if (s[i][j]=='#' && ((r>>i)&1)==0 && ((c>>j)&1)==0 ) black++;
            //cout<<black<<" "<<r<<" "<<c<<endl;
            if (black==k) res++;
        }
        cout<<res<<endl;
    }


 }

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

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<pii> cb(m);
  for (int i = 0; i < m; i++) {
    cin >> cb[i].second >> cb[i].first;
  }
  sort(a.begin(), a.end());
  sort(cb.begin(), cb.end(), greater<pii>());
  int base = 0;
  ll sum = 0;
  int j = 0;
  bool check = true;
  for (int i = 0; i < n; i++) {
    if (check && j < m && i >= cb[j].second + base) {
      base = i;
      j++;
    }
    if (j >= m)
      check = false;

    if (check && cb[j].first > a[i]) {
      sum += cb[j].first;
    } else {
      check = false;
      sum += a[i];
    }
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 2560
import java.util.*;
import java.io.*;
public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String n = sc.next();
   char[] s = n.toCharArray();
   int calc = 0;
   boolean rain = false;
   for(int i=0;i<3;i++){
     if (s[i]=='R') {
       rain =true;
       if (i<2) {
       if(s[i+1]=='R'){
         calc++;
       }
      }
     }
   }
   if (rain) {
    System.out.println(calc+1);
   }
   else{
     System.out.println(0);
   }

  }
}


Measured memory_bytes: 35616
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = n-1; i >= 0; i--) {
        if (i < n-1) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3096
# coding: utf-8

c1 = {1:[0]*10,2:[0]*10,3:[0]*10}
c2 = {1:[0]*10,2:[0]*10,3:[0]*10}
c3 = {1:[0]*10,2:[0]*10,3:[0]*10}
c4 = {1:[0]*10,2:[0]*10,3:[0]*10}

n = int(input())

for i in range(n):
    b,f,r,v = input().rstrip().split(" ")
    if int(b) == 1:
        c1[int(f)][int(r)-1] = c1[int(f)][int(r)-1] + int(v)
    elif int(b) == 2:
        c2[int(f)][int(r)-1] = c2[int(f)][int(r)-1] + int(v)
    elif int(b) == 3:
        c3[int(f)][int(r)-1] = c3[int(f)][int(r)-1] + int(v)
    else:
        c4[int(f)][int(r)-1] = c4[int(f)][int(r)-1] + int(v)


for i in (1,2,3):
    result = " " + str(c1[i][0])
    for j in range(1,10):
        result = result + " " + str(c1[i][j])
    print(result)
print("####################")
for i in (1,2,3):
    result = " " + str(c2[i][0])
    for j in range(1,10):
        result = result + " " + str(c2[i][j])
    print(result)
print("####################")
for i in (1,2,3):
    result = " " + str(c3[i][0])
    for j in range(1,10):
        result = result + " " + str(c3[i][j])
    print(result)
print("####################")
for i in (1,2,3):
    result = " " + str(c4[i][0])
    for j in range(1,10):
        result = result + " " + str(c4[i][j])
    print(result)

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

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

const int SZ=20005;
bool isInfected[SZ];
pair<int,P> p[SZ];

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

    int n,m;
    while(cin>>n>>m,n)
    {
	REP(i,n) isInfected[i]=false;
	isInfected[0]=true;

	REP(i,m){
	    int t,s,d;
	    cin>>t>>s>>d;
	    s--; d--;
	    p[i]=make_pair(t,P(s,d));
	}
	sort(p,p+m);

	REP(i,m){
	    int s=p[i].second.first;
	    int d=p[i].second.second;
	    if(isInfected[s]) isInfected[d]=true;
	}
	
	int ans=0;
	REP(i,n) if(isInfected[i]) ans++;
	cout<<ans<<endl;
    }
}



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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) s.begin(), s.end()
#define SZ(s) s.size()

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.length()) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans;
    return 0;
}


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

using namespace std;
using LLONG = long long;

int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    if (B <= A)
    {
        cout << "delicious" << endl;
    }
    else if (B <= A + X)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#134d
import math
 
#input
#3
#1 0 0
#output
#1
#1
 
N = int(input()) #1≤N≤2×10^5
 
#Nの後半は入力と一致するので直接代入   
ans = list(map(int, input().split()))
 
#N 個の空の箱が横一列に並んでいます。 左から i  (1≤i≤N) 番目の箱には整数 iが書かれています。
#それぞれの箱に対してボールを 1個入れるか何も入れないかを選ぶことができます。
#ここで、以下の条件を満たすようなボールの入れ方を、いいボールの入れ方と定めます。
 
# 1以上 N 以下の任意の整数 i について、i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った余りが aiである。
 
#いいボールの入れ方は存在するでしょうか。存在するならば 1つ求めてください。
 
if N%2==0:
    first = int(N/2)-1
else:
    first = int((N-1)/2)-1

#前半部分を処理
for i in range(first,-1,-1): # Max:10^5ループ
    #print(i,"→",i+1,":",ans[i])
    
    multiple_list = [(i+1)*j for j in range(1,1+N//(i+1))]
    #print(N,",",N//(i+1))
    #print(i+1,"の倍数:",multiple_list)
    #content = [ans[j-1] for j in multiple_list]
    #print("中身:",content)
    total = sum([ans[j-1] for j in multiple_list])
    
    if ans[i]==1 and total%2==0:
        ans[i] = 0
    elif ans[i]==0 and total%2==1:
        ans[i] = 1
        
#print(' '.join(map(str,ans)))
print(sum(ans))
print(' '.join(map(str,[j+1 for j in range(0,N) if ans[j]==1])))

Measured memory_bytes: 25520
program sample
    implicit none
  
    integer(8) :: n,x1,y1,x2,y2,x3,y3,x4,y4,m,i
    integer(8),allocatable::x(:)
  
    
  
    ! 整数を読み込む
    read(*,*) n
    allocate(x(3*n))
    read(*,*)x
    call msort(x)
    m=0
    do i=1,2*n-1,2
        m=m+x(3*n-i)
    end do
    
      write(*,*)m
  
    
    stop
    contains
    recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)
 
    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if
 
    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))
 
    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x
 
    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do
 
    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n
 
    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
  end program sample
  

Measured memory_bytes: 8748
#include <stdio.h>
#include <ctype.h>

int main(){
    char ch;
    while (1) {
        scanf("%c", &ch);
        if (ch == '\n') {
            printf("\n");
            break;
        } else if(islower(ch)) {
            printf("%c", toupper(ch));
        } else if(isupper(ch)) {
            printf("%c", tolower(ch));
        } else {
            printf("%c", ch);
        }
    }

    return 0;
}

Measured memory_bytes: 524
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input};
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

#[fastout]
fn main() {
    input! {
        N:usize
    }
    let mut f = vec![1usize; N + 1];
    for i in 2..N + 1 {
        let mut j = i;
        while j <= N {
            f[j] += 1;
            j += i;
        }
        //println!("{:?}", f);
    }
    //println!("{:?}", f);
    let mut ans = 0;
    for i in 1..N + 1 {
        ans += i * f[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 80184
package main

import (
	"fmt"
	"sort"
	"strconv"
)

func Max(x, y int) int {
    if x < y {
        return y
    }
    return x
}

func main() {

	var N, M int
	var A []int
	var ans = ""
	var tmp = 0
	const Inf = 2 << 10

	cost := [11]int {0,2,5,5,4,5,6,3,7,6}
	dp := [10001]int{0}

	fmt.Scan(&N)
	fmt.Scan(&M)
	for m := 0; m < M; m++ {
		fmt.Scan(&tmp)
		A = append(A, tmp)
	}
	sort.Ints(sort.IntSlice(A))

	for n := 1; n <= N; n++ {
		dp[n] = -Inf
		for _, e := range A {
			if  n >= cost[e] {
				dp[n] = Max(dp[n], dp[n-cost[e]]+1)
			}
		}
	}

	remain := N
	for ;; {
		if remain < 1 { break }
		for k := range A {
			e := A[M-k-1]
			if remain >= cost[e] && dp[remain] - 1 == dp[remain - cost[e]] {
				if 1 == dp[remain] && remain != cost[e] { continue }
				ans += strconv.Itoa(e)
				remain -= cost[e]
				break
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 5504
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());

            int score = 0;
            score += x / 500 * 1000;
            x -= (x / 500) * 500;
            score += x / 5 * 5;
            Console.WriteLine(score);
        }
    }
}


Measured memory_bytes: 13140
package main

import "fmt"

func main(){
	var N int64

	fmt.Scan(&N)
	
	// var a = make([]int64, N)
	var ans int64

	for i := int64(1) ; i <= N ; i++ {
		if i % 15 == 0{
		}else if i % 3 == 0 {
		}else if i % 5 == 0{
		}else {
			ans += i
		//	fmt.Println(i)
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1752
#include <stdio.h>

#define MAX 100000

int Partition(int*,int,int);

int main(){
  int n, i, arr[MAX], p;

  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" , arr+i);
  }

  p = Partition(arr, 0, n-1);
  for(i = 0 ; i < n ; i++){
    if(i == p){
      printf("[%d]%c" ,arr[i], i != n-1 ? ' ' : '\n');
    }else{
      printf("%d%c" ,arr[i], i != n-1 ? ' ' : '\n');
    }
  }

  return 0;
}

int Partition(int arr[], int p, int r){
  int x = arr[r], i = p - 1, j, tmp;

  for(j = p ; j < r ; j++){
    if(arr[j] <= x){
      i++;
      tmp = arr[i];
      arr[i] = arr[j];
      arr[j] = tmp;
    }
  }
  
  tmp = arr[i+1];
  arr[i+1] = arr[r];
  arr[r] = tmp;
  
  return ++i;
}

Measured memory_bytes: 988
import sys
sys.setrecursionlimit(10**6)
N, M, *L = map(int, open(0).read().split())
dic = [[] for i in range(N+1)]
for a,b in zip(*[iter(L)]*2):
  dic[a].append(b)
  dic[b].append(a)
color = [0]*(N+1)
def dfs(v,c):
  color[v] = c
  for u in dic[v]:
    if color[u]==c:
      return False
    if color[u]==0 and not dfs(u,-c):
      return False
  return True
for i in range(1,N+1):
  if color[i]==0:
    if not dfs(i,1):
      print(N*(N-1)//2-M)
      break
else:
  w = sum(c==1 for c in color)
  b = N-w
  print(w*b-M)

Measured memory_bytes: 32648
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

void MaxHeapify(std::vector<int>& Heap, unsigned int Index)
{
	unsigned int Left = 2 * Index;
	unsigned int Right = 2 * Index + 1;
	unsigned int Largest;
	if(Left < Heap.size() && Heap[Left] > Heap[Index]){
		Largest = Left;
	}else{
		Largest = Index;
	}
	
	if(Right < Heap.size() && Heap[Right] > Heap[Largest]){
		Largest = Right;
	}
	
	if(Largest != Index){
		std::swap(Heap[Largest], Heap[Index]);
		MaxHeapify(Heap, Largest);
	}
}

void BubbleUp(std::vector<int>& Heap, int Index)
{
	if(Index/2 == 0 || Heap[Index] <= Heap[Index/2]) return;
	std::swap(Heap[Index], Heap[Index/2]);
	BubbleUp(Heap, Index/2);
}

class TPriorityQueue
{
	std::vector<int> FHeap;
public:
	TPriorityQueue();
	void Insert(int Key);
	int ExtractMax();
};

TPriorityQueue::TPriorityQueue()
: FHeap(1, 0)
{
}

void TPriorityQueue::Insert(int Key)
{
	FHeap.push_back(Key);
	BubbleUp(FHeap, FHeap.size() - 1);
}

int TPriorityQueue::ExtractMax()
{
	int Result = FHeap[1];
	std::swap(FHeap[1], FHeap.back());
	FHeap.pop_back();
	MaxHeapify(FHeap, 1);
	return Result;
}

void Execute()
{
	TPriorityQueue Queue;
	while(1){
		std::string Command;
		std::cin >> Command;
		if(Command == "insert"){
			int Key;
			std::cin >> Key;
			Queue.Insert(Key);
		}
		if(Command == "extract"){
			std::cout << Queue.ExtractMax() << std::endl;
		}
		if(Command == "end") break;
	}
}

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

Measured memory_bytes: 7144
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

///////////////////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	int a[1005] = {};

	rep(i,0,n)cin >> a[i];
	sort(a,a+n);

	cout << a[n-1] - a[0]  << endl;

	return  0;
}

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

#define ll long long

int main()
{
	int a,b,c;
	cin>>a>>b;
	int s=0;
	for(int i=0;i<b;i++)
	{
		cin>>c;
		s+=c;
	}
	cout<<max(a-s,-1)<<endl;
}


Measured memory_bytes: 3672
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := map[string]int64{}

	ss := make([]string, n)

	for i := 0; i < n; i++ {
		ss[i] = getNextString(scanner)
		k := key(ss[i])
		if _, ok := m[k]; ok == false {
			m[k] = 0
		}
		m[k]++
	}

	var ans int64

	for _, v := range m {
		ans += v * (v - 1) / 2
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func key(s string) string {
	var cc [26]int
	var ans [26]string

	n := len(s)
	for i := 0; i < n; i++ {
		cc[s[i]-'a']++
	}
	for i := 0; i < 26; i++ {
		ans[i] = fmt.Sprintf("%02d", cc[i])
	}

	return strings.Join(ans[0:], "")
}


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

int main(){
  int n; 
  string s,t;
  cin >>n >>s >>t;
  for(int i = n; 0<=i; i--){
    if(s.substr(n-i)==t.substr(0,i)){
      int ans = 2*n-i;
      cout << ans << endl;
      return 0;
    }
  }
  return 0; 
}

Measured memory_bytes: 3604