akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

int main() {
    std::string s;
    std::cin >> s;
    const std::size_t size = s.size();

    std::string ret;
    ret.reserve(size);
    for (std::size_t i = 0; i < size; ++i) {
        if (i % 2 == 0) {
            ret += s[i];
        }
    }

    std::cout << ret << std::endl;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(void)
{
    char c;
    int ans = 0;
    cin >> c; if(c == '2') ans++;
    cin >> c; if(c == '2') ans++;
    cin >> c; if(c == '2') ans++;
    cin >> c; if(c == '2') ans++;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int tarou = 0;
  int hanako = 0;
  rep(i, n) {
    string t, h;
    cin >> t >> h;
    if (t > h) {
      tarou += 3;
    }
    else if (t < h) {
      hanako += 3;
    }
    else {
      tarou++;
      hanako++;
    }
  }
  cout << tarou << " " << hanako << endl;
}


Measured memory_bytes: 3128
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    char c,k;
    int ans=0;
	scanf("%c",&c);
    printf("%c",c);
    while(scanf("%c",&c)!=-1){
    	if(c==' '||c=='\n')break;
    	ans++;
    	k=c;
	}
	printf("%d%c",ans-1,k);
    return 0;
}

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

void solve(long long S, long long W) {
    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long S;
    scanf("%lld", &S);
    long long W;
    scanf("%lld", &W);
    solve(S, W);
    return 0;
}


Measured memory_bytes: 3724
#include<atcoder/all>
using namespace atcoder;

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

using MLL = static_modint<998244353>;

const int FZ = 200000;
MLL F[FZ + 1];
MLL I[FZ + 1];
MLL iF[FZ + 1];
MLL G[FZ + 1];

void init() {
    F[0] = I[1] = iF[0] = 1;
    for (int i = 1; i <= FZ; i++) F[i] = F[i - 1] * i;
    for (int i = 2; i <= FZ; i++) I[i] = MLL(i).inv();
    for (int i = 1; i <= FZ; i++) iF[i] = iF[i - 1] * I[i];
    G[0] = 1;
    for (int i = 1; i <= FZ; i++) G[i] = G[i - 1] * (i * 2 - 1);
}
MLL C(int n, int r) { return F[n] * iF[r] * iF[n - r]; }

const int xH = 100001;

int N;
int H[xH] = {};
vector<MLL> X[xH];

int main() {
    cin >> N; N *= 2;
    rep(i, N) { int h; cin >> h; H[h - 1]++; }

    init();

    rep(i, xH) {
        X[i].push_back(1);
        rep(j, H[i] / 2) {
            MLL tmp = X[i].back();
            tmp *= C(H[i] - 2 * j, 2) * I[j + 1];
            X[i].push_back(tmp);
        }
    }

    priority_queue<pair<int, int>> Q;
    rep(i, xH) Q.push({ -int(X[i].size()),i });
    while (Q.size() != 1) {
        auto a = Q.top().second; Q.pop();
        auto b = Q.top().second; Q.pop();
        X[a] = convolution(X[a], X[b]);
        Q.push({ -int(X[a].size()),a });
    }

    auto a = Q.top().second;
    MLL ans = 0;
    rep(i, X[a].size()) {
        X[a][i] *= G[N / 2 - i];
        if (i % 2 == 0) ans += X[a][i];
        else ans -= X[a][i];
    }

    cout << ans.val() << endl;

    return 0;
}

Measured memory_bytes: 16960
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define D(x) cerr << #x << " = " << (x) << '\n'
using ll = long long;

const int mod = 1e9 + 7;

void add_self(ll &x, ll y) {
	x += y;
	if(x >= mod) x -= mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	vector<vector<ll>> a(n, vector<ll>(n));
	vector<ll> dp(1 << n);
	for(int i = 0; i < n; ++ i)
		for(int j = 0; j < n; ++ j) cin >> a[i][j];
	dp[0] = 1;
	for(int mask = 1; mask < (1 << n); ++ mask) {
		int idx = __builtin_popcount(mask) - 1;
		for(int i = 0; i < n; ++ i) {
			if(!((mask >> i) & 1) || !a[idx][i]) continue;
			add_self(dp[mask], dp[mask - (1 << i)]);
		}
	}
	cout << dp[(1 << n) - 1] << '\n';
}


Measured memory_bytes: 16640
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	while(cin >> n && n){
		vector<int> data(n+1);
		vector<int> temp;
		for(int i=0;i<=n;i++){
			cin >> data[i];
		}
		for(int i=0;i<=n;i++){
			temp = data;
			temp.erase(temp.begin()+i);
			int s = temp[1] - temp[0];
			bool flg=true;
			for(int j=1;j<n;j++){
				if(temp[j]-temp[j-1] != s){
					flg = false;
					break;
				}
			}
			if(flg){
				cout << data[i] << endl;
				break;
			}
		}
	}
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b < c + d){
        cout << "Right" << endl;
    }else if (a + b == c + d){
        cout << "Balanced" << endl;
    }else{
        cout << "Left" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int X, Y, Z;
	long K;
	List<Long> A, B, C;
	List<Long> values;
	static long LIMIT = 3000;
	Comparator<Long> comp = new Comparator<Long>() {
		@Override
		public int compare(Long o1, Long o2) {
			if (o1 < o2) {
				return 1;
			} else if (o1 > o2) {
				return -1;
			} else {
				return 0;
			}
		}
	};

	Main() throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		this.X = Integer.parseInt(tokens[0]);
		this.Y = Integer.parseInt(tokens[1]);
		this.Z = Integer.parseInt(tokens[2]);
		this.K = Long.parseLong(tokens[3]);
		tokens = in.readLine().split(" ");
		this.A = new ArrayList<>(this.X);
		for (int i = 0; i < X; ++i) {
			this.A.add(Long.parseLong(tokens[i]));
		}
		tokens = in.readLine().split(" ");
		this.B = new ArrayList<>(this.Y);
		for (int i = 0; i < Y; ++i) {
			this.B.add(Long.parseLong(tokens[i]));
		}
		tokens = in.readLine().split(" ");
		this.C = new ArrayList<>(this.Z);
		for (int i = 0; i < Z; ++i) {
			this.C.add(Long.parseLong(tokens[i]));
		}
		in.close();
		Collections.sort(this.A, this.comp);
		Collections.sort(this.B, this.comp);
		Collections.sort(this.C, this.comp);
		this.calc();
	}

	void calc() {
		List<Long> subList = new ArrayList<>();
		for (int x = 0; x < X; ++x) {
			for (int y = 0; y < Y; ++y) {
				subList.add(this.A.get(x) + this.B.get(y));
			}
		}
		Collections.sort(subList, this.comp);
		subList = subList.subList(0, Math.min((int) K, subList.size()));

		this.values = new ArrayList<>();
		for (Long sub : subList) {
			for (int z = 0; z < Z; ++z) {
				this.values.add(sub + this.C.get(z));
			}
		}

		Collections.sort(this.values, this.comp);
	}

	void show() {
		for (int i = 0; i < Math.min(this.K, this.values.size()); ++i) {
			System.out.println(this.values.get(i));
		}
	}

	public static void main(String[] args) throws IOException {
		Main ins = new Main();
		ins.show();

	}

}

Measured memory_bytes: 188864
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<int,int>
ll n, k,a,b,c,i,j,x,y,z=0;

int main() {
	cin >> n;
	cin >> a;
	a--;
	rep(i, n - 1){
		cin >> b;
	if (a == b)a = b;
	if (a < b)a = b - 1;
	if (a > b) {
		z = 1;
		cout << "No";
		break;
	}
}
	if(z==0)cout <<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int n,i;
  double x1,x2,r1,y1,y2,r2;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&r1,&x2,&y2,&r2);
    if(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))+r2<r1)printf("2\n");
    else if(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))+r1<r2)printf("-2\n");
    else if(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))<=r2+r1)printf("1\n");
    else printf("0\n");
  }
  return 0;
}

Measured memory_bytes: 620
#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <bitset>
#include <fstream>
#include <tr1/unordered_map>
#include <assert.h>

#define x first
#define y second
#define y0 Y0
#define y1 Y1
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int MAXN = 50;
const int MAXM = MAXN * MAXN * MAXN;

int N, X, D;
int W[MAXN + 5], V[MAXN + 5];
int e, Begin[MAXN + 5], To[MAXN + 5], Next[MAXN + 5];

inline void add_edge (int x, int y) { To[++e] = y; Next[e] = Begin[x]; Begin[x] = e; }

inline void dfs (int x)
{
	V[x] = 1;
	for (int i = Begin[x]; i; i = Next[i])
	{
		int y = To[i];
		dfs (y);
		V[x] += V[y];
		W[x] = min (X + 1, W[x] + W[y]);
	}
}

int F[MAXM + 5];

inline int cmp (int a, int b) { return (LL) V[a] * W[b] > (LL) V[b] * W[a]; }

inline void Solve ()
{
	dfs (1);

//	for (int i = 1; i <= N; ++i) cout << W[i] << ' ' << V[i] << endl;

	memset (F, 0x3f, sizeof F);

	F[0] = 0;
	for (int i = 1; i <= N; ++i)
	{
		int tmp = min (D, MAXN), k = 1;

		while (tmp)
		{
			for (int j = MAXM; j - V[i] * k >= 0; --j)
				Chkmin (F[j], (int) min ((LL) X + 1, (LL) F[j - V[i] * k] + (LL) W[i] * k));
			tmp -= k;
			k = min (k * 2, tmp);
		}
	}

	static int Id[MAXN + 5];
	for (int i = 1; i <= N; ++i) Id[i] = i;
	sort (Id + 1, Id + N + 1, cmp);

	LL ans = 0;
	for (int w = 0; w <= MAXM; ++w) if (F[w] <= X)
	{
		int res = X - F[w];
		LL sum = w;
		for (int i = 1; i <= N; ++i)
		{
			int x = Id[i], t = min (res / W[x], max (0, D - MAXN));
			if (x == 1) t = res / W[x];
			sum += (LL) t * V[x], res -= (LL) t * W[x];
		}
		Chkmax (ans, sum);
	}
	cout << ans << endl;
}

inline void Input ()
{
	N = read<int>(), X = read<int>(), D = read<int>();
	for (int i = 1; i <= N; ++i) 
	{
		W[i] = read<int>();
		if (i > 1)
		{
			int f = read<int>();
			add_edge (f, i);
		}
	}
}

int main ()
{

#ifdef hk_cnyali
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}



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

const int INF=1001001001;

vector<int>to[100010];

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int u,v; cin>>u>>v;
        u--; v--;
        to[u].push_back(v);
    }
    int s,t;
    cin>>s>>t;
    s--; t--;
    vector<vector<int>>dist(n,vector<int>(3,INF));
    queue<P>q;
    q.push(P(s,0));
    dist[s][0]=0;
    while(!q.empty()){
        int v=q.front().first;
        int x1=q.front().second;
        int x2=(x1+1)%3;
        q.pop();
        for(int u:to[v]){
            if(dist[u][x2]!=INF)continue;
            dist[u][x2]=dist[v][x1]+1;
            q.push(P(u,x2));
        }
    }
    if(dist[t][0]==INF)cout<<-1<<endl;
    else cout<<dist[t][0]/3<<endl;
}

Measured memory_bytes: 14344
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()
ans = 0
cnt = 1
for i in range(1, N):
    if A[i] == A[i-1]:
        cnt += 1
    else:
        ans += cnt%2
        cnt = 1
ans += cnt%2
print(ans)


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n,cnt=0;
    cin>>n;
    queue<pair<string,ll>> q;
    rep(i,n){
        string s;
        ll t;
        cin>>s>>t;
        q.push({s,t});
    }
    string x;
    cin>>x;
    while(!q.empty()){
        pair<string,ll> a=q.front();
        if(a.first!=x) q.pop();
        else{
            q.pop();
            break;
        }
    }
    while(!q.empty()){
        pair<string,ll> p=q.front();
        cnt+=p.second;
        q.pop();
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3640
build=[[[0 for k in range(10)] for i in range(3)]for j in range(4)]

n=int(input())

for i in range(n):
    [b,f,r,v]=map(int,input().split())
    build[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' %d' % (build[i][j][k]), end='')
        print()
    if i < 3:
        print('####################')


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

void output_remain(char mark, int *card)
{
	for(int i=0; i<13; i++){
        if(card[i] == 0)
		    cout << mark << " " << i+1 << endl;
	}
}

int main()
{
	int total;
	char mark;
	int num;
	int sp[13]={0};
	int di[13]={0};
	int cr[13]={0};
	int ha[13]={0};

	cin >> total;

    for(int i=0; i<total; i++){
	    cin >> mark >> num;
		num--;
		switch(mark){
		case 'S':
            sp[num] = 1;
			break;
		case 'D':
			di[num] = 1;
			break;
		case 'C':
			cr[num] = 1;
			break;
		case 'H':
			ha[num] = 1;
			break;
		}
	}

	output_remain('S', sp);
	output_remain('H', ha);
	output_remain('C', cr);
	output_remain('D', di);
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll ZERO = 0;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N,R;
    cin >> N >> R;
    cout << 100 * max(0,10 - N) + R << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int c = (n-1)*(n-2)/2;
    if(k > c){
        cout << -1 << endl;
        return 0;
    }
    vector<P> ans;
    for(int i = 2; i <= n; ++i) ans.emplace_back(1, i);
    for(int i = 2; i <= n; ++i){
        for(int j = i+1; j <= n; ++j){
            if(c <= k) break;
            ans.emplace_back(i, j);
            --c;
        }
        if(c <= k) break;
    }
    cout << ans.size() << endl;
    for(auto p : ans) cout << p.first << " " << p.second << endl;
    return 0;
}


Measured memory_bytes: 3724
#include<cstdio>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


struct vu_t
{
	int n;
	int p;
	vi c;
	vu_t(int idx=-1) : n(1),p(idx) {}
};


void vu_cat(vector<vu_t>&vu, int a, int b)
{
	int ap=vu[a].p;
	int bp=vu[b].p;

	if(ap==bp) return;
	if(vu[ap].n<vu[bp].n) swap(ap, bp);
	vu[ap].n+=vu[bp].n;
	vu[ap].c.push_back(bp);
	for(auto mb:vu[bp].c)
	{
		vu[mb].p=ap;
		vu[ap].c.push_back(mb);
	}
	vu[bp].n=0;
	vu[bp].p=ap;
	vu[bp].c.clear();
}


ll vu_calc(vpii&xy, vector<vu_t>&vu, int idx)
{
	set<int> sx, sy;
	int p=vu[idx].p;

	sx.insert(xy[p].first);
	sy.insert(xy[p].second);
	for(auto&mc:vu[p].c)
	{
		sx.insert(xy[mc].first);
		sy.insert(xy[mc].second);
	}
	return sx.size()*sy.size()-vu[p].n;
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vpii xy(n);
		vvi x(100000+1);
		vvi y(100000+1);
		vector<vu_t> vu(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d%d", &xy[i].first, &xy[i].second);
			x[xy[i].first].push_back(i);
			y[xy[i].second].push_back(i);
			vu[i].p=i;
		}
		for(int i=1;i<=100000;i++)
		{
			for(int j=x[i].size()-1;j>0;j--)
			{
				vu_cat(vu, x[i][0], x[i][j]);
			}
			for(int j=y[i].size()-1;j>0;j--)
			{
				vu_cat(vu, y[i][0], y[i][j]);
			}
		}
		ll ans=0;
		for(int i=0;i<n;i++)
		{
			if(vu[i].n>0)
			{
//				printf("vu[%d].n=%d %d\n", i, vu[i].n, vu[i].c.size());
				ans+=vu_calc(xy, vu, i);
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 20340
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int K = sc.nextInt();
   int S = sc.nextInt();
   int z;
   int ans =0;
   for(int x =0;x<=K;x++)
   {
     for(int y=0;y<=K;y++)
     {
       z=S-x-y;
       if(z<=K&&z>=0)
       {
         ans++;
       }
     }
   }
   System.out.println(ans);
 }
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0;i<H;i++){
    cin >> S[i];
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j] == '.'){
        int cnt = 0;
        for(int k=i-1;k<=i+1;k++){
          for(int l=j-1;l<=j+1;l++){
            if(0 <= k && k < H && 0 <= l && l <= W && S[k][l] == '#'){
              cnt++;
            }
          }
        }
        S[i][j] = (char)(cnt+'0');
      }
    }
    cout << S[i] << endl;
  }
}

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

using namespace std;

int main() {
  int i, j, k, a, b, c, L, f;
  vector<int> v, v2;
     
  while(cin >> c >> L, c||L) {
    for(i = 0; 1; i++) {

      v2.push_back(c);
      
      while(c >= 1) {
	v.push_back(c % 10);
	c /= 10;
      }
      
      while(v.size() < L) {
	v.push_back(0);
      }
      
      sort(v.begin(), v.begin() + L);
      
      a = b = 0;
      for(k = 0; k < L; k++) {
	a += v[k] * pow(10, k);
	b += v[L - k - 1] * pow(10, k);
      }
      
      c = a - b;
      f = 0;
    
      for(j = 0; j < v2.size(); j++) {
	if(c == v2[j]) {
	  f++;
	  break;
	}
      }
      
      if(f) {
	cout << j  << ' ' << c << ' ' << i + 1 - j << endl;
	break;
      }
      v.clear();
      
    }
    v.clear();
    v2.clear();
    
  } 
  return 0;
}

      

Measured memory_bytes: 1264
import fractions

A, B, C, D = map(int, input().split())

lcm = C * D // fractions.gcd(C, D)

multiple_C_under_A = (A - 1) // C
multiple_D_under_A = (A - 1) // D
multiple_CD_under_A = (A - 1) // lcm

multiple_C_under_B = B // C
multiple_D_under_B = B // D
multiple_CD_under_B = B // lcm

total = B - A + 1

print(total - (multiple_C_under_B - multiple_C_under_A + multiple_D_under_B - multiple_D_under_A - (
            multiple_CD_under_B - multiple_CD_under_A)))


Measured memory_bytes: 5304
N, = map(int, input().split())
X = list(map(int, input().split()))

f=t=0
for x in X:
    if x % 4==0:
        f += 1
    elif x % 2==0:
        t += 1
if 2*f+1 >= N or 2*f+t>=N:
    print("Yes")
else:
    print("No")


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

using namespace std;

typedef long long ll;

int main() {
    int w, h; cin >> w >> h;
    priority_queue<ll, vector<ll>, greater<ll>> p, q;
    for (int i = 0; i < w; ++i) {
        ll pi; cin >> pi;
        p.push(pi);
    }
    for (int i = 0; i < h; ++i) {
        ll qi; cin >> qi;
        q.push(qi);
    }
    ll ans = 0;
    for (int c = 0; c < h + w; ++c) {
        if (q.empty() || (!p.empty() && p.top() < q.top())) {
            ans += p.top() * (q.size() + 1);
            p.pop();
        } else {
            ans += q.top() * (p.size() + 1);
            q.pop();
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2548
from collections import deque
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  ans = deque([])
  for i in range(N):
    if i%2==0:
      ans.append(A[i])
    else:
      ans.appendleft(A[i])
  ans = list(ans)
  if N%2==1:
    ans = ans[::-1]
  return ans
print(*solve())

Measured memory_bytes: 32404
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int countr = 0;
        String s = sc.next();
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'R' ) {
                countr++;
            }
        }
        
        if (countr * 2 > n) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }

}





Measured memory_bytes: 22228
#include <bits/stdc++.h>
typedef   long long int ll;
using namespace std;
int main ()
{
     ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    ll n,r,k,count=0;cin>>n>>r;
    k=n;
    while (k>0) {
        k=k/r;
        count++;
    }
    cout<<count<<endl;
}





Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	public static void main(String[] args) {
		String[] S = new String[2];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder ans = new StringBuilder();

		try {
			int n = Integer.parseInt(br.readLine());

			Deque<String> list = new ArrayDeque<String>();

			for (int i = 0; i < n; i++) {
				S = br.readLine().split(" ");
				if ("insert".equals(S[0]))
					list.addFirst(S[1]);
				if ("delete".equals(S[0]))
					list.remove(S[1]);
				if ("deleteFirst".equals(S[0]))
					list.removeFirst();
				if ("deleteLast".equals(S[0]))
					list.removeLast();
			}

			if (!list.isEmpty()) {
				ans.append(list.getFirst());
				list.removeFirst();
			}
			while (!list.isEmpty()) {
				ans.append(" ").append(list.getFirst());
				list.removeFirst();
			}

			System.out.println(ans.toString());

			br.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}



Measured memory_bytes: 229088
#include <vector>
#include <iostream>

#ifdef _XCODE_DEBUG
    #include <fstream>
#endif

#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
 
void prime_factorize(int n, std::vector<std::pair<int, int>>& res) {
    for (int p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(std::make_pair(p, num));
    }
    if (n != 1) res.push_back(std::make_pair(n, 1));
}
 
const int MAX = 210000;
 
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
 
int main(){
    #ifdef _XCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N,M;
    COMinit();
    std::cin>>N>>M;
    std::vector<std::pair<int, int>> vec;
    prime_factorize(M, vec);
    ll res=1;
    for(auto pa : vec){
        int num = pa.second;
        ll tmp=COM(num+N-1,N-1);
        res=(res*tmp)%MOD;
    }
    std::cout<<res<<"\n";
}

Measured memory_bytes: 5752
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

int main() {
	std::string s;
	std::cin >> s;

	int ans = 1e9;
	for (char c = 'a'; c <= 'z'; c++) {
		int prev = -1;
		int len = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == c) {
				len = std::max(len, i - prev - 1);
				prev = i;
			}
		}
		if (prev != -1) {
			len = std::max<int>(len, s.size() - prev - 1);
			ans = std::min(ans, len);
		}
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PRINT(str) printf(#str "\n")
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define v_pri(val) printf("%d\n",val);
#define s_pri(str) printf("%s\n",str);
#define v_sca(x) scanf("%d",&x);
#define s_sca(x) scanf("%s",x);

typedef long long int ll;


/*
puts("コメント");
//*/




int main(void) {
	
	char S[4];
	s_sca(S);

	if (strlen(S)==2) {
		s_pri(S);
	}
	else {
		printf("%c%c%c\n", S[2], S[1], S[0]);
	}

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    if(a.equals("SUN")){
      System.out.println(7);
    }
    if(a.equals("MON")){
      System.out.println(6);
    }
    if(a.equals("TUE")){
      System.out.println(5);
    }
    if(a.equals("WED")){
      System.out.println(4);
    }
    if(a.equals("THU")){
      System.out.println(3);
    }
    if(a.equals("FRI")){
      System.out.println(2);
    }
    if(a.equals("SAT")){
      System.out.println(1);
    }
  }
}

Measured memory_bytes: 20948
import java.io.FileNotFoundException;
import java.util.Scanner;

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

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int L = sc.nextInt();


		int sum = N*(2*L+N-1)/2;

		if(L+N-1<0) {
			System.out.println(sum-(L+N-1));
		} else {
			if(L>0) {
				System.out.println(sum-L);
			} else {
				System.out.println(sum);
			}
		}
	}
}

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

ll gcd(ll a, ll b) {
    if(a % b == 0) return b;
    else return(gcd(b, a % b));
}

int main()
{
    ll n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll l = n * m / gcd(n, m);
    ll x = l / gcd(n, m);
    bool ok = true;
    for(ll i = 0; i * x + 1 <= l; i++) {
        ll snum = i * x * n / l;
        ll tnum = i * x * m / l;
        if(s[snum] != t[tnum]) ok = false;
    }
    if(ok) cout << l << endl;
    else cout << -1 << endl;
    return 0;
}


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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)

int main(){
	lli n;
	cin>>n;
	cout<<1000-((n%1000)==0 ? 1000:(n%1000));

}

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

int main(){

  int n,m;
  cin>>n>>m;
  int a[100][100];
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) cin>>a[i][j];
  
  int b[100];
  for(int i=0;i<m;i++) cin>>b[i];

  int c[100] = {};
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) c[i] += a[i][j] * b[j];
  
  for(int i=0;i<n;i++) cout<<c[i]<<endl;
  
  return 0;
}



Measured memory_bytes: 3156
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
b = [list(map(int,input().split())) for _ in range(m)]
for ax,ay in a:
    mh = []
    for i,[bx,by] in enumerate(b):
        mh.append([abs(ax-bx) + abs(ay-by), i+1])   
    mh.sort()
    print(mh[0][1])

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    counter = [0] * n
    for a in map(int,input().split()):
        counter[a - 1] += 1
    print(*counter, sep='\n')
resolve()

Measured memory_bytes: 94848
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

vector<int> A;
int main() {
    A.resize(3); for (int i = 0; i< 3; ++i ) cin >> A[i];
    sort(A.begin(), A.end());
    cout << A.back() - A[0] << endl;
}





























Measured memory_bytes: 256
using System;
namespace ITP1_1_C {
	class Program {
		static void Main(string[] args) {
			string[] s = Console.ReadLine().Split();
			int a = int.Parse(s[0]), b = int.Parse(s[1]);
			Console.WriteLine((a * b) + " " + (2 * a + 2 * b));
        }
    }
}

Measured memory_bytes: 9036
#include <iostream>
#include <cmath>
using namespace std;
int gcd(int a, int b) {
  if (a==b or a==0 or b==0) return max(a,b);
  else if (a>b) {
    a = a%b;
  } else if (b>a) {
    b = b%a;
  }
  return gcd(a,b);
}
int main() {
  int a,b;
  cin >> a >> b;
  cout << gcd(a,b) << endl;
}


Measured memory_bytes: 3068
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
def _search(i, j):
    flag = True
    for k in range(M):
        for l in range(M):
            flag &= A[i+k][j+l] == B[k][l]
            if not flag:
                return flag
    return flag

def search():
    for i in range(N-M+1):
        for j in range(N-M+1):
            if _search(i, j):
                return 'Yes'
    return 'No'
print(search())



Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_H 21
#define MAX_W 21
#define INF   1000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll H, W;
char maze[MAX_H][MAX_W];
ll d[MAX_H][MAX_W];

ll bfs(ll si, ll sj, ll gi, ll gj){

  queue<P> q;

  for(ll i = 0; i < MAX_H; i++) fill(d[i], d[i] + MAX_W, INF);

  ll di[4] = {0, 1,  0, -1};  
  ll dj[4] = {1, 0, -1, 0};
  
  q.push( P(si, sj) );
  d[si][sj] = 0;
  
  while (q.size() != 0) {
    P p = q.front(); q.pop();
    if (p.first == gi && p.second == gj) break;
    
    for (ll k = 0; k < 4; k++){
      ll ni = p.first + di[k];
      ll nj = p.second + dj[k];
      
      if ( 0 <= ni && ni < H && 0 <= nj && nj < W && maze[ni][nj] != '#' && d[ni][nj] == INF ) {
        q.push( P(ni, nj) );
        d[ni][nj] = d[p.first][p.second] + 1;
      }
    }
  }

  return d[gi][gj];
}

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

    cin >> H >> W;

    for(ll i = 0; i < H; i++) {
      for(ll j = 0; j < W; j++) {
	cin >> maze[i][j];
      }
    }
    

    ll ans = 0;
    for(ll si = 0; si < H; si++)
      for(ll sj = 0; sj < W; sj++)
	for(ll gi = 0; gi < H; gi++)
	  for(ll gj = 0; gj < W; gj++) {
	    if (si == gi && sj == gj ) continue;
	    if (maze[si][sj] == '#' || maze[gi][gj] == '#') continue;
	    ans = max(ans, bfs(si, sj, gi, gj));
	  }
    
    cout << ans << endl;
    
    return 0;
}




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

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

	int n;
	cin >> n;

	vector<int> S( n );
	for( auto& v: S ) { cin >> v; }

	int q;
	cin >> q;

	int result = 0;

	for( int i = 0; i < q; ++i ) {
		int T;
		cin >> T;

		int l = 0;
		int r = n;

		while( l < r ) {
			int m = l + (r-l) / 2;
			int x = S.at( m );

			if( T < x ) {
				r = m;
			}
			else if( T > x ) {
				l = m+1;
			}
			else {
				result += 1;
				break;
			}
		}
	}

	cout << result << endl;
}



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

struct Main {
  map<string, vector<string> > m;
  set<string> num, vis;

  int rec(const string &s) {
    vis.insert(s);
    if(!m.count(s)) return 1;
    int res = 0;
    for(int i = 0; i < m[s].size(); ++i) {
      if(vis.count(m[s][i])) continue;
      res += rec(m[s][i]);
    }
    return res;
  }

  Main() {
    int n; cin >> n;
    if(n == 0) exit(0);
    string first;
    for(int i = 0; i < n; ++i) {
      string s; cin >> s;
      replace(s.begin(), s.end(), ':', ' ');
      replace(s.begin(), s.end(), ',', ' ');
      replace(s.begin(), s.end(), '.', ' ');
      stringstream ss(s);
      string group;
      ss >> group;
      if(first.empty()) first = group;
      string name;
      while(ss >> name) {
        m[group].push_back(name);
      }
    }
    cout << rec(first) << endl;
  }
};

int main() {
  while(delete new Main(), 1);
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    int n;
    cin >> n;
    map<int,int> e;
    map<int,int> o;
    int t;
    for(int i = 0; i < n; i++) {
        cin >> t;
        if(i%2==0) e[t]++;
        else       o[t]++;
    }
    vector<pair<int,int>> ape;
    vector<pair<int,int>> apo;
    pair<int,int> tmp;
    for(auto itr = e.begin(); itr != e.end(); itr++) {
        tmp.first=itr->second;
        tmp.second=itr->first;
        ape.emplace_back(tmp);
    }
    for(auto itr = o.begin(); itr != o.end(); itr++) {
        tmp.first=itr->second;
        tmp.second=itr->first;
        apo.emplace_back(tmp);
    }
    sort(ape.rbegin(),ape.rend());
    sort(apo.rbegin(),apo.rend());
    int ans;

    if(ape[0].second!=apo[0].second) ans=n-apo[0].first-ape[0].first;
    else{
        if(ape[0].first+apo[1].first > apo[0].first+ape[1].first){
            ans=n-ape[0].first-apo[1].first;
        }
        else{
            ans=n-apo[0].first-ape[1].first;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
#define lld long long
int ispal(string s){
	int n=s.length();
	int st=0;
	int en=n-1;
	while(st<en){
		if(s[st]!=s[en])return 0;
		st++,en--;
	}
	return 1;
}
int main()
{
   int l; cin>>l;
    double res=(l*1.0/3);
   res=res*res*res;
   printf("%.10lf", res);
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc166/tasks/abc166_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  map<char, ll> ct;
  cin >> N >> ct['A'] >> ct['B'] >> ct['C'];

  V<string> ops(N);

  rep(i, N) cin >> ops[i];

  V<char> res(0);

  auto move = [&](char dest, char src) {
    ct[dest] += 1;
    ct[src] -= 1;
    res.push_back(dest);
  };

  auto handle = [&](char x, char y, ll index) {
    if (ct[x] == 0 && ct[y] == 0) drop("No");

    if (ct[x] < ct[y]) {
      move(x, y);
      return;
    }

    if (ct[x] > ct[y] || index == N - 1) {
      move(y, x);
      return;
    }

    if (ops[index + 1].find(x) != string::npos) {
      move(x, y);
    } else {
      move(y, x);
    }
  };

  rep(i, N) {
    string o = ops[i];
    handle(o[0], o[1], i);
  }

  cout << "Yes"
       << "\n";

  rep(i, N) cout << res[i] << "\n";
}


Measured memory_bytes: 6696
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int sum = 0;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		sum += v[i];
	}
	sum /= n;
	int ans = 0, ans1 = 0;
	for (int i = 0; i < n; i++) {
		ans += (v[i] - sum) * (v[i] - sum);
		ans1 += (v[i] - sum - 1) * (v[i] - sum - 1);
	}
	cout << min(ans, ans1) << "\n";
	return 0;
}

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

int main() {
  ll a, b, k; cin >> a >> b >> k;

  if(k > a+b) cout << "0 0" << endl;
  else if(k > a) cout << "0 " << b-k+a << endl;
  else cout << a-k << " " << b << endl;
}


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

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){
    if(a>b) {
        a = b;
        return true;
    }
    return false;

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

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 *
 * */

int main() {
    int NUM[5];
    rep(i,5){
        cin >> NUM[i];
    }

    int minIndex;
    int min = 10;
    rep(i,5){
        float f = NUM[i]%10;
        if(f == 0) continue;
        if(chmin(min, NUM[i]%10)){
            minIndex = i;
        }
    }

    int res=0 ;
    rep(i,5) {
        if (i != minIndex) {
            double tmp = (double) NUM[i] / 10;
            int tmpInt = (int) ceil(tmp);
            NUM[i] = tmpInt * 10;
        }
        res += NUM[i];
    }



    cout << res << endl;
}

Measured memory_bytes: 256
import functools


@functools.lru_cache(maxsize=None)
def rec(i):
    if i <= 0:
        return i == 0
    return rec(i-1) + rec(i-2) + rec(i-3)

while True:
    N = int(input())
    if not N:
        break
    print(rec(N)//3650+1)

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


Measured memory_bytes: 256
# util functions
def gcd(arr) # arr: Array of non-negative integers
  if arr.size < 2
    raise "array (#{arr}) size is less than 2."
  end
  
  def gcd_two(a, b) # assume b <= a
    return a if b % a == 0
    return gcd_two(b % a, a)
  end

  g = arr[0]
  for i in 1..arr.size - 1 do
    g = gcd_two([g, arr[i]].min, [g, arr[i]].max)
  end
  return g
end

def lcm(arr)
  g = gcd(arr)
  arr.map! do |e_i| e_i / g end
  mul = 1
  arr.each do |f_i|
    mul *= f_i
  end
  return mul*g
end

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

aa = inputs[0][0]
bb = inputs[0][1]
cc = inputs[0][2]
dd = inputs[0][3]
ll = lcm([cc, dd])

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p aa
  p bb
  p cc
  p dd
  p ll
end

pd "---"

nU = bb - aa + 1
pd nU
nC = bb/cc - aa/cc
nC += 1 if aa % cc == 0
pd nC
nD = bb/dd - aa/dd
nD += 1 if aa % dd == 0
pd nD
nCandD = bb/ll - aa/ll
nCandD += 1 if aa % ll == 0

pd "---"

puts nU - nC - nD + nCandD


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define HRX 1e18
#define INF 1000000007
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;

int main()
{
  hs;
  ll n;
  cin>>n;
  ll a[n];
  f(n)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  ll zz=n/2;
  ll xx=zz-1;
  ll ans=a[zz]-a[xx];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;

int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	ll A, B;
	cin >> A >> B;
	ll res;
	ll orA = A, orB = B;
	
	if(A == B) { cout<<A<<endl; return 0; }
	if(A % 2 == 1) A++;
	if(B % 2 == 0) B--;
	
	if(((B - A) / 2) % 2 == 0) res = 1;
	else res = 0;
	
	if(orA % 2 == 1) { res ^= orA; }
	if(orB % 2 == 0) { res ^= orB; }
	
	
	cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=500005;
int n,d,a[N],b[N],Q,x;
long long f[N];
int main(){
	scanf("%d%d",&n,&d);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	b[0]=d;
	for (int i=1;i<=n;i++){
		if (a[i]<=b[i-1]) b[i]=b[i-1]-a[i];
		else if (a[i]-b[i-1]<b[i-1]) b[i]=a[i]-b[i-1];
		else b[i]=b[i-1];
	} 
	f[n+1]=0;
	for (int i=n;i>=1;i--){
		if (a[i]<2*(f[i+1]+1)) f[i]=f[i+1]+a[i];
		else f[i]=f[i+1];
	}
	scanf("%d",&Q);
	while (Q--){
		scanf("%d",&x);
		if (f[x+1]<b[x-1]) puts("YES");
		else puts("NO"); 
	} 
}

Measured memory_bytes: 11576
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}

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

using namespace std;

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

    long long ans = 0;
    long long x;
    cin >> x;

    if (x % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    ans += x / 10;
    x /= 10;

    for (long long i = 5; i <= x; i*=5) {
        ans += x/i;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  ll n, m, a = 0, tmp;
  cin >> n >> m;
  rep(i, m) {
    cin >> tmp;
    a += tmp;
  }
  if (a > n) {
    cout << "-1" << endl;
  } else {
    cout << n - a << endl;
  }
}


Measured memory_bytes: 3632
N = int(input())
B = list(map(int,input().split()))
A = [0 for i in range(N)]
A[0] = B[0]
for i in range(1,N-1):
    A[i] = min(B[i-1], B[i])
A[N-1] = B[N-2]
print(sum(A))


Measured memory_bytes: 3060