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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
ll X[MAX_N];
int W[MAX_N];

vector<int> solve(int N, ll L, ll T) {
  vector<int> res(N);
  if (count(W, W+N, 1) == N) {
    REP(i, N) res[i] = (X[i] + T) % L;
    return res;
  }
  if (count(W, W+N, 2) == N) {
    REP(i, N) res[i] = ((X[i] - T) % L + L) % L;
    return res;
  }

  vector<int> Y(N);
  REP(i, N) {
    if (W[i] == 1) Y[i] = (X[i] + T) % L;
    else Y[i] = ((X[i] - T) % L + L) % L;
  }
  sort(ALL(Y));
  // pv(ALL(Y));

  int o = 0;
  while (W[o] == 2) o++;
  // W[o] == 1

  ll co = 0;
  REP(i, N) if (i != o) {
    if (W[i] == 2) {
      ll t = T;
      if (o < i) {
        if (t >= (X[i]-X[o])/2) {
          co++;
          t -= (X[i]-X[o])/2;
          co += 2*t/L;
        }
      } else {
        if (t >= (L-X[o]+X[i])/2) {
          co++;
          t -= (L-X[o]+X[i])/2;
          co += 2*t/L;
        }
      }
    }
  }
  int y0 = (X[o] + T) % L;
  int p;
  for (p = N - 1; p >= 0; p--) if (y0 == Y[p]) break;
  // cout << "co=" << co << " " << y0 << " " << p <<  endl;
  REP(i, N) res[(co+o+i) % N] = Y[(p+i) % N];
  return res;
}

int main2() {
  int N = nextInt();
  ll L = nextInt();
  ll T = nextInt();
  REP(i, N) { X[i] = 2*nextInt(); W[i] = nextInt(); }
  vector<int> ans = solve(N, 2*L, 2*T);  
  REP(i, ans.size()) printf("%d\n", ans[i]/2);
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 2808
def printer(n, s, v)
  abc_index = s.index('ABC')
  return v if abc_index == nil
  s[abc_index, 3] = 'ZZZ'
  next_abc_index = s.index('ABC')
  return v+1 if next_abc_index == nil
  printer(n, s, v+1)
end
n = gets.chop.split.map(&:to_i)
s = gets.chop
print printer(n, s, 0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;


struct Unionfind{
    vector<int> parents;
    int n;
    Unionfind(int n):n(n),parents(n,-1){ }

    int find(int x){
        if(parents[x] < 0) return x;
        else return parents[x] = find(parents[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x==y) return;
        if(parents[x] > parents[y]) swap(x,y);
        parents[x] += parents[y];
        parents[y] = x;
    }  

   int size(int x){
       return -parents[find(x)];
   }

   bool same(int x,int y){
       return find(x) == find(y);
   }

   vector<int> members(int x){
       int root = find(x);
       vector<int> member;
       for(int i=0;i<n;i++){
           if(find(i)==root){
               member.push_back(i);
           }
       }
      return member;
  }

  int group_cnt(){
      int c = 0;
      rep(i,n){
          if(parents[i] < 0) ++c;
      }
      return c;
  }
};

int main(){
    int n,q;
    cin >> n >> q;
    Unionfind uf(n);
    rep(i,q){
        int t,x,y;
        cin >> t >> x >> y;
        if(t==0) uf.unite(x,y);
        else cout << (uf.same(x,y)?1:0) << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

int main() {
    string s;
    cin >> s ;
    cout <<  (s.find_last_of('Z') - s.find_first_of('A') + 1);
    return 0;
}



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


int main() {
    long long N; cin >> N;
    long long sqrt_N = (int)sqrt(N);
    long long num_1, num_2;
    long long sum = 1e13;

    for (int i = 1; i <= sqrt_N; i++) {
        if (N % i == 0) {
            num_1 = i;
            num_2 = N / num_1;
            if (num_1 + num_2 < sum) {
                sum = num_1 + num_2;
            }
        }
    }

    cout << sum - 2 << endl;
    return 0;
}


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

int main(){
  int N,min;
  cin >> N;
  rep(i,N){
    int x,nanjou=0;
    cin >> x;
    while(x%2 == 0){
      nanjou++;
      x /= 2;
    }
    if(nanjou == 0){
      min = 0;
      break;
    }
    else if(i == 0)
      min = nanjou;
    else if(nanjou < min)
      min = nanjou;
  }
  cout << min << 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;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 1; i < n; i++){
        int j;
        cin >> j;
        a.at(i) = j-1;
    }
    vector<int> buka(n);
    for(int i = 1; i < n; i++) buka.at(a.at(i))++;
    rep(i,n) cout << buka.at(i) << endl;
    return 0;
}

Measured memory_bytes: 4840
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
    int src,to;
    T cost;

    edge() = default;
    edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

int N;
vector<vector<edge<int>>> G;
vector<int> dist;

int dfs1(int v, int pv = -1) {
    for (auto &e : G[v]) {
        if (e.to == pv) continue;
        chmax(dist[v], dfs1(e.to,v) + e.cost);
    }
    return dist[v];
}

int dfs2(int v, int val, int pv = -1) {
    vector<pii> length;
    length.emplace_back(0,-1);
    for (auto &e : G[v]) {
        if (e.to == pv) length.emplace_back(val+e.cost,e.to);
        else length.emplace_back(dist[e.to] + e.cost,e.to);
    }
    sort(all(length)); reverse(all(length));
    int ret = length[0].first + length[1].first;

    for (auto &e : G[v]) {
        if (e.to == pv) continue;
        chmax(ret, dfs2(e.to, length[length[0].second==e.to].first, v));
    }

    return ret;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N;
    G.resize(N);
    rep(i,N-1) {
        int u,v,w; cin >> u >> v >> w;
        G[u].emplace_back(v,w);
        G[v].emplace_back(u,w);
    }
    dist.resize(N);
    dfs1(0);
    cout << dfs2(0,0) << ln;
}



Measured memory_bytes: 24068
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        mp[a]++;
    }
    int tot=0,tot2=0;
    for(auto x:mp){
        tot++;
        if(x.second%2==0){
            tot2++;
        }
    }
    cout<<tot-(tot2%2==1)<<endl;
}


Measured memory_bytes: 4992
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	if (n == 1)
	{
		if (m == 0)cout << 0 << endl;
		else
		{
			int s, c; cin >> s >> c;
			int res = c;
			--m;
			rep(i, m)
			{
				int s, c; cin >> s >> c;
				if (res != c)
				{
					cout << -1 << endl;
					return 0;
				}
			}
			cout << res << endl;
		}
		return 0;
	}
	vector<char> res(n);
	rep(i, m)
	{
		int s; cin >> s;
		--s;
		char c; cin >> c;
		if (s == 0 && c == '0')
		{
			cout << -1 << endl;
			return 0;
		}
		if (res[s] == NULL)res[s] = c;
		else if (res[s] != c)
		{
			cout << -1 << endl;
			return 0;
		}
	}
	if (res[0] == NULL)res[0] = '1';
	for (int i = 1; i < n; ++i)if (res[i] == NULL)res[i] = '0';
	rep(i, n)cout << res[i];
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  ll a, b, c, k, ans = 0;
  cin >> a >> b >> c >> k;

  if(k <= a){
    ans += k;
    print(ans);
    return 0;
  } else {
    ans += a;
    k -= a;
  }

  if(k <= b){
    print(ans);
    return 0;
  } else {
    k-=b;
  }

  ans -= k;
  print(ans);

}


Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N = int(input())
    M = int(input())
    ans = [1, 2, 3]
    ans.remove(N)
    ans.remove(M)
    print(ans[0])


if __name__ == "__main__":
    main()

Measured memory_bytes: 27628
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define endl "\n"
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const ll INF = 1001001001001001001LL;

ll next(ll a, ll b, ll x) {
    return x + (b + x + a - 1) / (x + a);
}

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

    int N, M, S, G;
    cin >> N >> M >> S >> G;
    S--, G--;

    vector<pair<ll, ll>> E(M);
    vector<vector<pii>> g(N);
    for (int i = 0; i < M; i++) {
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        g[u].push_back({v, i});
        g[v].push_back({u, i});
        E[i] = {a, b};
    }

    using pli = pair<ll, int>;
    priority_queue<pli, vector<pli>, greater<pli>> pq;
    vector<ll> dist(N, INF);
    dist[S] = 0;
    pq.push({0, S});
    while (!pq.empty()) {
        int T = pq.top().first;
        int v = pq.top().second; pq.pop();

        if (v == G) {
            cout << dist[v] << endl;
            return 0;
        }
        if (dist[v] < T) continue;

        ll t = dist[v];
        for(auto& e : g[v]) {
            int w = e.first;
            ll a = E[e.second].first;
            ll b = E[e.second].second;

            ll x;
            if (1 > (double) b / (t + a) / (t + a)) {
                x = t;
            } else {
                x = floor(sqrt(b)) - a;
            }
            if (x < t) x = t;

            ll mn = min(next(a, b, x), next(a, b, x + 1));
            if (dist[w] > mn) {
                dist[w] = mn;
                pq.push({dist[w], w});
            }
        }
    }

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



Measured memory_bytes: 24968
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if((a==b)&&(b==c)&&(c==a)){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
}


Measured memory_bytes: 128
//JSD
#include<iostream>
#include<vector>
#include<cmath>
#define ll long long 
using namespace std;
int main(){
	int n;
	cin>>n;
	ll a[n+1],b[n];
	for(int i=0;i<n+1;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	ll ans=0;
	for(int i=0;i<n;i++){
		if(b[i]>a[i]){
			ans+=a[i];
			b[i]-=a[i];
			if(b[i]>a[i+1]){
				ans+=a[i+1];
				a[i+1]=0;				
			}
			else{
				ans+=b[i];
				a[i+1]-=b[i];
			}
		}
		else{
			ans+=b[i];
		}
	}
	cout<<ans;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args)
	{
			Scanner in = new Scanner(System.in);
			int A = in.nextInt(), B = in.nextInt(), C = in.nextInt(), D = in.nextInt(), ans = 0;

			ans = ((A < B) ? A : B ) + ((C < D) ? C : D);
			System.out.println(ans);
	}
    
}

Measured memory_bytes: 23892
package main

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

func main() {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	nextInt := func() int { scn.Scan(); r, _ := strconv.Atoi(scn.Text()); return r }
	w := bufio.NewWriter(os.Stdout)

	n := nextInt()
	cs := make([][2]int, n)
	parents := make([]int, n)
	for i := range parents {
		parents[i] = -1
	}

	for i := 0; i < n; i++ {
		id, left, right := nextInt(), nextInt(), nextInt()
		cs[id] = [2]int{left, right}
		if left != -1 {
			parents[left] = id
		}
		if right != -1 {
			parents[right] = id
		}
	}

	root := -1
	for id, parent := range parents {
		if parent == -1 {
			root = id
		}
	}

	fmt.Fprintln(w, "Preorder")
	preorder(w, cs, root)
	fmt.Fprintln(w)

	fmt.Fprintln(w, "Inorder")
	inorder(w, cs, root)
	fmt.Fprintln(w)

	fmt.Fprintln(w, "Postorder")
	postorder(w, cs, root)
	fmt.Fprintln(w)

	w.Flush()
}

func preorder(w io.Writer, cs [][2]int, root int) {
	print(w, root)
	for _, c := range cs[root] {
		if c != -1 {
			preorder(w, cs, c)
		}
	}
}

func inorder(w io.Writer, cs [][2]int, root int) {
	if cs[root][0] != -1 {
		inorder(w, cs, cs[root][0])
	}
	print(w, root)
	if cs[root][1] != -1 {
		inorder(w, cs, cs[root][1])
	}
}

func postorder(w io.Writer, cs [][2]int, root int) {
	for _, c := range cs[root] {
		if c != -1 {
			postorder(w, cs, c)
		}
	}
	print(w, root)
}

func print(w io.Writer, n int) {
	fmt.Fprintf(w, " %d", n)
}



Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define P (3)

int b64(char ch) {
    if('A'<=ch && ch<='Z') return ch-'A';
    if('a'<=ch && ch<='z') return ch-'a'+26;
    if('0'<=ch && ch<='9') return ch-'0'+52;
    return ch=='+' ? 62 : 63;
}

int w, h, p, f[1024][1024], m[128][128], tmp[128][128];
char tf[1000][200], tm[100][20];
typedef unsigned long long hash;
hash hori[1024][1024], hs[8];

int main() {
    for(;;) {
        scanf("%d%d%d", &w, &h, &p);
        if(w==0 && h==0 && p==0) return 0;
        rep(i, h) scanf(" %s", tf[i]);
        rep(i, p) scanf(" %s", tm[i]);
        memset(f, 0, sizeof(f));
        rep(i, h) for(int j=0; tf[i][j]; j++) {
            const int x = b64(tf[i][j]);
            rep(k, 6) if(x&(1<<k)) f[i][j*6+5-k] = 1;
        }
        memset(m, 0, sizeof(m));
        rep(i, p) for(int j=0; tm[i][j]; j++) {
            const int x = b64(tm[i][j]);
            rep(k, 6) if(x&(1<<k)) m[i][j*6+5-k] = 1;
        }
        vector<hash> hs;
        rep(d, 8) {
            memcpy(tmp, m, sizeof(m));
            rep(i, p) rep(j, p) m[p-1-j][i] = tmp[i][j];
            if(d==4) {
                memcpy(tmp, m, sizeof(m));
                rep(i, p) rep(j, p) m[i][p-1-j] = tmp[i][j];
            }
            hash k = 0;
            rep(i, p) rep(j, p) k = k*P+m[i][j];
            hs.push_back(k);
        }
        sort(hs.begin(), hs.end());
        hs.erase(unique(hs.begin(), hs.end()), hs.end());
        hash t = 1;
        rep(i, p) t *= P;
        rep(i, h) {
            hash k = 0;
            rep(j, w) {
                k = k*P+f[i][j];
                if(j>=p) k -= t*f[i][j-p];
                hori[i][j] = k;
            }
        }
        hash tt = 1;
        rep(i, p) tt *= t;
        int ans = 0;
        for(int i=p-1; i<w; i++) {
            hash k = 0;
            rep(j, h) {
                k = k*t+hori[j][i];
                if(j>=p) k -= tt*hori[j-p][i];
                if(j>=p-1 && binary_search(hs.begin(), hs.end(), k)) ans++;
            }
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 0
using System;

namespace AtCoder.Abcdef
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //Input integer
            long n = long.Parse(Console.ReadLine());
            var ans = n % 1000 == 0 ? 0 : 1000 - n % 1000;
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

#define ll long long
#define lop(b) for(int i = 0; i < b; i++)

const int N = 1e2 + 2, NN = 1e5+5;
ll n, w[N], v[N];
ll dp[N][NN], inf = 1 << 16;

ll f(int p, int W)
{
    if(p == n)
        return 0;

    if(dp[p][W] != -1) {
        return dp[p][W];
    }

    ll ans = f(p + 1, W);
    if(W >= w[p])
        ans = max(ans, f(p + 1, W - w[p]) + v[p]);

    return dp[p][W] = ans;
}

int main()
{
    int W;

    cin >> n >> W;

    lop(n) cin >> w[i] >> v[i];

    memset(dp, -1, sizeof dp);

    cout << f(0, W) << endl;

    return 0;
}


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

int maxtime(int x){
    return (x + 9) / 10 * 10;
}

int remtime(int x){
    return maxtime(x) - x;
}

int main(){
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    int sum = maxtime(A) + maxtime(B) + maxtime(C) + maxtime(D) + maxtime(E);
    sum -= max({remtime(A), remtime(B), remtime(C), remtime(D), remtime(E)});
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println(a-b>c ? 0: c-(a-b));

//		if (a-b > c) {
//			System.out.println(0);
//		} else {
//			System.out.println(c-(a-b));
//		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int N; cin>>N;
	map<int,int> a;
	for(int i=0;i<N;i++){
		int tmp; cin>>tmp;
		a[tmp]++;
	}
	int ans=0;
	for(auto mp : a){
		int tmp=mp.second-mp.first;
		tmp=(tmp>=0 ? tmp : mp.second);
		ans+=tmp;
	}
	cout<<ans<<endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  ll ans = 0;
  FOR(i,1,N+1){
    if(i%3!=0 && i%5!=0) ans += i;
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			long n = sc.nextLong();
			long k = sc.nextLong();
			
			long residual = n % k;
			
			long minus = k - residual;
			
			if ( residual < minus ) {
				System.out.println(residual);
			}
			else {
				System.out.println(minus);
			}
		}
	}

}

Measured memory_bytes: 22100
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c, d = LI()
    print(max(a * b, c * d))
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
#include <algorithm>
#include <array>
#include <iostream>
#include <set>
#include <string>
#include <vector>

#include <cassert>
using namespace std;

int n, a, b;

void Solve() {
    if ((abs(a - b) & 1) == 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }
}

bool Read() {
    if (!(cin >> n >> a >> b)) {
        return false;
    }
    return true;
}

int main() {
    // freopen("input.txt", "r", stdin);

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (Read()) {
        Solve();
    }

    return 0;
}


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

int main() {
  string s;
  long k;
  cin>>s>>k;
  if(k==1){
    cout<<s[0]<<endl;
    return 0;
  }
  if(k>s.size()){
  int i=0;
  while(i<s.size()){
    if(s[i]!='1'){
      cout<<s[i]<<endl;
      return 0;
    }
    i++;
  }
  cout<<s[s.size()-1]<<endl;
}
else{
  int i=0;
  while(i<k){
    if(s[i]!='1'){
      cout<<s[i]<<endl;
      return 0;
    }
    i++;
  }
  cout<<s[k-1]<<endl;
}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int X; cin >> X;
    int kyu;
    if (X>=400 && X<=599) kyu = 8;
    if (X>=600 && X<=799) kyu = 7;
    if (X>=800 && X<=999) kyu = 6;
    if (X>=1000 && X<=1199) kyu = 5;
    if (X>=1200 && X<=1399) kyu = 4;
    if (X>=1400 && X<=1599) kyu = 3;
    if (X>=1600 && X<=1799) kyu = 2;
    if (X>=1800 && X<=1999) kyu = 1;
    cout << kyu << endl;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
int main(){
  int i,n;
  int blood[]={0,0,0,0};
  char str[3];
  while (scanf("%d,%s",&n,str)!=EOF){
    if (strlen(str)==1){
      if (str[0]=='A'){
        blood[0]++;
      }else if (str[0]=='B'){
        blood[1]++;
      }else if (str[0]=='O'){
      blood[3]++;
      }
    }else{
        blood[2]++;
    }
  }
  for (i=0;i<4;i++){
    printf("%d\n",blood[i]);
  }
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
using namespace std;
int main(void){
    int x, y;
    cin >> x >> y;
    
    switch(x){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            x = 1;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            x = 4;
            break;
        default:
            break;
            
        
    }
        switch(y){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            y = 1;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            y = 4;
            break;
        default:
            break;
            
        
    }
    
    if(x == y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
S = input()
t = ["{:03d}".format(i) for i in range(0, 1000)]

c = 0
for i in t:
    a = 0
    b = 0
    if S.count(i[0]):
        a = S.index(i[0])
        if S[a + 1:].count(i[1]):
            b = S[a + 1:].index(i[1]) + a + 1
            if S[b + 1:].count(i[2]):
                c += 1

print(c)


Measured memory_bytes: 3064
n=int(input())
a=[0]*n
for i in range(0,n):
  a[i]=int(input())
temp=a[0]
count=1
while count<=n:
  if temp==2:
    print(count)
    break
  temp=a[temp-1]
  count=count+1
else:
  print(-1)

Measured memory_bytes: 6900
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int n; 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	cout<<(n+1)/2;
	return 0;
}


Measured memory_bytes: 256
// user:halahen
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
int i,j,k;
int n,a[maxn];
int l,r,mid,ans;
int read(){
	int tot=0,fh=1;
	char c=getchar();
	while ((c<'0')||(c>'9')){ if(c=='-') fh=-1; c=getchar(); }
	while ((c>='0')&&(c<='9')){ tot=tot*10+c-'0'; c=getchar(); }
	return tot*fh;
}
map <int,int> mp;
int check(int col){
	int i,j;
	mp.clear();
	for (i=2;i<=n;i++){
		if (a[i]<=a[i-1]){
			if (col==1) return 0;
			j=a[i-1]+1;
			while (-(mp.upper_bound(-j)->first)>a[i]){
				j=-(mp.upper_bound(-j)->first);
				mp.erase(-j);
			}
			if (mp[-a[i]]==0) mp[-a[i]]=2;
			else mp[-a[i]]++;
			j=a[i];
			while (mp[-j]>col){
				if (j==1) return 0;
				mp[-j]=mp[-j]-col;
				if (mp[-j+1]==0) mp[-j+1]=1;
				mp[-j+1]=mp[-j+1]+1;
				j--;
			}
		}
	}
	return 1;
}
int main(){
	n=read();
	for (i=1;i<=n;i++){
		a[i]=read();
	}
	l=1; r=n;
	while (l<=r){
		mid=(l+r)>>1;
		if (check(mid)==1){
			ans=mid; r=mid-1;
		}
		else l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/11/20 07:34:59
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,x; cin>>n>>x;
  if (n == 2) {
    if (x != 2) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
      cout << "1\n2\n3" << endl;
    }
  } else {
    if (x == 1 or x == 2*n-1) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
      if (x != 2) {
        int m = 1;
        for (int i = 1; i < n-1; i++) {
          if (x-2 <= m and m <= x+1)
            m = x+2;
          cout << m << endl;
          m++;
        }
        cout << x-2<<endl<<x<<endl<<x+1<<endl<<x-1<<endl;
        for (int i = n+3; i <= 2*n-1; i++) {
          if (x-2 <= m and m <= x+1)
            m = x+2;
          cout << m << endl;
          m++;
        }
      } else {
        int m = 1;
        for (int i = 1; i < n-1; i++) {
          if (x-1 <= m and m <= x+2)
            m = x+3;
          cout << m << endl;
          m++;
        }
        cout << x+2<<endl<<x<<endl<<x-1<<endl<<x+1<<endl;
        for (int i = n+3; i <= 2*n-1; i++) {
          if (x-1 <= m and m <= x+2)
            m = x+3;
          cout << m << endl;
          m++;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3652
import collections

n = int(input())
s = []

for _ in range(n):
	s.append(input())

count = collections.Counter(s)

c = count.most_common()

max_num = 0
ans = []
for string,num in c:
	if max_num <= num:
		max_num = num
		ans.append(string)
	else:
		break
ans.sort()
for i in ans:
	print(i)


Measured memory_bytes: 47636
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int card[52]={0},a,n;
  char c;
  cin >> n;
  for(int i=0; i<n; i++) {
      cin >> c >> a;
      if(c=='S') {
          card[a-1]=1;
      }
      else if(c=='H') {
          card[a-1+13]=1;
      }
      else if(c=='C') {
          card[a-1+26]=1;
      }
      else if(c=='D') {
          card[a-1+39]=1;
      }
  }
  for(int i=0; i<52; i++) {
      if(card[i]==0) {
          if(i<13) {
              cout << "S ";
          }
          else if(i<26) {
              cout << "H ";
          }
          else if(i<39) {
              cout << "C ";
          }
          else if(i<52) {
              cout << "D ";
          }
          cout << i%13+1 << endl;
      }
  }
}


Measured memory_bytes: 3080
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;


int main(){
    string S; cin>>S;
    set<char> R(ALL(S));
    if(R.size()>1){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    return 0;
}


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

char s[1111], t[1111];

int main(void)
{
	int i, j, ans = 1000;

	scanf("%s %s", s + 1, t + 1);

	int n = strlen(s + 1);
	int m = strlen(t + 1);

	for (i = 1; i <= n - m + 1; i++)
	{
		int p = 0;

		for (j = i; j <= i + m - 1; j++)
			if (s[j] != t[j - i + 1])
				p++;

		ans = min(ans, p);
	}

	printf("%d", ans);
	return 0;
}

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

using namespace std;

int main()
{
    int a, b;   cin >> a >> b;
    int c = a + b;

    if (c % 2 == 0)
        cout << c / 2 << endl;
    else 
        cout << (c / 2) + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a,b;
char s[20];
int pos = 1;
scanf("%d %d",&a,&b);
scanf("%s",s);

if(s[a] != '-'){ //itu [A] karena di index 1,+1 -1 = karena di soal index 1 di awal
	pos = 0;
}

for(int i = 0;s[i]!='\0';i++){ //\0 (selama dia tidak sampai ke null maka loop terus
	if(i != a){//jika karakter bukan di A maka cek(selain -)
		if(s[i]< '0' || s[i]> '9'){ //kalau bukan di rentang ini bye
		 pos = 0;
		 break; //karena false break aja dari loopnya
		}
    }	
}
	//kalau benar dan tidak false print yes
	(pos) ? printf("Yes\n") : printf("No\n");
	return 0;
}

Measured memory_bytes: 2044
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

vector <vector <int> > g;
vector <int> parent;
void bfs(int s,int n);


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt(),m=nxt();
    g.resize(n+1,vector <int>(0));
    for(int i=0;i<m;i++)
    {
        int x=nxt(),y=nxt();
        g[x].push_back(y);
        g[y].push_back(x);
    }

    parent.resize(n+1,-1);
    bfs(1,n);

    for(int i=1;i<=n;i++)
        if(!parent[i]==-1)
        {
            cout<<"No\n";
            return 0;
        }
    cout<<"Yes\n";
    for(int i=2;i<=n;i++)
        cout<<parent[i]<<endl;
    return 0;   
}

void bfs(int s,int n){
    vector <bool> visited(n+1,0);
    queue <int> q;
    visited[s]=1;
    q.push(s);
    parent[s]=0;
    while(q.size())
    {
        int x=q.front();
        q.pop();
        for(auto i:g[x])
        {
            if(!visited[i])
            {
                visited[i]=1;
                q.push(i);
                parent[i]=x;
            }
        }
    }
}




 
 


Measured memory_bytes: 10228
n=int(input())
a=list(map(int,input().split()))
ans1=0
ans2=0
inf=-10**18
if n%2:
    dp=[[inf]*3 for i in range(n)]
    dp[0][0]=a[0]
    dp[2][0]=dp[0][0]+a[2]
    for i in range(2,n):
        dp[i][0]=dp[i-2][0]+a[i]
        if i>=3:
            dp[i][1]=max(dp[i-3][0],dp[i-2][1])+a[i]
        else:
            dp[i][1]=dp[i-2][1]+a[i]
        if i>=4:
            dp[i][2]=max(dp[i-4][0],dp[i-3][1],dp[i-2][2])+a[i]
        elif i>=3:
            dp[i][2]=max(dp[i-3][1],dp[i-2][2])+a[i]
        else:
            dp[i][2]=dp[i-2][2]+a[i]
    ans=max(dp[n-3][0],dp[n-2][1],dp[n-1][2])
    # print(dp)
    dp=[[inf]*2 for i in range(n)]
    dp[1][0]=a[1]
    for i in range(3,n):
        dp[i][0]=dp[i-2][0]+a[i]
        dp[i][1]=max(dp[i-3][0],dp[i-2][1])+a[i]
    ans=max(ans,dp[-1][1],dp[-2][0])
    for i in range(2,n,2):
        ans1+=a[i]
    print(max(ans,ans1))
else:
    dp=[[inf]*2 for i in range(n)]
    dp[0][0]=a[0]
    for i in range(2,n):
        dp[i][0]=dp[i-2][0]+a[i]
        if i>2:
            dp[i][1]=max(dp[i-3][0],dp[i-2][1])+a[i]
        else:
            dp[i][1]=dp[i-2][1]+a[i]
    ans=max(dp[-1][1],dp[-2][0])
    for i in range(1,n,2):
        ans1+=a[i]
    print(max(ans1,ans))


Measured memory_bytes: 85612
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll H;
ll W;

int main(){

    cin >> H;
    cin >> W;
    ll ph[H];
    ll pw[W];
    string s[H][W];

    rep(hi,H){
        string tmp;
        cin >> tmp;
        rep(wi,W){
            s[hi][wi]=tmp.substr(wi,1);
        }
    }

    
    ll d[H][W]={};
    int rev[H][W]={};
    for( int hi = 0 ; hi <=0 ; hi++ ){
        for( int wi = 0 ; wi <=0 ; wi++ ){
            if(s[hi][wi]=="#"){
                rev[hi][wi]=1;
                d[hi][wi]=1;
            }
        }
        for( int wi = 1 ; wi <W ; wi++ ){
            if(s[hi][wi]=="#"){
                rev[hi][wi]=1;
                if(rev[hi][wi-1]==1){
                    d[hi][wi]=d[hi][wi-1];
                }else{
                    d[hi][wi]=d[hi][wi-1]+1;
                }
            }else{
                rev[hi][wi]=0;
                d[hi][wi]=d[hi][wi-1];
            }
            
        }
    }

    for( int hi = 1 ; hi <H ; hi++ ){
        for( int wi = 0 ; wi <=0 ; wi++ ){
            if(s[hi][wi]=="#"){
                rev[hi][wi]=1;
                if(rev[hi-1][wi]==1){
                    d[hi][wi]=d[hi-1][wi];
                }else{
                    d[hi][wi]=d[hi-1][wi]+1;
                }
            }else{
                rev[hi][wi]=0;
                d[hi][wi]=d[hi-1][wi];
            }
        }
    }

    for( int hi = 1 ; hi <H ; hi++ ){
        for( int wi = 1 ; wi <W ; wi++ ){
            int d_from_top  = d[hi-1][wi];
            int d_from_left = d[hi][wi-1];
            if(s[hi][wi]=="#"){
                rev[hi][wi]=1;
                if(rev[hi-1][wi]==0){
                    d_from_top++;
                }
                if(rev[hi][wi-1]==0){
                    d_from_left++;
                }
            }else{
                rev[hi][wi]=0;
            }
            d[hi][wi]=min(d_from_left,d_from_top);
        }
    }
    cout << d[H-1][W-1] << endl;

}

Measured memory_bytes: 896
#include<bits/stdc++.h>
    using namespace std;
    #define PAIN___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair < ll, ll >
    #define mp make_pair
    #define vec vector < ll >
    #define vecp vector < pii  >
    #define forl(i,q1,n,q2) for(ll i=q1;i<q2;i++)
    #define null NULL
    #define mm 100005
    #define sqr(i) i*i;
   /* string with spaces   getline(cin,s);*/
   /*
          integer to string              ll n=0;  ostringstream o1;  string s; o1<<n; s=o1.str();
    */



int main()
{
    ll t;
    t=1;
    while(t--)
    {
       ll n;
       cin>>n;
       ll a[n],b[n];
       forl(i,0,n,n)cin>>a[i];
       sort(a,a+n);
              double ans=a[0];
       forl(i,1,n,n)
       {

           ans=(a[i]+ans)/2;

       }
       cout<<ans<<endl;
    }
}


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

int main() {
    std::string S, T;
    std::cin >> S >> T;

    for (size_t i = 0; i < S.size(); ++i) {
        size_t k = i;
        bool ok = true;
        for (size_t j = 0; j < T.size(); ++j) {
            if (T[j] != S[k]) {
                ok = false;
                break;
            }

            ++k;
            if (k == T.size()) {
                k = 0;
            }
        }

        if (ok) {
            std::cout << "Yes\n";
            return 0;
        }
    }

    std::cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100
int push(int x);
int pop();
int isEmpty();
int isFULL();
int Stack[MAX]; 
int top=0;

int main(){
  int x,a,b;
  char s[100];
  initialize();

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop() + pop());

    } 
    else if ( s[0] == '-' ){
      b = pop();
      push(pop()-b);

    } 
    else if ( s[0] == '*' ){

      push(pop() * pop());

    }
    else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",Stack[top]);

  return 0;
}

int initialize()
{
  top = 0;
}

int pop()
{
  if(isEmpty==0){printf("error : The stack is empty!!\n");
    exit(1);
  }
  top--;
  return Stack[top+1];
}

int push(int x)
{
  if(isFULL==0){
printf("error : The stack is FULL!!\n");
    exit(1);
  }
  top++;
  Stack[top]=x;
}

int isEmpty()
{
  if(top==0)return 0;
  else return 1;
}

int isFULL()
{
  if(top >= MAX - 1)return 0;
  else return 1;
}

Measured memory_bytes: 548
n = int(input())
s = input()

ans = 0

for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue
    for j in range(10):
        b = s.find(str(j), a + 1)
        if b == -1:
            continue
        for k in range(10):
            c = s.find(str(k), b + 1)
            if c == -1:
                continue
            ans += 1
print(ans)

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

long long N;
long long K;
long long P;

int main() {
  cin >> N >> K;
  P=N+1;
  while (P>N){
    P=N;
    if (N>K){
      N=N%K;
    }else{
      N=K-N;
    }
  }
  cout << P << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a-b, a*b));
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <climits>
#include <utility>

using namespace std;

#define int long long
#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 all(a) begin(a),end(a)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

signed main()
{
	string s;cin>>s;
	if (s[2]==s[3] and s[5]==s[4])cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int adf = 1e6+5;
vector<int> p[adf];
priority_queue<int> q;
int main(){
    int a,b,c=0,i,n,m;
    cin>>n>>m;
    for(i = 0;i < n;i++){
        cin>>a>>b;
        p[a].push_back(b);
    }
    for(i = 0;i < adf;i++){
        sort(p[i].begin(),p[i].end());
    }
    for(i = 1;i <= m;i++){
        for(int j = 0;j < p[i].size();j++){
            q.push(p[i][j]);
            //cout<<q.top()<<endl;
        }
        //cout<<q.top()<<endl;
        if(!q.empty()){
            c = c+q.top();
            //cout<<c<<endl;
            q.pop();
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 26752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
//#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
string s[3];

signed main() {
	int i;
	int ans = 0;
	
	cin >> n >> s[0] >> s[1] >> s[2];
	for (i = 0; i < n; i++) {
		if (s[0][i] == s[1][i] && s[1][i] == s[2][i]) {
		}
		else if (s[0][i] == s[1][i] || s[1][i] == s[2][i] || s[2][i] == s[0][i]) {
			ans++;
		}
		else {
			ans += 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    vector<int> num{
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    };

    int K;
    cin >> K;

    cout << num.at(K-1) << endl;
}

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

int main(){
  string str;
  cin >> str;
  string rez;
  for(const auto ch : str){
    if(rez.empty() || rez.back() != ch) rez.push_back(ch); }
  cout << rez.size()-1;
  return 0; }


Measured memory_bytes: 512
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] h = new int [n];

        for(int i = 0; i < n; i++){
            h[i] = sc.nextInt();
        }

        int ans = 0;

        for(int i = 0; i < n; i++){
            while(h[i] != 0){
                for(int j = i; j < n && h[j] != 0; j++){
                    h[j]--;
                }
                ans++;
            }
        }
        
        System.out.println(ans);

    }
}


Measured memory_bytes: 23124
import itertools

lst = [None]*5
for i in range(5):
    s=input()
    lst[i]=s
k = int(input())

lst_sub=[]
lst_C = list(itertools.combinations(lst,2))
for j in range(len(lst_C)):
    sub = abs(int(lst_C[j][0])-int(lst_C[j][1]))
    lst_sub.append(sub)

if max(lst_sub)>k:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int a = 1;
    while(a * 2 <= n)
        a *= 2;
    cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

using namespace std;
int main() {
	string s, t;
	cin >> s >> t;

	int ans = 0;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != t[i]) ans++;
	}

	cout << ans << endl;
}

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

int main() 
{
    int x, y;
    cin >> x >> y;
    if (x>=13)
        cout << y;
    else if (x<6)
        cout << 0;
    else
        cout << y/2;
    return 0;
}

Measured memory_bytes: 256