akhauriyash/Code-Regression huggingface dataset:
// Author: pankaj_m05 
// Problem: c 
// Created: 21.06.2020 17:36:08

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define f_in(file) freopen(file, "r", stdin)
#define f_out(file) freopen(file, "w", stdout)
#define sz(a) int((a).size())
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) c.begin(), c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())  // Set and Maps
#define cpresent(c,x) (find(allc,x) != c.end()) // Vectors
using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef long long ll;

const int mod = 1e9 + 7;       

void testcase() {
	ll n;
	cin >> n;
	string s;
	while (n) {
		--n;
		s += (char) ((n % 26 + 'a'));
		n /= 26;
	}
	reverse(s.begin(), s.end());
	cout << s;
}

int main(void) { 
	fast
	int t = 1; 
	// cin >> t;
	while (t--) {
		testcase();
	}
	return 0;
}                                          

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

int main()
{
    string S;

    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (((i % 2 == 0) && S[i] == 'L') || ((i % 2 == 1) && S[i] == 'R')) {
            cout << "No" << endl;
            return EXIT_SUCCESS;
        }
    }
    cout << "Yes" << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <cstdio>
const int N=200005;
int fst[N],nxt[N],p[N],q[N],deg[N],f[N];
bool u[N];
void addedge(int x,int y){
	nxt[y]=fst[x];fst[x]=y;
}
int calc(int x,bool bo){
	for (int i=fst[x];i;i=nxt[i]) if (!deg[i]) u[f[i]]=1;
	int y=0;
	for (;u[y];y++);
	if (bo) for (y++;u[y];y++);
	for (int i=fst[x];i;i=nxt[i]) u[f[i]]=0;
	return y;
}
bool check(int st,bool bo){
	for (int i=st;!deg[i];i=p[i]) deg[i]=1;
	f[st]=calc(st,bo);--deg[st];
	for (int i=p[st];i!=st;i=p[i]){
		f[i]=calc(i,0);
		deg[i]=0;
	}
	return calc(st,0)==f[st];
}
int main(){
	int n;
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&p[i]);
		addedge(p[i],i);
		deg[p[i]]++;
	}
	int head=1,tail=0;
	for (int i=1;i<=n;i++)
		if (!deg[i]) q[++tail]=i;
	for (;head<=tail;){
		int x=q[head++];
		if (!--deg[p[x]]) q[++tail]=p[x];
		f[x]=calc(x,0);
	}
	int st=0;
	for (int i=1;i<=n;i++)
		if (deg[i]) st=i;
	if (check(st,0) || check(st,1)) printf("POSSIBLE\n");
		else printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>

using namespace std;

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

	set<long long> k = {n};
	for (long long i = 2; i * i <= n; i++) {
		long long x = n;

		if (x % i != 0) {
			continue;
		}

		while (x % i == 0) {
			x /= i;
		}

		if (x % i == 1) {
			k.insert(i);
		}
	}

	long long m = n - 1;
	for (long long i = 1; i * i <= m; i++) {
		if (m % i == 0) {
			k.insert(i);
			k.insert(m/i);
		}
	}
	k.erase(1);
	cout << k.size() << endl;

	return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	rep(i, n) p[i]++;
	int mx = 0;
	int s = 0;
	queue<int> q;
	rep(i, n) {
		s += p[i];
		q.push(p[i]);
		if (q.size() > k) {
			s -= q.front(); q.pop();
		}
		if (q.size() == k) {
			mx = max(mx, s);
		}
	}
	double ans = mx;
	ans /= 2;
	printf("%.10f\n", ans);
	return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

void solve(int H, int W, vector<string>& a) {
    set<int> rs, cs;
    rep(r,H) {
        bool active = false;
        rep(c,W) if (a[r][c] == '#') { active = true; break; }
        if (active) rs.insert(r);
    }
    rep(c,W) {
        bool active = false;
        rep(r,H) if (a[r][c] == '#') { active = true; break; }
        if (active) cs.insert(c);
    }
    rep(r,H) {
        if (!found(rs, r)) continue;
        rep(c,W) {
            if (!found(cs, c)) continue;
            putchar(a[r][c]);
        }
        putchar('\n');
    }
}

int main() {
    int H, W; cin >> H >> W;
    vector<string> a(H);
    rep(i,H) cin >> a[i];
    solve(H,W,a);
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int ar[100000][3];
int dp[100000][3];

int main() {
	speed;
	int n, a, b, c;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> ar[i][0] >> ar[i][1] >> ar[i][2];
		if (i) {
			dp[i][0] = max(ar[i - 1][1] + dp[i - 1][1], ar[i - 1][2] + dp[i - 1][2]);
			dp[i][1] = max(ar[i - 1][0] + dp[i - 1][0], ar[i - 1][2] + dp[i - 1][2]);
			dp[i][2] = max(ar[i - 1][0] + dp[i - 1][0], ar[i - 1][1] + dp[i - 1][1]);
		}
	}
	cout << max({dp[n - 1][0] + ar[n - 1][0], dp[n - 1][1] + ar[n - 1][1], dp[n - 1][2] + ar[n - 1][2]});
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int n;
	int a,b;
	int a1,b1;
	int i;
	scanf("%d",&n);
	while(n!=0){
		a1=0;
		b1=0;
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b){
				a1+=a;
				a1+=b;
			}
			else if(a<b){
				b1+=a;
				b1+=b;
			}
			else{
				a1+=a;
				b1+=b;
			}
		}
		printf("%d %d\n",a1,b1);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
s=[[int(j) for j in input().split()] for i in range(2)]
N=s[0]
A=s[1]
accN=0
number=0
flag=1
while flag==1:
    for i in A:
        if i % 2==0:
            accN+=1
    if accN==N[0]:
        number+=1
        accN=0
        for i in range(N[0]):
            A[i]=A[i]/2
        
    else:
        flag=0
print(number)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    const int Nmax = 2*1e5+1;
    int a[Nmax];
    int ans[Nmax];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ss=0;
    for(int i=n;i>=1;i--){
        int sum=0;
        for(int j=2;j<=n/i;j++){
            sum += ans[i*j];
        }
        if(sum%2==a[i]) ans[i]=0;
        else ans[i]=1;
    }
    int cnt=0;
    for(int i=1;i<=n;i++) cnt+=ans[i];
    cout<<cnt<<endl;
    for(int i=1;i<=n;i++){
        if(ans[i]==1){
            cout<<i<<" ";
        }
    }
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    int num = 1;

    for (int i = 0; i < N; i++)
    {
        if (2 * num >= num + K)
        {
            num += K;
        }
        else
        {
            num *= 2;
        }
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	double ax,by,c,dx,ey,f,x1,x2,x,y;
	
	for(;cin >> ax >> by >> c >> dx >> ey >> f;)
	{
		
		x1=by/ax;
		x2=c/ax;
		y=(f-dx*x2)/(ey-dx*x1);
		x=x2-x1*y;
		
		printf("%.3f %.3f\n",x,y);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back

void solve() {
  int l;
  cin >> l;
  double a = l / 3.0;  
  cout << setprecision(7) << a * a * a;
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 110

int main(){
  int n,k,x,y;

  scanf("%d%d%d%d",&n,&k,&x,&y);
  
  printf("%d\n",min(k,n)*x + max(n-k,0)*y);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 10000007
#define ff first
#define ss second
#define ll long long
#define int long long
#define pii pair<ll,ll>
#define vi vector<ll>
#define mii map<ll,ll>
#define pb push_back
#define mp make_pair
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define str string
#define all(v) v.begin(),v.end()
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	//kehsihba();
	ll n,x;
	cin>>n>>x;
	ll arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	ll ans=0;
	for(int i=0;i<n-1;i++){
		if(arr[i]+arr[i+1]>x){
			ans+=(arr[i]+arr[i+1])-x;
			ll k=(arr[i]+arr[i+1])-x;
			if(k>arr[i+1]){
				k-=arr[i+1];
				arr[i+1]=0;
			}
			else{
				arr[i+1]-=k;
			}
		}
	}
	cout<<ans;
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    vector<pair<ll, ll>> m;
    cin >> N;
    for(ll i = 1;i <= N;i++) {
        ll temp;
        cin >> temp;
        m.emplace_back(i, temp);
    }
    sort(m.begin(), m.end(), [](pair<ll, ll> a, pair<ll, ll> b) { return a.second < b.second; });
    for(auto &i: m) cout << i.first << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

const int MAX_V=1000005;

struct edge{int to; ll cost;};
typedef pair<ll,int> P;

int V;
vector<vector<edge>> G(MAX_V);
vector<ll> d(MAX_V);

void add_edge(int s,int t,ll c){
    G[s].push_back((edge){t,c});
    G[t].push_back((edge){s,c});    
}

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d.begin(),d.end(),INF);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int H, W; cin >> H >> W;
    vector<string> S(H);
    REP(i,H)cin >> S[i];
    int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
    REP(i,H)REP(j,W){
        if(S[i][j]=='#'){
            add_edge(i*W+j,H*W, 0);
        }
        REP(k,4){
            int nx=i+dx[k],ny=j+dy[k];
            if(0<=nx && nx<H && 0<=ny && ny<W){
                add_edge(i*W+j, nx*W+ny, 1);
            }
        }
    }
    dijkstra(H*W);
    ll res=0;
    REP(i,H*W)res=max(res,d[i]);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 339172
#include <cstdio>
#include <queue>

#define mp std::make_pair
#define fi first
#define se second
typedef long long LL;
typedef std::pair<int, int> pii;
const int MN = 200005;

int N, A[MN], B[MN];
std::priority_queue<pii> pq;
LL Ans;

inline int nx(const int &x) { return x % N + 1; }
inline int ls(const int &x) { return (x - 2 + N) % N + 1; }

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	for (int i = 1; i <= N; ++i) scanf("%d", &B[i]);
	for (int i = 1; i <= N; ++i) {
		if (B[i] < A[i]) return puts("-1"), 0;
		if (B[i] > A[i]) pq.push(mp(B[i], i));
	}
	while (!pq.empty()) {
		pii p = pq.top(); pq.pop();
		int i = p.se, v = p.fi;
		int x = B[ls(i)] + B[nx(i)], t = (v - A[i]) / x;
		if (!t) return puts("-1"), 0;
		Ans += t;
		B[i] -= t * x;
		if (B[i] > A[i]) pq.push(mp(B[i], i));
//		for (int i = 1; i <= N; ++i) printf("%d%c", B[i], " \n"[i == N]);
	}
	printf("%lld\n", Ans);
	return 0;
}

/*
6
1 1 1 1 1 1
1 1 9 5 1 1

*/

Measured memory_bytes: 3956
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<map>
#include<string>
using namespace std;
int P[205],K[205],ans;
bool flag[205];
int n,x,y;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){scanf("%d%d",&x,&y);P[x]=y;K[x]=0;}
    for(int i=1;i<=n;i++){scanf("%d%d",&x,&y);P[x]=y;K[x]=1;}
    for(int i=0;i<=2*n-1;i++)
		if(K[i])
		{
			int Pnum=-1,nq=-1;
			for(int j=i-1;j>=0;j--)
			if(!flag[j]&&K[j]!=K[i]&&P[j]<P[i]&&Pnum<P[j]){Pnum=P[j];nq=j;}
			if(Pnum==-1)continue;
			flag[nq]=1;flag[i]=1;ans++;
		}
    printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string s;
  cin>>s;
  if(s[0]==s[1] && s[1]==s[2]) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

int main()
{
    int a,b,c,i,n=0;
    cin>>a>>b>>c;
    for(i=a;i<=b;i++) {
        if(c%i==0) {
            n++;
        } else {
            n=n+0;
        }
    }
    cout<<n<<endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795


ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll N=2e5+1;

ll solve(ll t,vector<ll>& a,ll n)
{
  ll ans=0;
  for(int i=1;i<=n;i++)
    ans+=(a[i]-t)*(a[i]-t);

  return ans;

}


ll bx(ll n)
{
  ll temp=10;
  while(n)
  {
    temp=min(temp,n%10);
    n/=10;
  }
  return temp;
}

ll ax(ll n)
{
  ll temp=0;
  while(n)
  {
    temp=max(temp,n%10);
    n/=10;
  }
  return temp;
}



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

ll n,d;
    cin>>n>>d;

ll ans=(n+2*d)/(2*d+1);

cout<<ans<<"\n";


return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

ll c[27];
ll s[400][27];
ll last[400][27];
ll score[27];

int main(void){
	int D;
	cin>>D;
	for(int i=1;i<=26;i++)cin>>c[i];
	for(int i=1;i<=D;i++){
		for(int j=1;j<=26;j++){
			cin>>s[i][j];
		}
	}
	vector<ll>mx(D+1,0);
	for(int d=1;d<=D;d++){
		ll S = 0;
		for(int i=1;i<=26;i++){
			if(S<s[d][i]){
				mx[d]=i;
				S = s[d][i];
			}
		}
	}
	ll ans=0;
	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> rand26(1,26),randday(1,D);
	for(ll d=1;d<=D;d++){
		for(int i=1;i<=26;i++){
            last[d][i]=last[d-1][i];
            if(i==mx[d])last[d][mx[d]]=d;
        }
		ans+=s[d][mx[d]];
		for(ll j=1;j<=26;j++){
            ans-=c[j]*(d-last[d][j]);
		}
	}
	for(ll qu=0;qu<100000;qu++){
		ll d = randday(mt);
		ll q = rand26(mt);
		ll tmp = ans;
		ans+=s[d][q]-s[d][mx[d]];
        ll old1 = last[d][mx[d]];
        ll new1 = last[d-1][mx[d]];
        ll old2 = last[d][q];
        ll new2 = d;
        for(ll i=d;i<=D;i++){
            tmp+=c[mx[d]]*(i-last[i][mx[d]]);
            if(last[i][mx[d]]==old1)last[i][mx[d]]=new1;
            tmp-=c[mx[d]]*(i-last[i][mx[d]]);
        }
        for(ll i=d;i<=D;i++){
            tmp+=c[q]*(i-last[i][q]);
            if(last[i][q]==old2)last[i][q]=new2;
            tmp-=c[q]*(i-last[i][q]);
        }
		if(ans<tmp){
			ans = tmp;
			mx[d]=q;
		} 
		else{
			for(ll i=d;i<=D;i++){
				if(last[i][mx[d]]==new1)last[i][mx[d]]=old1;
			}
			for(ll i=d;i<=D;i++){
				if(last[i][q]==new2)last[i][q]=old2;
			}
		}
	}
	for(int i=1;i<=D;i++)cout<<mx[i]<<endl;
    return 0;
}

Measured memory_bytes: 3792
package main

import "fmt"

func main() {
	var (
		s string
		k int
	)
	fmt.Scan(&s, &k)

	cnt := 0
	for i := 1; i < len(s); i++ {
		if s[i-1] == s[i] {
			cnt++
			i++
		}
	}

	eq := true
	for i := 1; i < len(s); i++ {
		if s[i-1] != s[i] {
			eq = false
			break
		}
	}
	if eq {
		fmt.Println(len(s) * k / 2)
		return
	}

	if s[0] != s[len(s)-1] {
		fmt.Println(k * cnt)
		return
	}

	a := 1
	for i := 1; i < len(s); i++ {
		if s[i] != s[0] {
			break
		}
		a++
	}
	b := 1
	for i := len(s) - 2; i >= 0; i-- {
		if s[i] != s[len(s)-1] {
			break
		}
		b++
	}
	cnt = 0
	for i := a; i < len(s)-b; i++ {
		if i+1 < len(s)-b && s[i] == s[i+1] {
			cnt++
			i++
		}
	}
	fmt.Println(k*cnt + (k-1)*((a+b)/2) + a/2 + b/2)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> p(n);
  for (i64 i = 0; i < n; i++)
    cin >> p[i];
  i64 ans = 0;
  for (i64 i = 1; i < n - 1; i++)
    if (p[i] == p[i - 1] + p[i] + p[i + 1] - max({p[i - 1], p[i], p[i + 1]}) - min({p[i - 1], p[i], p[i + 1]}))
      ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        if(n.charAt(0)==n.charAt(2)){
            System.out.print("Yes");
        } else {
            System.out.print("No");
    
        }
    }
    
}


Measured memory_bytes: 22228
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
using namespace std;
int inf = 1000000000;

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


int main(){

  string s;
  cin >> s;
  int cnt = 0;
  int tmp = 0;
  for(int i=0; i<s.size(); i++){
    if( tmp >= s[i]-'A' ){
      cnt++;
    }
    tmp = s[i]-'A';
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>
#include <functional>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int n,sum=0; cin >> n;
  int a[n]; 
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  cout << sum-n;
 
 return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	bool used[n];
	memset(used,false,sizeof used);
	vector<int>edge[n];
	deque<int>dq;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	dq.push_front(0);
	used[0]=true;
	while(true){
		int now=dq.front();
		bool f=true;
		for(int i=0;i<edge[now].size();i++){
			if(!used[edge[now][i]]){
				used[edge[now][i]]=true;
				f=false;
				dq.push_front(edge[now][i]);
				break;
			}
		}
		if(f==true)break;
	}
	while(true){
		int now=dq.back();
		bool f=true;
		for(int i=0;i<edge[now].size();i++){
			if(!used[edge[now][i]]){
				used[edge[now][i]]=true;
				f=false;
				dq.push_back(edge[now][i]);
				break;
			}
		}
		if(f==true)break;
	} 
	int k=dq.size();
	cout<<k<<endl;
	for(int i=0;i<k;i++){
		int c=dq[i]+1;
		cout<<c<<" ";
	} 
	return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // Failed to predict input format
    int N, K;
    cin >> N >> K;
    vector<bool> given(N+1, false);
    rep(i,0,K) {
        int d;
        cin >> d;
        rep(j,0,d) {
            int A;
            cin >> A;
            given[A] = true;
        }
    }
    cout << count(all(given), false) - 1 << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e16;
const ll mod=1000000007;
typedef pair<ll,ll> pi;

void solve()
{
 ll n;
 cin>>n;
 vector<bool>v(n,false);
 ll temp=7;
 ll ans=1;
 while(true)
 {
     if(temp%n==0)
     {
         cout<<ans;
         return;
     }
     if(v[temp%n])
     {

         break;
     }
     v[temp%n]=true;
     ans++;
     temp=(temp*10+7)%n;
 }
 cout<<-1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    t=1;
    for(ll i=1;i<=t;i++)
    {
        solve();
        cout<<endl;

    }
    return 0;
}


Measured memory_bytes: 3724
N, Y = map(int, input().split())
Y //= 1000
A, B, C = [-1, -1, -1]
for a in range(N + 1):
  for b in range(N - a + 1):
    if 9 * a + 4 * b + N == Y:
      A, B, C = [a, b, N - a - b]
      break
  if A != -1:
    break
print(A, B, C)

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

bool judgeLeapYear( int y )
{
    if( y % 400 == 0 )
        return true;
    else if( y % 100 == 0 )
        return false;
    else if( y % 4 == 0 )
        return true;
    else
        return false;
}

int cntDay( int y, int m, int d, int* a )
{
    int sum = 0;

    for( int i = 1; i < m; i++ )
        sum += a[i];

    if( judgeLeapYear(y) && m > 2 )
        sum++;

    return sum + d;
}

int main()
{
    int a[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    int y1, m1, d1, y2, m2, d2;

    while( cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2 )
    {
        if( y1 == -1 )
            break;

        int cntleap = 0;
        for( int i = y1; i < y2; i++ )
            if( judgeLeapYear(i) )
                cntleap++;

        int sum = cntDay( y2, m2, d2, a ) - cntDay( y1, m1, d1, a ) + 366 * cntleap + 365 * ( y2 - y1 - cntleap );
        cout << sum << endl;
    }

    return 0;
}



Measured memory_bytes: 3084
list1=list(input())
list1.reverse()
a=0
count=0
for i in range(len(list1)):
    if list1[i]=="W":
        a=i
        break
for i in range(a,len(list1)):
    if list1[i]=="B":
        count+=i-a
        a+=1
print(count)

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int Nmax = 1e5 + 5;

vector <int> c;

int a[Nmax];
int pos[Nmax];
int b[Nmax];
int maxx[Nmax];
int T[Nmax];
int num[Nmax];
int ans[Nmax];
int n,N;

void updatesum(int i, int val)
{
    while (i <= N)
    {
        T[i] += val;
        i += i & -i;
    }
}

int getsum(int i)
{
    int res = 0;
    while (i > 0)
    {
        res += T[i];
        i -= i & -i;
    }
    return res;
}

void updatenum(int i, int val)
{
    while (i <= N)
    {
        num[i] += val;
        i += i & -i;
    }
}

int getnum(int i)
{
    int res = 0;
    while (i > 0)
    {
        res += num[i];
        i -= i & -i;
    }
    return res;
}

signed main()
{
   // freopen("file.inp","r",stdin);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        c.push_back(a[i]);
    }
    sort(c.begin(), c.end());
    for (int i = 0; i < c.size(); i++)
    {
        if (c[i] != b[N]) b[++N] = c[i];
    }
    for (int i = 1; i <= n; i++)
    {
        int l = 1;
        int r = N + 1;
        while (r - l > 1)
        {
            int mid = (l + r) >> 1;
            if (b[mid] <= a[i]) l = mid;
            else r = mid;
        }
        pos[i] = l;
        updatesum(pos[i], a[i]);
        updatenum(pos[i], 1);
        maxx[i] = max(pos[i], maxx[i - 1]);
    }
    for (int i = 1; i <= n; i++)
    {
        if (maxx[i - 1] >= pos[i]) continue;
        ans[i] += (a[i] - b[maxx[i - 1]]) * (getnum(N) - getnum(pos[i] - 1));
        int x = getsum(pos[i] - 1) - getsum(maxx[i - 1]);
        int y = b[maxx[i - 1]] * (getnum(pos[i] - 1) - getnum(maxx[i - 1]));
        ans[i] += x - y;
        updatesum(pos[i], -a[i]);
        updatenum(pos[i], -1);
    }
    for (int i = 1; i <= n; i++)
    {
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 7412
n = list(input())
ans = 0
for i in range(1, len(n) + 1):
    if n[-i] != "9" and i != len(n):
        ans += 9
        n[-i - 1] = str(int(n[-i - 1]) - 1)
    else:
        ans += int(n[-i])
print(ans)

Measured memory_bytes: 3316
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vi v(n);
	rep(i,n){
		cin>>v[i];
	}
	sort(all(v),greater<int>());
	queue<int> q;
	if(n == 2){
		ll ans = 0;
		ans = v[0];
		cout<<ans;
		return 0;
	}
	q.push(v[1]);
	q.push(v[2]);
	q.push(v[2]);
	ll ans = v[0];
	ans += v[1];
	repa(i,3,n){
		ans += q.front();
		q.pop();
		q.push(v[i]);
		q.push(v[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4828
A,B,C,D = map(int, input().split())
mod = 998244353
    
dp = [[0]*(D+1) for _ in range(C+1)]
for i in range(A, C+1):
    for j in range(B, D+1):
        if i == A and j == B:
            dp[i][j] = 1
        elif i == A and j > B:
            dp[i][j] = i*dp[i][j-1]
        elif i > A and j == B:
            dp[i][j] = j*dp[i-1][j]
        else:
            dp[i][j] = j*dp[i-1][j] + i*dp[i][j-1] - dp[i-1][j-1]*(i-1)*(j-1)
        dp[i][j] %= mod
print(dp[-1][-1])

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

int main() {
	int a[6];
	for (int i = 0; i < 6; i++) {
		cin >> a[i];
	}

	if (a[4] - a[0] <=a[5] ) {
		cout << "Yay!" << endl;
	}
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc080_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(Math.Min(x[0] * x[1],x[2]));
        }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<ll> a(n);
    ll res=1e10;
    rep(i,n){
        ll a;cin>>a;
        ll cou=0;
        while(a%2==0){
            cou++;
            a/=2;
        }
        chmin(res,cou);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3536
/*
 Author: LargeDumpling
 Email: LargeDumpling@qq.com
 Edit History:
	2017-08-20	File created.
*/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=100050;
int n,num[MAXN],num2[MAXN];
long long a[MAXN],h[MAXN],h2[MAXN],ans=0;
int main()
{
	h[0]=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		h[++h[0]]=a[i];
	}
	sort(h+1,h+h[0]+1);
	h[0]=unique(h+1,h+h[0]+1)-h-1;
	for(int i=1;i<=n;i++)
		num[lower_bound(h+1,h+h[0]+1,a[i])-h]++;
	h2[0]=0;
	for(int i=1;i<=n;i++)
		if(2<=num[i])
		{
			h2[++h2[0]]=h[i];
			num2[h2[0]]=num[i];
		}
	for(int i=h2[0];i;i--)
	{
		if(4<=num2[i]) ans=max(ans,h2[i]*h2[i]);
		if(i<h2[0]) ans=max(ans,h2[i]*h2[i+1]);
	}
	printf("%lld",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<stack>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
    stack <char> ans;
    int n;
    string St;
    cin>>n>>St;
    int a= 0, b = 0;
    for (int i = 0;i < St.length(); i++){
        if (St[i] == '('){
            ans.push('('); // 存左  出现) 出(
        }
        else{
            if (!ans.empty()&&ans.top()=='('){
                ans.pop(); //自身配对了
            }
            else {
                ans.push(')');
            }
        }
    }
    while (!ans.empty()){
        if (ans.top() == ')'){
            a++;
        }
        else{
            b++;
        }
        ans.pop();
    }
    for (int i = 0;i < a;i++){
        cout<<"(";
    }
    cout<<St;
    for (int i = 0;i < b;i++){
        cout<<")";
    }
    cout<<endl;
}


Measured memory_bytes: 256
n = int(input())
s, t = input(), input()
p = ''
i = 0
while i < n:
    if s[i] == t[i]:
        p += 'X'
    else:
        p += 'Y'
        i += 1
    i += 1
ans = (3 if p[0] == 'X' else 6)
for i in range(1, len(p)):
    if p[i] == 'X':
        if p[i - 1] == 'X':
            ans *= 2
        else:
            ans *= 1
    else:
        if p[i - 1] == 'X':
            ans *= 2
        else:
            ans *= 3
print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

string s;
int dp[111111];

int solve(int p)
{
	int n = s.size();
	if (p == n) return 1;
	if (dp[p] >= 0) return dp[p];
	int res = 0;
	if (p + 5 <= n)
	{
		string a = s.substr(p, 5);
		if (s.substr(p, 5) == "erase" || s.substr(p, 5) == "dream") chmax(res, solve(p + 5));
	}
	if (p + 6 <= n)
	{
		if (s.substr(p, 6) == "eraser") chmax(res, solve(p + 6));
	}
	if (p + 7 <= n)
	{
		if (s.substr(p, 7) == "dreamer") chmax(res, solve(p + 7));
	}
	return dp[p] = res;
}


int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	MS(dp, -1);
	cin >> s;
	cout << (solve(0) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 3408
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll z =0;
    pr( max(z, a-c) * max(z, b-d) );
    return 0;
}



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9+100;

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

  int N; cin >> N;
  using MA = pair<PII,int>;
  vector<MA> xs(N*2);
  REP(i,N){
	cin >> xs[i].FF;
	xs[N+i] = MP(MP(xs[i].FF.SS, xs[i].FF.FF), 1);
  }
  sort(ALL(xs), [](const MA& l, const MA& r){
	  return
		l.FF.FF != r.FF.FF ?
		l.FF.FF < r.FF.FF :
		l.FF.SS > r.FF.SS;
	});

  VI dp(N*2, INF);
  REP(i,N*2){
	int ix = lower_bound(ALL(dp), xs[i].FF.SS) - begin(dp);
	if(xs[i].SS != ix%2){
	  if(ix == 0)
		continue;
	  --ix;
	}
	mini(dp[ix], xs[i].FF.SS);
  }

  cout << (lower_bound(ALL(dp), INF) - begin(dp)) << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

int main() {
    ll N, X;
    cin >> N >> X;
    cout << 3LL * (N - __gcd(N, X)) << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
[$A, $B, $C, $K] = array_map('intval',explode(' ',trim(fgets(STDIN))));
if($K <= $A){
  echo $K;
}elseif($K <= $A+$B){
  echo $A;
}else{
  echo $A * 2 - $K + $B;
}

Measured memory_bytes: 16160
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int N,L;cin>>N>>L;
  int x[N];
  rep(i,N){
    x[i]=L+i;
  }
  int tmp=INF;
  rep(i,N){
    if(abs(x[i]) < abs(tmp) ) tmp=x[i];
  }
  int ans=0;
  rep(i,N) ans+=x[i];
  ans-=tmp;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::io;
fn main() {
    let mut l1 = String::new();
    let stdin = io::stdin();
    stdin.read_line(&mut l1).unwrap();
    let trimed = l1.trim_end();
    let mut itr = trimed.split_ascii_whitespace();
    let mut a = itr.next().unwrap().parse::<i64>().unwrap();
    let b = itr.next().unwrap().parse::<i64>().unwrap();
    let mut c = itr.next().unwrap().parse::<i64>().unwrap();
    let d = itr.next().unwrap().parse::<i64>().unwrap();
    loop {
        c = c - b;
        if c <= 0 {
            println!("Yes");
            break;
        }
        a = a - d;
        if a <= 0 {
            println!("No");
            break;
        }
    }
}


Measured memory_bytes: 2136
# coding: utf-8


def solve(*args: str) -> str:
    n = str(args[0])

    RL = []
    for xl in args[1:]:
        x, l = map(int, xl.split())
        RL.append((x+l, x-l))

    RL.sort()

    count = 1
    cur, _ = RL[0]
    for r, l in RL[1:]:
        if cur <= l:
            cur = r
            count += 1

    return str(count)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 26724
#include<bits/stdc++.h>
using namespace std;
long long a[100001];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
		{
			cout<<"0";
			return 0;
		}
	}
	unsigned long long ans=1,cnt;
	for(int i=1;i<=n;i++)
	{
		cnt=1e18/ans;
		if(a[i]>cnt+1)
		{
			cout<<"-1";
			return 0;
		}
		ans*=a[i];
		if(ans>(unsigned long long)1e18)
		{
			cout<<"-1";
			return 0;
		}
	}
	if(ans>(unsigned long long)1e18)
	{
		cout<<"-1";
		return 0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4368
import sys
input = sys.stdin.readline


def prime_factor_count(n):
    def count(n, p):
        cnt = 0
        while n % p == 0:
            n //= p
            cnt += 1
        np_cnt = 1
        while (cnt := cnt - np_cnt) >= 0:
            np_cnt += 1
        return n, np_cnt - 1

    n, cnt = count(n, 2)

    if n == 1:
        return cnt

    for i in range(3, int(n ** 0.5) * 1, 2):
        n, tmp_cnt = count(n, i)
        cnt += tmp_cnt
        if n == 1:
            break
    else:
        cnt += 1

    return cnt


def main():
    n = int(input())
    ans = prime_factor_count(n)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9468
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    String IMPOSSIBLE = "IMPOSSIBLE";
    Scanner sc = new Scanner(is);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    if ((a + b) % 2 == 0) {
      pw.println((a + b) / 2);
    } else {
      pw.println(IMPOSSIBLE);
    }
  }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var a = int.Parse(list[0]);
        var b = int.Parse(list[1]);
        var c = int.Parse(list[2]);

        Console.WriteLine(Math.Max(0, c - Math.Max(0, a - b)));
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
     
    int main(void){
    int A,B;
    int i;
    scanf("%d %d",&A,&B);
    for(i = 0;i<16;i++){
    	if(i%2 == 0)
          A = A-1;
      	else
          B = B-1;
    }
    if(A > 0 || B > 0) printf(":(");
    else printf("Yay!");
     return 0;
    }

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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;



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

    int d,t,s;
    cin>>d>>t>>s;
    if(d<=t*s) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int n,k,sum,ans;
int u[N],v[N],d[N];
int cnt,head[N];
struct edge{int next,to;}e[N<<1];

inline void add(int u,int v)
{
	cnt++;
	e[cnt].next=head[u];
	e[cnt].to=v;
	head[u]=cnt;	
}

void dfs(int u,int fa)
{
	for (register int i=head[u]; i; i=e[i].next)
	if (e[i].to!=fa)
	{
		d[e[i].to]=d[u]+1;
		dfs(e[i].to,u);
	}
}

int main(){
	scanf("%d%d",&n,&k);
	for (register int i=1; i<n; ++i) scanf("%d%d",&u[i],&v[i]),add(u[i],v[i]),add(v[i],u[i]);
	ans=n;
	if (k%2==0)
	{
		for (register int i=1; i<=n; ++i)
		{
			memset(d,0,sizeof(d));
			d[i]=0;
			dfs(i,0);
			sum=0;
			for (register int j=1; j<=n; ++j) sum+=(d[j]>k/2);
			ans=min(ans,sum);
		}
	}
	else
	{
		for (register int i=1; i<n; ++i)
		{
			memset(d,0,sizeof(d));
			d[u[i]]=0; d[v[i]]=0;
			dfs(u[i],v[i]); dfs(v[i],u[i]);
			sum=0;
			for (register int j=1; j<=n; ++j) sum+=(d[j]>k/2);
			ans=min(ans,sum);
		}	
	}
	printf("%d\n",ans);
return 0;
}

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

typedef long long ll;

int main()
{
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i;
    string s;
    cin>>s;
    int n = s.length();
    vector <char> characs;
    for(i=0;i<n;i++)
    {
        characs.push_back(s[i]);
    }
    
    ll q;
    cin>>q;
    bool reversed = false;
    while(q--)
    {

        int c;
        cin>>c;
        if(c==1)
        {
            if(reversed == true)
                reversed = false;
            else
                reversed = true;
        }
        else
        {
            int c1;
            char s1;
            cin>>c1;
            cin>>s1;
            if(c1==1)
            {
                if(reversed)
                    characs.push_back(s1);
                else
                    characs.insert(characs.begin(),s1);
            }
            else
            {
                if(reversed)
                    characs.insert(characs.begin(),s1);
                else
                    characs.push_back(s1);
            }
        }
        //cout<<reversed<<endl;

    }
    //cout<<s<<endl;
    if(reversed == true)
    {
        for(i=characs.size()-1;i>=0;i--)
        {
            cout<<characs[i];
        }
    }
    else
    {
        for(i=0;i<characs.size();i++)
        {
            cout<<characs[i];
        }   
    }
    cout<<endl;
    
    return 0;
}

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

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

const double PI = acos(-1.0);
const int N = 200005;
const int MOD = 1e9 + 7;
const int inf = 1<<28;
typedef long long ll;

double a[105];
int main()
{
    
  int a;
  cin>>a;
  string s;
  cin>>s;
  
  if(a >= 3200)
    cout<<s;
  else
    cout<<"red";

   	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e10
typedef long long ll;
typedef long double ld;
int main(){
    string o,e;
    cin>>o>>e;
    ll s_o=SIZE(o), s_e=SIZE(e);
    ll length=s_o+s_e;
    vector<char> v(length);
    REP(i,s_o){
        v[i*2]=o[i];
    }
    REP(i,s_e){
        v[i*2+1]=e[i];
    }
    REP(i,length){
        cout<<v[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3636