akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[] chars = S.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            char ch = chars[i];
            if ((i + 1) % 2 == 0) {
                
                if (ch == 'R') {
                    System.out.print("No");
                    return;
                }
            }
            else {
               
                if (ch == 'L') {
                    System.out.print("No");
                    return;
                }
            }
        }
        System.out.print("Yes");
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

bool good (int x)
{
    int nd = 0;
    while (x > 0)
    {
        nd++;
        x /= 10;
    }
    return (nd % 2 == 1);
}

int main()
{
    ios_base::sync_with_stdio(0);
    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++)
        if (good (i))
            ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

int n, W;
ll weight[109], val[109], V;
ll dp[2][100009];
const ll INF = 1e12;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n >> W;
    for (int i = 1; i <= n; i++)
    {
        cin >> weight[i] >> val[i];
        V += val[i];
    }

    for (int i = 0; i <= 1; i++)
    {
        for (int j = 0; j <= V; j++)
        {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    // j - wartości plecaka, szukamy najmniejszej wagi
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= V; j++)
        {
            if (i != 0) dp[i % 2][j] = min(dp[i % 2][j], dp[(i - 1) % 2][j]);

            if (j >= val[i] && i != 0)
            {
                dp[i % 2][j] =
                    min(dp[i % 2][j], dp[(i - 1) % 2][j - val[i]] + weight[i]);
            }
        }
    }

    for (int i = V; i >= 0; i--)
    {
        if (dp[n % 2][i] <= W)
        {
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 1920
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String s = sc.next();

		char[] c = s.toCharArray();
		int ans = 0;

		for (int i = 0; i < s.length(); i++) {
			if (i < s.length() - 1 - i) {
				if (c[i] != c[s.length() - 1 - i])
					ans++;
			} else
				break;
		}

		System.out.println(ans);

	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23124
#include"bits/stdc++.h"
using namespace std;
#define MOD 1000000007
long long int ppow(long long int i, long long int j) {
	long long int res = 1LL;
	while (j) {
		if ((j & 1LL)) {
			res *= i;
			if (res >= MOD) {
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD) {
			i %= MOD;
		}
	}
	return res;
}
long long int gcd(long long int a, long long int b) {
	if (a > b) {
		swap(a, b);
	}
	while (a) {
		swap(a, b);
		a %= b;
	}
	return b;
}
long long int lcm(long long int a, long long int b) {
	return a / gcd(a, b)*b;
}

int main() {
	int n;
	string a, b, c;
	cin >> n;
	cin >> a;
	cin >> b;
	cin >> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		set<char> f;
		f.insert(a[i]);
		f.insert(b[i]);
		f.insert(c[i]);
		if (f.size() == 1)continue;
		if (f.size() == 2)ans++;
		if (f.size() == 3)ans += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define N 200005
using namespace std;
int read()
{
	int x=0;char ch=getchar();
	while (ch<'0'||ch>'9')ch=getchar();
	while (ch>='0'&&ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}
int n,cnt,a[N],b[N],mul[25],w;
bool p;
struct stk{
	int pos,num,c;
}s[N];int top;
inline void Plus(int x){while (mul[s[x].c]<=s[x].num&&s[x].c<=w)++s[x].c;}
inline void Sub(int x){while (mul[s[x].c-1]>s[x].num)--s[x].c;}
void add(int x)
{
	++top;
	s[top].pos=a[x];
	s[top].num=b[x]-1;
	s[top].c=1;
	Plus(top);
}
bool check(int m)
{
	if (m<=1)return 0;
	mul[1]=m;
	for (w=1;mul[w]<=n/m;++w)mul[w+1]=mul[w]*m;
//	mul[++w]=n+1;
	top=0;
//	add(1);
	for (int i=1;i<=cnt;++i)
	{
		if (a[i]>a[i-1])add(i);
		else
		{
			while (a[i]<=s[top].pos-s[top].c&&top)--top;
			if (!top||s[top].pos<a[i])++b[i],add(i),--b[i];
			else
			{
				if (s[top].pos>a[i])
				{
					int l=s[top].pos-a[i];
					s[top].pos=a[i];
					s[top].num/=mul[l];
					s[top].c-=l;
				}
				s[top].num+=b[i];
				Plus(top);
			}
		}
		for (int j=top;j>1&&s[j].pos-s[j].c<s[j-1].pos;--j)
		{
			int l=s[j].pos-s[j-1].pos,v=s[j].num/mul[l];
			s[j].num-=v*mul[l];
			s[j].c=l;Sub(j);
			s[j-1].num+=v;
			Plus(j-1);
		}
		if (s[1].pos-s[1].c<0)return 0;
	}return 1;
}
int main()
{
	n=read();a[0]=-1;
	for (int i=1,x;i<=n;++i)
	{
		x=read();
		if (x<=a[cnt])p=1;
		if (x!=a[cnt])a[++cnt]=x;
		++b[cnt];
	}
	if (!p){puts("1");return 0;}
	int ans=n;
	for (int A=n-1;A;A>>=1)
	if (check(ans-((A+1)>>1)))ans-=(A+1)>>1;
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll ans;
  if(N<B) ans = (A*N/B);
  else ans = (A*(B-1)/B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> cnt(4,0);
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    switch (s[0])
    {
      case 'G':
      cnt[0]=1;
      break;
      case 'W':
      cnt[1]=1;
      break;
      case 'Y':
      cnt[2]=1;
      break;
      case 'P':
      cnt[3]=1;
      break;
    default:
      break;
    }
  }
  int sum=0;
  for(int i=0;i<4;i++){
    sum+=cnt[i];
    //cout<<cnt[i]<<endl;
  }
  if(sum==3){
    cout<<"Three"<<endl;
  }else{
    cout<<"Four"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline
import numpy as np

def main():
    N, W = [int(item) for item in input().split()]
    item = np.array([[int(item) for item in input().split()] for _ in range(N)])


    dp = np.full((N+1, 10**5 + 1), 10**12+1)
    dp[0][0] = 0

    for i in range(N):
        dp[i+1] = dp[i]
        w, v = item[i]
        np.minimum(dp[i][v:], dp[i][:-v] + w, out=dp[i+1][v:])

    print(np.where(dp[N] <= W)[0][-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 92072
#include <iostream>

using namespace std;

int main(void){
    double N, a[120], s=1;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        s*= a[i];
    }
    double l = 0;
    for(int i = 0; i < N; i++){
        l += (s/a[i]);
    }
    cout << s/l << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    string r, g, b;
    cin >> r >> g >> b;
    string ans = r+g+b;
    int ans_int = stoi(ans);
    if(ans_int%4==0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int h, w ;
  int i, j ;

  while(1){
    scanf("%d %d",&h,&w) ;

    if (h!=0 && w!=0){
      for(i=1 ; i<=h ; i++){
        if(i==1 || i==h){
          for(j=1 ; j<=w ; j++){
            printf("#");
          }
          printf("\n");
        }
        else if (i>1 && i<h) {
          for(j=1 ; j<=w ; j++){
            if(j==1 || j==w){
              printf("#");
            }else{
              printf(".");
            }
          }
          printf("\n");
        }
      }
      printf("\n");
    }
    else if(h==0 && w==0){
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 2028
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n, i, j;
    double sum = 0;
    scanf("%d", &n);
    double a[n];
    for (i=0; i<n; i++) scanf("%lf", &a[i]);

    sort (a, a+n);

    for (i=0; i<n-1; i++) {
        sum += ((a[i] + a[i+1])/2.0);
        a[i+1] = sum;
        sum = 0;
    }
    printf("%lf", a[n-1]);
    return 0;
}


Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	string s;
	int k;
	cin >> s;
	cin >> k;
	set<string> ss;
	int n = s.length();
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 5; j++) {
			if (i + j <= n) {
				ss.insert(s.substr(i, j));
			}
		}
	}
	vector<string> v(ss.begin(), ss.end());
	cout << v[k - 1] << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



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

int dp[1000001];
int main(){
	int N; cin >> N;
	vector<int> h;
	h.resize(N);

	for(int i = 0; i < N; ++i) cin >> h[i];

	for(int i = 0; i < N; ++i){
		if(i == 0) dp[i] = 0;
		else if(i == 1) dp[i] = abs(h[i-1]-h[i]);
		else{
			dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
		}
	}

	cout << dp[N-1] << endl;

	return 0;
}


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

using ll = long long int;
const int MAX_N = (int)(1e5 + 5);

int n;
ll a[MAX_N];

ll ans;

ll comb(ll nn, ll rr) {
  ll son = 1;
  ll mom = 1;
  for (ll i = 1; i <= rr; ++i) {
    son *= (nn - i + 1);
  }
  for (ll i = 1; i <= rr; ++i) {
    mom *= i;
  }
  return son / mom;
}

int main(void) {
  // Here your code !
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
    scanf("%lld", &(a[i]));
  }

  ll maxelem = -1;
  for (int i = 0; i < n; ++i) {
    maxelem = max(maxelem, a[i]);
  }

  ll threshold;
  if (maxelem % 2 == 0) {
    auto divresult = lldiv(maxelem, 2);
    threshold = divresult.quot;
  }
  else {
    auto divresult = lldiv(maxelem, 2);
    threshold = divresult.quot + 1;
  }

  ll son = -1;
  for (int i = 0; i < n; ++i) {
    if (a[i] == maxelem) continue;
    if (abs(threshold - a[i]) < abs(threshold - son)) {
      son = a[i];
    }
  }

  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
    if (a[j] > a[i]) continue;
  }

  printf("%lld %lld\n", maxelem, son);

	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
int n;
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	long long ans = 0;
	sort(a, a+n);
	if(n > 1){
		ans += a[n-1];
	}	
	int k = 2;
	int cnt = 0;
	if(n > 2){
		for(int i = n-2; i >= 1; -- i){
			ans += a[n - k];
			cnt ++;
			if(cnt == 2){
				k ++;
				cnt = 0;
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2512
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    long long n,m;
    scanf("%lld%lld",&n,&m);n%=m;
    printf("%lld\n",min(n,m-n));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint operator^(const u64 rhs) const noexcept {
        return modint(*this) ^= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr modint &operator^=(u64 exp) {
        modint rhs = modint(*this);
        a = 1;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), co(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    mint res = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) {
            co[0]++;
            if (co[0] > 3) {
                cout << 0 << endl;
                return 0;
            }
            continue;
        }
        if (co[a[i] - 1] <= co[a[i]]) {
            cout << 0 << endl;
            return 0;
        }
        res *= mint(co[a[i] - 1] - co[a[i]]);
        co[a[i]]++;
        if (co[a[i]] > 3) {
            cout << 0 << endl;
            return 0;
        }
    }
    if (co[0] == 1) {
        res *= mint(3);
    } else {
        res *= mint(6);
    }
    cout << res.a << endl;
}

Measured memory_bytes: 1024
s = int(input())
a = [s]
for i in range(1000000):
    if a[i]%2 == 0:
        a.append(int(a[i]/2))
    else:
        a.append(a[i]*3 + 1)
    b = set(a)
    if len(b)!=len(a):
        break
print(len(a))


Measured memory_bytes: 3060
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

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

#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;   
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = (int)1e2 + 5;

int arr[MAXN], cnt[MAXN];

int n;

void bye(bool x = 0) {
    printf(x ? "Possible\n" : "Impossible\n");
    exit(0);
}

void solve() {
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
        scanf("%d", &arr[i]);
        ++cnt[arr[i]];
    }

    int D = *max_element(arr + 1, arr + n + 1);
    int R = (D + 1) / 2;

    if (*min_element(arr + 1, arr + n + 1) < R) {
        bye();
    }

    if (cnt[R] != 1 + (D % 2)) {
        bye();
    }

    for (int i = R + 1; i <= D; ++i) {
        if (cnt[i] < 2) {
            bye();
        }
    }

    bye(1);
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
    return 0;
}

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

int main() {
  vector<long long int> array(42);
  long long int turn = 0;
  cin >> array.at(0);
  for (size_t i = 0; i < 41; i++) {
    array.at(i + 1) = array.at(i) / 2;
  }
  for (size_t i = 0; i < 42; i++) {
    if(array.at(i))
      turn += pow(2,i);
  }
  cout << turn << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,i,j,count=0,min,num[1000],temp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	for(i=0;i<n-1;i++)
	{
		min=i;
		for(j=i+1;j<n;j++)
		{
			if(num[j]<num[min])
			{
				min=j;
			}
		}
		temp=num[i];
		num[i]=num[min];
		num[min]=temp;
		if(i!=min) count++;

	}
	for(i=0;i<n;i++){
	printf("%d",num[i]);
	if(i!=n-1) printf(" ");
}
printf("\n");
printf("%d\n",count);
return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<UL> P(N); rep(i, N) { cin >> P[i]; P[i]--; }
		vector<UL> p(N);
		UL ans = 0;
		rep(i, N) {
			p[P[i]] = 1;
			if (P[i]) p[P[i]] += p[P[i] - 1];
			ans = max(ans, p[P[i]]);
		}
		cout << (N - ans) << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[] = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        int l = Integer.parseInt(str[2]);
        int[][] a = new int[n][m];
        int[][] b = new int[m][l];
        long result;
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<n;i++){
            str = br.readLine().split(" ");
            for(int j=0;j<m;j++){
                a[i][j] = Integer.parseInt(str[j]);
            }
        }
        for(int i=0;i<m;i++){
            str = br.readLine().split(" ");
            for(int j=0;j<l;j++){
                b[i][j] = Integer.parseInt(str[j]);
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                result = 0;
                for(int k=0;k<m;k++){
                    result += a[i][k] * b[k][j];
                }
                if(j<l-1) sb.append(result).append(" ");
                else sb.append(result).append("\n");
            }
        }
        System.out.print(sb);
    }
}

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

int main() {
	int N;
	int a[10001];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> a[i];
	int count = 0;
	for (int i = 0; i < N; i++) {
		while (a[i] % 2 == 0) {
			count++;
			a[i] /= 2;
		}
	}
	cout << count << endl;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  long int W,H,x,y;
  cin >> W >> H >> x >> y;
  long int S;
  S = W * H / 2;
  int k = 0;
  if((W%2==0 && x==W/2) && (H%2==0 && y==H/2))
    k = 1;
  if(H * W % 2 == 0)
    cout << S << ".00000000000000 " << k << endl;
  if(H * W % 2 == 1)
    cout << S << ".50000000000000 "  << k << endl;
}

Measured memory_bytes: 256
n = int(input())

ans = 0

if n == 10000:
	ans = 0
else:
	for i in range(1000,11000,1000):
		if 0 < (i - n) < 1000:
			ans = (i - n)
			break
		elif i == n:
			ans == 0

print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int K,S,res=0;
    K=read(), S=read();
    for(ri int i=0;i<=K;i++)
    for(ri int j=0;i+j<=S&&j<=K;j++)
    if(S-i-j<=K) res++;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    int r,c;
    cin >> r >> c;
    vector<vector<int>> data(r+1,vector<int>(c+1));

    rep(i,r){
        rep(j,c){
            cin >> data[i][j];
        }
    }

    for(int i = 0; i < data.size()-1; i++){
        int cnt = 0;
        for(int j = 0; j < data[i].size()-1; j++){
            cnt += data[i][j];
        }
        data[i][data[i].size()-1] = cnt;
    }

    for(int i = 0; i < c+1; i++){
        int cnt = 0;
        for(int j = 0; j < r+1; j++){
            cnt += data[j][i];
        }
        data[r][i] = cnt;
    }

    rep(i,data.size()){
        rep(j,data[i].size()){
            cout << data[i][j];
            if(j < data[i].size()-1)cout << " ";
        }
        cout << endl;
    }

}


Measured memory_bytes: 3164
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>

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


using namespace std;

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vector(istream& in, size_t n) {
    vector<T> ret(n);
    for (size_t i = 0; i < n; ++i) {
        ret[i] = next<T>(in);
    }
    return ret;
}


void solve(istream &in, ostream &out) {
  auto n = next<int>(in);
  auto v = next_vector<int>(in, n);
  vector<int64_t> sums(n + 1);
  FOR(i, n) {
    sums[i + 1] = sums[i] + v[i];
  }
  map<int64_t, int> counts;
  int64_t res = 0;
  FOR(i, n + 1) {
    res += counts[sums[i]];
    ++counts[sums[i]];
  }
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 15104
#include <stdio.h>

using namespace std;

int main(){
	char str[20001];
	int m,tmp,length;
	while(true){
		scanf("%s",str);
		if(str[0] == '-') break;
		length = 0;
		for(int k = 0; str[k] != '\0';k++) length++;
		scanf("%d",&m);
		int index = 0;
		for(int i = 0; i < m; i++){
			scanf("%d",&tmp);
			for(int j = 0; j < tmp; j++){
				str[index+length] = str[index];
				index++;
			}
		}
		for(int p = 0; p < length; p++){
			printf("%c",str[index+p]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 2632
#include<iostream> 
#include<cstdio>
#include<algorithm>
#define ll long long 
using namespace std;
ll mod=1e9+7,ans,c[2002][2002];
int n,k;
void pre(){
	c[0][0]=1;
	for(int i=1;i<=n;i++)
	  for(int j=0;j<=i;j++){
	  	if(i==j||j==0) c[i][j]=1;
	  	else c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	  }
}
int main()
{
	scanf("%d%d",&n,&k);
	pre();
	for(int i=1;i<=k;i++){//c[n-k-1][i-2]+(2*c[n-k-1][i-1])%mod+
		ans=(c[n-k+1][i]*c[k-1][i-1])%mod;
		printf("%lld\n",ans);
	}
	return 0;
}

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

void main_()
{
    ll N, M;
    cin >> N >> M;

    auto ans = M * 1900 + (N - M) * 100;
    for (ll i = 0; i < M; ++i) {
        ans *= 2;
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
  int n, i;
  int c[51];
  int v[51];
  int ans = 0;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++){
    scanf("%d ", &v[i]);
  }
  
  for (i = 0; i < n; i++){
    scanf("%d ", &c[i]);
    if ((v[i] - c[i]) > 0){
      ans += (v[i] - c[i]);
    }
  }
  
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc108_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int x1 = input[0];
            int y1 = input[1];
            int x2 = input[2];
            int y2 = input[3];

            var dis_x = x2 - x1;
            var dis_y = y2 - y1;
            WriteLine($"{x2 - dis_y} {y2 + dis_x} {x1 - dis_y} {y1 + dis_x}");
        }
    }
}

Measured memory_bytes: 13396
//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define INF 2e9
typedef long long ll;
ll n;
char q[211111];
string s;
int main()
{
	cin>>s;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]=='T'&&n>0&&q[n]=='S')
			n--;
		else
			q[++n]=s[i];
	}
	cout<<n;
}

Measured memory_bytes: 832
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	namespace impl
	{
		struct max_t
		{
			template<class T>constexpr T operator()(T&& lhs, T&& rhs)const
			{
				return std::max(lhs, rhs);
			}
		};
		struct min_t
		{
			template<class T>constexpr T operator()(T&& lhs, T&& rhs)const
			{
				return std::min(lhs, rhs);
			}
		};
	}
	constexpr impl::max_t max;
	constexpr impl::min_t min;

	template<class T>auto orderby(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min(); 

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
}

void Main()
{
	std::size_t K;
	std::string str;
	std::cin >> K >> str;
	if (str.size() <= K)
	{
		std::cout << str << std::endl;
	}
	else
	{
		std::cout << str.substr(0, K) << "..." << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define REP(i,n) for (ll i = 0, i##_len = (n); i < i##_len; i++)
#define ALL_OF(v) (v).begin(), (v).end()
constexpr ll LINF = numeric_limits<ll>::max();
constexpr ll  INF = numeric_limits<int>::max();

int main() {

    ll n, m, s, t; cin >> n >> m >> s >> t; s--; t--;
    vector<vector<tuple<ll, ll, ll>>> g(n * 3);
    REP(i, m) {
        ll a, b, c, d; cin >> a >> b >> c >> d;
        a--; b--; c--;
        ll idx[3] = {a, b, c};
        REP(x, 3) REP(y, 3) if (x != y) {
            g[idx[x]].emplace_back(idx[y], i, d);
        }
    }

    using pll = tuple<ll, ll, ll>;
    priority_queue<pll, vector<pll>, greater<pll>> q;
    vector<ll> dp(n, LINF);
    dp[s] = 0;
    q.push(pll(0, s, -1));
    while (q.size()) {
        ll d, u, x; tie(d, u, x) = q.top(); q.pop();
        if (dp[u] < d) continue;
        for (auto &p : g[u]) {
            ll v, y, c; tie(v, y, c) = p;
            if (x == y) continue;
            if (dp[v] > d + c) {
                dp[v] = d + c;
                q.push(pll(dp[v], v, y));
            }
        }
    }
    cout << dp[t] << endl;

}


Measured memory_bytes: 36192
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int counter=0;
  for(int i=0;i<S.size();i++){
      int j=0;
      for(int k=0;k<i+1;k++){
       if(S.at(i-k)=='A'||S.at(i-k)=='T'||S.at(i-k)=='G'||S.at(i-k)=='C'){
         j++;
       }
        else{
          break;
        }
      }
    counter=max(counter,j);
  }
  cout<<counter<<endl;
}
        
        
      
    

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

string s, op;
vector<long long> memo, dep, v;
stack<long long> st;
set<long long> answers;

long long solve();

int main() {
  while(1) {
    cin >> s;
    if(s == "#") break;
    cout << solve() << endl;
  }
  return 0;
}

long long solve() {
  long long height = 0, n = s.size();
  op = "";
  memo.clear();
  v.clear();
  dep.clear();
  answers.clear();
  for(int i = 0; i < n;) {
    if(s[i] == '(')
      ++height, ++i;
    else if(s[i] == ')')
      --height, ++i;
    else if(isdigit(s[i])) {
      long long now = 0;
      while(i < n && isdigit(s[i])) {
        now *= 10;
        now += s[i] - '0';
        ++i;
      }
      memo.push_back(now);
    }
    else {
      op += s[i];
      dep.push_back(height);
      v.push_back(v.size());
      ++i;
    }
  }
  n = v.size();
  if(n == 0) return 1;
  do {
    bool ch = 1;
    height = dep[v[0]];
    for(int i = 0; i < n; ++i)
      if(dep[v[i]] <= height)
        height = dep[v[i]];
      else
        ch = 0;
    if(!ch) continue;
    st.push(memo[n]);
    for(int i = n - 1; i >= 0; --i) {
      st.push(i);
      st.push(memo[i]);
    }
    ch = 1;
    for(int t = 0; t < n; ++t) {
      stack<long long> tmp;
      while(1) {
        tmp.push(st.top());
        st.pop();
        if(st.top() == v[t]) break;
        tmp.push(st.top());
        st.pop();
      }
      st.pop();
      char nowop = op[v[t]];
      long long x = tmp.top(), y = st.top();
      st.pop();
      tmp.pop();
      if(nowop == '+')
        st.push(x + y);
      else if(nowop == '-')
        st.push(x - y);
      else if(nowop == '*')
        st.push(x * y);
      else {
        if(y == 0) {
          ch = 0;
          while(!st.empty()) st.pop();
          break;
        }
        st.push(x / y);
      }
      while(!tmp.empty()) {
        st.push(tmp.top());
        tmp.pop();
      }
    }
    if(!ch) continue;
    answers.insert(st.top());
    st.pop();
    assert(st.empty());
  } while(next_permutation(v.begin(), v.end()));
  return answers.size();
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
#include<algorithm>

const long long INF = 1ll << 60;

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

int main(){
	int n, k;
	std::cin >> n >> k;
	std::vector<long long> h(n);
	for(int i=0; i<n; i++){
		std::cin >> h[i];
	}
	std::vector<long long> dp(n, INF);

	dp[0] = 0;
	for(int i=0; i<n; i++){
		for(int j=0; j<=k; j++){
			if(i+j>=n) continue;
			chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
		}
	}
	std::cout << dp[n-1] << std::endl;
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

x = int(input())
for a in range(-300,300):
  for b in range(-300,300):
    if pow(a,5)-pow(b,5) == x:
      print(a,b);exit()

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

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n){
		cin >> a[i];
	}
	int ans = a[0];
	for(int i = 1; i < n; i++){
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> vec(3);
  vec = {A, B, C};
  sort(vec.begin(),vec.end());
  if (vec.at(0) == 5 && vec.at(1) == 5 && vec.at(2) == 7) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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


int main(){
  ll n;
  string s;
  cin >> n >> s;
  
  bool v = false;
  int ans = 1;
  for(ll i=0; i<n-1; i++){
    if(s[i] != s[i+1]){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 512
s = input()

dp = [True] * (len(s)+1)

check = ['dream', 'dreamer', 'erase', 'eraser']

for i in range(1,len(s)+1):
	found = False
	for word in check:
		j = i - len(word)
		if j >= 0 and s[j:i] == word and dp[j]:
			found = True
			break
	dp[i] = found

if dp[len(s)]:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 4084
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int w,a,b;
	scanf("%d%d%d",&w,&a,&b);
	if (a+w>=b&&a<=b){
		printf("%d",0);
		return 0;
	}
		if (b+w>=a&&b<=a){
		    printf("%d",0);
		    return 0;
		}
		else {
			printf("%d",max(b-w-a,a-w-b));
		}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    map<string, int> S;
    for (int i = 0; i < N; i++) {
        string tmp;
        cin >> tmp;
        S[tmp]++;
    }
    cout << "AC x " << S["AC"] << endl;
    cout << "WA x " << S["WA"] << endl;
    cout << "TLE x " << S["TLE"] << endl;
    cout << "RE x " << S["RE"] << endl;

    return 0;
}


Measured memory_bytes: 3640
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
  string s;
  cin >> s;
  int sum = 0;
  rep(i,3) sum += s[i] - '0';
  cout << sum << endl;
  return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;


class B {
	int X;

public:
	void solve()
	{
		cin >> X;

		int ans{ 1 }; // 1 is always an answer
		int tmp;
		for (int base{ 2 }; base <= (int)sqrt(X); base++)
		{
			tmp = base * base;

			while (X >= tmp)
			{
				tmp *= base;
			}
			tmp /= base;
			if (tmp > ans) ans = tmp;

		}

		cout << ans << endl;
	}
};


class A {
	int a, b, c, d;

public:
	void solve()
	{
		cin >> a >> b >> c >> d;

		if ((abs(a - c) <= d) || ((abs(b - a) <= d) && (abs(c - b) <= d))) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    string s;
    cin>>s;
    int ans=0;
    f(i,0,sz(s)-1)
        ans+= s[i]-'0';
    if(ans%9)   cout<<"No";
    else    cout<<"Yes";
}

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

int main()
{
    long long n;
    cin >> n;
    vector<long long> a(n), b(n);
    rep(i, n) cin >> a.at(i);
    rep(i, n) cin >> b.at(i);

    long long sum_a = 0, sum_b = 0;
    for (long long i = 0; i < n; i++)
    {
        sum_a += a.at(i);
        sum_b += b.at(i);
    }

    if (sum_a <= sum_b)
    {
        cout << -1 << endl;
        return 0;
    }

    bool is_all_ok = true;
    for (long long i = 0; i < n; i++)
    {
        if (a.at(i) < b.at(i))
        {
            is_all_ok = false;
            break;
        }
    }
    if (is_all_ok)
    {
        cout << 0 << endl;
        return 0;
    }

    long long s = 0;
    long long answer = 0;
    for (long long i = 0; i < n; i++)
    {
        if (a.at(i) < b.at(i))
        {
            s += b.at(i) - a.at(i);
            answer++;
        }
    }

    vector<long long> ab(n);
    rep(i, n) ab.at(i) = a.at(i) - b.at(i);

    sort(ab.begin(), ab.end(), greater<long long>());
    for (long long i = 0; i < n; i++)
    {
        s -= ab.at(i);
        answer++;
        if (s <= 0)
        {
            break;
        }
    }

    cout << answer << endl;
    return 0;
}

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

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

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

    int res = 0;
    for(auto k: cnt){

        if(k.first > k.second) res += k.second;
        if(k.first < k.second) res += (k.second-k.first);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 8096
import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
 
int main() {
        int[] hs;
        string l;
        int h;
        while((l = readln()).length >= 2) hs ~= to!int(to!float(l.split()[0]));
        sort!("a > b")(hs);
        printf("%d\n", hs[0]);
        printf("%d\n", hs[1]);
        printf("%d\n", hs[2]);
        return 0;
}

Measured memory_bytes: 1120
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <limits.h>
#include <memory.h>


using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef vector<double> vec;
typedef vector<vec> mat;

ll a[55];//

int main() {

	ll k;
	cin>>k;

	FORI(0,50){
		a[i]=i+k/50;	
	}
	FORI(0,k%50){
		FORJ(0,50){
			if(j==i){
				a[j]+=50LL;
			}
			else{
				a[j]--;
			}
		}
			
	}
	cout << 50 << endl;
	FORI(0,50){
		printf("%lld%c",a[i],(i<49)?' ':'\n');
	}
	
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 998244353;
const int INF = 2e18;

signed main() {
    int N, M;
    cin >> N >> M;
    map<int, int> count, check;
    for (int i = 0; i < N; i++) {
        int X;
        cin >> X;
        count[X % M]++;
        check[X]++;
    }
    map<int, int> oddCount;
    for (auto temp : check) {
        if (temp.second % 2 == 1) oddCount[temp.first % M]++;
    }
    int ans = count[0] / 2;
    if (M % 2 == 0) {
        ans += count[M / 2] / 2;
        count[M / 2] = 0;
        oddCount[M / 2] = 0;
    }
    for (int i = 1; i <= M / 2 - (M % 2 == 0); i++) {
        int minus = min(count[i], count[M - i]);
        count[i] -= minus;
        oddCount[i] -= minus;
        count[M - i] -= minus;
        oddCount[M - i] -= minus;
        ans += minus;
    }
    for (int i = 1; i <= 1e5; i++) {
        ans += (count[i] - max(0LL, oddCount[i])) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
#define parent(i) i/2
#define left(i) i*2
#define right(i) i*2+1
using namespace std;
int main(){
    int h;
    scanf("%d",&h);
    int heap[h+1];
    for(int i=1;i<=h;++i) scanf("%d",&heap[i]);
    for(int i=1;i<=h;++i){
        printf("node %d: key = %d, ",i,heap[i]);
        if(parent(i)>0&&parent(i)<=h) printf("parent key = %d, ",heap[parent(i)]);
        if(left(i)>0&&left(i)<=h) printf("left key = %d, ",heap[left(i)]);
        if(right(i)>0&&right(i)<=h) printf("right key = %d, ",heap[right(i)]);
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<string.h>
char a[105][3],b[105][3],c[105][3];
void squt(char a[],char b[]){
    char s[105];
    strcpy(s,a);memset(a,0,strlen(a));
    strcpy(a,b);memset(b,0,strlen(b));
    strcpy(b,s);
}
int main(){
    char s;
int n,m,i,j,k,bo=1;
scanf("%d%c",&n,&s);
for(i=0;i<n;i++){
    scanf("%s",a[i]);
    strcpy(b[i],a[i]);
}
for(i=1;i<n;i++){
    for(j=0;j<n-i;j++)
    {
        if(a[j][1]>a[j+1][1]){
            squt(a[j],a[j+1]);
        }
    }
}
for(i=0;i<n;i++){
        m=i;
        for(j=i;j<n;j++){

        if(b[j][1]<b[m][1])m=j;
         }
        squt(b[i],b[m]);
}

for(i=0;bo!=0&&i<n;i++){

    if(a[i][0]!=b[i][0]||a[i][1]!=b[i][1])bo=0;

}
for(i=0;i<n-1;i++)printf("%s ",a[i]);printf("%s",a[n-1]);

printf("\nStable\n");
for(i=0;i<n-1;i++)
printf("%s ",b[i]);printf("%s",b[n-1]);
if(bo==0)
printf("\nNot stable\n");
else printf("\nStable\n");
return 0;
}

Measured memory_bytes: 2820