akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
int f=0;
int m=1;
while(m<=n){
	f=f+(n/m)%10;
	m=m*10;
}
if((n%f)==0){
	printf("Yes\n");
}else{
	printf("No\n");
}

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define F first
#define S second
using namespace std;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n+1),cnt(n+1);
	for (int i = 1; i <= n; i++){
		cin >> v[i];
		cnt[v[i]]++;						
	}
	ll s = 0;
	for (int i = 1; i <= n; i++){
		s+=1ll*cnt[i]*(cnt[i]-1)/2;	
	}
	for (int i = 1; i<= n; i++){
		cout << s - cnt[v[i]] + 1 <<'\n';
	}
	
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds1;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

void solve(){
    int a[5];
    loop(i,0,5){
        cin>>a[i];
    }
    loop(i,0,5){
        if(a[i]==0){
            cout<<(i+1)<<endl;
        }
    }
}

int32_t main(){
    get_it_done(); 
    int tc=1;
    // cin >> tc;
    while (tc--){
        solve();        
    }
}


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

const int maxn(1e5 + 5);

int n, a[maxn];

bool Solve() {
	int d, i, cnt = 0;
	for (i = 1; i <= n; ++i) cnt += ~a[i] & 1;
	if (cnt & 1) return 1;
	for (i = 1; i <= n; ++i) if (a[i] == 1) return 0;
	if (n - cnt > 1) return 0;
	for (i = 1; i <= n; ++i) if (a[i] & 1) --a[i];
	d = a[1];
	for (i = 2; i <= n; ++i) d = __gcd(d, a[i]);
	for (i = 1; i <= n; ++i) a[i] /= d;
	return Solve() ^ 1;
}

int main() {
	int i, u, v;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%d", &a[i]);
	Solve() ? puts("First") : puts("Second");
	return 0;
}

Measured memory_bytes: 640
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

int tab[1005];
int C[1005];

list< pair<int,int> > V;
list< pair<int,int> > V2;

///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////



/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> tab[i];
	}
    for(int i = 0; i < n;i++){
		cin >> C[i];
	}
    
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(tab[i] > C[i]){
			ans += (tab[i] - C[i]);
		}
	}
    
    cout << ans << endl;
    
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (){
	int n,k,x,y;
	int sum = 0;
	scanf("%d\n%d\n%d\n%d",&n,&k,&x,&y);
	if(k <= n){
	for(int i = 0; i < k; i++){
		sum += x;
		}
	for(int j = 0;  j < n - k; j++){
		sum += y;
		}
	}
	else
	{
		for(int a = 0; a < n; a++){
		sum += x;
		}
	
		}
	printf("%d\n",sum);
	return 0;
	}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

ll N, M, K;

// n行m列のボタンを押したときの黒のマスの数
ll f(ll n, ll m){
    ll res = n * M;
    res += m * N;
    res -= (n * m)*2;
    return res;
}

int main()
{
    cin >> N >> M >> K;

    string ans = "No";
    for (int n = 0; n <= N; n++) {
        for (int m = 0; m <= M;m++){
           if(f(n,m)==K) {
               ans = "Yes";
               break;
           }
        }
    }

    cout << ans << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    cin >> s;
    if (s.size() % 2 != 0) {
        END("No")
    }

    REP(i, 0, s.size()) {
        if (i % 2 == 0) {
            if (s.at(i) != 'h') {
                END("No")
            }
        } else {
            if (s.at(i) != 'i') {
                END("No")
            }
        }
    }
    MSG("Yes")
}


Measured memory_bytes: 3636
#include<stdio.h>
 
 
int a[2000];
int n;
int sum;
 
int check(int,int);
 
int main(){
  int q,m;
  int i;
 
  sum = 0;
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  scanf("%d",&q);
 
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if (check(0,m)){
      printf("yes\n");
    }else{
      printf("no\n");
    }
 
  }
  return 0;
}

int check(int i,int m){
  if(sum < m)return 0;
  if(m == 0)return 1;
  if(i >= n)return 0;
  return check(i+1,m) || check(i+1,m-a[i]);
}
 

Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N; cin >> N;
  for(int i=0;i<=N;i++){
    if(i%4==0 && (N-i)%7==0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(size_t i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(size_t i = 0; i < n; i++)
#define asort(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.begin(), a.end(), greater<int>())
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
int32_t main()
{
    fast_io;                        
    int n, m, u, v;
    cin >> n >> m;
    vi graph[100005], in_deg(n+1), ans(n+1);
    for(int i = 0; i < m; i++)
    {
        cin >> u >> v;
        graph[u].pb(v);
        in_deg[v]++;
    }
    queue<int> que;
    for(int i = 1; i <= n; i++)
        if(in_deg[i] == 0)
            que.push(i);
    while(!que.empty())
    {
        u = que.front();
        que.pop();
        for(auto &i : graph[u])
        {
            ans[i] = max(ans[i], ans[u] + 1);
            in_deg[i]--;
            if(in_deg[i] == 0)
                que.push(i);
        }
    }
    cout << *max_element(ans.begin(), ans.end());

    return 0;
}

Measured memory_bytes: 10236
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	int n, m, k; cin >> n >> m >> k;
	int pre_a[n + 1] = {};
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		pre_a[i + 1] = pre_a[i] + x;
	}
	int pre_b[m + 1] = {};
	for (int i = 0; i < m; i++) {
		int x; cin >> x;
		pre_b[i + 1] = pre_b[i] + x;
	}
	int ans = 0;
	int j = m;
	for (int i = 0; i < n + 1; i++) {
		int ex = k - pre_a[i];
		if (ex >= 0) {
			while (j >= 0 and pre_b[j] > ex) --j;
			ans = max(ans, i + j);
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 6744
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(K: int, A: int, B: int):
    ret = 'NG'
    for i in range(A, B + 1):
        if i % K == 0:
            ret = 'OK'
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(K, A, B)

if __name__ == '__main__':
    main()


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

int main()
{
    int num,buddy,*line,a,b,c;
    cin >> num >> buddy;
    line = new int[num];
    for(int i = 0 ; i < num ; i++){
        line[i] = i + 1;
    }
    for(int i = 0 ; i < buddy ; i++){
        scanf("%d,%d",&a,&b);
        c = line[a - 1];
        line[a - 1] = line[b - 1];
        line[b - 1] = c;
    }
    for(int i = 0 ; i < num ; i++){
        cout << line[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 1244
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

// types
typedef long long ll;
typedef pair<int,int> pii;

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

const int MAX_N = 2000 + 7;

int dp[MAX_N];
vector<int> G[MAX_N];

int bfs(int lim, int p1, int p2 = -1) {
  queue<int> que;
  MS(dp, INF);
  dp[p1] = 0;
  que.push(p1);
  if (p2 != -1) {
    dp[p2] = 0;
    que.push(p2);
  }
  int res = 0;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (dp[u] > lim) res++;
    for (int v : G[u]) {
      if (dp[v] > dp[u] + 1) {
        dp[v] = dp[u] + 1;
        que.push(v);
      }
    }
  }
  return res;
}

int main() {
  srand(time(0));
  int N, K;
  RI(N, K);
  REP(i, N - 1) {
    int u, v;
    RI(u, v);
    G[u].PB(v);
    G[v].PB(u);
  }
  int ans = INF;
  if (K % 2 == 0) {
    REP1(i, 1, N) ans = min(ans, bfs(K / 2, i));
  }
  else {
    REP1(u, 1, N) {
      for (int v : G[u]) ans = min(ans, bfs(K / 2, u, v));
    }
  }
  PL(ans);
  return 0;
}



Measured memory_bytes: 384
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <array>
#include <set>
#include <sstream>
#include <cmath>

using namespace std;

typedef long long LL;


vector<vector<LL>> creat_matrix(LL h, LL w) {
	LL _temp;
	vector<vector<LL>> mat;
	for (LL i = 0; i < h; ++i) {
		vector<LL> vec;
		for (LL j = 0; j < w; ++j) {
			cin >> _temp;
			vec.emplace_back(_temp);
		}
		mat.emplace_back(vec);
	}
	return mat;
}


vector<vector<LL>> inner_product(vector<vector<LL>> X, vector<vector<LL>> Y) {
	size_t n = X.size();
	size_t m = X[0].size();
	size_t l = Y[0].size();

	vector<vector<LL>> mat(n, vector<LL>(l, 0));
	for (LL i = 0; i < n; ++i) {
		for (LL j = 0; j < m; ++j) {
			for (LL k = 0; k < l; ++k) {
				mat[i][k] += X[i][j] * Y[j][k];
			}
		}
	}
	return mat;
}


void show_matrix(vector<vector<LL>> mat) {
	size_t len = mat[0].size();
	for (auto&& t : mat) {
		for (LL i = 0; i < len; ++i) {
			printf("%d", t[i]);
			if (i != (len - 1)) printf(" ");
		}
		printf("\n");
	}
}


int main() {
	vector<string> inputs;

	string str;
	while (true)
	{
		cin >> str;
		if (str == "0") break;

		inputs.emplace_back(str);
	}

	for (auto&& input : inputs) {
		int result = 0;
		for (auto s : input) {
			string temp{ s };
			result += stoi(temp);
		}
		printf("%d\n", result);
	}

	return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
#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-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

// combinationのテーブルを作る前処理
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;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    ll k,s,cnt;
    cin>>k>>s;
    cnt=0;
    REP(x,k+1) REP(y,k+1) if(x+y<=s&&x+y+k>=s)cnt++;
        
//答え出力パート    
    cout<<cnt
    <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define left first
#define right second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    string res;
    for(int n, w, h; cin >> n >> w >> h; cout << res << endl){
        res = "No";

        vector<pii> wifix(n), wifiy(n);
        rep(i, n){
            int x, y, range; cin >> x >> y >> range;

            wifix[i].left = max(x - range, 0);
            wifix[i].right = min((ll)x + range, (ll)w);
            wifiy[i].left = max(y - range, 0);
            wifiy[i].right = min((ll)y + range, (ll)h);
        }

        rep(i, 2){
            vector<pii> wifi;
            int len;
            if(i){
                wifi = wifix;
                len = w;
            }
            else{
                wifi = wifiy;
                len = h;
            }

            sort(all(wifi));

            bool ok = true;
            if(wifi[0].left != 0){
                ok = false;
            }
            int rightedge = wifi[0].right;
            range(i, 1, n){
                if(rightedge < wifi[i].left){
                    ok = false;
                    break;
                }
                rightedge = max(rightedge, wifi[i].right);
            }
            if(rightedge < len){
                ok = false;
            }

            if(ok){
                res = "Yes";
                break;
            }
        }
    }

	return 0;
}

Measured memory_bytes: 3380
#ifndef CLion
//#pragma GCC optimize ("O3")
#endif

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define rep(i,s,e) for (int i = s; i < e; ++i)
#define rev(i,s,e) for (int i = s; i > e; --i)
#define mem(a,v) memset(a , v , sizeof a)
//#define mod(x,m) ((x%m + m)%m)
using namespace std;
using namespace __gnu_pbds;

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

const int N = 1e6 + 99 ;

int n , a[N] , b[N];

void Main(int cse , bool last){
    cin >> n;
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    reverse(b , b + n);

    int val = -1;
    rep(i,0,n) if ( a[i] == b[i] ) val = a[i];
    if ( ~val ){
        vector<int> pos;
        rep(i,0,n){
            if ( val != a[i] && val != b[i] ) pos.pb(i);
        }
        rep(i,0,n){
            if ( a[i] == b[i] && b[i] == val ){
                if ( pos.empty() ){
                    cout << "No";
                    return;
                }
                swap(b[i] , b[pos.back()]);
                pos.pop_back();
            }
        }
    }

    cout << "Yes\n";
    rep(i,0,n) cout << b[i] << " ";
}

int main(){

#ifndef CLion
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
#ifdef CLion
    freopen( "in.txt" , "r" , stdin  );
//    freopen( "out.txt", "w" , stdout );
    clock_t st = clock();
#endif

    int t = 1;
//    cin >> t;
    for ( int cse = 1; cse <= t; ++cse ) Main(cse, cse == t);

#ifdef CLion
    clock_t en = clock();
    cout << "\n\nTime: " << fixed << (en - st - 0.0) / CLOCKS_PER_SEC;
#endif
    return 0;
}

Measured memory_bytes: 5852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<19,INF=1<<30;

int n;
ll dat[2*MAX-1],lazy[2*MAX-1];

void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=0;
        lazy[i]=0;
    }
}

void eval(ll k,int l,int r){
    
    if(lazy[k]!=0){
        dat[k]+=lazy[k];
        
        if(r-l>1){
            lazy[k*2+1]+=lazy[k]/2;
            lazy[k*2+2]+=lazy[k]/2;
        }
        
        lazy[k]=0;
    }
}

void add(int a,int b,ll x,int k,int l,int r){
    eval(k,l,r);
    
    if(r<=a||b<=l) return;
    
    if(a<=l&&r<=b){
        lazy[k]+=(r-l)*x;
        eval(k,l,r);
    }
    
    else{
        add(a,b,x,2*k+1,l,(l+r)/2);
        add(a,b,x,2*k+2,(l+r)/2,r);
        dat[k]=dat[2*k+1]+dat[2*k+2];
    }
}

ll query(int a,int b,int k,int l,int r){
    
    if(r<=a||b<=l) return 0;
    
    eval(k,l,r);
    
    if(a<=l&&r<=b) return dat[k];
    
    ll vl=query(a,b,2*k+1,l,(l+r)/2);
    ll vr=query(a,b,2*k+2,(l+r)/2,r);
    return vl+vr;
}


int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,D,A;cin>>N>>D>>A;
    init(N);
    
    vector<pair<ll,ll>> S(N);
    
    for(int i=0;i<N;i++) cin>>S[i].first>>S[i].second;
    
    sort(all(S));
    
    for(int i=0;i<N;i++) add(i,i+1,S[i].second,0,0,n);
    
    ll ans=0;
    
    for(int i=0;i<N;i++){
        S[i].second=query(i,i+1,0,0,n);
        if(S[i].second<=0) continue;
        ans+=(S[i].second+A-1)/A;
        auto it=upper_bound(all(S),make_pair(S[i].first+2*D+1,-1LL));
        //it--;
        int dis=it-S.begin();
        
        add(0,dis,-((S[i].second+A-1)/A*A),0,0,n);
        
        //cout<<dis<<" "<<ans<<endl;
    }
    
    cout<<ans<<endl;
}




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

int main(){
  	ll n,x,f_x = 0;
  	cin >> n;
  	x = n;
  	
  	while(n != 0){
      f_x += n % 10;
      n /= 10;
    }
  
  		
  	cout << ((x % f_x == 0)? "Yes" : "No" ) << endl;
	return 0; 
}

Measured memory_bytes: 384
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int timer;
int level[N], par[N][22], tin[N], tout[N];
vector<int> adj[N];

void dfs(int u, int p) {
	tin[u] = ++timer;
	level[u] = level[p] + 1;
	par[u][0] = p;
	for(int v : adj[u]) {
		if(v == p) continue;
		dfs(v, u);
	}
	tout[u] = ++timer;
}

bool is_ancestor(int u, int v) {
	return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(0, 0);
	for(int i = 1; i < 22; i++) {
		for(int j = 0; j < n; j++) {
			par[j][i] = par[par[j][i-1]][i-1];
		}
	}

	auto lca = [&](int u, int v) {
		if(is_ancestor(u, v)) return u;
		if(is_ancestor(v, u)) return v;
		for(int i = 21; i >= 0; i--) {
			if(!is_ancestor(par[u][i], v)) {
				u = par[u][i];
			}
		}
		return par[u][0];
	};

	int c1 = 0, c2 = 0;

	for(int i = 0; i < n; i++) {
		int d1 = level[i] + level[0] - 2 * level[lca(i, 0)];
		int d2 = level[i] + level[n - 1] - 2 * level[lca(i, n - 1)];
		if(d1 <= d2) c1++;
		else c2++;
	}
	if(c1 > c2) cout << "Fennec";
	else cout << "Snuke";
	return 0;
}


Measured memory_bytes: 20224
/* ex 9_2
   offNaria */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node
{
    char elem;
    struct node *next;
} node;

void push(node **first, char elem); //スタックにデータを追加
char pop(node **first);             //スタックからデータを取り出す

int main(void)
{
    int count = 0, length;
    char input[100001];
    //最初のノードの指す先
    node *first = NULL;
    //スタックにノードを追加
    scanf("%s", input);
    length = (int)strlen(input);
    for (int i = 0; i < length; i++)
    {
        //スタックが空でないとき
        if (first != NULL)
        {
            //スタックの一番上のものと次に来るものが同じならばpush
            if (input[i] == first->elem)
            {
                push(&first, input[i]);
            }
            //異なるならばpopしてキューブ2個を取り除いたと記録
            else
            {
                pop(&first);
                count += 2;
            }
        }
        //スタックが空のとき
        else
        {
            push(&first, input[i]);
        }
    }
    printf("%d\n", count);
    return 0;
}

void push(node **first, char elem)
{
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if (new == NULL)
        exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

char pop(node **first)
{
    char elem;
    node *tmp = *first;
    if (tmp != NULL)
    {
        elem = tmp->elem;
        *first = tmp->next;
        //取り出したノードのメモリを解放
        free(tmp);
        return elem;
    }
}

Measured memory_bytes: 4904
#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>

using namespace std;
const int INF=10000000LL;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> Pa;
int H,W;
int A[35][35];
P C[35][35];
int main(){
	string str;
	cin>>str;
	str[3]='8';
	cout<<str<<endl;
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int taka=0,ao=0;
  if(c%b==0){
    taka+=c/b;
  }
  else{
    taka+=c/b+1;
  }
  if(a%d==0){
    ao+=a/d;
  }
  else{
    ao+=a/d+1;
  }
  if(taka<=ao){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n, k;
	cin >> n >> k;
	
	vi p(n);
	readArr(p, 0, n);
	
	sort(all(p));
	
	int sum=0;
	for(int i=0 ; i<k ; ++i)sum += p[i];
	
	cout << sum;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3660
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <cassert>
#include <random>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(ll a, ll b);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % mod;
        inv_fact[i] = exp(fact[i], mod-2, mod);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(ll a, ll b){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}
const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	int a1[n], a2[n];
	for(int i = 0; i < n; i++) cin>>a1[i]>>a2[i];
	bool check = false;
	for(int i = 0; i < n-2; i++){
		check |= a1[i] == a2[i] && a1[i+1] == a2[i+1] && a1[i+2] == a2[i+2];
	}
	cout<<(check ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3668
import Control.Applicative

func :: Int -> Int -> [Char]
func a b | a > b = "a > b"
		 | a < b = "a < b"
		 | otherwise = "a == b"

main = do
	[a,b] <- (map (read::String->Int) . words) <$> getLine
	putStrLn $ func a b

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  if (k == 0) {
    cout << "Yes" << '\n';
    return;
  }
  for (int i = 1; i <= n; i++)
  for (int j = 1; j <= m; j++) {
    if (i * j + (n - i) * (m - j) == k) {
      cout << "Yes" << '\n';
      return;
    }
  }
  cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n, m;
	cin >> n >> m;
	unordered_map<int, int> mp;
	int L = 0, R = n + 1;
	rep(_, m) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		chmax(L, l);
		chmin(R, r);
	}
	cout << max(0, R - L + 1) << endl;
}


Measured memory_bytes: 256
#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>;
using G = vector<vector<int>>;
    
int main(){
    int a;
    cin >> a;
    int ans = a + a*a + a*a*a;
    cout << ans << endl;
    return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

int64_t getVal(int64_t d){
  int64_t ans = 1;
  for(int i=1;i<d;i++){
    ans *= 10;
  }
  return ans;
}



signed main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int count = 0;
  char lastC = 0;
  for(auto c:s){
    if(c==lastC) continue;
    lastC = c;
    count++;
  }
  cout << count << endl;
  return 0;
  
}




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

int main() {
  int n, h[110];
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> h[i];
  int res = 1;
  
  for (int i = 1; i < n; ++i) {
    
      bool big = false;
      for (int j = 0; j < i; ++j) {
        if (h[i] < h[j]) big = true;
      }
      if (big) continue;
      ++res;
    
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    getline(cin,s);
    for(int i=0;i<s.size();i++){
        if('a'<=s.at(i)&&s.at(i)<='z'){
            s.at(i)-='a'-'A';
        }
        else if('A'<=s.at(i)&&s.at(i)<='Z'){
            s.at(i)+='a'-'A';
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 3152
import sys
N = int(input())
num = list(map(int,input().split()))
num.sort(reverse=True)
a = 1
if num[-1] == 0:
  print(0)
else:
  for n in range(N):
    a = num[n]*a
    if a> 10**18:
      print(-1)
      sys.exit()
  print(a)


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

bool check(set<int> s, int n) {
	while (n > 0) {
		if (!s.count(n % 10))
			return true;
		n /= 10;
	}
	return false;
}

int main(){
    cin.tie(0)->sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	set<int> d = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
	REP(i, k) {
		int tmp;
		cin >> tmp;
		d.erase(tmp);
	}

	while (check(d, n)) {
		n++;
	}

	cout << n << '\n';
    return 0;
}


Measured memory_bytes: 3628
//import java.io.*

fun main() {
    val d = readInt()
    val c = readInts()
    val s = mutableListOf<List<Int>>()
    repeat(d) {
        s.add(readInts())
    }

    val last = MutableList(c.size) { 0 }

    fun calcDissatisfaction(currDay: Int): Int {
        return c.mapIndexed { index, num -> num * (currDay - last[index]) }.sum()
    }

    val contests = c.mapIndexed { index, cost -> Contest(index + 1, s[0][index], cost) }

    fun updateContests(day: Int) {
        contests.forEachIndexed { index, contest -> contest.update(day + 1, s[day - 1][index], last[index]) }
    }

    var satisfaction = 0
    var dissatisfaction: Int
    val t = mutableListOf<Int>()
    repeat(d) { day ->
        updateContests(day + 1)
        dissatisfaction = contests.map { it.dissatisfaction }.sum()
        val contestToHold = contests.maxBy { it.contribution(dissatisfaction) }!!
        last[contestToHold.id - 1] = day + 1
//        println("Dissatisfaction on day $day : ${calcDissatisfaction(day + 1)}")
        satisfaction += (s[day][contestToHold.id - 1] - calcDissatisfaction(day + 1))
        t.add(contestToHold.id)
    }

//    println("Satisfaction: $satisfaction")
//    println("Score: ${1000_000 + satisfaction}")

//    writeToFile("output.txt", t.joinToString("\n"))

//    // For submission
    println(t.joinToString("\n"))
}

data class Contest(val id: Int, var satisfaction: Int, val cost: Int) {
    var dissatisfaction = cost

    fun update(nextDay: Int, newSatisfaction: Int, lastDayHeld: Int) {
        satisfaction = newSatisfaction

        dissatisfaction = cost * (nextDay - lastDayHeld)
    }

    fun contribution(totalDissatisfaction: Int): Int {
        return satisfaction - 2*(totalDissatisfaction - dissatisfaction)
    }
}

//// Write to file
//fun writeToFile(filename: String, content: String) {
//    val outputWriter = OutputStreamWriter(FileOutputStream(File(filename)))
//    outputWriter.append(content)
//    outputWriter.close()
//}
//
//// Read from file
//private val inputReader = InputStreamReader(FileInputStream(File("input.txt")))
//private val lines = inputReader.readLines()
//private var currLine = -1
//private fun readLn(): String {
//    currLine++
//    return lines[currLine]
//}

// Current score: 62484479
// 1414762


// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


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

using namespace std;

long long sum(long long n) {
    return n * (n + 1) / 2;
}

long long ans(long long n) {
    long long a, b, c, d;
    a = sum(n);
    b = 3 * sum(n / 3);
    c = 5 * sum(n / 5);
    d = 15 * sum(n / 15);
    return a - b - c + d;
}

void solve(long long n) {
    cout << ans(n) << endl;
}

int main() {
    long long n;
    cin >> n;
    solve(n);
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };


void solve() {
	int a, b; cin >> a >> b;
	for (int i = 1; i <= 10000; i++) {
		int x = (ld)i*0.08+eps;
		int y = (ld)i*0.10 + eps;
		if (x == a && y == b) {
			cout << i << endl; return;
		}
	}
	cout << -1 << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<limits>
#include<array>
using namespace std;
typedef long ll;

int main() { 
    ll n;
    cin >> n;
    vector<array<ll, 3>> nums(n);
    for(auto&e:nums) {
        for(auto&a:e)
            cin >> a;
    }

    // cout << "done" << endl;
    vector<array<ll, 3>> dp(n);
    dp[0][0] = nums[0][0];
    dp[0][1] = nums[0][1];
    dp[0][2] = nums[0][2];
    
    for(ll i=1; i < n; i++) { 
        for(ll prev=0; prev < 3; prev++)   
            for(ll curr=0; curr < 3; curr++)
                if(curr!=prev) { 
                    dp[i][curr] = max(dp[i][curr], nums[i][curr] + dp[i-1][prev]);
                }
    }
    ll res = 0;
    for(ll i=0; i <3; i++)
        res = max(res, dp[n-1][i]);
    cout << res << endl;
}

Measured memory_bytes: 7540
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> a,b;
  int n;

  cin >> n;
  a.resize(n);
  b.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  long long int prev = 10e9 +1;
  int pos;
  pos = 0;
  for(ii=0;ii<n;ii++){
    if(prev != a[ii]){
      b[pos] = a[ii];
      pos++;
    }

    prev = a[ii];
  }

  vector<int>::iterator it = b.begin();

//  while(it != b.end()){
//    cout << *it;
//    it++;
//    if(it != b.end()){
//      cout << " ";
//    }
//    else{
//      cout << endl;
//    }
//  }
  for(ii=0;ii<pos;ii++){
    cout << b[ii];
    if(ii != pos -1){
      cout << " ";
    }
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3616
N = int(input())
A = [int(x) for x in input().split()]

d = dict()
for i in range(N):
    d[A[i]] = d.get(A[i], 0) + 1

if len(d) > 3:
    print('No')

else:
    k = list(d.keys())
    v = list(d.values())
    
    # a1 ^ a2 ^ a3 = 0 and an: N/3
    if len(d) == 3 and k[0]^k[1]^k[2] == 0 and v[0]==v[1]==v[2]:
        print('Yes')
    
    # a1: 2N/3, 0: N/3
    elif len(d) == 2 and ((k[0] == 0 and v[1] == 2*v[0]) or (k[1] == 0 and v[0] == 2*v[1])):
        print('Yes')
    
    # 0: N
    elif len(d) == 1 and k[0] == 0:
        print('Yes')
    
    else:
        print('No')

Measured memory_bytes: 20660
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readInt
  val f = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val p = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray

  var ans = Int.MinValue
  val a = Array.ofDim[Int](10)

  def evaluate():Unit = {
    if(!a.forall(_ == 0)) {
      val itp = p.iterator
      val score = 
        f./:(0)((fcc,fe) => {
          val itf = fe.iterator
          val arr = itp.next
          val s = a./:(0)((acc, e) => {
            if((e & itf.next) == 1) acc+1
            else acc
          })
          fcc + arr(s)
        })
      ans = math.max(ans, score)
    }
  }

  def dfs(pos:Int):Unit = {
    if(pos == 10) evaluate()
    else {
      a(pos) = 0; dfs(pos+1)
      a(pos) = 1; dfs(pos+1)
    }
  }

  dfs(0)
  println(ans)
}

Measured memory_bytes: 36120
package main

import (
	"fmt"
)

func main() {
	var s, k, o string
	fmt.Scan(&s)
	o = ""

	for i := 0; i < len(s); i++ {
		k = string(s[i])

		if k == "0" || k == "1" {
			o += k
		} else if k == "B" && len(o) > 0 {
			o = o[:len(o)-1]
		}
	}

	fmt.Println(o)
}

Measured memory_bytes: 512