akhauriyash/Code-Regression huggingface dataset:
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

/* Waise Zinda Hu Zindagi Bin Tere Main ,Dard Hi Dard Baaki Raha Hai Seene Mein
Saans Lena Bhar Hi Yaha Jeena Nahi Hain ,Ab Toh Aadat Si Hai Mujhko Aaise Jeene Mein  :) */

#include <bits/stdc++.h>

//define

#define                boost_                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                iter_(i,n)                     for (int i = 0; i < int(n); i++)
#define                for_n(i, n)                    for (int i = 1; i <= int(n); i++)
#define                pb                             push_back
#define                mp                             make_pair
#define                itr                            ::iterator
#define                s_sort(s)                      sort(s.begin(),s.end())
#define                n_sort(a)                      sort(a,a+n)
#define                thank_you                      return 0
#define                precise_impact                 cout<<setprecision(10)<<fixed;

using namespace std;

//data type
typedef long long int ll;
typedef unsigned long long int ulli;
typedef double db;


//constants
#define PI acos(-1.00)
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
int egcd(int a,int b,int &x,int &y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d=egcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return d;
}

void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    solve();

    thank_you;
}


void solve()
{
    ll n;
    db d;
    cin>>n>>d;
    int c=0;
    iter_(i,n){
        db x,y;
        cin>>x>>y;
        db tm=sqrt(x*x+y*y);
        if(tm<=d)
            c++;
    }
    cout<<c<<endl;

}



Measured memory_bytes: 3860
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
typedef pair<int,int> P;
string s;
int k;
int INF=1000000000;
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

int main(){
    int r;
    int v[6]={500,100,50,10,5,1};
    while(true){
        cin>>r;
        if(r==0) break;
        int ans=0;
        int m=1000-r;
        int i=0;
        while(m!=0&&i<6){
            ans+=m/v[i];
            m%=v[i];
            i++;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 2984
import sys

n = int(input())
d1 = []
d2 = []
for i in range(n):
  t,u = map(int,input().split())
  d1.append(t)
  d2.append(u)
c = 0
for i in range(n):
  if d1[i] == d2[i]:
    c += 1
  else:
    c = 0
  if c == 3:
    print("Yes")
    sys.exit()
print("No")

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  string S;
  cin >> S;
  int ans = 0;
  int tmp = 0;
  for (char x : S) {
    if (x == 'R') {
      tmp++;
      ans = max(ans, tmp);
    } else {
      tmp = 0;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
#define sz(v) ((int)(v).size())

int solve(){
	int n; cin >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++) cin >> v[i];
	int ans = 0;
	for(int i=1; i<n-1; i++){
		if(min({v[i-1], v[i], v[i+1]}) != v[i] && 
		max({v[i-1], v[i], v[i+1]}) != v[i]) ans++;
	}
	return ans;
}
int main(){
	int tc = 1; //cin >> tc;
	for(int i=0; i<tc; i++) cout << solve() << endl;
}


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

int main(void)
{
    int x,y;
    cin >> x >> y;

    for (int i = 0;i <= 100;i++)
    {
        for (int j = 0;j <= 100;j++)
        {
            if (4*i+2*j == y && i+j == x)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    
    return 0;
}


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

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

    int N;
    cin >> N;
    vector<ll> A(N + 1);
    for (auto &x : A) cin >> x;

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ll B;
        cin >> B;
        ans += min(A.at(i), B);
        B = max(0LL, B - A.at(i));
        ans += min(A.at(i + 1), B);
        A.at(i + 1) = max(0LL, A.at(i + 1) - B);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
# include <bits/stdc++.h>
using namespace std;
int main(){
	int q;
	long long res = 0;
	map < string , long long > mp;  
	cin >> q;
	while(q --){
		string s; 
		cin >> s;
		sort(s.begin() , s.end());
		mp[s] ++;
		res += mp[s] - 1;
	}
	cout << res << "\n";
} 

Measured memory_bytes: 11136
A,B,C,X,Y = map(int,input().split())

answer = 10**18
for c in range(10**5+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a,0)*A
  cost += max(b,0)*B
  answer = min(answer,cost)
print(answer)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 1; i < (int)(n + 1); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

int main(){
  int K;
  int ans = 0;
  cin >> K;
  rep(a, K){
    rep(b, K){
      rep(c, K){
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
N, K = map(int,(input().split()))

A=[]
B=[]
for i in range(2*K):
    get=list(map(int,(input().split())))
    if i%2==1:
        A.append(get)
for i in range(len(A)):
    for j in range(len(A[i])):
        B.append(A[i][j])
cnt=0
for i in range(1,N+1):
    if i not in B:
        cnt+=1
        
print(str(cnt))

Measured memory_bytes: 67996
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int N;
  cin>>N; 
  if(N==1||N==2||N==3||N==5||N==7||N==11||N==13||N==15||N==17||N==19||N==23||N==29||N==31){
    cout<<1<<endl;
  }
  else if(N==4||N==6||N==9||N==10||N==14||N==21||N==22||N==25||N==26){
    cout<<2<<endl;
  }
  else if(N==28||N==30){
    cout<<4<<endl;
  }
  else if(N==8||N==12||N==18||N==20||N==27){
    cout<<5<<endl;
  }
  else if(N==16){
    cout<<14<<endl;
  }
  else if(N==24){
    cout<<15<<endl;
  }
  else{
    cout<<51<<endl;
  }
  

}
//1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);
// https://youtu.be/FAQxdm0bTaw?t=11830
int main() {
    string s;
    int D;
    ll mod = 1e9 + 7;
    cin >> s >> D;
    // example 256
    // 00~24 => 0~9
    // 25 => 0~6
    vector<vector<ll>> dp(D, vector<ll>(2, 0));
    // dp[sum][less_than_prefix]: the num of ways to choose digits so far
    // such that the sum of digits %D is 'sum' and 'less_than_prefix'
    // represents if we've already chosen digits less than prefix;
    dp[0][0] = 1;
    for(int i = 0; i < s.size(); i++) {
        vector<vector<ll>> nxt_dp(D, vector<ll>(2, 0));
        for(int sum = 0; sum < D; sum++) {
            for(bool less_than_prefix: {false, true}) { // if less than prefix, we can append any digit from 0~9
                for(int digit = 0; digit < 10; digit++) {
                    if (less_than_prefix == false && digit > (s[i]-'0'))
                        break;
                    bool less_next = less_than_prefix || (digit < (s[i]-'0'));
                    nxt_dp[(sum+digit)%D][less_next] += dp[sum][less_than_prefix];
                    nxt_dp[(sum+digit)%D][less_next] %= mod;
                }
            }
        }
        swap(dp, nxt_dp);
    }
    ll ans = (dp[0][0] + dp[0][1] - 1 + mod) % mod;
    cout << ans << endl;
}




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

int main(){
  int n,c[501],s[501],f[501];
  cin>>n;
  for(int i=1;i<n;++i)cin>>c[i]>>s[i]>>f[i];

  for(int i=1;i<n;++i){
    int t=0;
    for(int j=i;j<n;++j){
        if(t<s[j])t=s[j];
        else if(t%f[j]!=0)t+=f[j]-t%f[j];
        t+=c[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user --> CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"\Case #"<<x<<"\:"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}


void virus(){
        ll a, b, c;
        cin>>a>>b>>c;
        ll ans = (c - (a-b));
        if(ans<=0) cout<<"0";
        else cout<<ans;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 20005;
const int MXV = 0;
#define MP  make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);
vector<int> dp(MXN, INF);

void sol(int a, int b)
{
    for(int i = a; i < MXN; ++i)
    {
        dp[i] = min(dp[i], dp[i - a] + b);
    }
}

int main()
{
    IOS;
    int h, n;
    cin >> h >> n;
    dp[0] = 0;
    for (int i = 0, a, b; i < n; ++i)
    {
        cin >> a >> b;
        sol(a, b);
    }
    cout << *min_element(dp.begin() + h, dp.begin() + MXN) << '\n';
}


Measured memory_bytes: 384
N,D = list(map(int,input().split()))
X = []
for n in range(N):
    X.append(list(map(int,input().split())))
#N個のリスト入力を受け取る

cnt = 0

for i in range(N):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d += (X[i][k]-X[j][k])**2
        d = d**0.5
        if d.is_integer() :
            cnt += 1

print(cnt)

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

int main() {
    string s;
    cin >> s;
    int N = s.size();
    reverse(all(s));
    map<ll, ll> ma;
    vector<ll> sum(N + 1, 0);
    ll MOD = 2019;
    ll num = 0, keta = 1;
    rep(i, N + 1) {
        num += keta * (s[i] - '0');
        keta *= 10;
        keta %= MOD;
        num %= MOD;
        sum[i + 1] = num;
    }

    rep(i, N + 1) { ma[sum[i]]++; }

    ll res = 0;
    for (auto p : ma) {
        res += (p.second * (p.second - 1) / 2);
    }

    cout << res << endl;
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> S(M), C(M);
  vector<i64> ans(N, -1);
  rep(i,0,M) {
    cin >> S[i] >> C[i];
    S[i]--;
    if(ans[S[i]] == -1 || (ans[S[i]] == C[i])) {
      ans[S[i]] = C[i];
    }
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  if(N > 1) {
    if(ans[0] == 0) {
      cout << -1 << endl;
      return 0;
    }
    i64 OK = false;
    rep(i,0,N) {
      if(ans[i] == -1) {
        if(OK) ans[i] = 0;
        else ans[i] = 1;
      }
      OK = true;
    }
    rep(i,0,N) {
      cout << ans[i];
    }
    cout << endl;
  }
  else {
    if(ans[0] == -1) {
      ans[0] = 0;
    }
    cout << ans[0] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>


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

#define PII pair<int,int>
#define PP pair< int,PII >


using namespace std;

int dp[256][256];
int c[256];
int t[256];
int a[256];
int b[256];

int main(){
	
	int n,d;
	scanf("%d%d", &d, &n);
	rep(i,d)scanf("%d", &t[i]);
	rep(i,n)scanf("%d%d%d", &a[i], &b[i], &c[i]);
	
	rep(i,256)rep(j,256)dp[i][j] = -1;
	
	dp[0][0] = 0;
	
	
	rep(i,d)rep(j,128){
		if(dp[i][j] != -1){
			rep(k,n){
				if(a[k] <= t[i] && t[i] <= b[k]){
					if(i == 0)dp[i+1][c[k]] = 0;
					else dp[i+1][c[k]] = max(dp[i+1][c[k]], dp[i][j] + abs(j-c[k]));
				}
			}
		}
	}
	
	int ans = 0;
	rep(j,d+1){
		rep(i,128){
			ans = max(ans, dp[j][i]);
		}
	}
	
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1448
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int r[MAXN],g[MAXN],b[MAXN],rr[MAXN],gg[MAXN],bb[MAXN];
char s[MAXN];
int main(){
    cin>>n;
    cin>>s+1;
    REP(i,1,n){
        r[i]=r[i-1]+(s[i]=='R');
        g[i]=g[i-1]+(s[i]=='G');
        b[i]=b[i-1]+(s[i]=='B');
    }
    PER(i,n,1){
        rr[i]=rr[i+1]+(s[i]=='R');
        gg[i]=gg[i+1]+(s[i]=='G');
        bb[i]=bb[i+1]+(s[i]=='B');
    }
    ll ans=0;
    REP(i,1,n){
        if(s[i]=='R')ans+=g[i-1]*bb[i+1]+b[i-1]*gg[i+1];
        if(s[i]=='G')ans+=r[i-1]*bb[i+1]+b[i-1]*rr[i+1];
        if(s[i]=='B')ans+=r[i-1]*gg[i+1]+g[i-1]*rr[i+1];
    }
    REP(i,1,n){
        REP(j,1,n){
            if(i+j>n||i-j<1)break;
            if(s[i+j]!=s[i]&&s[i]!=s[i-j]&&s[i-j]!=s[i+j])ans--;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3224
s = int(input())

a = [0,s]
for n in range(2,10**6+1):
  if a[n-1] % 2 == 0:
    an = a[n-1] // 2
  else:
    an = a[n-1] * 3 + 1
  
  if an in a:
    m = n
    break
  
  a.append(an)
  
print(m)

Measured memory_bytes: 9160
n = gets.chomp.to_i
s = gets.chomp

ans = 0
(n-1).times do |i|
  s1 = s.slice(0,i+1)
  s2 = s.slice(i+1, n)

  icchi = []
  s1.split(//).each do |c|
    icchi.push c if s2.include?(c)
  end
  ans = [ans, icchi.uniq.count].max
end

puts ans

Measured memory_bytes: 1916
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

const dd PI = 3.1415926535;
int main()
{
    dd A, B;
    ll H, M;
    cin >> A >> B >> H >> M;

    dd rotate = min(abs(H * 30.0 + M * 0.5 - M * 6.0), 360.0 - abs(H * 30.0 + M * 0.5- M * 6.0));
    dd ans = A * A + B * B - 2.0 * A * B * cos(rotate / 360.0 * 2.0 * PI);

    cout << fixed << setprecision(10) << sqrt(ans) << endl;
}


Measured memory_bytes: 4184
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N; 
    vint cnt(26,100);
    REP(i,N){
        string s; cin>>s;
        REP(j,26){
            cnt[j]=min(cnt[j],(int)count(ALL(s),'a'+j));
        }
    }
    
    string ans;
    REP(i,26){
        string s(cnt[i],'a'+i);
        ans+=s;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline

a,b,c = map(int,readline().split())

if c-a-b <0:
    print("No")
    exit()
if 0 < c**2+2*a*b-2*b*c-2*a*c+a**2+b**2-4*a*b :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int K,S,res=0;
    scanf("%d%d",&K,&S);
    for(int x=0;x<=K;x++)
        for(int y=0;y<=K;y++)
        {
            int z=S-x-y;
            if(z>=0 && z<=K)res++;
        }
    return 0*printf("%d\n",res);
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d%d", $n,$m);

if($n == 1 && $m == 1){
    echo "1000000";
    exit;
}
$ans=0;
if($n==1){
    $ans += 300000;
}elseif($n==2){
    $ans += 200000;
}elseif($n==3){
    $ans += 100000;
}

if($m==1){
    $ans += 300000;
}elseif($m==2){
    $ans += 200000;
}elseif($m==3){
    $ans += 100000;
}
echo $ans;

Measured memory_bytes: 4856
#include <stdio.h>
#include <string.h>

int main(void)
{
  int N,i,j;
  char temp[11];

  scanf("%d", &N);

  struct data{
    int n;
    char city[11];
    int p;
  } store[N + 1];



for(i= 0; i < N; i++)
{
  store[i].n = 0;
}

  for(i = 0; i < N; i++)
  {
    store[i].n = i + 1;
    scanf("%s", store[i].city);
    scanf("%d", &store[i].p);
  }


  for (i = 0; i < N; i++)
  {
    for (j = i + 1; j < N; j++)
    {
      if (strcmp(store[i].city, store[j].city) > 0)
      {
        store[N] = store[i];
        store[i] = store[j];
        store[j] = store[N];
      }
      else if(strcmp(store[i].city, store[j].city) == 0)
      {
        if (store[i].p < store[j].p)
        {
          store[N] = store[i];
          store[i] = store[j];
          store[j] = store[N];
        }
      }
    }
  }

  for (i = 0; i < N; i++)
  {
    printf("%d\n", store[i].n);
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)

int32_t main()
{

	string str;
	cin>>str;
	for(int i=0;str[i];i++){
		if(str[i]=='?')
		{
			str[i]='D';
		}
	}
	cout<<str<<endl;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		int h[] = new int[n];

		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}

		double[] sa = new double[n];

		for (int i = 0; i < n; i++) {
			sa[i] = Math.abs(t - h[i] * 0.006 - a);
		}

		int kotae = 0;
		double hikaku = 2000000000;

		for (int j = 0; j < n; j++) {
			if (hikaku > sa[j]) {
				hikaku = sa[j];
				kotae = j;
			}

		}
		System.out.println(kotae + 1);
	}
}


Measured memory_bytes: 24148
m=int(input())

for j in range(m,1000000):
    #print(j)
    pf={}
    for i in range(2,int(j**0.5)+1):
        while j%i==0:
            pf[i]=pf.get(i,0)+1
            j//=i
    if j>1:pf[j]=1
    #print(pf)
    if sum(pf.values())==1:
        print(j)
        exit()

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

int main(){
    int N;
    cin >> N;
    vector<int>P(N);
    int cnt = 0;
    int X = 0;
    for(int i = 0; i < N; i++) {
        cin >> P[i];
        cnt += P[i];
        X = max(X,P[i]);
    }
    cout << cnt-X/2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define SIZE 100
#define true 1
#define false -1

int stack[SIZE];
int top = 0;

void push (int);
int pop (void);

int main() {

  char data[5];
  int temp,plus,minus,multi,temp1,temp2;
  
  while(1) {
    if(scanf("%s",data)== EOF) break;
    
    if(data[0] == '+') {
      temp1 = pop();
      temp2 = pop();
      plus = temp1 + temp2;
      push(plus);
    }
   
    else if(data[0] == '-') {
      temp1 = pop();
      temp2 = pop();
      minus = temp2 - temp1;
      push(minus);
    }
    
    else if(data[0] == '*') {
      temp1 = pop();
      temp2 = pop();
      multi = temp1 * temp2;
      push(multi);
    }
    
    else {
      temp = atoi(data);
      push(temp);
    }
  }
  printf("%d\n",stack[0]);
  return 0;
}
      

void push(int input)
{
  stack[top] = input;
  top++;
}

int pop(void)
{
  top--;
  return stack[top];
}



Measured memory_bytes: 2100
n, k = map(int, input().split())
vs = list(map(int, input().split()))

values = []

if k > 1:
  for num_enqueue in range(k // 2):
    for num_dequeue in range(k-num_enqueue+1):
      for num_dequeue_left in range(num_dequeue+1):
        num_dequeue_right = num_dequeue - num_dequeue_left
        if num_dequeue >= n:
          dequeued = vs[:]
        else:
          dequeued = vs[:num_dequeue_left] + ([] if num_dequeue_right == 0 else vs[-num_dequeue_right:])
        dequeued_pos = [v for v in dequeued if v >= 0]
        dequeued_neg = sorted([v for v in dequeued if v < 0], reverse=True)

        for _ in range(num_enqueue):
          if dequeued_neg:
            dequeued_neg.pop()
        value = sum(dequeued_pos) + sum(dequeued_neg)
        #print(f'value={value}, enq={num_enqueue}, left={num_dequeue_left}, right={num_dequeue_right}, dequeued={dequeued}')
        values.append(value)
  print(max(values))
else:
  print(max(vs[0], vs[-1], 0))






Measured memory_bytes: 9152
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;

int main() {

	//ifstream cin("in/01-01.txt");
	//ofstream cout("OUTPUT.txt");

	char S[1000010];
	
	cin >> S;
	
	int len = strlen(S);
	int stat = 0;
	int cnt[3] = {0};
	int ans = 0;
	
	for(int i = 0; i < len; i++) {
		if(stat == 0) {
			if(S[i] == 'J') {
				cnt[0]++;
			} else if(cnt[0] != 0 && S[i] == 'O') {
				stat = 1;
				cnt[1]++;
			} else {
				cnt[0] = 0;
			}
		} else if(stat == 1) {
			if(S[i] == 'O') {
				cnt[1]++;
			} else if(S[i] == 'I') {
				stat = 2;
				cnt[2]++;
			} else {
				stat = 0;
				cnt[0] = 0;
				cnt[1] = 0;
				i--;
			}
		} else if(stat == 2) {
			if(S[i] == 'I') {
				cnt[2]++;
			} else {
				if(cnt[1] <= cnt[0] && cnt[1] <= cnt[2]) {
					ans = max(ans, min(min(cnt[0], cnt[1]), cnt[2]));
				}
				//cout << cnt[0] << " " << cnt[1] << " " << cnt[2] << endl;
				stat = 0;
				cnt[0] = 0;
				cnt[1] = 0;
				cnt[2] = 0;
				i--;
			}
		}
	}
	
	if(cnt[2] > 0 && cnt[1] <= cnt[0] && cnt[1] <= cnt[2]) {
		//cout << cnt[0] << " " << cnt[1] << " " << cnt[2] << endl;
		ans = max(ans, min(min(cnt[0], cnt[1]), cnt[2]));
	}
	
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,k;cin>>n>>k;
  int ans=0;
  while(n>0){
    ans++;
    n/=k;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#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>
using namespace std;
#define FOR(i, a, b) for (ll 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 piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int 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;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	int N; cin >> N;
	string S[310];
	REP(i, N)cin >> S[i];
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		char x[310][310];
		REP(j, N) {
			REP(k, N) {
				x[(j + i) % N][k] = S[j][k];
			}
		}
		bool ok = true;
		REP(j, N) {
			REP(k, N) {
				if (x[j][k] != x[k][j]) {
					ok = false;
				}
			}
		}
		if (ok)ans += N;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
ParseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String},1}) = map(ParseInt,x)
a,b = parseMap(split(readline()))
c = 0
for i in 1:1000
    if floor(i * 0.08) == a && floor(i * 0.10) == b
        println(i)
        c = -1
        break
    end
end
if c == 0
    println(-1)
end

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

using namespace std;
// using Graph = vector<vector<ll>>;

typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e4;
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;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll a, b, c, d, td = 0, ad = 0;
  cin >> a >> b >> c >> d;

  i = 0;
  while (a > 0 && c > 0)
  {
    if (i % 2 == 1)
    {
      a -= d;
    }
    else
    {
      c -= b;
    }
    i++;
  }

  if (c <= 0)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }

  // if (td <= ad)
  // {
  //   cout << "Yes";
  // }
  // else
  // {
  //   cout << "No";
  // }
}


Measured memory_bytes: 3640
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let xy: Vec<(f64, f64)> = vec(n, |_| (scan(tokens), scan(tokens)));
    let mut sum_d = 0.0;
    for i in 0..n {
        let (xi, yi) = xy[i];
        for j in i + 1..n {
            let (xj, yj) = xy[j];
            sum_d += ((xi - xj) * (xi - xj) + (yi - yj) * (yi - yj)).sqrt();
        }
    }
    println!("{}", sum_d * 2.0 / n as f64);
}


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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> sun(n);
  rep(i, n)
    sun.at(i) = i;
  
  vector<vector<ll>> safe(k);
  
  rep(i, k){
    ll kosu;
    cin >> kosu;
    
    rep(j, kosu){
      ll name;
      cin >> name;
      safe.at(i).push_back(name-1);
    }
  }
  
  rep(i, k){
    rep(j, safe.at(i).size()){
      rep(m, n){
        if(sun.at(m) == safe.at(i).at(j))
          sun.at(m) = -1;
      }
    }
  }
  
  ll count=0;
  rep(i, n){
    if(sun.at(i) != -1)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3656
n = gets.chomp.to_i
# 添字調整
a_arr = [nil] + gets.chomp.split(" ").map(&:to_i)

MOD = 10 ** 9 +7

# A1(A2 + A3 + ... + AN) + A2(A3 + A4 + ... + AN) + ... + AN-2(AN-1 + AN) + AN-1AN
result = 0
sum = 0
n.downto(2) do |i|
  sum += a_arr[i]
  result += a_arr[i-1] * sum
  result %= MOD
end
puts result


Measured memory_bytes: 37456
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N+10;i++){
		if(i*i>N){
			cout << (i-1)*(i-1) << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d) co("Left");
  else if(a+b<c+d) co("Right");
  else co("Balanced");
  
  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;

	int ans = 0;
	rep(i, 1, N + 1)
	{
		int t = N / i;
		ans += i * (t*(t + 1) / 2);
	}

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

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int a[5], b[5], c, cnt;
int main() {
	while (cin >> c) {
		if (cnt) { cout << endl; }
		cnt++;
		for (int i = 0; i < 5; i++) {
			a[4 - i] = ((c / (int)pow(10, i)) % 10) / 5;
			b[4 - i] = (c / (int)pow(10, i)) % 5;
		}

		for (int i = 0; i < 5; i++) {
			if (a[i] == 0) {
				cout << '*';
			}
			else {
				cout << ' ';
			}
		}
		cout << endl;

		for (int i = 0; i < 5; i++) {
			if (a[i] == 1) {
				cout << '*';
			}
			else {
				cout << ' ';
			}
		}
		cout << endl;

		for (int i = 0; i < 5; i++) {
			cout << '=';
		}
		cout << endl;

		for (int i = 0; i < 5; i++) {
			if (b[i] != 0) {
				cout << '*';
			}
			else {
				cout << ' ';
			}
		}
		cout << endl;

		for (int i = 0; i < 5; i++) {
			if (b[i] != 1) {
				cout << '*';
			}
			else {
				cout << ' ';
			}
		}
		cout << endl;

		for (int i = 0; i < 5; i++) {
			if (b[i] != 2) {
				cout << '*';
			}
			else {
				cout << ' ';
			}
		}
		cout << endl;

		for (int i = 0; i < 5; i++) {
			if (b[i] != 3) {
				cout << '*';
			}
			else {
				cout << ' ';
			}
		}
		cout << endl;

		for (int i = 0; i < 5; i++) {
			if (b[i] != 4) {
				cout << '*';
			}
			else {
				cout << ' ';
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1200
b = input()
a = [k for k in b]
l = len(a)
num = 0
h = l/2
i = int(h)
if l//2 == 0:
  for j in range(i):
    if a[j] != a[-1-j]:
      num += 1
else:
  for j in range(i):
    if a[j] != a[-1-j]:
      num += 1

print(num)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
char trans[26]; //どの文字をどの文字に変化させるか
bool used[26];//変換後で使ってしまった文字
int main()
{
	string s,t;
	bool ans=true;
	fill(trans,trans+26,'-');
	fill(used,used+26,false);
	cin>>s;
	cin>>t;
	for(int i=0;i<s.size();i++)
	{
		if(trans[s[i]-'a']=='-')
		{
			trans[s[i]-'a']=t[i];
		}else if(trans[s[i]-'a']!=t[i])
			ans=false;
		if(!ans)
			break;
	}
	//cerr<<ans<<endl;
	//違う文字を同じ文字に対応付けてないか
	for(int i=0;i<26;i++)
	{
		if(trans[i]!='-')
		{
			if(used[trans[i]-'a'])
			{
				ans=false;
				break;
			}
			used[trans[i]-'a']=true;
		}
	}
	if(ans)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  bool ans = false;
  
  for(int i=0; i<=X; i++) {
    for(int j=0; j<=X; j++) {
    if(Y == 4*i + 2*j && X == i + j) ans = true;
    }
  }

  if(ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int X; cin >> X;
  
  int a=X%100, b=X/100;
  
  int k = 0;
  k = a/5;
  if(a%5 != 0) k++;
  
  if(k <= b) cout << 1 << endl;
  else cout << 0 << endl;
  
}


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

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int beki(int num) {
    for (int i = 2; i <= sqrt(num); i++) {
        for (int j = 1; j <= num; j *= i) {
            if (j == num)
                return 1;
        }
    }
    return 0;
}

int main() {
    int x;
    cin >> x;

    int ans = 1;
    
    for (int i = 2; i <= x; i++) {
        if (beki(i))
            ans = i;
    }
    
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long num[200003];
int main(){
	for(int i=1;i<200003;i++)num[i]=0;
	long long a=0,b=0,x=0,y=0,z=0;
	long long c=0;
	scanf("%lld",&a);
	for(int i=1;i<=a;i++){
		scanf("%lld",&num[i]);
	}
	b=num[1];c=0;
	for(int i=2;i<=a;i++){
		x=0;
		if(num[i]>=b){
			b=num[i];
		}else{
			x=b-num[i];	
			c+=x;
		}
	}
	printf("%lld",c);
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  ll k;
  cin >> k;
  
  cout << (k % 2 == 0 ? a - b : b - a) << endl;
  
  return 0;
}

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

long long n;
long long cnt = 0;

void dfs(string s){
    long long x;
    x = stoll(s);
    if(x > n) return;

    if(s.find('3') != string::npos and s.find('5') != string::npos and s.find('7') != string::npos) cnt++;

    char c[] = {'3', '5', '7'};

    for(long long i = 0; i < 3; i++){
        string t;
        t = s + c[i];
        dfs(t);
    }
}

int main(){
    cin >> n;

    dfs("3");
    dfs("5");
    dfs("7");

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

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;  
ll MOD = 1e9 + 7;

int main() 
{ 
    FIO
    int t;
    t = 1;
    while(t--)
    {
        ll n;
        cin >> n;

        if(n==1)
        {
            cout << 0 << endl;
            continue;
        }

        ll ans = 0;
        ll nn = n;
        for(ll i=2;i<=ll(sqrt(nn));i++)
        {
            int cnt = 0;
            while(n%i==0)
            {
                n/=i;
                cnt++;
            }

            ll lo = 0, hi = 1e8;
            ll mid;
            ll tm;
            while(lo<=hi)
            {
                mid = (lo+hi)/2;

                if((mid*(mid+1))/2==cnt)
                {
                    tm = mid;
                    break;
                }
                else if((mid*(mid+1))/2 < cnt)
                {
                    tm = mid;
                    lo = mid +1;
                }
                else
                    hi = mid - 1;
            }

            ans += tm;
        }

        if(n>1)
            ans++;

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

Measured memory_bytes: 3692
import java.util.*;

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

    int a = scan.nextInt();
    int b = scan.nextInt();

    if(a < b)System.out.println("a < b");
    else if(a == b)System.out.println("a == b");
    else System.out.println("a > b");
  }
}

Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n;
    cin>>n;
    unordered_set<string> m;
    string a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    m.insert(a[0]);
    for (int i=1;i<n;i++)
    {
        string x=a[i-1];
        string y=a[i];
        if (x[x.length()-1]!=y[0]||m.find(a[i])!=m.end())
        {
            cout<<"No";
            return 0;
        }
        m.insert(a[i]);
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3656
// Problem : 
// 			A - Rainy Season
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mod (int)1e9+7
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define repf(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define N 100005
int main()
{
	FAST
    int t=1;
    // cin>>t;
    while(t--)
    {
		string s;
		cin>>s;
		if(s=="RRR") cout<<3;
		else if(s=="SRR" || s=="RRS") cout<<2;
		else if(s=="SSS") cout<<0;
		else cout<<1;
    }
    return 0;
} 


Measured memory_bytes: 3564
#include <iostream>

int main(int argc, char const* argv[]) {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    long long N, M, num;
    std::cin >> N >> M;
    if (N == 1 && M == 1) {
        num = 1;
    }
    else if (N == 1 || M == 1) {
        num = N * M - 2;
    }
    else {
        num = (N-2) * (M-2);
    }
    std::cout << num << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

int main()
{
	string s;
	int a=0;
	int z=0;
	int ans=0;
	
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='A')
		{
			a=i;
			break;
		}
	}
	for(int i=s.length()-1;i>-1;i--)
	{
		if(s[i]=='Z')
		{
			z=i;
			break;
		}
	}
	ans=z-a+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
input_array=[]

while True:
    a, b = [int(x) for x in raw_input().split(" ")]

    if a == 0 and b == 0:
        break
    elif a > b:
        tmp = a
        a = b
        b = tmp

    input_num = str(a) + " " + str(b)
    input_array.append(input_num)

for x in range(0,len(input_array)):
    print(input_array[x])

Measured memory_bytes: 6404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            int n = ReadAndParseInt();
            var t = new int[n];
            var x = new int[n];
            var y = new int[n];
            for(int i=0;i<n;++i)
            {
                var tmp = ReadAndParseIntArr();
                t[i] = tmp[0];
                x[i] = tmp[1];
                y[i] = tmp[2];
            }

            bool success = true;
            int prev_t = 0;
            int prev_x = 0;
            int prev_y = 0;
            for(int i=0;i<n;++i)
            {
                int dt = t[i] - prev_t;
                int dx = x[i] - prev_x;
                int dy = y[i] - prev_y;

                int dist = Math.Abs(dx) + Math.Abs(dy);
                if( dist > dt) { success = false; break; }
                if( (dist % 2) != (dt % 2)) { success = false; break; }

                prev_t = t[i];
                prev_x = x[i];
                prev_y = y[i];
            }
            string ans = success ? "Yes" : "No";
            Console.WriteLine(ans);
        }
        
        
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 16204