akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

unsigned long long int inversions = 0;

// merge merges the array from [left, middle) with [middle, right).
void merge(int *array, int left, int middle, int right)
{
  int *leftArray, *rightArray, i, j, k,
    leftSize = middle-left, rightSize = right-middle;
  leftArray = (int *) malloc(leftSize*sizeof(int));
  rightArray = (int *) malloc(rightSize*sizeof(int));
  // assign the values from array to the left and right arrays
  for ( i = 0; i < leftSize; i++ )
    leftArray[i] = array[left+i];
  for ( i = 0; i < rightSize; i++ )
    rightArray[i] = array[middle+i];
  i = 0; // leftArray index
  j = 0; // rightArray index
  // merge leftArray and rightArray
  for ( k = left; k < right; k++ )
    {
      // if we are at the end of the leftArray
      if ( i == leftSize )
	array[k] = rightArray[j++];
      // if we are at the end of the rightArray
      else if ( j == rightSize )
	array[k] = leftArray[i++];
      // if the leftArray contains the next element
      else if ( leftArray[i] <= rightArray[j] )
	array[k] = leftArray[i++];
      // if the rightArray contains the next element
      else
	{
	  array[k] = rightArray[j++];
	  inversions += leftSize-i;
	}
    }
  return;
}

// mergeSort recursively splits the array into smaller chunks and then
// merges those chunks.
void mergeSort(int *array, int left, int right)
{
  // only split the array if the piece isn't yet length 1
  if ( left+1 < right )
    {
      int middle = (left + right)/2;
      mergeSort(array, left, middle);
      mergeSort(array, middle, right);
      merge(array, left, middle, right);
    }
  return;
}

int main()
{
  int length, *array, i;
  // get input
  scanf(" %d", &length);
  array = (int *) malloc(length*sizeof(int));
  for ( i = 0; i < length; i++ )
    scanf(" %d", array+i);
  // sort the array using mergeSort
  mergeSort(array, 0, length);
  /* for ( i = 0; i < length; i++ ) */
  /*   printf("%d%c", array[i], i == length-1 ? '\n' : ' '); */
  // print the number of inversions
  printf("%llu\n", inversions);
  return 0;
}



Measured memory_bytes: 25488
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>

using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

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

  int a,b;
  cin>>a>>b;
  string s;
  bool flag=1;
  cin>>s;
  if(s[a]!='-'){flag=0;}
  else
  {
    s[a]='1';
    flag=all_of(s.begin(),s.end(),[](unsigned char a){return isdigit(a);});


  }
  cout<<yn(flag);


}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn main() {
    let n = read::<u32>();
    let s: std::collections::HashSet<String> = (0..n).map(|_| read()).collect();

    println!("{}", s.len());
}


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

int main(void) {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = n;
    for (int i = 0; i < n; ++ i) {
        int x;
        cin >> x;
        if (x >= a && x < b) -- ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;


int main(void){
    string s;
    cin>>s;
    if(s.length()==1){
        cout<<"YES"<<endl;
        return 0;
    }
    if(s.length()==2){
        if(s=="aa" || s=="bb" ||s=="cc")cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
        return 0;
    }
    map<char,int>m;
    int n = s.length();
    set<char>alpha;
    for(int i=0;i<n;i++){
        m[s[i]]++;
        alpha.insert(s[i]);
    }
    if(alpha.size()<3){
        cout<<"NO"<<endl;
        return 0;
    }
    int mi = min(m['a'],min(m['b'],m['c']));
    vector<char>k;
    for(char y ='a';y<='c';y++){
        m[y]-=mi;
    }
    for(auto itr = alpha.begin();itr!=alpha.end();++itr){
        char now = *itr;
        if(m[now]!=0)k.push_back(now);
    }
    if(k.size()==0){
        cout<<"YES"<<endl;
        return 0;
    }
    if(k.size()==1){
        if(m[k[0]]>1)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
    else{
        if(m[k[0]]==1 && m[k[1]]==1)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

int n, m;
Vi va;
vector<pii> vm;
priority_queue<int, Vi, greater<int>> que;

void init()
{
	cin >> n >> m;
	va.resize(n);
	REP(i, n) cin >> va[i];
	vm.reserve(m);
	REP(i, m)
	{
		int b, c; cin >> b >> c;
		vm.push_back(pii(c, b));
	}
	sort(ALL(vm), greater<pii>());
}


int main()
{
	init();

	int i = 0;
	while (que.size() < n && i < m)
	{
		int x = vm[i].first;
		int t = vm[i].second;
		REP(_i, t)
			que.push(x);
		++i;
	}

	REP(i, n)
		que.push(va[i]);

	while (que.size() > n)
		que.pop();
	
	ll ans = 0;
	REP(i, n)
	{
		ans += (ll)que.top();
		que.pop();
	}

	cout << ans << endl;
	
}

//// done A-D in 15min on Sep 27, 2019 ////


Measured memory_bytes: 2552
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
ll a[110];
vector<ll> vec;
ll sum=0;
ll len;
int main(){
  ll x,y;
  cin >> x >> y;
  cout << x + y / 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

using graph = vector<vector<int>>;

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

  graph g(n);

  REP(i, n-1){
    int u, v; cin >> u >> v;
    --u; --v;

    g[u].push_back(v);
    g[v].push_back(u);
  }

  vector<int> c(n);
  REP(i, n) cin >> c[i];

  sort(c.begin(), c.end());
 
  int i=0;
  vector<int> a(n, -1);
  function<int(int, int)> rec = [&](int v, int bv){
    int ret = 0;
    for(int u : g[v]){
      if(u != bv) ret += rec(u, v) + a[u];
    }

    a[v] = c[i++];

    return ret;
  };

  cout << rec(0, -1) << endl;
  for_each(a.begin(), a.end(), [](const int x){ cout << x << " "; });
  cout << endl;

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  string ans;
  for(int bit = 0; bit < (1<<(n-1)); bit++){
    int temp = s[0] - '0';
    ans = s[0];
    for(int i = 0; i < n-1; i++){
      if(bit & (1<<i)){
        temp += s[i+1] - '0';
        ans += "+";
        ans += s[i+1];
      }else{
        temp -= s[i+1] - '0';
        ans += "-";
        ans += s[i+1];
      }
    }
    if(temp == 7){
        cout << ans << "=7" << endl;
        return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <complex>
using namespace std;


int main() {
	int N,Y;
	cin >> N >> Y;
	int rest[2], x[2] = {};
	int matrix_m[2][2] = { {1,-1000},{-1,5000} };

	int max_i = Y/10000;
	for (int i = 0; i <= max_i; i++) {
		rest[0] = Y - 10000 * i;
		rest[1] = N - i;
		for (int r = 0; r < 2; r++) {
			x[r] = 0;
			for (int c = 0; c < 2; c++) {
				x[r] += matrix_m[r][c] * rest[c];
			}
		}
		if (x[0] >= 0 && x[1] >= 0 && x[0] % 4000 == 0 && x[1] % 4000 == 0){
			cout << i << ' ' << x[0] / 4000 << ' ' << x[1] / 4000 << endl;
			return 0;
		}
			

	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int N;
    cin >> N;

    N = 2*N;
    vi L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    sort(all(L));
    int ans=0;
    for (int i = 0; i < N; i+=2) {
        ans += L[i];
    }
    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(3e5) + 5;
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll w,h;
    vector<P> edges;
    cin >> w >> h;
    REP(i,w){
        ll p;
        cin >> p;
        edges.push_back({p,0});
    }
    REP(i,h){
        ll q;
        cin >> q;
        edges.push_back({q,1});
    }
    sort(ALL(edges));
    ll ans = 0;
    for(auto e : edges){
        ans += e.first*(e.second?w+1:h+1);
        if(e.second)h--;
        else w--; 
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

bool U[3000];

int main()
{
    ll L, R;
    cin >> L >> R;
    memset(U, 0, sizeof(U));
    FOR(i, R + 1, L)
    {
        if (U[i % 2019])
            break;
        U[i % 2019] = true;
    }

    ll min = 2019;
    REP(i, 2020)
    {
        if (!U[i])
            continue;
        FOR(j, 2020, i + 1)
        {
            if (!U[j])
                continue;
            min = std::min(min, i * j % 2019);
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;



int main(){

    int n,m;
    cin >> n >> m;

    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

const int Mod = 1000000007;
const int MN = 300005;

inline void Add(int &x, int y) { x -= (x += y) >= Mod ? Mod : 0; }

int N;
char S[MN];
int t0[7] = {2, 4, 0, 0, 6, 5, 4}, t1[7] = {3, 5, 0, 1, 1, 5, 4};
int f[7], g[7];

int main() {
	scanf("%s", S + 1), N = strlen(S + 1);
	f[0] = S[1] != '1', f[1] = S[1] != '0';
	for (int i = 2; i <= N; ++i) {
		for (int j = 0; j < 7; ++j) g[j] = 0;
		for (int j = 0; j < 7; ++j) {
			if (S[i] != '1') Add(g[t0[j]], f[j]);
			if (S[i] != '0') Add(g[t1[j]], f[j]);
		}
		std::swap(f, g);
	}
	printf("%d\n", (f[1] + f[5]) % Mod);
	return 0;
}

Measured memory_bytes: 512
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

template <typename T>
struct twodim_fenwick_tree {
    int h, w;
    vector<vector<T>> data;
    twodim_fenwick_tree(int h, int w) : h(h), w(w), data(h+1, vector<T>(w+1)) {}
    void add(int r, int c, T x=1) {
        for (int i = r+1; i <= h; i += i&-i)
            for (int j = c+1; j <= w; j += j&-j) data[i][j] += x;
    }
    T sum(int r, int c) {
        T res = 0;
        for (int i = r; i; i -= i&-i)
            for (int j = c; j; j -= j&-j) res += data[i][j];
        return res;
    }
    T sum(int r1, int c1, int r2, int c2) {
        return sum(r2, c2) - sum(r1, c2) - sum(r2, c1) + sum(r1, c1);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    twodim_fenwick_tree<int> ft(1001, 1001);
    rep(i, n) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        ft.add(a, b, 1);
        ft.add(a, d, -1);
        ft.add(c, b, -1);
        ft.add(c, d, 1);
    }
    int ans = 0;
    for (int i = 1; i <= 1001; ++i) {
        for (int j = 1; j <= 1001; ++j) {
            chmax(ans, ft.sum(i, j));
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 6848
#include <bits/stdc++.h>
#define ll long long int
#define mod int(1e9+7)
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll ans=0ll,pre=1ll*a[0];
	for(int i=1;i<n;i++){
		ans=(ans+(pre*1ll*a[i])%mod)%mod;
		pre=(pre+1ll*a[i])%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  ll n, m;
  cin >> n >> m;
  priority_queue<ll> a;
  int A;
  rep(i, n) {
    cin >> A;
    a.push(A);
  }
  while(m) {
    int x = a.top();
    a.pop();
    x /= 2;
    a.push(x);
    m--;
  }
  ll res = 0;
  rep(i, n) {
    res += a.top();
    a.pop();
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

#define int long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 1000005

vector<int>prime;
char sieve[SIZE];
map<int,int>factors;//used for prime factorization

void isprime(int n)
{
    sieve[0] = 1,sieve[1] = 1;
    sieve[2] = 0;
    for(int i =4; i <= n; i+=2) sieve[i] = 1;
    for(int i = 3; i <= sqrt(n); i+=2)
    {
		if(sieve[i] == 0)
		{
			for(int j = i*i; j <= n; j+= 2*i)
			{
				sieve[j] = 1;
			}
		}
	}
	prime.push_back(2);
	for(int i = 3; i <= n; i+=2)
	{
		if(sieve[i] == 0) prime.push_back(i);
	}	
}

void factorize(int n)
{
	int sqrtn = sqrt(n);
	for(int i = 0; i < prime.size() && prime[i] <= sqrtn; i++)
	{
		//if(sieve[n] == 0) break;
		if(n%prime[i] == 0)
		{
			while(n%prime[i] == 0)
			{
				n /= prime[i];
				factors[prime[i]]++;
			}
			sqrtn = sqrt(n);
		}
	}
	if(n != 1)
	{
		factors[n]++;
	}
	int tot = 0;
	for(auto it : factors)
	{
		int ans = it.second;
		int total = 0;
		int times = 0;
		for(int i = 1; i <= ans; i++)
		{
			if(total+i > ans) break;
			total+=i;
			times++;
		}
		tot+=times;
	}
	cout << tot << endl;
}

int32_t main()
{
	isprime(1000000);
	int n;
	cin >>n;
	if(n == 1) 
	{
		cout << 0 << endl;
		return 0;
	}
	factorize(n);
	factors.clear();
	return 0;
}


Measured memory_bytes: 5128
/*
=============================================================

------------------Welcome To My Code-------------------------

---------Ankit Kumar || IIITBH || CSE || 2018-2022-----------

=============================================================
*/

#include <bits/stdc++.h>

using namespace std;

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
map<ll, ll>::iterator itr;
vector<ll>::iterator it, it1;
const double PI = 3.141592653589793238;

int main()
{
	FASTIO;
	ll t;


        ll i=0,j,k,x,y,z,m,n,a,b,c,c1=0,c2=0,flag=0,sum=0;
	string s,s1,str;
	map<ll,ll>MAP;
	vector<ll>v;
	cin>>s;

	while(i<s.size())
    {
        char r=s[i];
        x=r-'0';

        sum=sum+x;
        i++;
    }

    if(sum%9==0)
        cout<<"Yes";
    else
        cout<<"No";




}


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

using namespace std;

typedef long long lli;

main(){
  lli n, h[501];
  cin >> n;
  h[0] = 0;
  for(int i=1;i<=n;i++) cin >> h[i];
  sort(h, h+n);
  lli ans = 0, pre = 0;
  for(int i=1;i<=n;i++){
    lli rem = n - i + 1;
    lli id = min(rem / 4, h[i]);
    lli a = rem * (h[i] - h[i-1]);
    lli b = max(0LL, rem * id - rem * pre) - max(0LL, (id * (id + 1) * 2 - pre * (pre + 1) * 2));
    ans += a - b; 
    pre = id;
  }
  cout << ans + 1 << endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

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

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

vll color;

bool dfs(const vvll &G, ll v, ll cur=0){
 color[v]=cur;
 for(auto nv :G[v]){
   if(color[nv]!=-1){
    if(color[nv]==cur) return false;
    continue;
}
 if(!dfs(G,nv,1-cur)) return false;
}
return true;
}

void solve(){
 ll n,m;
  cin >> n >> m;
  
  vvll G(n);
  rep(i,0,m){
   ll a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].eb(b);
    G[b].eb(a);
  }
  
  color.assign(n,-1);
bool bipartite=true;
rep(v,0,n){
 if(color[v]!=-1) continue;
 if(!dfs(G,v)) bipartite=false;
}
  ll b=sum(color);
  if(bipartite) cout << b*(n-b)-m << endl;
  else cout << n*(n-1)/2-m << endl;
   
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

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

signed main(){
	int N, M, i, S = 0;
	scanf("%d%d", &N, &M);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
		S += A[i];
	}
	sort(A.begin(), A.end(), greater<int>());
	if(A[M - 1] * 4 * M >= S){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
m = gets.chomp.split("")

w = m.select{|t| t == "W"}.count
e = m.select{|t| t == "E"}.count
lw = 0
le = 0
result = w + e

m.each do |t|
  if t == "W"
    lw += 1
    w -= 1
    result = lw + e - 1 if result > lw + e
  else
    le += 1
    e -= 1
    result = lw + e if result > lw + e
  end
end

puts result

Measured memory_bytes: 30732
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vi vector<ll>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vt vector<tuple<ll, ll, ll>>
using namespace std;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll n;
	cin >> n;
	Graph g(n);
	REP(i, n)
	{
		ll t;
		cin >> t;
		add_edge(g, i, t - 1, 1);
	}
	vi isdone(n, 0);
	ll pos = 0, dep = 0;
	while (pos != 1 && !isdone[pos])
	{
		isdone[pos] = 1;
		pos = g[pos].front().to;
		dep++;
	}
	cout << (pos == 1 ? dep : -1) << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include<climits>
using namespace std;
int main() {
    int n;cin>>n;
    int k;cin>>k;

    int  h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[n];
    for(int i=0;i<n;i++){
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    if(k>n){
       for(int i=2;i<n;i++){
        for(int j=i-1;j>=0;j--){
            dp[i]=min(abs(h[i]-h[j])+dp[j],dp[i]); 
        }
    } 
    }
    else{
    for(int i=2;i<k;i++){
        for(int j=i-1;j>=0;j--){
            dp[i]=min(abs(h[i]-h[j])+dp[j],dp[i]); 
        }
    }
    for(int i=k;i<n;i++){
        for(int j=i-1;j>=i-k;j--){
            dp[i]=min(abs(h[i]-h[j])+dp[j],dp[i]); 
        }
        
    }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	s := Scanner()
	ans := 0
	r := make([]int, 0)
	g := make([]int, 0)
	b := make([]int, 0)
	for i := 0; i < n; i++ {
		if string(s[i]) == "R" {
			r = append(r, i)
		} else if string(s[i]) == "G" {
			g = append(g, i)
		} else if string(s[i]) == "B" {
			b = append(b, i)
		}
	}
	for i := 0; i < len(r); i++ {
		for j := 0; j < len(g); j++ {
			x, y := r[i], g[j]
			if x < y {
				idx := sort.SearchInts(b, y)
				ans += len(b) - idx
				if 2*y-x < n {
					if string(s[2*y-x]) == "B" {
						ans -= 1
					}
				}
			}
		}
		for j := 0; j < len(b); j++ {
			x, y := r[i], b[j]
			if x < y {
				idx := sort.SearchInts(g, y)
				ans += len(g) - idx
				if 2*y-x < n {
					if string(s[2*y-x]) == "G" {
						ans -= 1
					}
				}
			}
		}
	}
	for i := 0; i < len(g); i++ {
		for j := 0; j < len(r); j++ {
			x, y := g[i], r[j]
			if x < y {
				idx := sort.SearchInts(b, y)
				ans += len(b) - idx
				if 2*y-x < n {
					if string(s[2*y-x]) == "B" {
						ans -= 1
					}
				}
			}
		}
		for j := 0; j < len(b); j++ {
			x, y := g[i], b[j]
			if x < y {
				idx := sort.SearchInts(r, y)
				ans += len(r) - idx
				if 2*y-x < n {
					if string(s[2*y-x]) == "R" {
						ans -= 1
					}
				}
			}
		}
	}
	for i := 0; i < len(b); i++ {
		for j := 0; j < len(g); j++ {
			x, y := b[i], g[j]
			if x < y {
				idx := sort.SearchInts(r, y)
				ans += len(r) - idx
				if 2*y-x < n {
					if string(s[2*y-x]) == "R" {
						ans -= 1
					}
				}
			}
		}
		for j := 0; j < len(r); j++ {
			x, y := b[i], r[j]
			if x < y {
				idx := sort.SearchInts(g, y)
				ans += len(g) - idx
				if 2*y-x < n {
					if string(s[2*y-x]) == "G" {
						ans -= 1
					}
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1984
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

def main():
    n = int(input())
    a = list(map(int, input().split()))
    p, q, r, s = a[0], a[1], a[2], sum(a[3:])
    lb, rb = 1, 3
    ans = max(p, q, r, s) - min(p, q, r, s)
    for mb in range(2, n-1):
        if mb > 2:
            q += a[mb-1]
            r -= a[mb-1]
        if mb == rb:
            r = a[rb]
            s -= a[rb]
            rb += 1
        while lb+1 < mb and abs(q-p) >= abs(p+a[lb] - (q-a[lb])):
            p += a[lb]
            q -= a[lb]
            lb += 1
        while rb+1 < n and abs(s-r) >= abs(r+a[rb] - (s-a[rb])):
            r += a[rb]
            s -= a[rb]
            rb += 1
        ans = min(ans, max(p, q, r, s) - min(p, q, r, s))
    print(ans)


if __name__ == '__main__':
    main()


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

int main(void){
    vector<string> s(3);
    for(int i=0;i<3;i++)
        cin>>s[i];

    for(int i=0;i<3;i++){
        s[i][0]+='A'-'a';
        cout<<s[i][0];
    }

    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#解説参照
n,m=map(int, input().split())
*a,=map(int, input().split())
*b,=map(int, input().split())
a.sort();b.sort()

import bisect

sa=set(a);sb=set(b)
if len(sa)<n or len(sb)<m:
    print(0)
    exit()
ans=1;mod=10**9+7

for x in range(n*m,0,-1):
    if x in sa and x in sb:
       continue
    if x in sa:
        j=bisect.bisect_left(b,x)
        ans*=m-j
        ans%=mod
    elif x in sb:
        j=bisect.bisect_left(a,x)
        ans*=n-j
        ans%=mod
    else:
        i=bisect.bisect_left(a,x)
        j=bisect.bisect_left(b,x)
        ans*=(m-j)*(n-i)-(n*m-x)
        ans%=mod
print(ans)



Measured memory_bytes: 45148
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,y;
	cin >> n >> y;
	int Y=y/1000;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			int k=n-i-j;
			if(i+5*j+10*k==Y&&k>=0){
				cout << k << ' ' << j << ' ' << i << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" <<  endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
vector<int> G[51];
int sa, sb;
int arrived[51];

void dfs( int node )
{
  arrived[node] = 1;
  for( int i=0; i<G[node].size(); i++ ){
    int to = G[node][i];
    if( !arrived[to] &&
        !( ( sa == node && sb == to ) || ( sa == to && sb == node) )){
      dfs( G[node][i] );
    }
  }
}

int main( void )
{
  ios::sync_with_stdio(false);
  int N, M, a, b;
  cin >> N >> M;
  for( int i=0; i<M; i++ ){
    cin >> a >> b;
    G[a].push_back( b );
    G[b].push_back( a );
  }
  int ret = 0;
  for( int i=1; i<N; i++ ){
    for( int j=0; j<G[i].size(); j++ ){
      sa = i;
      sb = G[i][j];
      if( sa >= sb ) continue;
      for( int k=1; k<=N; k++ ) arrived[k] = 0;
      dfs(1);
      int f = 0;
      for( int k=1; k<=N; k++ ){
        if( !arrived[k] ) f = 1;
      }
      ret += f;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int k,x;
    cin >> k >> x;
    if(500*k>=x) cout<< "Yes"<< endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

int main(void){
  int n;
  cin>>n;
  int v,c;
  int ans = 0;
  vector<int> V,C;
  rep(i,n){
  	cin>>v;
  	V.push_back(v);
  }
  rep(i,n){
  	cin>>c;
  	C.push_back(c);
  }
  rep(i,n){
  	ans += max(0, V[i]-C[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 636
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
for i in range(n):a[i+1]=(a[i+1]+a[i]-1)%k
from collections import defaultdict
d=defaultdict(int)
x=0
d[0]=1
for i in range(1,n+1):
  if i-k>=0:d[a[i-k]]-=1
  x+=d[a[i]]
  d[a[i]]+=1
print(x)

Measured memory_bytes: 33256
#include <iostream>
using namespace std;
int arr[100];
int main() {
    int cnt = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    for (int i = 0; i < n; ++i) {
        int minj = i;
        for (int j = i; j < n; ++j) {
            if (arr[j] < arr[minj]) {
                minj = j;
            }
        }
        if (i != minj){
            swap(arr[i],arr[minj]);
            ++cnt;
        }
    }

    for (int i = 0; i < n; ++i) {
        cout <<arr[i]<< ((i == n - 1) ? "\n" : " ");
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int  maxn = 1e5 + 5;
int a, b, c;
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
//        ifstream cin("in.txt");
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    for(int i = 1; i <= 10000; i ++){
        if(a % i == 0 and b % i == 0){
            v.push_back(i);
//            cout << i << " " ;
        }
       
    }
    reverse(v.begin(), v.end());
    cout << v[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define in insert
#define pb push_back
#define endl '\n'
#define ub upper_bound
#define lb lower_bound
#define pf pop_front
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);srand(time(0));
using namespace std;
ll mod=1e9+7;
vector<ll> d;
void fun()
{
	int n;cin>>n;
	d.assign(n+1,1);
	
	for(int i=2;i<=n;i++)
	{
		for(int j=i;j<=n;j+=i)
		d[j]++;
	}
	
	ll a=0;
	for(ll i=1;i<=n;i++)
	a=a+(i*d[i]);
	
	cout<<a;
}
int main()
{
    fast;
    int t=1;
    //cin>>t;
    while(t--)
    {
    	fun();
	}
}

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

int n;

void recursive(string str, char ch) {
  if(str.length() == n){
    cout << str << endl;
    return;
  }
  for(int i=0; i<ch-'a'+1; i++){
    string addBack{(char)('a'+i)};
    ('a'+i) == ch ? recursive(str+addBack, ch+1) : recursive(str+addBack, ch);
  }
}
  

int main(){
  cin >> n;
  recursive("", 'a');
  return 0;
}
  

Measured memory_bytes: 1536
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 7)
    
    
    N, Q = map(int, input().split())
    
    T = [[]for i in range(N)]
    
    for i in range(N-1):
        a, b = map(int, input().split())
        T[a-1].append(b-1)
        T[b-1].append(a-1)
    
    X = [0 for i in range(N)]
    for i in range(Q):
        p, x = map(int, input().split())
        X[p-1] += x
    
    def dfs(x, p):
        for j in T[x]:
            if j == p:
                continue
            X[j] += X[x]
            dfs(j, x)
    
    dfs(0, -1)
    
    for i in range(N):
        print(X[i], end =" ")
main()

Measured memory_bytes: 265280
#include<stdio.h>
#include<algorithm>
#include<set>
#include<math.h>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
	b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}

Pt hLP(Pt a,Pt b,Pt c){
	return pLL(a,b,c,c+(b-a)*Pt(0,1));
}
double dLP(Pt a, Pt b, Pt c) {
	return ABS(tri(a, b, c)) / (b - a).ABS();
}
double x[1100];
double y[1100];
Pt p[1100];
set<pair<int,int> > S;
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%lf%lf",x+i,y+i);
	for(int i=0;i<a;i++)p[i]=Pt(x[i],y[i]);
	for(int i=0;i<a;i++)S.insert(make_pair(round(x[i]),round(y[i])));
	bool dame=true;
	for(int i=2;i<a;i++){
		if(dLP(p[0],p[1],p[i])>EPS)dame=false;
	}
	if(dame){
		printf("No\n");
		return 0;
	}
	bool ok=false;
	for(int i=0;i<3;i++){
		for(int j=i+1;j<a;j++){
			Pt L=(p[i]+p[j])/2;
			Pt v=(p[j]-p[i])*Pt(0,1);
			Pt R=L+v;
			bool OK=true;
			int cnt=0;
			for(int k=0;k<a;k++){
				if(i==k||j==k)continue;
				if(dLP(L,R,p[k])<EPS)cnt++;
				else{
					Pt tmp=hLP(L,R,p[k]);
					Pt to=tmp+tmp-p[k];
					int X=round(to.x);
					int Y=round(to.y);
	//				if(i==0&&j==3)printf("%d: %f %f %d %d\n",k,to.x,to.y,X,Y);
					if((Pt((double)X,(double)Y)-to).ABS()>EPS)OK=false;
					else if(!S.count(make_pair(X,Y)))OK=false;
				}
			}
			//printf("%d %d: %d\n",i,j,cnt);
			if(!OK)continue;
			
			if(cnt>2){
				printf("No\n");return 0;
			}else ok=true;
		}
	}
	if(ok)printf("Yes\n");
	else printf("No\n");
}

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

using namespace std;

bool compare_by_b(pair<long long , long long> lhs, pair<long long , long long> rhs) {
  if(lhs.second != rhs.second){
    return lhs.second < rhs.second;
  }else{
    return lhs.second > rhs.second;
  }
}

int main(){
  long long n;
  cin >> n;
  vector<pair<long long , long long> > job;
  for (int i = 0; i < n; i++) {
    long long t, h;
    cin >> t >> h;
    job.push_back(make_pair(t, h));
  }

  sort(job.begin(), job.end(), compare_by_b);

  string ans = "Yes";

  long long need = 0;
  for(int i = 0; i < n; i++) {
    need += job[i].first;

    if (need > job[i].second) {
      ans = "No";
      break;
    }
  }

  cout << ans << "\n";
}


Measured memory_bytes: 6256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	a, b := sc.nextInt(), sc.nextInt()
	if a <= b {
		fmt.Fprintln(wtr, a)
	} else {
		fmt.Fprintln(wtr, a-1)
	}

	wtr.Flush()
}


Measured memory_bytes: 640
n = int(raw_input())
cout = ""

for i in range(1,n+1):
	x = i

	if (x%3) == 0:
		cout = cout + " " + str(i)
		continue

	while x > 0:
		if (x%10) == 3:
			cout = cout + " " + str(i)
			break
		x /= 10

print cout

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

const int MAX = 2*510000;
const int MOD=998244353;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  ll ans=0;
  COMinit();
  //vector<int> mm;
  int num=n-1-k;
  ll cal=1;
  for(int i=0;i<num;++i){
    cal=(cal*(m-1))%MOD;
  }
  for(int i=k;i>=0;--i){
    ll tmp=(m*COM(n-1,i))%MOD;
    tmp=(tmp*cal)%MOD;
    ans+=tmp;
    ans=ans%MOD;
    cal=cal*(m-1)%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 27460
X=int(input())
if 400<=X<=599:
    print(8)
elif 600<=X<=799:
    print(7)
elif 800<=X<=999:
    print(6)
elif 1000<=X<=1199:
    print(5)
elif 1200<=X<=1399:
    print(4)
elif 1400<=X<=1599:
    print(3)
elif 1600<=X<=1799:
    print(2)
elif 1800<=X<=1999:
    print(1)

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D){
    cout << "Left" << endl;
  }
  else if (A+B == C+D){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
/*
ID: 123feli1
TASK: test
LANG: C++
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int length=s.length();
	int consecutive[length];
	memset(consecutive,0,sizeof(consecutive));
	for(int i=0;i<length;i++){
		for(int j=i;j<length;j++){
			if(s[i]=='R'&&s[j]=='R'){
				consecutive[i]++;
			}else{
				break;
			}
		}
	}
	int max=consecutive[0];
	for(int i=1;i<length;i++){
		if(max<consecutive[i]){
			max=consecutive[i];
		}
	}
	cout<<max<<'\n';
    return 0;
}



Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.nextLine());
		
		if(n % 100 % 10 == 7){
		    System.out.println("Yes");
		}else if(n % 100 / 10 == 7){
		    System.out.println("Yes");
		}else if(n / 100 == 7){
		    System.out.println("Yes");
		}else{
		    System.out.println("No");
		}
        
    }
}

Measured memory_bytes: 35824
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int a, b, k, c=0;
    cin >> a >> b >> k;
    int m = min(a, b);
    for(int i=m; i>=1; i--) {
        if(b % i == 0 && a % i == 0) {
            c++;
            if(c == k) {
                cout << i << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    auto sign = [](int x){
        if (x == 0) return 0;
        else if (x > 0) return 1;
        else return -1;};
    
    ll pos = 0, neg = 0;
    REP(i,2) {
        int now = 0;
        int prevsign = 0;
        ll count = 0;
        if (i == 0) {
            if (sign(v[0]) != 1) {
                now = 1;
                count = abs(v[0]) +1;
            } else now = v[0];
            prevsign = 1;
        } else {
            if (sign(v[0]) != -1) {
                now = -1;
                count = abs(v[0]) +1;
            } else now = v[0];
            prevsign = -1;
        }

        FOR(j,1,n) {
            now += v[j];
            int s = sign(now);
            //cerr << i << " " << j << " " << now << " " << s;
            if (prevsign == s || s == 0) {
                count += abs(now) + 1;
                if (prevsign == 1) {
                    now = -1;
                } else {
                    now = 1;
                }
            }
            prevsign = sign(now);
            //cerr << " " << count << endl;
        }
        if (i == 0) pos = count;
        else neg = count;
    }

    cout << min(pos,neg) << endl;
    

    return 0;
}

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

int main()
{
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);     //昇順にソートする.
    cout << arr[2]*10 + arr[1] + arr[0] << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 mod=1e9+7;
const int INF=1001001001;

int dp[105][10][1000];
int main() {
  int H,W,K;
  cin>>H>>W>>K;
  
  dp[0][0][0]=1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      for(int p=0;p<(1<<W-1);p++){
        if(dp[i][j][p]==0){continue;}
        for(int s=0;s<(1<<W-1);s++){  
          vector<int>t(W-1);
          for(int k=0;k<W-1;k++){
            if((s>>k)&1){t[k]=1;}
          }
          bool ok=true;
          for(int k=0;k<W-1;k++){
            if(k<W-2&&t[k]==1&&t[k+1]==1){ok=false;}
          }
          if(ok){
            if(j<W-1&&t[j]){(dp[i+1][j+1][s]+=dp[i][j][p])%=mod;}
            else if(j>0&&t[j-1]){(dp[i+1][j-1][s]+=dp[i][j][p])%=mod;}
            else{(dp[i+1][j][s]+=dp[i][j][p])%=mod;}
          }
        }
      }
    }
  }
  int sum=0;
  //for(int i=0;i<W;i++){
  for(int s=0;s<(1<<(W-1));s++){
    (sum+=dp[H][K-1][s])%=mod;
  }
  //}
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 6616
import java.util.Scanner;

public class Main {
	void call(int n) {
		for (int i = 1; i <= n; i++) {
			int x = i;
			if (x % 3 == 0) {
				System.out.printf(" %d", i);
				continue;
			}
			do {
				if (x % 10 == 3) {
					System.out.printf(" %d", i);
					break;
				}
				x /= 10;
			} while(x >= 1);
		}
		System.out.println();
	}
	public static void main(String[] args) {
		Main m = new Main();
		Scanner scan = new Scanner(System.in);
		m.call(scan.nextInt());
	}
}

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

const ll maxs = 1e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}

const ll N = 2003;

ll dp[N][N];
bool vis[N][N];
pair<ll,ll> a[N];
ll n;

ll go(ll ind,ll i,ll j){
    if(ind >= n )
        return 0;
    ll& ans = dp[ind][i];
    if(vis[ind][i])
        return dp[ind][i];
    vis[ind][i] = true;
    ans = a[ind].ff*abs(i - a[ind].ss) + go(ind+1,i+1,j);
    ans = max( ans , a[ind].ff*abs(j - a[ind].ss) + go(ind+1,i,j-1) );
    return ans;
}

void solve(){ 
    cin >> n;
    for(ll i=0;i<n;i++){
        ll val;
        cin >> val;
        a[i].ff = val;
        a[i].ss = i;
    }
    sort(a,a+n);
    reverse(a,a+n);
    ll ans = go(0,0,n-1);
    cout << ans << endl;
}


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;   
    //cin>>T;
    while(T--){  
        solve();
    }
    return 0;
}

Measured memory_bytes: 30352