akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
struct segtree{
private:
	T init;
	int n;
	function<T(T,T)> op;
	vector<T>arr;
	vector<T>st;
	vector<T>lz;
	void build(int lo,int hi,int u){
		if(lo==hi){
			st[u]=arr[lo];
		}
		else{
			int mi=(hi+lo)>>1;
			build(lo,mi,u<<1);
			build(mi+1,hi,u<<1|1);
			st[u]=op(st[u<<1],st[u<<1|1]);
		}
	}
	void apply(T x,int u,int lo,int hi){
// 		st[u]+=x*(hi-lo+1);
// 		st[u]+=x;
//		st[u]=x;
 		st[u]=x*(hi-lo+1);
// 		lz[u]+=x;
		lz[u]=x;
	}
	void push(int u,int lo,int hi){
		if(lz[u]!=init){
			int mi=(lo+hi)>>1;
			apply(lz[u],u<<1,lo,mi);
			apply(lz[u],u<<1|1,mi+1,hi);
			lz[u]=init;
		}
	}
	void modify(int l,int r,T x,int u,int lo,int hi){
		if(r<lo||l>hi||l>r)return;
		if(l<=lo&&r>=hi){
			apply(x,u,lo,hi);
			return;
		}
		push(u,lo,hi);
		int mi=(lo+hi)>>1;
		if(mi>=r){
			modify(l,r,x,u<<1,lo,mi);
		}
		else if(mi<l){
			modify(l,r,x,u<<1|1,mi+1,hi);
		}
		else{
			modify(l,mi,x,u<<1,lo,mi);
			modify(mi+1,r,x,u<<1|1,mi+1,hi);
		}
		st[u]=op(st[u<<1],st[u<<1|1]);
	}
	T query(int l,int r,int u,int lo,int hi){
		if(l>r||l>hi||r<lo)return init;
		if(l<=lo&&r>=hi){
			return st[u];
		}
		push(u,lo,hi);
		int mi=(hi+lo)>>1;
		if(mi>=r){
			return query(l,r,u<<1,lo,mi);
		}
		else if(mi<l){
			return query(l,r,u<<1|1,mi+1,hi);
		}
		else{
			return op(query(l,mi,u<<1,lo,mi),query(mi+1,r,u<<1|1,mi+1,hi));
		}
	}
public:
	segtree(T n,function<T(T,T)> op):n(n),st(n*4),op(op),lz(n*4){
		init=T();
	}
	segtree(vector<T> v,function<T(T,T)> op):n(v.size()),st(v.size()*4),op(op),lz(v.size()*4){
		init=T();
		arr=v;
		build(0,n-1,1);
	}
	T query(int l,int r){
		return query(l,r,1,0,n-1);
	}
	void setinit(T x){
		init=x;
		for(int i=0;i<4*n;i++){
//			st[i]=init;
			lz[i]=init;
		}
	}
	void modify(int l,int r,T x){
		modify(l,r,x,1,0,n-1);
	}
	void debug(){
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				cout<<i<<" "<<j<<" "<<query(i,j)<<"\n";
			}
		}
	}
};
int main(){
	int n,q;
	cin>>n>>q;
	segtree<int> seg(n,[](int a,int b){
		return a+b;
	});
	seg.setinit(INF);
	while(q--){
		int c;
		cin>>c;
		if(c){
			int l,r;
			cin>>l>>r;
			if(l==-1)seg.debug();
			else cout<<seg.query(l,r)<<"\n";
		}
		else{
			int l,r,x;
			cin>>l>>r>>x;
			seg.modify(l,r,x);
			
		}
	}
}




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

int main()
{
    int n, m;
    cin >> n >> m;
    int a[n][m], b[m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int j=0;j<m;j++)
    {
        cin >> b[j];
    }
    
    int ci;
    for(int i=0;i<n;i++)
    {
        ci = 0;
        for(int j=0;j<m;j++)
        {
            ci += a[i][j] * b[j];
        }
        cout << ci << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3144
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector <int> a(n);
    rep(i, n){
        int v;
        cin>>v;
        a[i]+=v;
    }
    rep(i, n){
        int c;
        cin>>c;
        a[i]-=c;
    }
    int ans=0;
    rep(i, n){
        if (a[i]>0) ans+=a[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long n,a,b,c,d,kt=0;
char square[200005];
int main(){
	cin>>n>>a>>b>>c>>d;
	for(int i=1;i<=n;i++) cin>>square[i];
	if(c<d){
		kt=0;
		while(b<d){
			if(b+2<=d && square[b+2]=='.'){
				b=b+2;
			}else{
				if(b+1<=d && square[b+1]=='.'){
					b=b+1;
				}else{
					kt=1;
					break;
				}
			}
		}
		while(a<c){
			if(a+2<=c && square[a+2]=='.'){
				a=a+2;
			}else{
				if(a+1<=c && square[a+1]=='.'){
					a=a+1;
				}else{
					kt=1;
					break;
				}
			}
		}
		if(kt==0){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
	}else{
		kt=0;
		while(a+2<b){
			if(square[a+1]=='.'){
				a++;
			}else{
				if(square[a+2]=='.'){
					a=a+2;
				}else{
					kt=1;
					break;
				}
			}
		}
		if(kt==1){
			cout<<"No";
			return 0;
		}
		if(a+2==b && square[a+1]=='.'){
			a++;
		}
		while(a<b){
			if(a+2==b){
				if(b+1<=n && square[b+1]=='.'){
					b=b+1;
					a=a+2;
				}else{
					if(b+2<=n && square[b+2]=='.'){
						b=b+2;
						a=a+2;
					}else{
						kt=1;
						break;
					}
				}
			}else{
				if(b+1<=n && square[b+1]=='.'){
					a=a+2;
				}else{
					if(b+2<=n && square[b+2]=='.'){
						b=b+2;
						a=a+1;
					}else{
						kt=1;
						break;
					}
				}
			}
		}
		if(kt==1){
			cout<<"No";
			return 0;
		}
		if(b>d || a>c){
			cout<<"No";
		}else{
			kt=0;
			while(a<c){
				if(a+2<=c && square[a+2]=='.'){
					a=a+2;
				}else{
					if(a+1<=c && square[a+1]=='.'){
						a=a+1;
					}else{
						kt=1;
						break;
					}
				}
			}
			while(b<d){
				if(b+2<=d && square[b+2]=='.'){
					b=b+2;
				}else{
					if(b+1<=d && square[b+1]=='.'){
						b=b+1;
					}else{
						kt=1;
						break;
					}
				}
			}
			if(kt==0){
				cout<<"Yes";
			}else{
				cout<<"No";
			}
		}
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    for (char c : S) {
        cout << char('A' + (c - 'A' + N) % 26);
    }
    cout << LN;
}


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

ll h,w,a[11][11],mag[11];
bool b[11][11],check[11];

void dep(int st, int now,ll sum){
	if(now==1){
		mag[st]=min(sum,mag[st]);
		return ;
	}
	for(int i=0;i<10;i++){
		if(b[now][i]==true){
			continue;
		}
		if(check[i]){
			continue;
		}
		check[i]=b[now][i]=true;
		dep(st,i,sum+a[now][i]);
		check[i]=b[now][i]=false;
	}
}
int main() {
	cin>>h>>w;
	for(int i=0;i<10;i++){
		mag[i]=inf;
	}
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<10;i++){
		if(i==1){
			continue;
		}
		check[i]=true;
		dep(i,i,0);
		check[i]=false;
	}
	ll ans=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			int z;
			cin>>z;
			if(z==-1||z==1){
				continue;
			}
			else{
				ans+=mag[z];
			}
		}
	}
	cout <<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        var n1 = sc.nextInt();
        p(String.valueOf((int)Math.ceil(n1 / 1000.0) * 1000 - n1));
    }

    static void p(String s) { System.out.println(s); }
}


Measured memory_bytes: 35812
#include<stdio.h>
#include<math.h>
#include <string.h>

void merge_sort(int array[], int left, int right) {
	int i, j, k, mid;
	int work[210000];  // 作業用配列
	if (left < right) {
		mid = (left + right) / 2; // 真ん中
		merge_sort(array, left, mid);  // 左を整列
		merge_sort(array, mid + 1, right);  // 右を整列
		for (i = mid; i >= left; i--) { work[i] = array[i]; } // 左半分
		for (j = mid + 1; j <= right; j++) {
			work[right - (j - (mid + 1))] = array[j]; // 右半分を逆順
		}
		i = left; j = right;
		for (k = left; k <= right; k++) {
			if (work[i] < work[j]) { array[k] = work[i++]; }
			else { array[k] = work[j--]; }
		}
	}
}

int main() {
	int i, j, k, l = 0;
	int m, g, n, q;
	long long int f = 0;
	int h[210000];


	scanf("%d %d", &n, &k);

	for (i = 0;i < n;i++) {
		scanf("%d", &h[i]);
	}
	
	if (k == 0) {
		for (i = 0;i < n;i++) {
			f = h[i] + f;
		}
	}
	else if(k>=n){
		f = 0;
	}
	else {
		merge_sort(h, 0, n-1);
		for (i = 0;i < n - k;i++) {
			f = h[i] + f;
		}
	}

	printf("%lld", f);


	return 0;
}

Measured memory_bytes: 15104
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace CSharp_Shell
{

    public static class Program 
    {
        public static void Main() 
        {
           var inputs=Console.ReadLine().Split();
           if(inputs[0][inputs[0].Length-1]!=inputs[1][0])
           {
               Console.WriteLine("NO");
               return;
           }
           if(inputs[1][inputs[1].Length-1]!=inputs[2][0])
           {
               Console.WriteLine("NO");
               return;
           }
           
           Console.WriteLine("YES");
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main(void){
  int a,b,c,d=0,e=0;
  while(scanf("%d,%d,%d",&a,&b,&c)==3){
    if(a==b)d++;
    if(a*a+b*b==c*c)e++;
  }
  printf("%d\n%d\n",e,d);
  return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int k,x;
    cin>>k>>x;
    k--;
    f1(i,x-k,x+k+1)
    {
    	if(i>=-1000000&&i<=1000000)
    		cout<<i<<gp;
    }
    return 0;
}

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

using namespace std;

int n, x, ans;
string s;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            x++;
        } else {
            x--;
        }
        ans = max(ans, x);
    }
    cout << ans << "\n";
}



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

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  bool Al[101]; bool Bo[101];
  int co = 0;
  for (int i = 0; i < 101; i++) {
    Al[i] = (i >= A && i < B);
    Bo[i] = (i >= C && i < D);
    co += (Al[i] && Bo[i]);
  }
  cout << co << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n,m;
    cin >>n >>m;
    vector<int> a(n),b(n);
    rep(i,n) cin >>a[i] >>b[i];
    vector<int> c(m),d(m);
    rep(i,m) cin >>c[i] >>d[i];

    vector<int> x(n+1, n);
    rep(i,m){
        int idx = lower_bound(all(a), c[i]) - a.begin();
        x[idx] = min(x[idx], d[i]);
    }

    rep(i,n) x[i+1] = min(x[i+1], x[i]);

    set<int> s;
    for(int i=n-1; i>=0; --i){
        s.insert(b[i]);
        if(s.size() == x[i]) s.erase(s.begin());
    }

    ll ans = 0;
    for(int i:s) ans += i;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4932
#include<iostream>
using namespace std;
int N,k[4]={0};
char S[100];
int main(void){
	cin>>N;
	for(int i=0;i<N;i++)cin>>S[i];
	for(int i=0;i<N;i++)
		switch(S[i]){
			case 'P':
				k[0]=1;
				break;
			case 'W':
				k[1]=1;
				break;
			case 'G':
				k[2]=1;
				break;
			default:
				k[3]=1;
				break;
		}
	cout<<(k[0]+k[1]+k[2]+k[3]==3?"Three":"Four");
	return 0;
}


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

int main() {
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    
    if (u == s) a--;
    else if (u == t) b--;

    printf("%d %d", a, b);
    cout << endl;
    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,ans=1e9;
struct P{
	int x,y;
	char dir[2];
}a[200005];
bool cmp3(P x,P y){
	return x.x^y.x?x.x<y.x:x.y<y.y;
}
bool cmp4(P x,P y){
	return x.y^y.y?x.y<y.y:x.x<y.x;
}
bool cmp5(P x,P y){
	return (x.y-x.x)^(y.y-y.x)?(x.y-x.x)<(y.y-y.x):x.x<y.x;
}
bool cmp6(P x,P y){
	return (x.y+x.x)^(y.y+y.x)?(x.y+x.x)<(y.y+y.x):x.x<y.x;
}
int main() {
	cin>>n;
	for(int i=1;i<=n;i++)scanf("%d%d%s",&a[i].x,&a[i].y,a[i].dir);
	sort(a+1,a+n+1,cmp3);
	for(int i=1;i<=n;i++){
		int j=i;
		while(j<n&&a[j+1].x==a[i].x)j++;
		if(j==i)continue;
		int maxy=-1e8;
		for(int k=i;k<=j;k++){
			if(a[k].dir[0]=='D')ans=min(ans,(a[k].y-maxy)*5);
			if(a[k].dir[0]=='U')maxy=a[k].y;
		}
		i=j; 
	}//x相同 前面的U 后面的D 
	sort(a+1,a+n+1,cmp4);
	for(int i=1;i<=n;i++){
		int j=i;
		while(j<n&&a[j+1].y==a[i].y)j++;
		if(j==i)continue;
		int maxx=-1e8;
		for(int k=i;k<=j;k++){
			if(a[k].dir[0]=='L')ans=min(ans,(a[k].x-maxx)*5);
			if(a[k].dir[0]=='R')maxx=a[k].x;
		}
		i=j; 
	}//y相同 前面的R 后面的L 
	//下面：y-x相同/y+x相同
	sort(a+1,a+n+1,cmp5);//y-x排序
	for(int i=1;i<=n;i++){
		int j=i;
		while(j<n&&a[j+1].y-a[j+1].x==a[i].y-a[i].x)j++;
		if(j==i)continue;
		int maxx=-1e8,maxx2=-1e8;
		for(int k=i;k<=j;k++){
			if(a[k].dir[0]=='D')ans=min(ans,(a[k].x-maxx)*10);
			if(a[k].dir[0]=='R')maxx=a[k].x;
			if(a[k].dir[0]=='L')ans=min(ans,(a[k].x-maxx2)*10);
			if(a[k].dir[0]=='U')maxx2=a[k].x;
		}
		i=j; 
	}//y-x相同 前面的r/u 后面的d/u 
	sort(a+1,a+n+1,cmp6);//y-x排序
	for(int i=1;i<=n;i++){
		int j=i;
		while(j<n&&a[j+1].y+a[j+1].x==a[i].y+a[i].x)j++;
		if(j==i)continue;
		int maxx=-1e8,maxx2=-1e8;
		for(int k=i;k<=j;k++){
			if(a[k].dir[0]=='U')ans=min(ans,(a[k].x-maxx)*10);
			if(a[k].dir[0]=='R')maxx=a[k].x;
			if(a[k].dir[0]=='L')ans=min(ans,(a[k].x-maxx2)*10);
			if(a[k].dir[0]=='D')maxx2=a[k].x;
		}
		i=j; 
	}//x+y相同 前面的r/d 后面的u/l 
	if(ans<1e7)cout<<ans<<endl;
	else puts("SAFE");
}

Measured memory_bytes: 6088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
    int n; cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    int m;
    cin>>m;
    int ans=0;
    rep(i,m){
        //???????????????????????????t?????¢???
        int t;
        cin>>t;
        int imax=n;
        int imin=-1;
        int mid;
        while(imax-imin>1){
            mid=(imax+imin)/2;
            if(v[mid]>t)imax=mid;
            else imin=mid;
        }
        if(v[imin]==t)ans++;
    }
    cout<<ans<<endl;
}

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

int main(){
  int n,x,y,k[2500]={0};
  cin >> n >> x >> y;
  for(int i=1; i<=n-1; i++)
     for(int j=i+1; j<=n; j++)
        k[min(j-i,1+abs(x-i)+abs(y-j))]++;

  for(int i=1;i<=n-1;i++)
    cout<<k[i]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define ll         	long long int
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,n)   	for(ll i =0;i<n;i++)
#define inf 		INT_MAX
#define pll 		pair<ll,ll>
const ll INF = 1e18;
void init(){
	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
}

bool checkp2(ll n){
	return n && (n-1);
}

ll power(ll x , ll n){
	ll po = 1;
	while(n){
		if(n & 1){
			po *= x;
		}
		n = n>>1;
		x = x * x;
	}
	return po;
}

bool isPrime(ll x){
	if(x < 2)
		return 0;
	for(ll y = 2; y * y <= x; y++){
		if(x % y == 0){
			return 0;
		}
	}
	return true;
}
void solve(){

	ll L,R,d;
	cin>>L>>R>>d;
	ll count = 0;
	ll start;
	if(L % d == 0){
		start  = L;
	}
	else{
		start = (L / d + 1)*d;
	}
	if(start > R){
		cout<<"0"<<endl;
	}
	else{
		count++;
		count += (R - start)/d;
		cout<<count<<endl;
	}

	
}
int main(){
	
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}

}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define x first
#define y second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

ll dp[200100];

int main() {
	pll src, dst;
	cin >> src.x >> src.y >> dst.x >> dst.y;
	if(src.x > dst.x) swap(src, dst);
	int N;
	cin >> N;
	vector<pll> c;
	rep(i,N) {
		ll x, y;
		cin >> x >> y;
		if((src.x <= x && x <= dst.x)
				&& (min(src.y, dst.y) <= y && y <= max(src.y, dst.y))) {
			if(src.y > dst.y) {
				y = -y;
			}
			c.push_back(pll(x,y));
		}
	}
	//cout << c.size() << endl;

	ll LIS = 0;
	sort(all(c));
	fill(dp, dp+200100, (ll)1e15);
	rep(i,c.size()) {
		*lower_bound(dp, dp+200100, c[i].y) = c[i].y;
	}
	LIS = lower_bound(dp, dp+200100, (ll)1e15) - dp;
	//cout << LIS << endl;
	double res = (abs(dst.x - src.x) + abs(dst.y - src.y)) * 100ll - LIS*20;

	if(LIS == min(abs(dst.x-src.x), abs(src.y-dst.y)) + 1) {
		LIS++;
	}
	//cout << LIS << "," << res << endl;
	res += LIS * 5 * M_PI;

	printf("%.15f\n", res);

	return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
static const int INF = 2000000000;
static const int NIL = -1;
typedef long long ll;

int main(){
    bool s[31];
    int tmp;
    memset(s,false,sizeof(s));
    for(int i=1;i<=28;i++){
        scanf("%d",&tmp);
        s[tmp] = true;
    }
    for(int i=1;i<=30;i++){
        if(!s[i]) printf("%d\n",i);
    }
}

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

int main() {
  	int n;
  	cin >> n;
  	vector<int> p(n);
  	rep(i,n) cin >> p[i];
  	int ans = 0;
  	int curMin = 1e9;
  	rep(i,n) {
    	curMin = min(curMin, p[i]);
    	if (curMin == p[i]) ans++;
  	}
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 1024
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// contancer library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "{";
    for (auto vv : v) os << vv << ",";
    return os << "}";
}

template <class T>
ostream& operator<<(ostream& os, queue<T> q) {
    os << "[";
    while (!q.empty()) {
        os << q.front() << ",";
        q.pop();
    }
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, priority_queue<T> q) {
    os << "{";
    while (!q.empty()) {
        os << q.top() << ",";
        q.pop();
    }
    return os << "}";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <class T>
vector<T> Vec(size_t l, T v) { return vector<T>(l, v); }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <typename T>
T gcd(T a, T b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

template <typename T, typename U>
T ipow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= b;
        n >>= 1;
        b *= b;
    }
    return ret;
}

template <typename T, typename U>
T mpow(T b, U n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * b % MOD;
        n >>= 1;
        b = b * b % MOD;
    }
    return ret;
}

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<ll> cnt(26, 0);
    for (char c : S) {
        ++cnt[c - 'a'];
    }

    ll ans = 1;
    for (auto c : cnt) {
        ans *= c + 1;
        ans %= MOD;
    }
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 512
T = list(str(input()))
X = ''
for i in range(len(T)):
    if T[i] == 'P' :
        X += 'P'
    elif T[i] == 'D' :
        X += 'D'
    elif T[i] == '?' :
        if T[i-1] == 'D' :
            X += 'D'
        elif T[i-1] == 'P' :
            X += 'D'
        elif T[i-1] == '?':
            X += 'D' 
            
print(X)
    

Measured memory_bytes: 10776
#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, min, ans;
  ans = 0;
  min = pow(10, 6);
  cin >> n;
  rep(i, n) {
    int p;
    cin >> p;
    if (p <= min) {
      ans++;
      min = p;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val set = mutableSetOf<Int>()
    var x = 1
    while (true) {
        val rem = (a * x) % b
        if (rem == c) {
            println("YES")
            return
        }
        if (set.contains(rem)) {
            break
        }
        set.add(rem)
        x++
    }
    println("NO")
}

Measured memory_bytes: 35924
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

vector <ll> adj[100005];
bool visited[100005];
ll dp[100005];

void dfs(ll s){
  visited[s]=true;
  for(auto it:adj[s]){
    if(!visited[it])
      dfs(it);
    dp[s]=max(dp[s],dp[it]+1);
  }
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,m,x,y;
  cin>>n>>m;
  forn(i,0,m){
    cin>>x>>y;
    adj[x].pb(y);
  }
  for(ll i=1;i<=n;i++){
    if(!visited[i])
      dfs(i);
  }
  ll ans=0;
  forn(i,1,n+1)
    ans=max(ans,dp[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 8704
n = int(input())
A = list(map(int, input().split()))
total = sum(A)
center_index = 0
counter = 0
g = total / 2
for i, a in enumerate(A):
  counter += a
  if counter >= g:
    center_index = i
    break
#print(center_index)

left_can_minus = sum(A[:center_index]) - center_index
right_can_minus = sum(A[center_index+1:]) - (n - center_index - 1)
right = counter - g
left = g - (counter - A[center_index])
#print(right, left)
right_cost = 0
left_cost = 0
right_cost += min(left_can_minus, int(right)) * 2
right -= min(left_can_minus, int(right))
right_cost += right * 2
left_cost += min(left_can_minus, int(left)) * 2
left -= min(left_can_minus, int(left))
left_cost += left * 2
print(int(min(right_cost, left_cost)))

Measured memory_bytes: 88140
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <list>
#include <string>

using namespace std;
typedef long long ll;

int main(){
    int y,m,d;
    char c1,c2;
    cin >> y >> c1 >> m >> c2 >> d;
    cout << (m<=4 ? "Heisei" : "TBD") << endl;
}


Measured memory_bytes: 256
import math
def gcd(x, y): 
  
   while(y): 
       x, y = y, x % y 
  
   return x 
  
a,b = map(int,input().split())
n = gcd(a,b)
count = [1]
while (n % 2 == 0):
    count += [2]
    n = n / 2
for i in range(3, int(math.sqrt(n)) + 1, 2):
    while (n % i == 0):
        count+=[i]
        n = n / i

if n > 2:
    count+=[n]
c = 1
count = sorted(count)
for i in range(1,len(count)):
    if (count[i-1] != count[i]):
        c+=1
print(c)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;


struct UnionFind{
private:
    vector<ll> par;
    vector<ll> rank;
    vector<ll> sz;

public:
    //n要素で親を初期化、par[x]はxの親を表す
    UnionFind(ll n){
        par.resize(n,0);
        rank.resize(n,0);
        sz.resize(n,1);
        rep(i,n){
            par[i] = i;
        }
    }

    //木の根を求める
    ll root(ll x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //xとyの属する集合を併合
    void unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        else{
            par[y] = x;
            sz[x] += sz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //xとyが同じ集合に属するか否か
    bool same(ll x, ll y){
        return root(x) == root(y);
    }

    //xが属する集合のサイズを返す
    ll size(ll x){
        return sz[root(x)];
    }
};


int main(){
    ll n,m; cin >> n >> m;
    vector<P> bridge(m);
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--;b--;
        bridge[i] = P(a,b);
    }
    UnionFind uf(n);
    ll ans = n * (n-1) / 2;
    vector<ll> ans_v;
    for(ll i = m-1;0 <= i;i--){
        ans_v.push_back(ans);
        ll a = bridge[i].first, b = bridge[i].second;
        if(!uf.same(a,b))ans -= (uf.size(a) * uf.size(b));
        uf.unite(a,b);
    }
    while(ans_v.size()){
        ll temp = ans_v.back();ans_v.pop_back();
        cout << temp << "\n";
    }
    return 0;
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
long long cnt,sum;
long long a[200005],b[200005];
vector<long long>v;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++) 
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]>=b[i])
			v.push_back(a[i]-b[i]);
		else
		{
			sum+=(b[i]-a[i]);
			cnt++;
		}
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		if(sum>0)
		{
			sum-=v[i];
			cnt++;
		}
	}
	if(sum>0)
		cnt=-1;
	cout<<cnt;

	return 0;
}

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

int main() {
    int H,W;
    while (cin >> H >> W) {
        if (H == 0 && W == 0) {
            break;
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, long long D, long long A, std::vector<long long> X,
           std::vector<long long> H) {
    vector<pair<ll, ll> > vs;
    for (int i = 0; i < N; i++)
        vs.push_back({X[i], H[i]});
    sort(vs.begin(), vs.end());
    priority_queue< pair<ll, ll>> dec;
    long long tot = 0;
    long long ans = 0;
    for (int i = 0; i < vs.size(); i++) {

        while(!dec.empty()){
            long long t = dec.top().first * -1;
            if( t > vs[i].first){
                break;
            }
            tot -= dec.top().second;
            dec.pop();
        }
        long long cnt = (vs[i].second - tot * A + A - 1) / A;
        if( cnt < 0 ) cnt = 0;
        tot += cnt;
        dec.push({-(vs[i].first + 2 * D + 1), cnt});
        ans += cnt;
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long D;
    scanf("%lld", &D);
    long long A;
    scanf("%lld", &A);
    std::vector<long long> X(N);
    std::vector<long long> H(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &X[i]);
        scanf("%lld", &H[i]);
    }
    solve(N, D, A, std::move(X), std::move(H));
    return 0;
}


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

int pow(int i){return i*i;}

int main(){
    int num;
    cin >> num;
    int a[3];
    for(int i=0;i<num;i++){
        cin >> a[0] >> a[1] >> a[2];
        sort(a,a+3,greater<int>());
        if(pow(a[0])==pow(a[1])+pow(a[2]))cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define F first
#define S second
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define N 200010
using namespace std;
ll n;
ll f(ll a,ll b)
{
    ll d=b-a;
    ll p=min(n-b+1,a);
    ll tmp=p*(p+1);
    ll c=n-d;
    tmp+=(c-2*p)*p;
    return tmp;
}
void solve()
{
    cin>>n;
    ll ans=0;
    rep(i,0,n-1)
    {
        ll a,b; cin>>a>>b;
        if(a>b) swap(a,b);
        ans+=f(a,b);
    }
    ll tmp=0;
    for(ll i=1;i<=n;i++)
        tmp+=i*(n-i+1);
    cout<<tmp-ans<<endl;
}
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int t=1;
  //cin>>t;
  //freopen("b2.in", "r", stdin);
  //freopen("output2.txt", "w", stdout);
  for(int i=1;i<=t;i++)
  {
      solve();
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define all( X ) ( X ).begin(), ( X ).end()

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	bool is_visited = false;
} node;
typedef struct {
	int to;
	int cost;
	P <int, int> change;
} edge;

int main(){
	int N, K; cin >> N >> K;
	vector <int> vec( N );
	rep( i, 0, N )
		cin >> vec[ i ];
	rep( i, K - 1, N - 1 )
		cout << ( vec[ i - K + 1 ] < vec[ i + 1 ] ? "Yes" : "No" ) << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


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

int main( )
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int i, up, right, left, down;
    up = ty - sy;
    for (i = 0; i < up; i++) {
        cout << "U";
    }
    right = tx - sx;
    for (i = 0; i < right; i++) {
        cout << "R";
    }
    down = up;
    for (i = 0; i < down; i++) {
        cout << "D";
    }
    left = right;
    for (i = 0; i < left; i++) {
        cout << "L";
    }
    cout << "L";
    up++;
    for (i = 0; i < up; i++) {
        cout << "U";
    }
    right++;
    for (i = 0; i < right; i++) {
        cout << "R";
    }
    cout << "D";
    cout << "R";
    down++;
    for (i = 0; i < down; i++) {
        cout << "D";
    }
    left++;
    for (i = 0; i < left; i++) {
        cout << "L";
    }
    cout << "U\n";
    return 0;
}


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


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

  vector<long long> weight(110),value(110);
  for(int i = 0;i < N;i++) {
    cin >> weight.at(i) >> value.at(i);
  }

  long long dp[110][100100] = {0};
  // for(int i = 0;i <= W;i++) {
  //   dp[0][i] = 0;
  // }

  for(int i = 0;i < N;i++) {
    for(int w = 0;w <= W;w++) {
      if(w >= weight[i]) {
        dp[i+1][w] = max(dp[i][w],dp[i][w - weight[i]] + value[i]);
      }else {
        dp[i+1][w] = dp[i][w];
      } 
    }
  }

  cout << dp[N][W] << endl;

}



Measured memory_bytes: 86272
#include<cstdio>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
	if(a<b)swap(a,b);
	if(b)return gcd(b,a%b);
	else return a;
}
int abs(int a)
{
	if(a<0)a=-a;
	return a;
}
int n,x,a,ans;
int main()
{
	scanf("%d%d%d",&n,&x,&a);
	ans=abs(a-x);
	for(int i=1;i<n;i++)
	{
		scanf("%d",&a);
		ans=gcd(ans,abs(a-x));
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
//#include "puzzle.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)
#pragma warning (disable:4244)
#pragma warning (disable:4996)

using namespace std;
typedef long long int lint;


//***** Main Program *****

int main() {
	deque<int> dq;
	const int base = -50000;
	dq.push_back(base);
	string s;
	cin >> s;
	int maxh = base;
	Loop(i, s.length()) {
		if (s[i] == '/') {
			const int x = dq.back() + 1;
			if (x > maxh) {
				dq.push_back(x);
				maxh = x;
			}
			else {
				int j = dq.size() - 1;
				int area = 0;
				while (dq[j] < x || dq[j]>0) {
					if (dq[j] < x) area++;
					else {
						area += dq[j];
						dq.erase(dq.begin() + j);
					}
					j--;
				}
				dq.push_back(area);
				dq.push_back(x);
			}
		}
		else if (s[i] == '\\') {
			dq.push_back(dq.back() - 1);
		}
		else {
			dq.push_back(dq.back());
		}
	}
	vector<int> ret;
	Loop(i, dq.size()) {
		if (dq[i] > 0) ret.push_back(dq[i]);
	}
	cout << accumulate(ret.begin(), ret.end(), 0) << endl;
	cout << ret.size();
	Loop(i, ret.size()) cout << " " << ret[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 3296
n = int(input())
a = list(map(int, input().split()))
l = [0] * (n + 1)
ans = []
for i in range(n, 0, -1):
    cnt = 0
    for j in range(1, n // i + 1):
        cnt += l[i * j]
    if cnt % 2 != a[i - 1]:
        ans.append(i)
        l[i] = 1
print(len(ans))
print(" ".join(map(str, ans)))

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T> inline bool chkmax(T &x, const T &y){ return y > x ? x = y, 1 : 0; }
template <typename T> inline bool chkmin(T &x, const T &y){ return y < x ? x = y, 1 : 0; }

#ifdef ONLINE_JUDGE
#define debug(...) ;
#else
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 1e5 + 100;

LL R, C;
int n, m;
pll pnt[maxn];

LL get(LL x, LL y)
{
	if(!x) return y;
	if(y == C) return x + C;
	if(x == R) return C - y + R + C;
	if(!y) return R - x + C + R + C;
	return -1;
}

int main()
{
	scf(R, C);
	scf(n);
	rep(i, n)
	{
		LL x1, y1, x2, y2;
		scf(x1, y1, x2, y2);
		LL u = get(x1, y1), v = get(x2, y2);
		if(~u && ~v) pnt[m++] = mp(min(u, v), max(u, v));
	}
	sort(pnt, pnt + m);
	set<int> all; all.clear();
	rep(i, m)
	{
		LL l = pnt[i].X, r = pnt[i].Y;
		auto it = all.lower_bound(l);
		if(it != all.end() && *it <= r)
		{
			puts("NO");
			return 0;
		}
		while(SZ(all) && *all.begin() < l) all.erase(all.begin());
		all.insert(r);
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定 setprecision()
#include <list> //前後に数値を入れれる配列
#include <map> //map
#include <vector> //vecror

#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = acos(-1); //円周率
ll mod = 1e9 + 7;


//提出コード↓

ll n, a[200010],tmp[200010];


int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		tmp[i] = a[i];
	}
	sort(tmp, tmp + n);
	rep(i, n) {
		if (tmp[n - 1] != a[i]) cout << tmp[n - 1] << endl;
		else cout << tmp[n - 2] << endl;
	}

	return 0;
}



Measured memory_bytes: 4736
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int h=scan.nextInt(),a=scan.nextInt(),total=0;
        while (h>0){
      		h-=a;
      		total+=1;}
      System.out.println(total);
        }
    }


Measured memory_bytes: 22868
#include <stdio.h>

int abs(int a) {
  return a > 0 ? a : -a;
}

int main(void) {
  int i, j, k, n, z, w, ans;
  scanf("%d%d%d", &n, &z, &w);
  int a[n];
  for(i = 0; i < n; ++i) scanf("%d", &a[i]);
  ans = abs(w - a[n - 1]);
  for(i = 0; i < n; ++i) a[i] = abs(a[i] - a[n - 1]);
  printf("%d", n == 1 ? ans : ans > a[n - 2] ? ans : a[n - 2]);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#define INF 1<<28
#define F first
#define S second
using namespace std;
  
int sx, sy, gx, gy;
typedef pair < int, int > P;
vector < P > v[5];
int memo[5][5][1111];
 
int dist(P a, P b){
  return abs(a.F - b.F) + abs(a.S - b.S);
}
 
 
int solve(int cnt, int now, int p){
  
  if(cnt == 4) return dist(v[now][p], P(gx, gy));
  if(memo[cnt][now][p]) return memo[cnt][now][p];
  
  int ans = INF, next = (now+1)%5, cost;
  for(int i=0;i<v[next].size();i++){
    if(!cnt) cost = dist(P(sx, sy), v[next][i]);
    else cost = dist(v[now][p], v[next][i]);
    ans = min(ans, solve(cnt+1, next, i) + cost);
  }
  
  return memo[cnt][now][p] = ans;
}
  
int main(){
  
  int w, h;
  char c;
  
  while(scanf("%d %d", &w, &h), w){
     
    for(int i=0;i<5;i++) v[i].clear();
     
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
    scanf(" %c", &c);
    if(c == '.') continue;
    else if(c == 'S') sx = j, sy = i;
    else if(c == 'G') gx = j, gy = i;
    else v[c-'1'].push_back( P(j,i) );
      }
    }
     
    int a, b = INF;
    memset(memo, 0, sizeof(memo));
    for(int i=0;i<5;i++){
      if(b > solve(0,i,0)) a = i+1, b = solve(0,i,0);
    }
  
    b == INF?puts("NA"):printf("%d %d\n", a, b);
  
  }
}

Measured memory_bytes: 1192
import std.stdio;
import std.string;
import std.conv;

void main(){
  int n=to!int(readln().chomp);
  while(n--){
  	const int[string] MP=["yotta":24,"zetta":21,"exa":18,"peta":15,"tera":12,"giga":9,"mega":6,"kilo":3,"hecto":2,"deca":1,
  	"deci":-1,"centi":-2,"milli":-3,"micro":-6,"nano":-9,"pico":-12,"femto":-15,"ato":-18,"zepto":-21,"yocto":-24];
    auto s = readln.chomp.split;
    int a=0;
    if(s[0][0]=='0'){
    	s[0]=s[0].split(".").join;
    	for(;a<s[0].length&&s[0][a]=='0';++a){}
    	if(a==s[0].length-1) s[0]=to!string(s[0][a]);
    	else s[0]=s[0][a]~"."~s[0][a+1..s[0].length];
   		a=-a;
    }else{
    	for(;a<s[0].length&&s[0][a]!='.';++a){}
    	if(a==s[0].length){
    		s[0]=s[0][0]~"."~s[0][1..s[0].length];
    		--a;
    	}else{
    		auto t=s[0].split(".").join;
    		s[0]=t[0]~"."~t[1..t.length];
    		--a;
    	}
    }
    if(s[1] in MP) a+=MP[s[1]];
    writeln(s[0]~" * "~"10^"~to!string(a)~" "~((s.length>2)?s[2]:s[1]));
  }
}

Measured memory_bytes: 1080
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define VPII vector<PII>
#define VPLL vector<PLL>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
int n, m;
ll k;

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    FOR(i,0,n-1) cin >> a[i];
    FOR(i,0,m-1) cin >> b[i];
    FOR(i,1,n-1) a[i] += a[i-1];
    FOR(i,1,m-1) b[i] += b[i-1];
    int ans = 0;

    FOR(i,0,n-1) {
        if(a[i] <= k) {
            auto iter = upper_bound(ALL(b), k-a[i]);
            int b_n;
            b_n = iter - b.begin();
            // }
            if(ans < b_n + i+ 1) ans = b_n + i + 1;
        }
    }

    auto iter = upper_bound(ALL(b), k);
    int b_n;
    b_n = iter - b.begin();
    if(ans < b_n) ans = b_n;
    


    cout << ans << endl;
    return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll, ll> m;
  for (int i = 0; i < n; i++) {
    ll tmp;
    cin >> tmp;
    m[tmp]++;
  }

  ll mx = 0, mx2 = 0;
  for (auto v : m) {
    if (v.second >= 4) {
      if (mx < v.first) {
        mx  = v.first;
        mx2 = v.first;
      }
    } else if (v.second >= 2) {
      if (mx < v.first) {
        mx2 = mx;
        mx  = v.first;
      } else if (mx2 < v.first) {
        mx2 = v.first;
      }
    }
  }
  cout << mx * mx2 << endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  char station_list[3];
  for(int i = 0; i < 3; i++) {
    std::cin >> station_list[i];
  }
  if(station_list[0] == station_list[1] && station_list[1] == station_list[2]) {
    std::cout << "No";
  }
  else {
    std::cout << "Yes";
  }
  return 0;
}

Measured memory_bytes: 504
#include<stdio.h>

int main(void){
    int a;
    scanf("%d", &a);
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i * j == a){
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}



Measured memory_bytes: 128