akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

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

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890


int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll h[n];
    for(i=0;i<n;i++) cin>>h[i];
    ll m=0;
    ll te=0;
    for(i=0;i<n;i++){
        if(h[i]>=h[i+1]) te++;
        else {
            m=max(m,te);
            te=0;
        }
    }
    cout<<m<<endl;
    

    return 0;   
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007

ll findgcd(ll n,ll m){
    return __gcd(n,m);
}
ll findlcm(ll n,ll m){
    return (n*m)/findgcd(n,m);
}

ll nodig(ll n){
    int ans =0;
    while(n!=0){
        ans+=1;
        n=n/10;
    }
    return ans;
}

ll countOrderedPairs(ll N) 
{ 
    ll count_pairs = 0; 
    for (int i = 1; i <= sqrt(N - 1); ++i) { 
        for (int j = i; j * i < N; ++j) 
            ++count_pairs; 
    } 
    count_pairs *= 2; 
    count_pairs -= int(sqrt(N - 1)); 
    return count_pairs; 
} 

int main(){
    ll n,temp=0,cnt=0,ans=0;
    cin>>n;
    temp = countOrderedPairs(n);
    cout<<temp<<endl;

return 0;
}

Measured memory_bytes: 3676
n,m = gets.strip.split.map &:to_i
points = gets.strip.split.map(&:to_i).sort

if m == 1 or n >= m
  puts 0
else
  difs = points.each_cons(2).map { |a,b| (b - a).abs }.sort
  puts difs[0, m - n].inject(0, &:+)
end

Measured memory_bytes: 14656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a[100005],i,j,x,y,s=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	s/=2;
	for(i=1;i<n;i+=2)
	{
		s-=a[i];
	}
	s*=2;
	cout<<s<<" ";
	for(i=0;i<n-1;i++)
	{
		cout<<2*a[i]-s<<" ";
		s=2*a[i]-s;
	}	
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#define sz(x) int(x.size())
using namespace std;

int main () {

    string s, t;
    cin >> s >> t;

    int n = sz(s), m = sz(t);
    vector<vector<int> > alph(26);
    string tmp = s + s;
    for (int i = 0; i < tmp.size(); i++) {
        alph[tmp[i]-'a'].push_back(i);
    }

    long long ans = 0;
    int p = 0;
    for (int i = 0; i < t.size(); i++) {
        int c = t[i] - 'a';
        if (sz(alph[c]) == 0) {
            cout << "-1" << endl;
            return 0;
        }
        p = *lower_bound(alph[c].begin(), alph[c].end(), p)+1;
        if (p >= n) {
            p -= n;
            ans += n;
        }
    }
    cout << ans + p << endl;

    return 0;
}

Measured memory_bytes: 1980
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    for (int i=A; i<=B; i++) {
        if (i <= A+K-1 || B-K+1 <= i) cout << i << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, T;
	cin >> N >> T;
	int ans = INF;
	REP(i, N) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			ans = min(ans,c);
		}
	}
	if (ans == INF)cout << "TLE" << endl;
	else cout << ans << endl;
	PAU;
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int cnt = 0;
    for (int i = 1; i < N; i++) {
        if (S[i] == S[i - 1]) cnt++;
    }
    cout << min(N - 1, cnt + 2 * K) << '\n';
    return 0;
}


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

ll f(ll H, ll ans){
    ans++;
    if(H == 1) {
        return ans;
    }
    ll tmp = H / 2;
    ans = f(tmp, ans);
    // ans = f(tmp, ans);
    return ans;
}

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    ll H;
    cin >> H;
    ll ans = 0;
    ans = f(H, ans);
    ll ansa = pow(2, ans) -1;
    cout << ansa << endl;
}
// 1 2
// 2 3
// 3 3
// 4 7 3
// 5 7
// 6 7
// 7 7
// 8 15 4
// 9 15
// 10 15
// 11 15
// 12 15
// 13 15
// 14 15
// 15 15
// 16 31
// 100 127 7
// 1000000000000 ? 40


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long a, b, c,mx=0,tmp1,tmp2;
	cin >> a >> b >> c;
	mx = max(max(a, b), c);
	if (a == mx)tmp1 = b, tmp2 = c;
	else if (b == mx)tmp1 = a, tmp2 = c;
	else if (c == mx)tmp1 = a, tmp2 = b;
	if (mx%2==0) cout << 0 << endl;
	else cout << tmp1 * tmp2 << endl;
	return 0;
}

Measured memory_bytes: 256
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pdd pair<double, double>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 1LL << 60;


int main(){
    StarBurstStream

    int n;
    cin >> n;
    int ans = 0;
    int k;
    cin >> k;
    for(int i = 0; i < n; i++){
        int t;
        cin >> t;
        if(t >= k) ans++;
    }

    cout << ans << "\n";

    return 0;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


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

int N, M;
bool v[101010];
int A[101010];

int main() {
    cin >> N;
    ll ans = 0;
    REP(i, N)cin >> A[i];
    REP(i, N) {
        if (A[i] % 2 == 1) {
            v[i] = 1;
            ans += A[i] / 2;
        } else ans += A[i] / 2;
        if (v[i] && A[i + 1] > 0) {
            A[i + 1]--;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if (S.charAt(2)==S.charAt(3) && S.charAt(4)==S.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
import java.io.*;
import java.util.StringTokenizer;
 
class Main{
 
static final PrintWriter out=new PrintWriter(System.out);
 
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] a=new int[n];
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) a[i]=Integer.parseInt(st.nextToken());
InsertionSort(a);
out.flush();
}
}
 
static void InsertionSort(int[] a){
getValue(a);
for(int i=1;i<a.length;i++){
int j=i-1;
int tmp=a[i];
while(j>=0&&a[j]>tmp){
a[j+1]=a[j];
a[j]=tmp;
j--;
}
getValue(a);
}
}
 
private static void getValue(int[] a){
for(int i=0;i<a.length-1;i++) out.print(a[i]+" ");
out.println(a[a.length-1]);
}
}


Measured memory_bytes: 27268
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}
ll s[N],sum[N];

ll dfs(ll n,ll k)
{
	if(n == 0) return k;
    if(k <= 1) return 0;
    if(k <= 1+s[n-1]) return dfs(n-1,k-1);
    return sum[n-1]+1+dfs(n-1,min(k-s[n-1]-2,s[n-1]));
}

int main()
{
	ll n,i,k;
	while(~sl(n))
	{
		sl(k);
		if(n == 0)
		{
			puts("1");
			continue;
		}
		s[0] = sum[0] = 1;
		for(i = 1;i <= 50;i++)
			sum[i] = 2*sum[i-1]+1;
		for(i = 1;i <= 51;i++)
			s[i] = s[i-1]*2+3;
		ll ans = dfs(n,k);
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 2304
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
  	cin >> a[i];
	}
	vector<int> dp(n);
	if (n == 1) {
		cout << 0 << '\n';
		return 0;
	}
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1], abs(a[i] - a[i - 2]) + dp[i - 2]);
	}
	cout << dp[n - 1] << '\n';
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int t;
  double maxavarage = 0;
  while(cin>>t && t){
    REP(numofdice, t + 1){
      int n;
      cin>>n>>n;
      double sumpos=0, avarage=0;
      vector<int> number(n);
      vector<double> pos(n);
      REP(i, n){
        cin>>number[i]>>pos[i];
        sumpos += pos[i];
      }
      REP(i, n){
        avarage += (double)number[i] * (pos[i]/sumpos);
      }
      if(numofdice != t){
        maxavarage = max(avarage, maxavarage);
      }else{
        if(maxavarage - avarage > 1e-7){
          cout<<"YES"<<endl;
        }else{
          cout<<"NO"<<endl;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int N, M, X, Y;
int x[128];
int y[128];

int main(void) {
	int i;
	int asumisu, mizuhasu;
	if (scanf("%d%d%d%d", &N, &M, &X, &Y) != 4) return 0;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &x[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &y[i]) != 1) return 1;
	}
	asumisu = x[0];
	for (i = 1; i < N; i++) {
		if (x[i] > asumisu) asumisu = x[i];
	}
	mizuhasu = y[0];
	for (i = 1; i < M; i++) {
		if (y[i] < mizuhasu) mizuhasu = y[i];
	}
	if (asumisu < mizuhasu && asumisu < Y && X < mizuhasu) printf("No ");
	puts("War");
	return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
dp = [1]*(n+1)

for _ in range(m):
    idx = int(input())
    dp[idx] = 0
for i in range(2,n+1):
    if dp[i] != 0:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%1000000007)

Measured memory_bytes: 460020
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int aa,bb;
int a[2000],b[2000];
int main()
{
scanf("%d%d",&aa,&bb);
for (int i=1;i<=999;i++)
{
    a[i]=a[i-1]+i;
}
printf("%d\n",a[bb-aa]-bb);
    return(0);
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

const int maxn=1e7+10;

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 n;
	cin>>n;
	vii haha;
	for(ll i=2;i*i<=n;++i){
		if(n%i==0){
			ll x=0;
			while(n%i==0){
				++x;
				n/=i;
			}
			haha.pb({i,x});
		}
	}
	if(n!=1)
		haha.pb({n,1});
	ll ans=0;
	for(int i=0;i<haha.size();++i){
		for(int j=1;j<=300;++j){
			++ans;
			if(haha[i].ss-j>j){
				haha[i].ss-=j;
			}
			else
				break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3676
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
counts = Counter(A)
Q = int(input())
cur = sum(A)
for _ in range(Q):
    B, C = map(int, input().split())
    if B in counts:
        cur -= counts[B] * B
        cur += counts[B] * C
        print(cur)
        counts[C] += counts[B]
        del counts[B]
    else:
        print(cur)

Measured memory_bytes: 21616
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#include <numeric>
#include <cmath>
#include <set>
#include <functional>

using namespace std;

#define ll long long;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl;

int main() {
    string div[4] = { "dream","dreamer","erase","eraser" };
    rep(i, 4) {
        reverse(div[i].begin(), div[i].end());
    }
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool dflag = false;
        for (int j = 0; j < 4; j++) {
            if (S.substr(i, div[j].size()) == div[j]) {
                dflag = true;
                i += div[j].size();
            }
        }
        if (!dflag) {
            can = false;
            break;
        }
    }
    if (can)cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main()
{
  int W, H, N;
  cin >> W >> H >> N;
  int S[110][110] = {};
  for (int i = 0; i < N; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    switch(a) {
      case 1:
        for (int w = 0; w < x; w++) {
          for (int h = 0; h < H; h++) {
            S[w][h] = 1;
          }
        }
        break;
      case 2:
        for (int w = x; w < W; w++) {
          for (int h = 0; h < H; h++) {
            S[w][h] = 1;
          }
        }
        break;
      case 3:
        for (int w = 0; w < W; w++) {
          for (int h = 0; h < y; h++) {
            S[w][h] = 1;
          }
        }
        break;
      case 4:
        for (int w = 0; w < W; w++) {
          for (int h = y; h < H; h++) {
            S[w][h] = 1;
          }
        }
        break;
    };
  }
  int ans = 0;
  for (int w = 0; w < W; w++) {
    for (int h = 0; h < H; h++) {
      if (S[w][h] == 0)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] sum = new int[201];
		sum[1] = 1;
		for (int i = 2; i <= n; i++) {
			sum[i]+= sum[i-1];
			for (int j = 1; j <= i ; j++) {
				for (int k = 1; k <= i ; k++) {
					for (int l = 1; l <= i; l++) {
						if (j == i || k == i || l ==i) {
							sum[i] += gcd(j,k,l);
						}
					}
				}
			}
		}
		System.out.println(sum[n]);
	}

	private static int gcd(int a, int b) {
//		      辗转相减法
      while(a!=b) {
          if(a>b) {
              a=a-b;
          }else {
              b=b-a;
          }
      }
      return b;
	}


	private static int gcd(int a, int b, int c) {
		int gcd1 = gcd(a,b);
		return gcd(gcd1, c);
	}
}


Measured memory_bytes: 36252
#include <iostream>
using namespace std;
int main()
{
    int x, y;
    cin >> x >> y;
    int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    cout << (days[x] == days[y] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
lst = []
total = 0
for i in range(5):
    n = int(input())
    lst.append([(n-1) % 10, n])
lst.sort()

for i in range(len(lst)):
    if i == 0:
        total += lst[i][1]
    else:
        total += ((lst[i][1] + 9) // 10) * 10
print(total)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

    using namespace std;

bool is_harshad_number(long long N) {
    long long n = N;
    long long sum = 0;
    while (0 < n) {
        long long s = n % 10;
        sum += s;
        n /= 10;
    }

    return N % sum == 0;
}

int main() {
    using namespace std;

    long long N;
    cin >> N;

    bool flg = is_harshad_number(N);

    cout << (flg ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 256
n, d = map(int, input().split())

list_N = []
for i in range(n):
    list_N.append(list(map(int, input().split())))

#二重ループで各点の距離を計算
score = 0
for i in range(len(list_N)):
    for j in range(i+1, len(list_N)):
        val = 0

        for a, b in zip(list_N[i], list_N[j]):
            val += (a-b)**2

        val = val**0.5
        
        if val.is_integer():
            score += 1

print(score)

Measured memory_bytes: 3188
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
LL a,b;
LL c[100],d[100],e[100];

int main()
{
scanf("%lld%lld",&a,&b);

for (LL i=0;i<=63;i++)
{
    if (i==0)
    {
        c[i]=a/2;
        continue;
    }
    LL k=(LL)1<<(LL)i;
    if (k>a-1) break;
    LL num=a/k;
    if (a%k==0)
    {
        if (num%2==0)
        {
            c[i]=(num/2)*k;
        } else
        {
            c[i]=(num/2)*k;
        }
    } else
    {
        if (num%2==0)
        {
            c[i]=(num/2)*k;
        } else
        {
            c[i]=((num-1)/2)*k;
            c[i]+=a%k;
        }
    }
}

for (LL i=0;i<=63;i++)
{
    if (i==0)
    {
        d[i]=(b+1)/2;
        continue;
    }
    LL k=(LL)1<<(LL)i;
    if (k>b) break;
    LL num=(b+1)/k;
    if ((b+1)%k==0)
    {
        if (num%2==0)
        {
            d[i]=(num/2)*k;
        } else
        {
            d[i]=(num/2)*k;
        }
    } else
    {
        if (num%2==0)
        {
            d[i]=(num/2)*k;
        } else
        {
            d[i]=((num-1)/2)*k;
            d[i]+=(b+1)%k;
        }
    }
}

for (int i=0;i<=63;i++)
e[i]=d[i]-c[i];
/*
for (int i=0;i<=20;i++)
    printf("%lld ",e[i]);
*/
LL ans=0;
for (int i=0;i<=63;i++)
{
    if (e[i]%2==1)
        ans+=(LL)1<<(LL)i;
}
printf("%lld\n",ans);
    return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

bool f(string s){
	auto t=s;
	reverse(t.begin(),t.end());
	return s==t;
}

string s;

int main(){
	cin>>s;
	int n=s.size();
	cout<<(f(s)&&f(s.substr(0,n/2))&&f(s.substr(n/2+1,n/2))?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
import math

def a():
    h1, m1, h2, m2, k = map(int, input().split())
    t1 = h1 * 60 + m1
    t2 = h2 * 60 + m2

    if t1 < t2:
        print(t2 - t1 - k)
    else:
        print(1440 - (t1 - t2) - k)


def b():
    t = input()
    print(t.replace('?','D'))
            



def c():
    print('')



def d():
    print('')


b()

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

#define CO const
#define IN inline
typedef long long int64;

template<class T> IN T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}

CO int P=1e9+7;
IN int add(int a,int b){
	return (a+=b)>=P?a-P:a;
}
IN int mul(int a,int b){
	return (int64)a*b%P;
}
IN int fpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}
IN void chkadd(int&a,int b){
	a=add(a,b);
}

CO int N=3e5+10;
char str[N];
int F[N][3][3];

int main(){
	scanf("%s",str+1);
	int n=strlen(str+1);
	F[0][0][0]=1;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=2;++j)for(int k=0;k<=2;++k){
			if(str[i]!='0'){
				if(k) chkadd(F[i][j][k-1],F[i-1][j][k]);
				else chkadd(F[i][min(j+1,2)][k],F[i-1][j][k]);
			}
			if(str[i]!='1'){
				if(k==2) chkadd(F[i][j][1],F[i-1][j][k]);
				else chkadd(F[i][j][k+1],F[i-1][j][k]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=2;++i)for(int j=0;j<=i;++j)
		chkadd(ans,F[n][i][j]);
	printf("%d\n",ans);
	return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) cout << "No";
    else
    if(a == b || a == c || b == c) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
def resolve():
    import copy
    D = int(input())
    cost = list(map(int, input().split()))
    sat = [list((map(int, input().split()))) for _ in range(D)]
    last = [0]*26

    for i in range(D):
        maxcost = 0
        ans = 0

        for j in range(26):
            nowlast = copy.deepcopy(last)
            nowlast[j] = i+1
            plussat = sat[i][j]
            minussat = 0
            for k in range(26):
                minussat += (i + 1 - nowlast[k]) * (cost[k])
            cum = plussat-minussat

            if maxcost < cum:
                ans = j
                maxcost = cum
        last[ans] = i

        print(ans+1)

resolve()

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

int main()
{
    long long int a,b,c,d;
    cin >> a >> b >> c >> d;
    long long int temp1 = max(a,b)*max(c,d);
    long long int temp2 = max(a,b)*min(c,d);
    long long int temp3 = min(a,b)*max(c,d);
    long long int temp4 = min(a,b)*min(c,d);
    cout << max(temp1,max(temp2,max(temp3,temp4))) << endl;;
    return 0;
   
}

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

using namespace std;


int main() {
    // ?D => DD / PD , quotient = 2
    // P?
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) if (s[i] == '?') s[i] = 'D';
    cout << s << endl;
}


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

#define FOR(i, b, e) for(int i = (int)(b); i < (int)(e); ++i)
#define RFOR(i, b, e) for(int i = (int)(e-1); i >= 0; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>
#define ALL(x) (x).begin(),(x).end()
#define PAIR pair<int,int>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;

using namespace std;

int main() {
	int n;
	cin >> n;
	int t = n / 100;
	int r = 100 * t + 10 * t + t;
	if (n > r) {
		cout << t + 1 << t + 1 << t + 1 << endl;;
	} else {
		cout << t << t << t << endl;;
	}

}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back



int main(){
    int n,r;
    cin >> n >> r;
    if(10>n){
        cout << 100*(10-n)+r << endl;
    }else{
        cout << r << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
int p[N];
int n;

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 1; i < n; i++) {
        if(p[i] == i) {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }
    if(p[n] == n) {
        swap(p[n], p[n - 1]);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int K;
  	cin >> K;
  	string S;
  	cin >> S;
  	
  	if(S.size() <= K){
        cout<<S<<endl;
    }
  	else{
       for(int i=0; i<K; i++)
           cout<<S[i];
  	   cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3600
def ways(number, sum, max)
  return 0 if max <= 0 || sum <= 0
  return max >= sum ? 1 : 0 if number == 1
  min_variation = sum / number 
  return 0 if min_variation == 0
  result = 0
  (1..min_variation).each do |i|
    result += ways(number - 1, sum - i * number, max - i)
  end
  result 
end

while true
  n, x = gets.split(" ").map(&:to_i)
  break if n == 0 && x == 0
  puts ways(3, x, n)
end

Measured memory_bytes: 8696
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
int n;
int main()
{
    cin>>n;
    vector<int> b(n);
    for(int i=0;i<n-1;i++) scanf("%d",&b[i]);
    int ans=b[0]+b[n-2];
    for(int i=0;i<n-2;i++)
        ans+=min(b[i],b[i+1]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

int main() {
    int a, b, h;
    cin >> a >> b >> h;

    cout << (a + b) * h / 2 << endl;

    return 0;
}

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


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

	int mn = 1001;
	int mx = 0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		mn = min(mn,x);
		mx = max(mx,x);
	}

	cout<<mx-mn;
}

Measured memory_bytes: 256
n,_ = map(int, input().split())
rate = list(map(int, input().split()))
rmax = [rate[-1]]*n
for i in range(n-2,-1,-1):
  rmax[i] = max(rmax[i+1],rate[i])
benemax = 0
cnt = 0
for i in range(n-1):
  newr = rmax[i]-rate[i]
  if newr > benemax:
    benemax = newr
    cnt = 1
  elif newr == benemax:
    cnt += 1
print(cnt)

Measured memory_bytes: 15020
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		  Scanner sc = new Scanner(System.in);
	         int n = sc.nextInt();
      		 int m = sc.nextInt();
      		 int a =0;
        for(int i=0; i<m; i++){
           a += sc.nextInt();
        }
      if(a>n){
      System.out.println("-1");
      }else{
        System.out.println(n-a);
      }
    }
}

Measured memory_bytes: 46168
#include <iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if (a < b){
		cout << "a < b" << endl;
	}
	else if (a>b){
		cout << "a > b"<<endl;
	}
	else cout << "a == b" << endl;
	return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
     string s;
     cin>>s;
     ll i,sum=0;
     for(i=0;i<s.length();i++)
       sum+=(s[i]-'0');
     if(sum%9)
       cout<<"No";
     else
       cout<<"Yes";
   }
}


Measured memory_bytes: 3764
#include<iostream>
using namespace std;
string str[8], tmp;
char ch;
int main() {
	while (cin >> str[0]) {
		for (int i = 1; i < 8; i++)cin >> str[i];
		getline(cin, tmp);
		//11
		//11
		for (int i = 0; i < 7; i++) {
			for (int j = 0; j < 7; j++) {
				if (str[i][j] == '1' && str[i + 1][j] == '1' && str[i][j + 1] == '1' && str[i + 1][j + 1] == '1') {
					ch = 'A';
				}
			}
		}

		//1
		//1
		//1
		//1
		for (int i = 0; i < 5; i++) {
			for (int j = 0; j < 8; j++) {
				if (str[i][j] == '1' && str[i + 1][j] == '1' && str[i + 2][j] == '1' && str[i + 3][j] == '1')ch = 'B';
			}
		}

		//1111
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 5; j++) {
				if (str[i][j] == '1' && str[i][j + 1] == '1' && str[i][j + 2] == '1' && str[i][j + 3] == '1')ch = 'C';
			}
		}

		//01
		//11
		//10
		for (int i = 0; i < 6; i++) {
			for (int j = 0; j < 7; j++) {
				if (str[i][j + 1] == '1' && str[i + 1][j] == '1' && str[i + 1][j + 1] == '1' && str[i + 2][j] == '1')ch = 'D';
			}
		}

		//110
		//011
		for (int i = 0; i < 7; i++) {
			for (int j = 0; j < 6; j++) {
				if (str[i][j] == '1' && str[i][j + 1] == '1' && str[i + 1][j + 1] == '1' && str[i + 1][j + 2] == '1')ch = 'E';
			}
		}

		//011
		//110
		for (int i = 0; i < 7; i++) {
			for (int j = 0; j < 6; j++) {
				if (str[i][j + 1] == '1' && str[i][j + 2] == '1' && str[i + 1][j] == '1' && str[i + 1][j + 1] == '1')ch = 'G';
			}
		}

		//10
		//11
		//01
		for (int i = 0; i < 6; i++) {
			for (int j = 0; j < 7; j++) {
				if (str[i][j] == '1' && str[i + 1][j] == '1' && str[i + 1][j + 1] == '1' && str[i + 2][j + 1] == '1')ch = 'F';
			}
		}

		cout << ch << endl;
	}
	return 0;
}


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

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

    int flag = 0;
    int count_b[n];
    int count_w[n];
    int count1 = 0;
    int count2 = 0;
    fill_n(count_b, n, 0);
    fill_n(count_w, n, 0);
    for(int i = 0; i < n; i++){
        //cout << count_b[i] << count_w[i] << endl;
        if(s[i] == '#'){
            count1++;
        }
        else {
            count2++;
        }
        count_b[i] = count1;
        count_w[i] = count2;

    }

    
    int ans = 10000;
    int cb_r = 0;
    int cw_r = 0;
    int cb_l = 0;
    int cw_l = 0;

    ans = min(count1, count2);
    ans = min(ans, count_w[n-1]);
    for(int i = 1; i < n; i++){
       
        
        ans = min(count_b[i-1] + count_w[n-1] - count_w[i], ans);

        
        
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) (x).begin(),(x).end()
typedef vector<int> vi;
#define inf 10e18;
#define pb push_back
#define pii pair<int,int>
#define vector<pii> vp
//int i=0,j=0,k;
#define pi atan(1)*4
#define mp make_pair
#define F first
#define S second
#define loop(n) for(int i=0;i<n;++i)
#define ld long double

int main(){
    int n;cin>>n;
    ll ans = 0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            for(int k=1;k<=n;++k){
                ans += __gcd(i,__gcd(j,k));
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var N = Sarray()[0];
            var points = new List<(int i, int x, int y)>();
            for (var i = 0; i < N; ++i)
            {
                var xy = Sarray();
                points.Add((i, (int)xy[0], (int)xy[1]));
            }
            points.Sort((l, r) => l.x - r.x);
            var dft = new (int dst, int f, int t)[2 * (N - 1)];
            for (var i = 0; i < N - 1; ++i)
                dft[i] = (points[i + 1].x - points[i].x, points[i].i, points[i + 1].i);
            points.Sort((l, r) => l.y - r.y);
            for (var i = 0; i < N - 1; ++i)
                dft[N - 1 + i] = (points[i + 1].y - points[i].y, points[i].i, points[i + 1].i);
            var cst = 0L;
            var uf = new UnionFind((int)N);
            Array.Sort(dft);
            foreach (var d in dft)
            {
                if (uf.issame(d.f, d.t)) continue;
                uf.merge(d.f, d.t);
                cst += d.dst;
            }
            WriteLine(cst);
        }

        class UnionFind
        {
            int[] par;
            public UnionFind(int n)
            {
                init(n);
            }
            public void init(int n)
            {
                par = new int[n];
                for (var i = 0; i < n; ++i) { par[i] = -1; }
            }
            public int root(int x)
            {
                if (par[x] < 0) return x;
                else return par[x] = root(par[x]);
            }
            public bool issame(int x, int y)
            {
                return root(x) == root(y);
            }
            public bool merge(int x, int y)
            {
                x = root(x);
                y = root(y);
                if (x == y) return false;
                if (par[x] > par[y])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                par[x] += par[y];
                par[y] = x;
                return true;
            }
            public int size(int x)
            {
                return -par[root(x)];
            }
        }
    }
}

Measured memory_bytes: 53876
n,x = map(int, input().split())
list = list(map(int, input().split()))

a = 0
i = 0

list.sort()

if list[0] > x:
    print(0)

elif x > sum(list):
    print(n-1)

else:
    while x > 0 and x >= list[i]:
        x -= list[i]
        i += 1
        a += 1
        if i == n:
            break

    print(a)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;


struct Node {
    int v;
    Node* l;
    Node* r;
};

Node* root = NULL;

void insert(int v) {
    if (!root) {
        root = new Node;
        root -> v = v;
        root -> l = NULL;
        root -> r = NULL;
        return;
    }

    Node* par = NULL;
    Node* x = root;
    while (x) {
        par = x;
        if (v < x -> v) {
            x = x -> l;
        } else {
            x = x -> r;
        }
    }
    if (v < par->v) {
        par -> l = new Node;
        Node* p = par -> l;
        p -> v = v;
        p -> l = NULL;
        p -> r = NULL;
    } else {
        par -> r = new Node;
        Node* p = par -> r;
        p -> v = v;
        p -> l = NULL;
        p -> r = NULL;
    }
}

void preOrder(Node* root) {
    if (root == NULL) return ;
    printf(" %d", root -> v);
    preOrder(root -> l);
    preOrder(root -> r);
}

void inOrder(Node* root) {
    if (root == NULL) return ;
    inOrder(root -> l);
    printf(" %d", root -> v);
    inOrder(root -> r);
}


int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    int num;
    char s[10];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", s);
        if (s[0] == 'i') {
            scanf("%d", &num);
            insert(num);
        } else if (s[0] == 'p') {
            inOrder(root);
            printf("\n");
            preOrder(root);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 18796
qty_500 = gets.chomp.to_i
qty_100 = gets.chomp.to_i
qty_50 = gets.chomp.to_i
total_money = gets.chomp.to_i
pattern_count = 0

qty_500.downto(0) do |num_500|
  qty_100.downto(0) do |num_100|
    qty_50.downto(0) do |num_50|
      check_money = 500*num_500 + 100*num_100 + 50*num_50
      pattern_count += 1 if total_money == check_money
    end
  end
end

puts pattern_count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
using ll = long long;
int main()
{
	string s;
    cin >> s;
    int sum = 0;
    for(int i =0; i < s.length(); i++)
    {
        sum += s[i] - '0';
    }
    
    if(sum % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
	return 0;
}

Measured memory_bytes: 3724
N = int(input())
X = list(map(int,input().split()))
sx = sorted(X,reverse=True)
med1 = sx[int(N/2)-1]
med2 = sx[int(N/2)]
ans = []
for x in X:
    if x >= med1:
        ans.append((med2))
    else:
        ans.append((med1))
print(*ans)
        

Measured memory_bytes: 25220
#input:長さ４の英大文字列
#output:文字列が２文字で構成されていてそれぞれ二回出てきているかを判定 Yes,No

S = list(input())
S_K = []
n = 0

for i in range(4):
    if i == 0:
        S_K.append(S[i])
        n += 1
    else:
        if S[i] not in S_K:
            S_K.append(S[i])
            n += 1

if n == 2:
    if S.count(S_K[0]) == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  map<int, int> num;
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
    if( num.count(A.at(i)) ) num.at(A.at(i))++;
    else num[A.at(i)] = 1;
  }
  
  int start;
  if( N%2 == 0 ) start = 1;
  else start = 0;
  for( auto p : num ){
    if( p.first == start ){
      if( start == 0 && p.second != 1 ){
        cout << 0 << endl;
        return 0;
      }else if( start != 0 && p.second != 2 ){
        cout << 0 << endl;
        return 0;
      }
      start += 2;
    }else{
      cout << 0 << endl;
      return 0;
    }
  }
  
  int ans = 1;
  for( int i = 0; i < N/2; i++ ){
    ans = (ans*2)%MOD;
  }
  cout << ans << endl;
  
  
  
}


Measured memory_bytes: 4992
x, y = map(int, input().split())
if y > x:
    ans = y - x
    if y >= abs(x):
        ans = min(ans, 1 + y - abs(x))
    if x < 0 and abs(x) > y:
        ans = min(ans, 1 - y - x)
    print(ans)
elif x < 0:
    print(2 + x - y)
elif abs(x) >= abs(y):
    print(min(1 + x + y, 2 - abs(y) + x))
else:
    print(1 - y - x)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#define M 1000009 ///care!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
using namespace std;
typedef long long ll;
const int maxn=1000000;
const int mod=998244353;
ll jie[M],ni[M],ans;
int n,m;
inline ll rd(){
	int x=0;char c=getchar();bool f=0;
	while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
	while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return f?-x:x;
} 
inline ll power(ll x,ll y){
	ll ans=1;
	while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;} 
	return ans;
}
inline void MOD(ll &x){x=x>=mod?x-mod:x;}
inline ll ny(ll x){return power(x,mod-2);}
inline ll C(int n,int m){return jie[n]*ni[m]%mod*ni[n-m]%mod;}
int main(){
	n=rd();m=rd();
	jie[0]=1;
	for(int i=1;i<=maxn;++i)jie[i]=jie[i-1]*i%mod;
	ni[maxn]=power(jie[maxn],mod-2);
	for(int i=maxn-1;i>=0;--i)ni[i]=ni[i+1]*(i+1)%mod;
    for(int i=1;i<=min(n,m);++i)MOD(ans+=C(2*i,i)*C(n-i+m-i,n-i)%mod);
	ans=ans*ni[2]%mod*ny(C(n+m,m))%mod;
    cout<<(ans+max(n,m))%mod;
	return 0;
}

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

int n , ans=0 , size ;
string name ;
string s ;

int f( int x , int space ){
	int w = 1 ;
	int e = 1 ;
	for( int l = x ; l < size ; l += space ){
		if( name[w] == s[l] ) e++ ;
		w++ ;
		if( w == name.size() ){
			if( e == w ) return 1 ;
			break ;
		}
	}
	return 0 ;
}

int main(){
	
	cin >> n ;
	cin >> name ;
	
	for( int i=0 ; i<n ; i++ ){
		cin >> s ;
		int p = 0 ;
		size = s.size() ;
		for( int j=0 ; j<size ; j++ ){
			if( name[0] == s[j] ){
				for( int k=j+1 ; k<size ; k++ ){
					if( name[1] == s[k] ){
						if( f(k,k-j) == 1 ){
							ans++ ;
							p++ ;
						}
					}
					if( p > 0 ) break ;
				}
			}
			if( p > 0 ) break ;
		}
	}
	
	cout << ans << endl ;
	
return 0 ;
}

Measured memory_bytes: 1208
N = int(input())
A = list(map(int, input().split()))
cur = 1000
kabu = 0

for i, a in enumerate(A):
  for j in (range(i+1, len(A))):
    if A[j] > a:
      n = cur // a
      cur -= n * a
      kabu += n
      break
    elif A[j] < a:
      cur += a * kabu
      kabu = 0 
      break
    else:
      continue

cur += a * kabu
print(cur)

Measured memory_bytes: 9208
a=input()
a=int(a)
b=input().split()
b=[int(i) for i in b]
ans=0
of=0
for i in b:
  if of>=2:
    if b[of-2]>b[of-1]>i or b[of-2]<b[of-1]<i:
      ans+=1
  of+=1
print(ans)


Measured memory_bytes: 3060
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    bool solve(int a, int b, int c) {
        int eq = 0;
        if (a == b) {
            ++eq;
        }
        if (b == c) {
            ++eq;
        }
        if (a == c) {
            ++eq;
        }
        return eq == 1;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b, c;
    cin >> a >> b >> c;
    Solution sol;
    if (sol.solve(a, b, c)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256