akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= (n); i++)
using namespace std;

signed main(void)
{
	int n, m;

	cin >> n;
	rep(i, n)
	{
		m = i * 1.08;
		if (n == m)
		{
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}


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

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int max = A[0];
    int res =0;
    for(int i=1;i<n;i++){
        if(max < A[i]){
            max = A[i];
        }
        else if(max>A[i]){
            res+= (max - A[i]);
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 4756
// AOJ 2155: Infected Computer
// 2017.10.20 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int t, s, d; } T;
T tbl[20002];
char f[20002];

int cmp(T *a, T *b) { return a->t - b->t; }

char buf[130], *p;
int getInt(void)
{
	int n;
	if (*p == ' ') p++;
	n = 0; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}
int main()
{
	int n, m, i, ans;
	register T *t;
	char *q;

	while (fgets(p=buf, 128, stdin) && *p != '0') {
		n = getInt(), m = getInt();
		memset(f, 0, n+1);
		for (t = tbl, i = m; i--; t++) {
			fgets(p=buf, 128, stdin);
			t->t = getInt(), t->s = getInt(), t->d = getInt();
		}
		qsort(tbl, m, sizeof(T), cmp);
		for (f[1] = 1, t = tbl, i = m; i--; t++) f[t->d] |= f[t->s];
		for (ans = 0, q = f+1, i = n; i--; ) ans += *q++;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2292
#include <cmath>
#include <iostream>
#include <vector>
typedef std::vector <int> vi;
vi P;
vi f(int n){
	int i=0,j=1,h=(n+1)/2,x,r=(int)pow(n,.5);
	vi s(h),p(1);
	while(j<=n){
		s[i++]=j;
		j+=2;
	}
	p[0]=2;
	for (i=1;i<h;i++)
		if (x=s[i]){
			p.push_back(x);
			if (i<=r) for (j=x*x/2;j<h;j+=x) s[j]=0;
		}
	return p;
}
int main(void){
	int n,s;
	P=f(105000);
	while (true){
		std::cin>>n; if (n==0) break;
		for (s=0;n--;) s+=P[n];
		std::cout<<s<<"\n";
	}
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  ll N,C,K;
  cin >> N >> C >> K;

  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  
  sort(ALL(A));
  ll cnt = 0;
  ll buscnt = 1;
  ll time = A[0];
  REP(i,N-1){
    if(time+K>A[i+1]&&buscnt<C){
      buscnt++;
    }else if(buscnt == C||time+K<A[i+1]){
      buscnt=1;
      cnt++;
      time = A[i+1];
    }
  }
  cout << cnt+1 << endl;
}

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

using namespace std;

typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define endl "\n"
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	string s;
	cin>>s;
	if (s[s.size()-1]=='s') cout<<s+"es"<<endl;
	else cout<<s+'s'<<endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  string S, T;
  llong A, B;
  string U;

  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  cout << A - (S == U) << " " << B - (T == U) << endl; 

  return 0;
}

Measured memory_bytes: 256
/*
* じょえチャンネル
* 高評価・チャンネル登録よろしくおねがいします！
* https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
*/

#include <bits/stdc++.h>


#define f(i,n) for(int i=0;i<(n);i++)


#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)

#define intt long long
#define P pair<int,int>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)

using namespace std;

//Library
//モッドパウ
int modpow(int x, int y, int m = mod) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
            res %= m;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}

int mypow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
        }
        x = x * x;
        y /= 2;
    }
    return res;
}
//is the number (x) a prime number?
bool prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (!(x % i)) {
            return false;
        }
    }
    return true;
}


//saidai-kouyakusuu
inline int gcd(int x, int y) {
    if (!y) {
        return x;
    }
    return gcd(y, x % y);
}


//number of keta
int keta(int x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}

//sum of keta
int ketasum(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

inline int lcm(int x, int y) {
    int ans = x / gcd(x, y) * y;
    return ans;
}
int twobeki(int x) {
    int ans = 0;
    while (1) {
        if (!(x & 1)) {
            ans++;
            x /= 2;
        }
        else {
            break;
        }
    }
    return ans;
}


template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
    if (lhs < rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
void YES(){
    cout<<"YES"<<endl;
}
void NO(){
    cout<<"NO"<<endl;
}


#define fin(i) scanf("%lld",&i)
#define fout(i) printf("%lld",i)
#define fendl printf("\n")
//Library-End

int n,m,s[10],c[10];
int did[10];
int ans[10],ta;
signed main() {
    cin>>n>>m;
    rep(i,m){
        cin>>s[i]>>c[i];
        if (s[i]==1) {
            if (c[i]==0) {
                if(n!=1){
                    cout<<-1<<endl;
                    return 0;
                }
            }
        }
        if (did[s[i]]) {
            if (ans[s[i]]!=c[i]) {
                cout<<-1<<endl;
                return 0;
            }else{
                continue;
            }
        }
        ans[s[i]]=c[i];
        did[s[i]]=1;
    }
    if (!ans[1]&&n>1) {
        ans[1]=1;
    }
    REP(i,n){
        ta+=ans[i]*mypow(10,n-i);
    }
    cout<<ta<<endl;
}


Measured memory_bytes: 256
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

S = input()
ans = int(S[0] == "R" and S[1] == "R") + int(S[2] == "R" and S[1] == "R") + 1
print(ans if "R" in S else 0)

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

using namespace std;

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

	int n;
	cin>>n;
	int num;
	map<int,int>cnt;
	long long sum=0;
	for(int i=0;i<n;++i)
	{
		cin>>num;
		sum+=num;
		cnt[num]++;
	}
	int m;
	cin>>m;
	for(int i=0;i<m;++i)
	{
		int a,b;
		cin>>a>>b;
		sum-=1LL*cnt[a]*a;
		sum+=1LL*cnt[a]*b;
		cnt[b]+=cnt[a];
		cnt.erase(a);
		cout<<sum<<'\n';
	}
}


Measured memory_bytes: 6580
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define iiUS unordered_set<ii>
#define ST stack<int>
#define MS multiset<int>
#define scan1(n) cin>>n
#define scan2(a,b) cin>>a>>b
#define scan3(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define vi vector<int>
#define vii vector<ii>
#define viii vector<iii>
#define fi first
#define se second
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,s,e) for(int i=s;i<e;++i)
#define REPS(i,s,e,st) for(int i=s;i<e;i+=st)
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define repr(i,s,e) for(int i=s;i>=e;--i)
#define reps(i,s,e,st) for(int i=s;i>=e;i-=st)
#define SET(arr,k) memset(arr,k,sizeof arr)
#define speed ios::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define pb push_back
#define Qu queue
#define Vt vector
#define Dq deque
#define prints(n) cout << n << " ";

void m1(){
  int n; cin >> n;
 if(n%1000 == 0) cout << 0;
  else cout << 1000 - n%1000;
}
/* 
void m2(){
  int t; scan1(t);
  while(t--) m1();
}
*/
 
signed main(){
  speed;
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int cnt[10][10];
signed main() {
    cin >> N;
    int ans = 0;
    reps(i, N) {
        string s = to_string(i);
        cnt[s[0] - '0'][s[s.length() - 1] - '0']++;
    }
    reps(i, N) {
        string s = to_string(i);
        ans += cnt[s[s.length() - 1] - '0'][s[0] - '0'];
    }
    cout << ans << 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++)

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    char c[H][W];
    int all = 0, h_cnt[H], w_cnt[W];
    rep(i,H) h_cnt[i] = 0;
    rep(j,W) w_cnt[j] = 0;
    rep(i,H) {
        rep(j,W) {
            cin >> c[i][j];
            if(c[i][j] == '#') {
                all++;
                h_cnt[i]++;
                w_cnt[j]++;
            }
        }
    }

    int ans = 0;
    rep(h_bit,1<<H) {
        vector<int> s;
        vector<int> t;
        rep(i,H) {
            if(h_bit & (1<<i)) s.push_back(i);
        }
        rep(w_bit,1<<W) {
            vector<int> t;
            rep(j,W) {
                if(w_bit & (1<<j)) t.push_back(j);
            }
            int cnt = all;
            rep(i,s.size()) cnt -= h_cnt[s[i]];
            rep(j,t.size()) cnt -= w_cnt[t[j]];
            rep(i,s.size()) {
                rep(j,t.size()) {
                    if(c[s[i]][t[j]] == '#') cnt++;
                }
            }
            if(cnt == K) ans++;
        }        
    }
    cout << ans << endl;
}

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

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

	int n;
	set <pair<int,int>> res;
	cin >> n;

	if(n%2==0)
	{
		int val = n;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(i==j || j==val)
				{
					continue;
				}
				if(i < j)
				{
					res.insert(make_pair(i,j));
				}
				else
				{
					res.insert(make_pair(j,i));
				}
			}
			val--;
		}
	}
	else
	{
		int val = n - 1;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(i==j || j==val)
				{
					continue;
				}
				if(i < j)
				{
					res.insert(make_pair(i,j));
				}
				else
				{
					res.insert(make_pair(j,i));
				}
			}
			val--;
		}
	}

	cout << res.size() << '\n';

	for(auto it : res)
	{
		cout << it.first << ' ' << it.second << '\n';
	}

    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void solve() {
		int n=s.nextInt();
		String str = s.next();
		String pattern = "ABC";
		int count = 0;
		for(int i=0;i<n-2;i++) {
			boolean ans = true;
			for(int j=i;j<=i+2 ;j++ ) {
				if(pattern.charAt(j-i)==str.charAt(j)) {
					
				}else {
					ans = false;
				}
			}
			if(ans )count++;
		}
		out.println(count);
	}

	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
	
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define DAU  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int n, q, op, x, y, res, p2[30], arb[2000002];
char ch;
string s;
inline void Update(int node, int st, int dr, int pos, int val) {
    if (st == dr) {
        arb[node] = val;
        return;
    }
    int mid = (st + dr) / 2;
    if (pos <= mid)
        Update(2 * node, st, mid, pos, val);
    else Update(2 * node + 1, mid + 1, dr, pos, val);
    arb[node] = (arb[2 * node] | arb[2 * node + 1]);
}
inline int Query(int node, int st, int dr, int l, int r) {
    if (l <= st && dr <= r)
        return arb[node];
    int mid = (st + dr) / 2, r1(0), r2(0);
    if (l <= mid)
        r1 = Query(2 * node, st, mid, l, r);
    if (mid < r)
        r2 = Query(2 * node + 1, mid + 1, dr, l, r);
    return (r1 | r2);
}
int main() {
    DAU
    p2[0] = 1;
    for (int i = 1; i < 30; ++i)
        p2[i] = p2[i-1] * 2;
    cin >> n >> s;
    for (int i = 1; i <= n; ++i)
        Update(1, 1, n, i, p2[s[i-1] - 'a']);
    cin >> q;
    for (int i = 1; i <= q; ++i) {
        cin >> op >> x;
        if (op == 1) {
            cin >> ch;
            Update(1, 1, n, x, p2[ch - 'a']);
        }
        else {
            cin >> y;
            cout << __builtin_popcount(Query(1, 1, n, x, y)) << '\n';
        }
    }
    PLEC
}


Measured memory_bytes: 7068
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x[] = new int[n];
        int y[] = new int[n];
        int h[] = new int[n];
        int Hindex = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextInt();
            if (h[i] != 0) {
                Hindex = i;
            }
        }
        // i,j を中心とする
        int H = 0; // 最終的な答え

        sc.close();
        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                H = h[Hindex] + Math.abs(i - x[Hindex]) + Math.abs(j - y[Hindex]);
                boolean ok = true;
                for (int k = 0; k < n; k++) {
                    // n個の情報全てが適しているか確かめる
                    if (Math.max(H - Math.abs(i - x[k]) - Math.abs(j - y[k]), 0) != h[k]) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    System.out.println(i + " " + j + " " + H);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 21844
import java.util.PriorityQueue;
import java.util.Scanner;

//Dangerous Bridge
public class Main {

	public static class E implements Comparable<E>{
		public boolean on;
		public int w;
		public int t;
		public E(boolean on, int w, int t) {
			this.on = on;
			this.w = w;
			this.t = t;
		}
		public int compareTo(E o) {
			if(o.t == t){
				return on?1:-1;
			}
			return t-o.t;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			PriorityQueue<E> q = new PriorityQueue<E>();
			for(int i=0;i<n;i++){
				int w = sc.nextInt();
				q.add(new E(true, w, sc.nextInt()));
				q.add(new E(false, w, sc.nextInt()));
			}
			int s = 0;
			boolean f = true;
			while(!q.isEmpty()){
				E e = q.poll();
				if(e.on){
					s += e.w;
					if(s>150){
						f = false;
						break;
					}
				}
				else{
					s -= e.w;
				}
			}
			System.out.println(f?"OK":"NG");
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
int main()
{
  int n, max;
  scanf("%d", &n);
  double a[10], sum = 0;

  for (int i = 0; i < n; ++i)
  {
    scanf("%lf", a+i);
    if (i==0)
    {
      max = i;
    }
    if(a[i] > a[max])
    {
      max = i;
    }
  }
  for (int i = 0; i < n; ++i)
  {
    sum += a[i];
    // if(i == max)
  }
      sum -= a[max]/2;
      // printf("max = %.0f\n", a[max]);
  if (sum == (int)sum)
    printf("%.0lf\n", sum);
  else
    printf("%lf", sum);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
const int maxn=2e5+10;
int a[maxn],b[maxn];
int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);cout.tie(0);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	sort(a+1,a+1+n);
 	sort(b+1,b+1+n);
 	if(n&1){
 		cout<<b[(n+1)/2]-a[(n+1)/2]+1<<endl;
	}else{
		cout<<(b[n/2+1]+b[n/2]-a[n/2+1]-a[n/2])+1<<endl;
	}
	 return 0;
}
/*
2
1 6
1 6
*/


Measured memory_bytes: 5328
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

int const MaxSize = 2e5 + 5;
LL const MOD = 1e9 + 7;
LL const BASE = 256;

/*
 effective painting classes
 1. no overlapping bands
 2. neighboring endpoints should have the same color

 how many ways we can paint in terms of eq classes?

 for each c,
 if never seen before, just update last seen, add the current number to

 if seen before,
 if there is no gap between cur and last - paint or not does not matter, just add that last num to cur ans
 if there is gap
 idea 1: paint , add that last seen number to cur ans
 idea 2: no paint, add that last one's number to cur ans

 */
int N;
int seen[MaxSize];
LL cnt[MaxSize];

int main() {
	ios_base::sync_with_stdio(false);
//	freopen("/Users/georgeli/A_1.in", "r", stdin);

	memset(seen, 0, sizeof(seen));
	//memset(first, 0, sizeof(first));
	cin >> N;

	cnt[0] = 1;

	LPE(i, 1, N)
	{
		int c;
		cin >> c;

		cnt[i] = cnt[i - 1];
		if (seen[c]) {
			if (seen[c] == i - 1) {
				//no gap, include that main or not does not matter
			} else {
				cnt[i] += cnt[seen[c]];
				cnt[i] %= MOD;
			}
		}

		seen[c] = i;
	}

	cout << cnt[N];

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN=1e5+5;
int a[MAXN];
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int h,n;
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		h-=a[i];
	printf("%s",h<=0?"Yes":"No");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

map<int,int> M;
int n;

int Pow(int a, int n){
    int ret = 1, pv = a;
    for(;n;n>>=1){
        if(n & 1) ret = (long long)ret * pv % mod;
        pv = (long long)pv * pv % mod;
    }
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 0, x; i < n; i++){
        cin >> x;
        ++M[x];
    }
    for(int i = 1; i <= n; i++){
        --M[abs((i-1) - (n-i))];
    }
    for(auto m : M) if(m.second) return !puts("0");
    cout << Pow(2, n/2) << '\n';
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>

using namespace std;

#define ll long long
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)

int main()
{
    int n;
    cin >> n;
    vector<int> a(n+1);
    
    for (int i = 1; i < n+1; i++)
    {
        cin>> a[i];
    }
    
    vector<int> ans(n+1);

    for (int i = 1; i < n+1; i++)
    {
        ans[a[i]] = i; 
    }
    for (int i = 1; i < n+1; i++)
    {
        cout << ans[i] << " ";
    }
    cout  << endl;
    
    

}

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

const int N = 11;

// int64_t str2num (string &str){
//     int64_t num;
//     int64_t num_0, num_1;

//     int order = str.size();
//     string num_str_0="";
//     string num_str_1="";
//     if (order < 9){
//         num = atoi(str.c_str());
//     }else{
//         cout << "order > 9" << endl;
//         for(int i=0; i<num-9; i++){
//             num_str_0 += str.at(i);
//         }
//         for(int i=num-9; i<num; i++){
//             num_str_1 += str.at(i);
//         }
//         num_0 = atoi(num_str_0.c_str());
//         num_1 = atoi(num_str_1.c_str());

//         num = num_0 * 1000000000 + num_1;
//     }

//     return num;
// }

int main(){
    string str;
    cin >> str;
    int n = str.size();

    int64_t sums_total=0;

    for (int64_t tmp = 0; tmp < (1 << n-1); tmp++) {
        bitset<N> s(tmp);
        vector<string> nums;
        int64_t sum=0;
        string num_str="";
        rep(i, n){
            if(s.test(i) || i==n-1){
                num_str += str.at(i);
                nums.push_back(num_str);
                num_str = "";
            }else {
                num_str += str.at(i);
            }
        }
        for(string num_str : nums){
            int64_t num = stol(num_str);
            sum += num;
        }
        sums_total += sum;
    }
    cout << sums_total << endl;
}


Measured memory_bytes: 256
void main()
{
    long n = readln.chomp.to!long;
    dchar[] s = readln.chomp.to!(dchar[]);
    dchar[] t = readln.chomp.to!(dchar[]);

    long len = 2 * n;
    foreach_reverse (i; 0 .. n)
    {
        if (s[i..$] == t[0..$-i])
        {
            len = i + n;
        }
    }

    len.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

signed main() {
	int n, a, b;
	
	cin >> n;
	if (n == 1) { cout << "Hello World" << endl; return 0; }
	cin >> a >> b;
	cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 764
/**
 *    author:  tourist
 *    created: 03.06.2018 15:16:04       
**/
#include <bits/stdc++.h>

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
  return (int) ((long long) a * b % md);
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, a, b, k;
  cin >> n >> a >> b >> k;
  vector<int> c(n + 1);
  c[0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i] = mul(c[i - 1], mul(n - i + 1, inv(i)));
  }
  int ans = 0;
  for (long long x = 0; x <= n; x++) {
    long long rm = k - a * x;
    if (rm < 0 || rm % b != 0) {
      continue;
    }
    long long y = rm / b;
    if (y >= 0 && y <= n) {
      add(ans, mul(c[y], c[x]));
    }
  }
  cout << ans << '\n';
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> T(N), A(N);
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> A[i];

    vector<int> H(N);
    vector<bool> D(N, false);
    H[0] = T[0];
    D[0] = true;
    rep(i, N - 1) {
        if (T[i] < T[i + 1]) D[i + 1] = true;
        H[i + 1] = T[i + 1];
    }

    if (D[N - 1] && H[N - 1] != A[N - 1]) {
        puts("0");
        return 0;
    }

    D[N - 1] = true;
    H[N - 1] = A[N - 1];

    for (int i = N - 2; i >= 0; --i) {
        if (A[i] > A[i + 1] && D[i] && H[i] != A[i]) {
            puts("0");
            return 0;
        }
        if (A[i] > A[i + 1] && H[i] < A[i]) {
            puts("0");
            return 0;
        }
        if (A[i] > A[i + 1]) D[i] = true;
        H[i] = min(H[i], A[i]);
    }

    ll ans = 1;
    rep(i, N) {
        if (!D[i]) {
            ans *= H[i];
            ans %= MOD;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
    
    using namespace std;
    
    using ll = long long;
    using ld = long double;
    using vi = vector<int>;
    using vvi = vector<vi>;
    using pii = pair<int, int>;
    using vpi = vector<pii>;

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

        int n;
        cin >> n;
        vi a(n);
        for (int &x : a) cin >> x;
        ll res = 0, cur = 0;
        for (int i = n - 1; i >= 0; i--) {
            res += cur * a[i];
            res %= (ll)1e9+7;
            cur += a[i];
            cur %= (ll)1e9+7;
        }
        cout << res << "\n";

        return 0;
    }

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

using namespace std;

const int N = 110;

int n;
int s[N];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", s + i);
  }
  int sum = 0;
  vector <int> v;
  for (int i = 0; i < n; ++i) {
    if (s[i] % 10 != 0) v.push_back(s[i]);
    sum += s[i];
  }
  if (sum % 10) {
    printf("%d\n", sum);
  } else {
    sort(v.begin(), v.end());
    if (v.empty()) {
      printf("%d\n", 0);
    } else {
      sum -= v[0];
      assert(sum % 10);
      printf("%d\n", sum);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define irep(i,a,b) for(typeof(i) i = (a); i < (b); ++i)
#define itrep(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)


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

	int N,K;
	cin >> N >> K;
	vector<int> A(N, 0);
	for (int i = 1; i <= K; i++) {
		int d;
		cin >> d;
		for (int j = 1; j <= d; j++) {
			int a;
			cin >> a;
			A.at(a - 1)++;
		}
	}
	
	int c = 0;
	for (int i = 0; i < N; i++) {
		if (A.at(i) == 0) c++;
	}

	cout << c << endl;
	return(0);
}


Measured memory_bytes: 3656
char out[1<<20];outsz;
char ffs[]="0101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110111011101010111011101110101011101010111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111010101110101011101110111010101110111011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101110111010101110111011101010111010101110101011101110111010101110101011101010111011101110101011101010111010101110111011101010111011101110101011101110111010101110101011101010111011101110101011101";
main(N,M){
	scanf("%d%d",&N,&M);
	for(int i=1;i<1<<N;i++)
	{
		for(int j=1;j<1<<M;j++)
		{
			out[outsz++]=ffs[i|j];
		}
		out[outsz++]='\n';
	}
	write(1,out,outsz);
}

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

int main()
{
    int n,sum=0,i,j;
    cin>>n;
    int arr[n+10];
    for(i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            sum = sum+arr[i]*arr[j];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#define ll long long int
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

#include "bits/stdc++.h"
using namespace std;

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

	ll m = n / 2;
	ll ans = 0;

	if (n % 2 == 1) {
		ans = 0;
	}
	else {
		while (m > 0) {
			ans += m / 5;
			m /= 5;
		}
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;
const int maxn = 100100; // 字符串最大长度
const int sz = 1010;     // 字符集最大ASCII码

// 下面五个都是求后缀数组时基数排序用的
int cntA[maxn];   
int cntB[maxn];
int A[maxn];
int B[maxn];
int tsa[maxn];

int sa[maxn];     // sa[i]表示字典序第i小的后缀的起始位置
int rk[maxn];       // rk[i]表示第i个字符开始的后缀字典序排第几
int height[maxn];   // height[i]表示字典序排第i的后缀与排第i-1的后缀的最长公共前缀长度
char ch[maxn];      // 待处理字符串，从1到n

// 传入字符串长度,求sa[]，rk[],height[]
void solve(int n)
{
    for (int i = 0; i < sz; i ++) cntA[i] = 0;
    for (int i = 1; i <= n; i ++) cntA[ch[i]] ++;
    for (int i = 1; i < sz; i ++) cntA[i] += cntA[i - 1];
    for (int i = n; i; i --) sa[cntA[ch[i]] --] = i;
    rk[sa[1]] = 1;
    for (int i = 2; i <= n; i ++)
    {
        rk[sa[i]] = rk[sa[i - 1]];
        if (ch[sa[i]] != ch[sa[i - 1]]) rk[sa[i]] ++;
    }
    for (int l = 1; rk[sa[n]] < n; l <<= 1)
    {
        for (int i = 0; i <= n; i ++) cntA[i] = 0;
        for (int i = 0; i <= n; i ++) cntB[i] = 0;
        for (int i = 1; i <= n; i ++)
        {
            cntA[A[i] = rk[i]] ++;
            cntB[B[i] = (i + l <= n) ? rk[i + l] : 0] ++;
        }
        for (int i = 1; i <= n; i ++) cntB[i] += cntB[i - 1];
        for (int i = n; i; i --) tsa[cntB[B[i]] --] = i;
        for (int i = 1; i <= n; i ++) cntA[i] += cntA[i - 1];
        for (int i = n; i; i --) sa[cntA[A[tsa[i]]] --] = tsa[i];
        rk[sa[1]] = 1;
        for (int i = 2; i <= n; i ++)
        {
            rk[sa[i]] = rk[sa[i - 1]];
            if (A[sa[i]] != A[sa[i - 1]] || B[sa[i]] != B[sa[i - 1]]) rk[sa[i]] ++;
        }
    }
    for (int i = 1, j = 0; i <= n; i ++)
    {
        if (j) j --;
        while (ch[i + j] == ch[sa[rk[i] - 1] + j]) j ++;
        height[rk[i]] = j;
    }
}   

bool check(int n, int K)
{
    int minsa = 1e9, maxsa = -1e9;
    for(int i = 1; i <= n; i ++)
        if(height[i] < K)
        {
            minsa = sa[i];
            maxsa = sa[i];
        }
        else 
        {
            minsa = min(minsa,sa[i]);
            maxsa = max(maxsa,sa[i]);
            if(maxsa-minsa >= K)
                return true;
        }
    return false;
}

int main()
{
    #ifdef AFei
    freopen("in.txt", "r", stdin);
    #endif

    int n;
    scanf("%d%s", &n, ch+1);
    
    solve(n);

    int l = 0, r = n;
    int ans = 0;
    while (l <= r)
    {
        int k = l + ((r-l) >> 1);
        if(check(n, k))
        {
            ans = k;
            l = k+1;
        }
        else
        {
            r = k-1;
        }
    }

    cout << ans << endl;
    

    return 0;
}

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

int main()
{
  int a = 0, b = 0;
  for(int i=0;i<3;i++)
  {
    char tmp;
    scanf(" %c", &tmp);
    if(tmp=='A') a++;
    else b++;
  }
  if(a==0||b==0) printf("No");
  else printf("Yes");
  return 0;
}

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

using namespace std;

#define ll long long

int main(void){
    int n, m;
    cin >> n >> m;

    vector<int> k(m), p(m);
    vector<vector<int>> s(m, vector<int>());
    for(int i = 0;i < m;++i){
        cin >> k[i];
        for(int j = 0;j < k[i];++j){
            int tmp;
            cin >> tmp;
            s[i].push_back(tmp);
        }
    }
    for(int i = 0;i < m;++i){
        cin >> p[i];
    }

    int bits_max = (int)pow(2.0, (double)n);
    int ans = 0;
    int on_flag = 1;
    for(int bits = 0;bits < bits_max;++bits){
        for(int i = 0;i < m;++i){
            int on_switch = 0;
            for(int j = 0;j < k[i];++j){
                if((bits >> (s[i][j]-1)) & 1){
                    on_switch += 1;
                } 
            }
            if(on_switch % 2 != p[i]){
                on_flag = 0;
                break;
            }
        }

        if(on_flag == 1){
            ans += 1;
        }
        on_flag = 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

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

    vector<int> S(N), T(M);
    rep(i, 0, N) cin >> S[i];
    rep(i, 0, M) cin >> T[i];

    vector<vector<ll>> dp(M+1, vector<ll>(N+1, 0));
    rep(m, 0, M)
        rep(n, 0, N)
        {
            dp[m+1][n+1] = dp[m][n+1] + dp[m+1][n] - dp[m][n];
            // cout << "***********" << endl;
            // cout << dp[m][n+1] << ' ' << dp[m+1][n] - dp[m][n] << endl;
            dp[m+1][n+1] %= MOD;
            if (dp[m+1][n+1] < 0) dp[m+1][n+1] += MOD;
            if (S[n] == T[m])
                dp[m+1][n+1] += dp[m][n] + 1;
            dp[m+1][n+1] %= MOD;
            // cout << m << ' ' << n << ' '<< dp[m+1][n+1] << endl;
        }
    cout << dp[M][N] + 1<< endl;
    return 0;
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,y; cin>>x>>y;
	cout<<(x%y==0 ? -1 : x)<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int A,B; cin>>A>>B;
    if(max(A,B)>=10) cout<<-1<<endl;
    else cout<<A*B<<endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 305;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int x;
	cin >> x;

	int cx = 600;
	int ans = 8;
	while (x >= cx) {
		cx += 200;
		ans--;
	}
	cout << ans;
}

Measured memory_bytes: 3504
#include <iostream>
using namespace std;
int main(void){
    for(int a=0;a<=10000;a++){
    int tate,yoko;
    cin>>tate>>yoko;
    if(tate==0&&yoko==0){
            break;
        }
    for(int i=1;i<=tate;i++){
        for(int j=1;j<=yoko;j++){
            cout<<"#";
        }cout<<endl;
        }cout<<endl;
    }
}


Measured memory_bytes: 3080
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
struct bridge
{
	int start,end;
}a[100010];
ll bcj[100010],lj[100010],ans[100010];
ll finds(ll x)
{
	if(bcj[x]==x)
		return x;
	return bcj[x]=finds(bcj[x]);
}
int main()
{
	ll n,m;
	cin>>n>>m;
	for(ll i=1;i<=n;i++)
	{
		bcj[i]=i;
		lj[i]=1;
	}
	for(ll i=0;i<m;i++)
		cin>>a[i].start>>a[i].end;
	ll sum=n*(n-1)/2;
	for(ll i=m-1;i>=0;i--)
	{
		ans[i]=sum;
		ll x=finds(a[i].start);
		ll y=finds(a[i].end);
		if(x!=y)
		{
			bcj[y]=x;
			sum-=lj[x]*lj[y];
			lj[x]+=lj[y];
		}
	}
	for(ll i=0;i<m;i++)
		cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <atcoder/all>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=300005;
//i_am_noob
int n,k,a[maxn],dp[maxn],x,ans=0;

struct segment_tree{
    vector<int> val,tag;
	int type;
	inline int mid(int l, int r){return l+r>>1;}
	segment_tree(int _siz, int _type){val.resize(4*_siz),tag.resize(4*_siz),type=_type;}
	inline int oper(int i, int j){
	    if(type==0) return i+j;
	    else if(type==1) return min(i,j);
	    else return max(i,j);
	}
	inline int def(){
	    if(type==0) return 0;
	    else if(type==1) return 4e18;
	    else return -4e18;
	}
	void pull(int k){val[k]=oper(val[k<<1],val[(k<<1)+1]);}
	void push(int k, int l, int r){
		if(l!=r){
            if(type){
                tag[k<<1]+=tag[k];
                tag[(k<<1)+1]+=tag[k];
                val[k<<1]+=tag[k];
                val[(k<<1)+1]+=tag[k];
            }
			else{
                tag[k<<1]+=tag[k];
                tag[(k<<1)+1]+=tag[k];
                val[k<<1]+=(mid(l,r)-l+1)*tag[k];
                val[(k<<1)+1]+=(r-mid(l,r))*tag[k];
			}
		}
		tag[k]=0;
	}
	void modify(int k, int l, int r, int ql, int qr, int x){
		if(l>qr||r<ql) return;
		if(ql<=l&&qr>=r){
			if(type) val[k]+=x;
			else val[k]+=(r-l+1)*x;
			tag[k]+=x;
			return;
		}
		push(k,l,r);
		modify(k<<1,l,mid(l,r),ql,qr,x);
		modify((k<<1)+1,mid(l,r)+1,r,ql,qr,x);
		pull(k);
	}
	int query(int k, int l, int r, int ql, int qr){
		if(l>qr||r<ql) return def();
		if(ql<=l&&qr>=r) return val[k];
		push(k,l,r);
		return oper(query(k<<1,l,mid(l,r),ql,qr),query((k<<1)+1,mid(l,r)+1,r,ql,qr));
	}
};
segment_tree stree(maxn,2);

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> k;
    rep(n) cin >> a[i];
    rep(n){
        dp[i]=stree.query(1,1,maxn-1,a[i]-k+1,a[i]+k+1)+1;
        x=stree.query(1,1,maxn-1,a[i]+1,a[i]+1);
        if(dp[i]>x) stree.modify(1,1,maxn-1,a[i]+1,a[i]+1,dp[i]-x);
    }
    rep(n) ans=max(ans,dp[i]);
    print1(ans);
    return 0;
}


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

int main(){
    int N;
    std::cin>>N;
    std::vector<long> A(N);

    for(auto i = A.begin();i != A.end();i++){
        std::cin>>*i;
    }

    int max = *std::max_element(A.begin(), A.end());
    int min = *std::min_element(A.begin(), A.end());

    std::cout<<max - min<<std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=2019;llfor;///////////////////////////////////////////////////////////
int main(){
 ll a,b,c;sc(a);sc(b);sc(c);
 pr(min(a*b,c));
return 0;}

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

int lcs[3010][3010] = {};
pair<int,int> path[3010][3010] = {};
int main(){
    string S,T;
    cin >> S >> T;

    for(int i=0;i<S.size();i++){
        for(int j=0;j<T.size();j++){
            if(S[i] == T[j]){
                lcs[i+1][j+1] = lcs[i][j] + 1;
                path[i+1][j+1] = {i, j};
            }
            else {
                lcs[i+1][j+1] = max(lcs[i+1][j], lcs[i][j+1]);
                if(lcs[i+1][j] >= lcs[i][j+1]) path[i+1][j+1] = {i+1, j};
                else path[i+1][j+1] = {i, j+1};
            }
        }
    }

    string ans = "";
    int len = lcs[S.size()][T.size()];

    pair<int,int> last = path[S.size()][T.size()];
    while(len != 0){
        if(len != lcs[last.first][last.second]){
            ans += S[last.first];
            len--;
        }
        last = path[last.first][last.second];
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 106368
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, D, X, A[110], an = 0, j = 0;
	scanf("%d%d%d", &N, &D, &X);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	an += X;
	for (int i = 0; i < N; i++) {
		j = 0;
		while (true) {
			if (A[i] * j + 1 > D) {
				break;
			}
			an++;
			j++;
		}
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int c[n],s[n],f[n];
    for (int i = 0;i<n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    c[n-1]=0;s[n-1]=0;f[n-1]=1;
    
    for (int x=0;x<n-1;x++){
        int ans=s[x];
        for (int i = x;i<n-1;i++){
            ans += c[i];
            if (ans%f[i+1]>0){
                ans+=(f[i+1]-ans%f[i+1]);
            }
            ans=max(ans,s[i+1]);
        }
        cout<<ans<<endl;
    }
    cout<<0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
a,b = LS()
if a == b:
    print("H")
else:
    print("D")
#B

#C
"""

x = I()
a = 0
i = 1
while a < x:
    a += i
    i += 1
print(i-1)
"""

#D
"""
n,k = LI()
a = LI(n)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512