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

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

    int sum = 0;
    int n = N;
    while (n) {
        sum += n % 10;
        n /= 10;
    }

    cout << (N % sum == 0 ? "Yes" : "No") << endl;
    return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >>n >>s;
	VI sd(n);
	rep(i, n) sd[i] = s[i]=='o'? 0: 1;
	rep(i, 4){
		VI ck(n+1, -1);
		bool ok=true;
		ck[0] = i&1; ck[1] = (i>>1) &1;
		rep2(i, 1, n){
			if(ck[i] == sd[i] ) ck[i+1]=ck[i-1];
			else ck[i+1] = ck[i-1] ^ 1;
		}
		if(ck[0] != ck[n]) ok=false;
		if(ck[0]==sd[0] && ck[1] != ck[n-1]) ok=false;
		if(ck[0]!=sd[0] && ck[1] == ck[n-1]) ok=false;
		if(ok){
			rep(i, n) cout <<(ck[i]==0? 'S':'W');
			cout <<"\n";
			return 0;
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<tuple>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	int a,b;
	cin >> a >> b;
	vector<string> sa, sb;
	rep(a){
		string tmp;
		cin >> tmp;
		sa.push_back(tmp);
	}
	rep(b){
		string tmp;
		cin >> tmp;
		sb.push_back(tmp);
	}
	
	bool flag;
	rep(a-b+1){
		repp(j, a-b+1){
			flag = true;
			repp(ii, b){
				repp(jj, b){
					if(sa[i+ii][j+jj] != sb[ii][jj]){
						flag = false;
						break;
					}
				}
				if(!flag) break;
			}
			if(flag){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <vector>

#include <boost/range/adaptors.hpp>


class Node {
 public:
  Node() {}
  ~Node() {}

  void Connect(long index) {
    connections_.push_back(index);
  }

  std::vector<long> GetConnections() const {return connections_;}

 private:
  std::vector<long> connections_;
};

int main() {
    int N;
    int M;
    std::cin >> N >> M;

    std::vector<long> H(N, 0);
    for (int i = 0; i < N; ++i) {
      std::cin >> H[i];
    }

    std::vector<Node> nodes(N);
    int a;
    int b;
    for (int i = 0; i < M; ++i) {
      std::cin >> a >> b;
      nodes[a - 1].Connect(b - 1);
      nodes[b - 1].Connect(a - 1);
    }

    long count = 0;
    for (int i = 0; i < N; ++i) {
      auto connections = nodes[i].GetConnections();
      bool is_ok = true;
      for (auto x : connections) {
        if (H[i] <= H[x]) {
          is_ok = false;
          break;
        }
      }
      if (is_ok) ++count;
    }
    std::cout << count << std::endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n;
	cin >> n;
	vector<ll> v(n - 1);
	vector<ll> dp(n + 1,0);
	for(ll i = 0;i<n-1;i++){
		cin >> v[i];
		dp[v[i]]++;
	}
	for(ll i = 1;i<dp.size();i++)
		cout << dp[i] << "\n";
}



Measured memory_bytes: 6368
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];
  int maxl = -1;
  int index;
  rep(i, n) {
    if(maxl < l[i]) {
      maxl = l[i];
      index = i;
    }
  }
  int sum = 0;
  rep(i, n) {
    if(i != index) sum += l[i];
  }

  // cout << maxl << endl;
  // cout << sum << endl;
  yorn(maxl < sum);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int m,k;
	cin >> m >> k;
	if((1<<m)<=k) cout << -1 << endl;
	else {
		if(m==0){
			if(k==0) cout << 0 << ' ' << 0;
			else cout << -1 << endl;
		}else if(m==1){
			if(k==0) cout << 0 << ' ' << 0 << ' ' << 1 << ' ' << 1 << endl;
			else cout << -1 << endl;
		}else{
			for(int i=0;i<(1<<m);i++) if(i!=k) cout << i << ' ';
			cout << k << ' ';
			for(int i=(1<<m)-1;i>=0;i--) if(i!=k) cout << i << ' ';
			cout << k << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1792
N, M, X, Y = map(int, input().split())
ma_x = max(map(int, input().split()))
mi_y = min(map(int, input().split()))
for z in range(X + 1, Y + 1):
    if ma_x < z and mi_y >= z:
        print('No War')
        break
else:
    print('War')

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
 
    int ans = 1; 
    while(ans*2<=N) {
        ans *= 2;
    }
	System.out.println(ans);
    }
}



Measured memory_bytes: 35668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

int a,b; cin >> a >> b;
if(a <= b) cout << a << endl;
else cout << a-1 << endl;

return 0;
}

Measured memory_bytes: 256
from math import gcd
 
n,m=map(int, input().split())
s=input()
t=input()
 
g=gcd(n,m)
 
ng=n//g
mg=m//g
 
for i in range(0,g):
    if s[ng*i]!=t[mg*i]:
        print(-1)
        exit()
print(ng*mg*g)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    int n;
    while (cin >> n) {
        int cnt = 0;

        rep(a, 10) rep(b, 10) rep(c, 10) rep(d, 10) {
            if (a + b + c + d == n) cnt++;
        }
        cout << cnt << endl;
    }



    return 0;
}




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

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

    ll N, K;
    cin >> N >> K;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }
    ll ans = 0;
    for (ll b = K + 1; b <= N; b++) {
        ans += (b - K) * (N / b) + max(N % b - K + 1, 0LL);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
    int h,w;
    cin >> h >> w;
    if(h == 1 || w == 1)cout << 1;
    else cout << (h*w+1)/2;
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...#include <bits/stdc++.h>
 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <array>
#include <stdlib.h>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define REP(i,a,b) for(i = (a); i < (b); i++)
#define rep(i,n) REP(i,0,n)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int n;
	string s1, s2;
	cin >> n;
	cin >> s1 >> s2;
	ll int ans = 1;
	int flag = 0;
	if (s1[0] == s2[0]) {
		ans = 3;
		flag = 0;
	}
	else {
		ans = 6;
		flag = 1;
	}
	REP(i, flag + 1, n) {
		if (s1[i] == s2[i]) {
			if (flag == 0) {
				ans = ans * 2 % MOD;
			}
			flag = 0;
		}
		else {
			if (flag == 0) {
				ans = ans * 2 % MOD;
			}
			else {
				ans = ans * 3 % MOD;
			}
			flag = 1;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node {
  struct node *left, *right;
  int number;
};

static struct node *root = NULL;
#define BUF_SIZE 30
#define COMMAND_MAX 500001

void insert(int num) {
  struct node *nod = malloc(sizeof(struct node));
  nod->number = num;
  nod->left = nod->right = NULL;
  if(!root) {
    root = nod;
    return;
  }
  struct node **tmp = &root;
  while(*tmp) {
#ifdef DEBUG
    printf("%d: %d\n", num, (*tmp)->number);
#endif
    tmp = ((*tmp)->number > num) ? &(*tmp)->left : &(*tmp)->right;
  }
  // tmp = &nod is not the answer!
  *tmp = nod;
  return;
}

void pre_order(struct node *node) {
  if(!node) return;
  printf(" %d", node->number);
  pre_order(node->left);
  pre_order(node->right);
}

void in_order(struct node *node) {
  if(!node) return;
  in_order(node->left);
  printf(" %d", node->number);
  in_order(node->right);
}

void print(void) {
  in_order(root);
  putchar('\n');
  pre_order(root);
  putchar('\n');
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;

  int num;
  sscanf(line, "%d", &num);

  int i, j;
  for(i = 0; i < num; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    char command[8];
    int n;
    sscanf(line, "%s %d", command, &n);
    if(!strncmp(command, "insert", 6)) {
      insert(n);
    } else if (!strncmp(command, "print", 5)) {
      print();
    }
  }
  return 0;
}


Measured memory_bytes: 17324
x = int(input())

ans=0
if x>=400 and x<600:
  ans=8
elif x>=600 and x<800:
  ans=7
elif x>=800 and x<1000:
  ans=6
elif x>=1000 and x<1200:
  ans=5
elif x>=1200 and x<1400:
  ans=4
elif x>=1400 and x<1600:
  ans=3
elif x>=1600 and x<1800:
  ans=2
else:
  ans=1
  
  
print(ans)

Measured memory_bytes: 9188
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int n = 0;
vector<int> h;

void solve() {
    int ans = 0;
    while (true) {
        bool ended = true;
        rep(i, n) {
            if (h[i] != 0) {
                ans++;
                ended = false;
            }
            while (i < h.size() && h[i] != 0) {
                h[i]--;
                i++;
            }
        }
        if (ended) goto LABEL;
    }
    LABEL:

    cout << ans << endl;
}

int main() {
    cin >> n;
    h.resize(n);
    rep(i, n) cin >> h[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooll 0x3f3f3f3f3f3f3f3f
typedef long long ll;
int main(){
    int n, s;
    cin >> n >> s;
    int weight[n+1], price[n+1];
    int sum = 0;
    for(int i = 1; i <= n ; ++i){
         cin >> weight[i] >> price[i];
         sum+=price[i];
    }
    vector<vector<ll>> dp(n+1, vector<ll>(sum+1, ooll));
    dp[0][0] = 0;
    for(int i = 1; i <= n ; ++i){
        for(int j = 0 ; j <= sum ; ++j){
            if(j < price[i]) dp[i][j] = dp[i-1][j];
            else dp[i][j] = min(dp[i-1][j], dp[i-1][j-price[i]] + weight[i]);
        }
    }

    ll ans = 0;
    for(int i = 1; i <= n ; ++i){
        for(int j = 0; j <= sum ; ++j) if(dp[i][j] <= s){
            ans = max(ans, (ll)j);
        }
    }

    printf("%lld\n", ans);
 
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}


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

    int N; cin >> N; int cnt = 0;
    rep(i,N) {
        int p; cin >> p;
        for(int j = 2; j * j <= p; j++) {
            if(p % j == 0) { cnt++; break; }
        }
    }
    cout << N - cnt << endl;
}










Measured memory_bytes: 3136
import sys
input = sys.stdin.readline
X, K, D = map(int, input().split())
if abs(X) >= K * D:
  print(abs(X) - K * D)
  exit(0)
a = abs(X) // D
b = -(-abs(X) // D)
res = float("inf")
if (K - a) % 2:
  res = min(res, abs(X) % D + D, abs(abs(X) % D - D))
else: res = min(res, abs(X) % D)
print(res)

Measured memory_bytes: 61820
#include <iostream>

using namespace std;

const int MAX_A = 17;
const int MAX_B = 17;
bool passable[MAX_A][MAX_B];
int dp[MAX_A][MAX_B];
int main() {
  int a, b;
  while (cin >> a >> b) {
    if (a == 0 && b == 0) break;
    int N;
    cin >> N;
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        passable[i][j] = true;
      }
    }
    for (int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      passable[x][y] = false;
    }
    dp[1][0] = 1;
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if (passable[i][j]) {
          dp[i][j] = dp[i-1][j] + dp[i][j-1];
        } else {
          dp[i][j] = 0;
        }
      }
    }
    cout << dp[a][b] << endl;
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long N = sc.nextLong();
        if (B <= N) {
        	N = B - 1;
        }
        System.out.println(A * N / B - A * (N / B));
    }
}

Measured memory_bytes: 35728
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((a==b&&a!=c)||(a==c&&a!=b)||(c==b&&a!=c)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a[i];
    if (n == 0) {
        if (a[0] == 1) { cout << 1 << "\n"; return 0; }
        else { cout << -1 << "\n"; return 0; }
    }
    // cout << "a: " << a << "\n";
    vector<ll> ar(n+2);
    ar[n+1] = 0;
    rrepSE(i, n, -1) {
        ar[i] = ar[i+1] + a[i];
    }
    // cout << "ar: " << ar << "\n";
    vector<ll> b(n+1);
    b[0] = 1 - a[0];
    repSE(i,1,n+1) {
        if (2*b[i-1] < a[i]) { cout << -1 << "\n"; return 0; }
        b[i] = min(2*b[i-1] - a[i], ar[i+1]);
        if (b[i] + a[i] < b[i-1]) { cout << -1 << "\n"; return 0; }
    }
    // cout << "b: " << b << "\n";
    ll ans = 0;
    rep(i,n+1) ans += a[i] + b[i];
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5632
#include<cstdio>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;

int flag[301] = {0};

int main(void){
    while(1){
        for(int i = 1;i <= 300;i++){
            flag[i] = 2;
        }
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        if(a == 0 && b == 0 && c == 0) break;
        vector < pair<pair<int,int> ,pair<int,int> > > v;
        pair<pair<int,int>,pair<int,int> > input;
        int n; scanf("%d",&n);
        for(int i = 0;i < n;i++){
            int x,y,z,w; scanf("%d%d%d%d",&x,&y,&z,&w);
            input.first.first = w;
            input.first.second = x;
            input.second.first = y;
            input.second.second = z;
            v.push_back(input);
        }
        sort(v.begin(),v.end(),greater <pair< pair<int,int>,pair<int,int> > >());
        for(int i = 0;i < n;i++){
            if(v[i].first.first == 1){
                flag[v[i].first.second] = 1;
                flag[v[i].second.first] = 1;
                flag[v[i].second.second] = 1;
            }
            else{
                if(flag[v[i].first.second] == 1 &&
                   flag[v[i].second.first] == 1 &&
                   flag[v[i].second.second] == 2){
                    flag[v[i].second.second] = 0;
                }

                if(flag[v[i].first.second] == 1 &&
                   flag[v[i].second.first] == 2 &&
                   flag[v[i].second.second] == 1){
                    flag[v[i].second.first] = 0;
                }

                if(flag[v[i].first.second] == 2 &&
                   flag[v[i].second.first] == 1 &&
                   flag[v[i].second.second] == 1){
                    flag[v[i].first.second] = 0;
                }
            }
        }
        for(int i = 1;i <= a+b+c;i++){
            printf("%d\n",flag[i]);
        }

    }
    return 0;
}

Measured memory_bytes: 1068
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf 1000000000000000000

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h;
    cin>>h;
    vi a(h+1);
    REP(i,1,h)cin>>a[i];
    REP(i,1,h){
        cout<<"node "<<i<<": key = "<<a[i]<<", ";
        int p=i/2,l=i*2,r=i*2+1;
        if(p)cout<<"parent key = "<<a[p]<<", ";
        if(l<=h)cout<<"left key = "<<a[l]<<", ";
        if(r<=h)cout<<"right key = "<<a[r]<<", ";
        cout<<endl;
    }
}


Measured memory_bytes: 3132
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	k := nextInt()

	if a == b && b == c {
		fmt.Println("0")
		return
	}

	ans := a - b
	if k%2 == 1 {
		ans = b - a
	}

	if abs(ans) > pow(10, 18) {
		fmt.Println("Unfair")
		return
	}

	fmt.Println(ans)

}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func pow(a, b int) int {
	var ret int = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret *= a
		}
		a *= a
		b >>= 1
	}
	return ret
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

int main()
{
	long long n;
	cin >> n;
	vector<long long> av(n);
	for (auto& a : av) {
		cin >> a;
	}

	long long c = 1000;
	for(int i = 1; i < n; ++i)
	{
		if (av[i - 1] < av[i]) {
			c = c / av[i - 1] * av[i] + c % av[i - 1];
		}
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 3620
//https://atcoder.jp/contests/abc105/tasks/abc105_c

import java.io.*;
import java.util.ArrayList;

class Main{
    ArrayList<String> ans = new ArrayList<>();
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        long N = Long.parseLong(str);
        StringBuffer ans = new StringBuffer();
        while (N!=0){
            if (N%2==0){
                ans.insert(0, "0");
            } else {
                N--;
                ans.insert(0, "1");
            }
            N /= -2;
        }
        if (ans.length()==0){
            ans.append("0");
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cassert>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int ans;
int n;
int like[100010];
int main() {
  cin >> n;
  ans = 0;
  REP(i,1,n+1){
    cin >> like[i];
    if(like[i] < i){
      if(like[like[i]] == i){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
  int n,k;
  cin>>n>>k;
  vector<double>p(n);
  rep(i,n)cin>>p[i];
  vector<double>s(n+1);
  s[0]=0;
  rep(i,n)s[i+1]=s[i]+(p[i]+1)/2;
  double max=0,tmp;
  rep(i,n-k+1){
    tmp=s[k+i]-s[i];
    if(max<tmp)max=tmp;
  }
  cout<<fixed<<setprecision(6)<<max<<endl;

}
    





Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[200005];
ll b[100005];
ll modpow(ll a,ll n,ll tmp){
	ll res=1ll;
	while(n){
		if(n%2)res=(res*a)%tmp;
		a=(a*a)%tmp;
		n/=2ll;
	}
	return res;
}
bool cmp(ll a,ll b){
	return abs(a)>abs(b);
}
int main(){
    ll n,k;
    boost;
    cin>>n;
    ll ans=n*(n+1)*(n+2);
    ans/=6ll;
    for(ll i=1;i<n;i++){
    	ll u,v;
    	cin>>u>>v;
    	if(u>v)swap(u,v);
    	ans-=(u*(n-v+1ll));
	}
	cout<<ans;
			
			
			
}

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

const int mod = 1000000007;
class modint {
public:
    ll a = 0;
    modint(ll x = 0) {while(x < 0)x += mod;a = x%mod;}
    modint(const modint &r) {a = r.a;}
    modint operator -(){return modint(-a);}
    modint operator +(const modint &r) {return modint(*this)+=r;}
    modint operator -(const modint &r) {return modint(*this)-=r;}
    modint operator *(const modint &r) {return modint(*this)*=r;}
    modint &operator +=(const modint &r){
        a += r.a;
        if(a >= mod) a -= mod;
        return *this;
    }
    modint &operator -=(const modint &r) {
        a -= r.a;
        if(a < 0) a += mod;
        return *this;
    }
    modint &operator *=(const modint &r) {
        a = a * r.a % mod;
        return *this;
    }
    modint pow(ll r) const {
        if (!r) return 1;
        modint x = pow(r >> 1);
        x *= x;
        if (r & 1) x *= *this;
        return x;
    }
    modint inverse() const {
        return pow(mod-2);
    }
    modint& operator/=(const modint r) {
        return (*this) *= r.inverse();
    }
    modint operator/(const modint r) const {
        modint res(*this);
        return res /= r;
    }
};
istream &operator>>(istream &is, modint &x) {
    ll t;
    is >> t;
    x = t;
    return is;
}
ostream &operator<<(ostream &os, const modint& x) {
    return os << x.a;
}
const int MAX = 500000;
modint fac[MAX], inv[MAX], finv[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] * modint(i);
        inv[i] = - inv[mod%i] * modint(mod/i);
        finv[i] = finv[i-1] * inv[i];
    }
}
modint Com(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
modint Per(ll n, ll k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k];
}

using Mint = modint;

int main() {
    int n, m;
    cin >> n >> m;
    if(n < m) swap(n, m);
    if(n - m > 1) {
        cout << 0 << endl;
        return 0;
    } else {
        Mint ans = 1;
        for(int i = 1; i <= n; i++) {
            ans *= i;
        }
        for(int i = 1; i <= m; i++) {
            ans *= i;
        }
        if(n == m) ans *= 2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 15332
#include<iostream>
#include<vector>
#include<stdio.h>
#define ll long long
using namespace std;

void max_self(ll &a,ll b){
  a=max(a,b);
}

int main()
{
  ll n,W;
  scanf("%d%d",&n,&W);
  vector<ll>dp(W+1);
  for(ll item=0;item<n;item++){
    ll weight,value;
    scanf("%d%d",&weight,&value);
    for(ll weight_already=W-weight;weight_already>=0;weight_already--){
    max_self(dp[weight_already+weight],dp[weight_already]+value);
    }
  }
  ll answer=0;
  for(ll i=0;i<=W;i++)
    max_self(answer,dp[i]);
  printf("%lld\n",answer);
}
  

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll r;
	cin >> r;
	cout << r*r;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 1007 , mo = 1000000007;

inline lint powa(lint a,lint t)
{
	lint b=1;
	while(t){if(t&1)b=b*a%mo;a=a*a%mo,t>>=1;}
	return b;
}

inline lint inva(lint a)
{
	return powa(a,mo-2);
}

lint jc[_],rjc[_];

inline void fuck(int n=_-1)
{
	jc[0]=jc[1]=rjc[0]=1;
	for(int i=2;i<=n;i++)jc[i]=jc[i-1]*i%mo;
	rjc[n]=inva(jc[n]);
	for(int i=n-1;i>=1;i--)rjc[i]=rjc[i+1]*(1ll+i)%mo;
}

inline lint C(int n,int m)
{
	if(n<m || n<0 || m<0)return 0;
	return jc[n]*rjc[m]%mo*rjc[n-m]%mo;
}

int n,m,len[_],got[_]={0};
lint f[_][_]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	fuck();

	n=ty(),m=ty();
	for(int i=1;i<=n;i++)len[i]=ty(),got[len[i]]++;

	f[0][0]=1;
	for(int i=m;i>=1;i--)
	{
		for(int j=m;j>=1;j--)
			for(int k=i;k<=m;k++)
				for(int a=1;a<=j && a*i<=k;a++)
					f[j][k]=(f[j][k]+f[j-a][k-a*i]*rjc[a]%mo)%mo;
		if(got[i])
			for(int j=0;j<=m;j++)
				for(int k=0;k<=m;k++)
					f[j][k]=f[j][k]*powa(k-j*(i-1),got[i])%mo;
	}

	lint ans=0;
	for(int j=1;j<=m;j++)
	{
		for(int k=1;k<=m;k++)
		{
			if(!f[j][k])continue;
			lint sum=0;
			for(int a=0;a<j;a++)
				sum=(sum+((a&1)?mo-1ll:1ll)*C(j-1,a)%mo*C(m-k+j-a,m-k)%mo)%mo;
			sum=sum*f[j][k]%mo*jc[j]%mo;
			ans=(ans+(((m-k)&1)?mo-1ll:1ll)*sum%mo)%mo;
		}
	}

	cout<<ans<<lf;
	
	return 0;
}


Measured memory_bytes: 4480
import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def main():
    n,k=map(int,input().split())
    P_num=np.array([int(_) for _ in input().split()])
    PP=(P_num+1)/2
    PP_cum=np.cumsum(PP)
    PP_cum=np.insert(PP_cum,0,0)
    ans=PP_cum[k:]-PP_cum[:n-k+1]
    print(np.max(ans))

if __name__=='__main__':
    main()

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  vector<ll> vec(N + 1); REP(i, N + 1) vec[i] = 0;
  vector<ll> path;
  ll tmp = 1;
  vec[0] = 1;
  ll ans = 0;
  path.push_back(vec[0]);
  ll cnt = 0;
  for(ll i = 0; i < K; ++i) {
    if(vec[tmp] == 0) {
      vec[tmp] = A[tmp - 1];
      tmp = A[tmp - 1];
      path.push_back(tmp);
      cnt++;
    } else if(vec[tmp] != 0) {
      // なんらかの処理
      ans = tmp;
      break;
    }
  }

  vector<ll> b;
  bool flag = false;
  REP(i, path.size()) {
    if(path[i] == ans) flag = !flag;
    if(flag == true) b.push_back(path[i]);
  }

  if(K - (cnt - b.size()) <= 0) {
    cout << path[K] << endl;
  } else {
    ll c = (K - (cnt - b.size())) % b.size();
    cout << b[c] << endl;
  }
}


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

int main()
{
  char c;
  cin >> c;

  switch (c)
  {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
    cout << "vowel" << endl;
    break;
  default:
    cout << "consonant" << endl;
    break;
  }
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for _ in range(N):
    A = list(map(int, input().split()))
    res = C
    for i in range(M):
        res += A[i]*B[i]

    if res > 0:
        ans += 1
print(ans)

Measured memory_bytes: 61896
///Bismillahir Rahmanir Rahim
#define ll long long
#define ull unsigned long long
#define scf1(a)  scanf("%lld",&a)
#define scf2(a,b)  scanf("%lld %lld",&a,&b)
#define pf    printf
#define pb    push_back
#define rsrt(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define ff first
#define ss second
#define spd ios_base::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
ll arr[100001];
ll dp[100001],n,k;
ll mincost(ll pos)
{
    if(pos>=n)return 0;

    if(dp[pos]!=-1)return dp[pos];

   ll res = abs(arr[pos]-arr[pos+1]) + mincost(pos+1);
    for(ll i=2;i<=k;i++){
    if(pos+i<=n)
    res = min(res,(abs(arr[pos]-arr[pos+i])+mincost(pos+i)));

    }

    dp[pos] = res;
   return dp[pos];
}
int main()
{
    ll i,j;

    cin>>n>>k;

    for(i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<mincost(1)<<endl;
}


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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2;
}

Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())

x=[int(i) for i in input().split()]

y=[int(i) for i in input().split()]

battle_flag=False

X_max=max(x)
Y_min=min(y)

battle_flag=True

for Z in range(X,Y+1):
    if X_max<Z and Z<=Y_min:
        
        if X<Z and Z<=Y:
            battle_flag=False

if battle_flag:
    print("War")
else:
    print("No War")





Measured memory_bytes: 3060
n,k,s = (int(i) for i in input().split())
ans = ""
if s != 10**9:
    for i in range(k):
        ans += str(s) + " "
    if n > k:
        for j in range(n-k):
            ans += str(10**9) + " "
    print(ans)
else:
    for i in range(k):
        ans += str(s) + " "
    if n > k:
        for j in range(n-k):
            ans += str(1) + " "
    print(ans)

Measured memory_bytes: 6292
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    using namespace std;
    int main(){
    	int n,x[100005],a=0;
    	long long s[2];
    	cin >> n;
    	for(int i=0;i<n;i++){
    		cin >> x[i];
    	}
    	sort(x,x+n);
    	for(int i=n-1;i>0;i--){
    		if(x[i]==x[i-1]){
    			s[a]=x[i];
                a++;
    			i--;
    			if(a==2){
    				cout << s[0]*s[1] << endl;
    				return 0;
    			}
    		}
    	}
    	cout << "0" << endl;
    	return 0;
    }

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

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

  if (A > 8 || B > 8) {
    cout << ":(" << endl;
    return 0;
  }

  cout << "Yay!" << endl;  
  return 0;
}

Measured memory_bytes: 3620
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

    int a,b;
    cin>>a>>b;
    if(a<b)swap(a,b);
    cout<<a+max(a-1,b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
a = sorted(map(int,input().split()))
c = collections.Counter(a)
ans = 0

for i in c.keys():
    if i == 0:
        pass
    if i < c[i]:
        ans += (c[i]-i)
    elif c[i] < i:
        ans += c[i]

print(ans)

Measured memory_bytes: 18668
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(ll i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int main()
{
    fio;
    int t=1;;
    //cin>>t;
    while(t--)
    {
        ll h,w,m;
        cin>>h>>w>>m;
        vector<pair<ll,ll>> c;
        map<pair<ll,ll>,ll> chk;
        rep(i,m)
        {
            ll a,b;
            cin>>a>>b;
            c.pb({a,b});
            pair<ll,ll> p={a,b};
            chk[p]++;
        }
        unordered_map<ll,ll> m1,m2;
        rep(i,m)
        {
            m1[c[i].first]++;
        }
        rep(i,m)
        {
            m2[c[i].second]++;
        }
        ll mx=INT_MIN,f=0,mx1=INT_MIN,s=0;
        for(auto x:m1)
        {
            if(x.second>mx)
            {
                mx=x.second;
                f=x.first;
            }
        }
        for(auto x:m2)
        {
            if(x.second>mx1)
            {
                mx1=x.second;
                s=x.first;
            }
        }
        ll sum=0,mxs=INT_MIN;
        if(mx>mx1)
        {
            repp(i,1,w+1)
            {
                pair<ll,ll> p={f,i};
                if(chk[p]!=0)
                {
                    sum--;
                }
                sum=sum+(mx+m2[i]);
                mxs=max(mxs,sum);
                sum=0;
            }
            cout<<mxs<<endl;
        }
        else
        {
            repp(i,1,h+1)
            {
                pair<ll,ll> p={i,s};
            if(chk[p]!=0)
                {
                    sum--;
                }
                sum=sum+(mx1+m1[i]);
                mxs=max(mxs,sum);
                sum=0;
            }
            cout<<mxs<<endl;
        }
    }
}

Measured memory_bytes: 72364
#D
N = int(input())
S = list(str(input()))
count = 0
for i in range(1000):
    si = str(i)
    while len(si) < 3:
        si = "0"+si
        
    flag = 0
    for s in S:
        if s == si[flag]:
            flag+=1
            if flag == 3:
                break
            
    if flag == 3:
        count+=1
    
print(count)

Measured memory_bytes: 42732
a = []
for i in range(3):
    tmpa, tmpb = map(int, input().split())
    a.append(tmpa)
    a.append(tmpb)

count = []
for i in range(4):
    c = 0
    for j in range(6):
        if a[j] == i+1:
            c += 1
    count.append(c)

if max(count) >= 3:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"

signed main(){
	cout<<fixed<<setprecision(7);
	int n = 0, m = 0;
	int a = 0, b = 0, c = 0, d = 0, e = 0;
	bool f = false, flag = true;
	string S, T;
	cin>>n>>m>>S>>T;
	
	if(n<m) {
			b = n;
			n = m;
			m = b;
			swap(S,T);
	} else{
	
	}	
		
		a =  n*m/__gcd(n,m);
		b = n*m/__gcd(n,m);
		d = n*m/__gcd(n,m);
		
		for(int i = 0; d*i/m < n; i++){
			// cout<<i*m/__gcd(n,m)<<" "<<i*n/__gcd(n,m)<<endl;
			// cout<<S[i*m/__gcd(n,m)]<<" "<<T[i*n/__gcd(n,m)]<<endl;
			// if(S[i*m/__gcd(n,m)] != T[i*n/__gcd(n,m)]) flag = false;
			// cout<<S[d*i/m]<<" "<<T[d*i/n]<<endl;
			 if(S[d*i/m] != T[d*i/n]) flag = false;
		}
		if(flag)cout<<d<<endl;
		else cout<<-1<<endl;
	
	// if(n%m==0||m%n==0){
		
		// for(int i = 0; i*c < n; i++){
			// cout<<i<<" "<<i*c<<endl;
			// if(S[i] != T[i*c]) flag = false;
		// }
		// if(f==false)cout<<-1<<endl;
		// else cout<<n<<endl;
	// }else{
		// cout<<<<endl;
	// }
	//cin>>S;
	//cin>>n;
	
	//for(int i = 0; i < n; i++){
	//}
	
	// cout<<yn(f)<<endl;
	// cout<<YN(f)<<endl;
	
	return 0;
}

Measured memory_bytes: 512