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

using namespace std;

#define int long long
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;

inline void setMax(int &a, int b){ a = max(a, b); }
inline void setMin(int &a, int b){ a = min(a, b); }

signed main(){
    cin.tie(0); cout.tie(0); cin.sync_with_stdio(0); cout.sync_with_stdio(0);

    string a, b;
    cin >> a >> b;

    vvi pos(a.size()+1, vi(26, 1e9));
    for(int i=a.size()-1; i>=0; i--){
        for(int x=0; x<26; x++) pos[i][x] = pos[i+1][x];
        pos[i][a[i]-'a'] = i;
    }

    for(auto i : b) if(pos[0][i-'a'] == 1e9){
        cout << -1;
        return 0;
    }

    int sol = 0;
    int idx = 0;
    for(auto i : b){
        if(pos[idx][i-'a'] == 1e9){
            idx = 0;
            sol++;
        }
        idx = pos[idx][i-'a'] + 1;
    }

    cout << sol*a.size() + idx;
}

Measured memory_bytes: 24656
#include<stdio.h>
int main(void){
	int i,w,cnt,n,h[101],sa[5];
	while(scanf("%d",&n),n!=0){
		for(i=cnt=w=0;i<=n;i++)scanf("%d",&h[i]);
		sa[0]=h[1]-h[0];
		sa[1]=h[i-1]-h[i-2];
		sa[2]=h[(i-1)/2]-h[(i-1)/2-1];
		sa[3]=h[(i-1)/2+1]-h[(i-1)/2];
		if(sa[0]==sa[1] || sa[1]==sa[2] || sa[1]==sa[3])sa[4]=sa[1];
		if(sa[0]==sa[2] || sa[0]==sa[3])sa[4]=sa[0];
		for(i=1;i<=n;i++){
			if(h[i]-h[i-1]!=sa[4]){
				cnt++;
				if(cnt>1)w=h[i-1];
				if(h[i+1]-h[i]==sa[4])w=h[i-1];
				if(i==n && w<1)w=h[i];
			}
		}
		printf("%d\n",w);
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>

struct Node{
    int key;
    struct Node *prev,*next;
};

struct Node *nil;

struct Node* listSearch(int key){
    struct Node *cur=nil->next;
    while(cur!=nil&&cur->key!=key){
        cur=cur->next;
    }
    return cur;
}

void init(){
    nil=(struct Node *)malloc(sizeof(struct Node));
    nil->next=nil;
    nil->prev=nil;
}

void printList(){
    struct Node *cur=nil->next;
    int isf=0;
    while(1){
        if(cur==nil) break;
        if(isf++>0) printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}

void deleteNode(struct Node *t){
    if(t==nil) return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}

void deleteLast(){
    deleteNode(nil->prev);
}

void deletekey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    struct Node *x=(struct Node *)malloc(sizeof(struct Node));
    x->key=key;
    x->next=nil->next;
    nil->next->prev=x;
    nil->next=x;
    x->prev=nil;
}

int main(){
    int key,n,i;
    int size=0;
    char com[20];
    int np=0,nd=0;
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++){
        scanf("%s%d",com,&key);
        if(com[0]=='i') {insert(key);np++;size++;}
        else if(com[0]=='d'){
            if(strlen(com)>6){
                if(com[6]=='F') deleteFirst();
                else if(com[6]=='L') deleteLast();
            }else{
                deletekey(key); nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}



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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 1e5 + 55;

int n;
set<int> tot;
vector<int> g[maxN];
map<pair<int, int>, int> ans;

void dfs(int u, int par){
	int cur = 1;
	for(int i = 0, L = g[u].size(); i < L; i++){
		int v = g[u][i];
		if(v == par){
			continue;
		}

		if(cur == ans[make_pair(u, par)]){
			cur++;
		}
		
		tot.insert(cur);
		ans[make_pair(v, u)] = ans[make_pair(u, v)] = cur++;
		dfs(v, u);
	}
}

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

	cin >> n;

	vector<pair<int, int> > edg;

	for(int i = 1; i <= n - 1; i++){
		int a, b;	cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
		edg.push_back(make_pair(a, b));
	}

	dfs(1, 0);

	cout << (int)tot.size() << '\n';

	for(int i = 0; i < n - 1; i++){
		cout << ans[edg[i]] << '\n';
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int n,a,b; cin >> n >> a >> b;

	cout << min(a,b) << " " << max(0,a+b-n) << endl;

	return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>

using namespace std;

typedef long long LL;

int n,m;
LL k;
int x[110000];
int dx[110000];
int pp[110000];
LL ans[110000];
int a[110000],nn,id[110000];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&x[i]),dx[i-1]=x[i]-x[i-1],id[i]=i;
	scanf("%d %lld",&m,&k);
	for (int i=1;i<=m;i++)
	{
		int x;
		scanf("%d",&x);
		swap(id[x-1],id[x]);
	}
	for (int i=1;i<n;i++)
		if (!pp[i])
		{
			nn=0;
			int now=i;
			while (!pp[now]) a[nn++]=now,pp[now]=1,now=id[now];
			for (int j=0;j<nn;j++)
				ans[a[j]]=dx[a[((LL)j+k)%nn]];
		}
	ans[0]=dx[0];
	LL now=0;
	for (int i=1;i<=n;i++)
		printf("%lld.0\n",now+=ans[i-1]);
	return 0;
}

Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()



int h, w;
int ch, cw;
int dh, dw;
string s[1000];

int cost[1000][1000][3];


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

	cin >> h >> w;
	cin >> ch >> cw;
	cin >> dh >> dw;
	rep(i, h)cin >> s[i];
	ch--; cw--;
	dh--; dw--;

	rep(i, h)rep(j, w)rep(k, 3)cost[i][j][k] = INF;
	cost[ch][cw][0] = 0;

	deque<tuple<int, int, int>> q;
	q.emplace_back(ch, cw, 0);

	auto update = [&](int y, int x, int c, int v, bool f1, bool f2) {
		if (0 <= y && y < h && 0 <= x && x < w) {
			if (s[y][x] == '.' || f1) {
				if (v < cost[y][x][c]) {
					cost[y][x][c] = v;
					if (f2)q.emplace_back(y, x, c);
					else q.emplace_front(y, x, c);
				}
			}
		}
	};

	while (!q.empty()) {
		int y, x, c;
		tie(y, x, c) = q.front();
		q.pop_front();
		int co = cost[y][x][c];

		if (s[y][x] == '.') {
			update(y - 1, x, 0, co, false, false);
			update(y + 1, x, 0, co, false, false);
			update(y, x - 1, 0, co, false, false);
			update(y, x + 1, 0, co, false, false);
		}

		if (0 < c) {
			update(y , x, 0, co, false, false);
		}
		if (c < 2) {
			if (c == 0)co++;
			for (int i = -1; i <= 1;i++) {
				for (int j = -1; j <= 1; j++) {
					update(y + i, x + j, c + 1, co, true, c == 0);
				}
			}
		}
	}

	int ans = INF;
	rep(i, 3)ans = min(ans, cost[dh][dw][i]);

	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;


	return 0;
}


Measured memory_bytes: 16644
#include<bits/stdc++.h>
using namespace std;
int n,a,f[100001],ans;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        f[a-1]++,f[a+1]++,f[a]++;
    }
    for(int i=1;i<=100000;i++)
    {
        if(f[i]>ans) ans=f[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2) cout << "Odd\n";
    else cout << "Even\n";
}

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

int main(){
  int n,k;
  while(1){
    cin >> n >> k;
    if(n==0&&k==0) break;
    vector<int> card(n+1,0);
    for(int i=1;i<n+1;++i) card[i]=n-i+1;

    //for(int i=1;i<n+1;++i){
      //cout << card[i] << endl;
    //}

    for(int i=0;i<k;++i){
      int p,c;
      cin >> p >> c;
      rotate(card.begin()+1,card.begin()+p,card.begin()+p+c);
      for(int j=1;j<n+1;++j){
	//cout << card[j] << endl;
      }
    }
    cout << card[1] << endl;
  }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;i<(n);(i)++)
using namespace std;
 
int main(){
 int N,M,sum=0;
 cin>>N;
 int Nhai[N];
 rep(i,N)cin>>Nhai[i];
 cin>>M;
 int Mhai[M];
 rep(i,M)cin>>Mhai[i];
    vector <int> L;
    for (int bit = 0; bit < (1<<N); ++bit) {
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) {
               sum+=Nhai[i];
            }
        }
   L.push_back(sum); 
  sum=0;
    }
    
    sort(L.begin(),L.end());
    rep(i,M){
    if(binary_search(L.begin(),L.end(),Mhai[i]))
   cout<<"yes"<<endl;
   else cout<<"no"<<endl;
    }
  }








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

int main() {
  ll n,m,d;
  cin >> n >> m >> d;
  ll zero=0;
  double out=2*(n-d)*(m-1)/double(n)/double(n);
  if(d==0) {
    out/=2.0;
  }
  cout << fixed << setprecision(10) << out << endl;
}

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

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

    vector<vector<pair<int, int> > > p(n);
    vector<int> a;
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        a.push_back(k);
        for(int j = 0; j < k; j++){
            int l, m;
            cin >> l >> m;
            p[i].push_back(make_pair(l - 1, m));
        }
    }

    int ans = 0;
    int flag = 0;
    for(int bit = 0; bit < (1<<n); ++bit) {
        vector<int> S;
        for(int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        flag = 0;
        
        for(int i = 0; i < n; i++){
            if(a[i] != 0){
                auto itr = find(S.begin(), S.end(), i);
                if(itr == S.end()){ // iさんが正直者
                    for(int j = 0; j < p[i].size(); j++){
                        if(p[i][j].second == 1){ //p[i][j].firstさんが正直者
                            auto itr_2 = find(S.begin(), S.end(), p[i][j].first);
                            if(itr_2 != S.end()){
                                flag = 1;
                                break;
                            }
                        }else{
                            auto itr_2 = find(S.begin(), S.end(), p[i][j].first);
                            if(itr_2 == S.end()){
                                flag = 1;
                                break;
                            }
                        }
                    }
                }
                
                /*else{//iさんが嘘つき
                    for(int j = 0; j < p[i].size(); j++){
                        if(p[i][j].second == 1){ //正直者
                            auto itr_2 = find(S.begin(), S.end(), p[i][j].first);
                            if(itr_2 == S.end()){
                                flag = 1;
                                break;
                            }
                        }else{
                            auto itr_2 = find(S.begin(), S.end(), p[i][j].first);
                            if(itr_2 != S.end()){
                                flag = 1;
                                break;
                            }
                        }
                    }
                }*/
            }
        }

        if(flag == 0){
            if(ans < n - S.size()){
                ans = n - S.size();
            }
        }  
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,k,ans,Max = -1;
int a[300001 + 222],b[300002];
void solve(){
	cin >> k >> n;
	for(int i = 1;i <= n;i ++) scanf("%d",&a[i]);
	int dis = a[1],sum = 0;
	for(int i = 2;i <= n;i ++)
		b[i] = a[i] - a[i - 1],sum += b[i];
	b[1] = k - sum;
	for(int i = 1;i <= n;i ++) Max = max(b[i],Max);
	cout << k - Max << endl;
	return;
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N, x;
    cin >> N >> x;
    int a[N];
    rep(i, N) {
        cin >> a[i];
    }
    ll ans = 0;

    rep(i, N-1) {
        if(a[i]+a[i+1] <= x) {
            continue;
        }
        else if(a[i] <= x) {
            ans += a[i] + a[i+1] - x;
            a[i+1] = x - a[i];
        }
        else if(x < a[i]) {
            ans += (a[i] + a[i+1]) - x;
            a[i+1] = 0;
        }
    }
    
    cout << ans;
    
    cout << endl;
    return 0;
}

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

void print(std::vector<long long> v) {
    for (size_t i = 0; i < v.size(); i++) {
        std::cout << v[i] << ' ';
    }
    std::cout << '\n';
}

int main(int argc, char const *argv[]) {
    int N, K;
    std::cin >> N >> K;
    std::vector<long long> R{0}, L;
    long long x;
    for (size_t i = 0; i < N; i++) {
        std::cin >> x;
        if (x > 0) {
            R.push_back(x);
        } else if (x < 0) {
            L.push_back(x);
        } else {
            K--;
        }
    }
    L.push_back(0);
    reverse(begin(L), end(L));

    long long ans = 100000000000000;
    for (size_t i = std::max(0, K + 1 - (int)L.size());
         i < std::min((int)R.size(), K + 1); i++) {
        ans = std::min({2 * R[i] - L[K - i], R[i] - 2 * L[K - i], ans});
    }
    std::cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1656
import java.util.Scanner;

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

        long n = scan.nextLong();

        StringBuilder name = new StringBuilder();
        int surplus;
        for (; n > 0; n = (n - 1) / 26) {
            surplus = (int) ((n - 1) % 26);
            name.append((char) (surplus + 'a'));
        }
        
        for (int i = name.length(); i > 0; --i) {
            System.out.print(name.charAt(i - 1));
        }
    }
}

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

int main() {
  int N, a, b, c, d;
  
  cin >> N;
  a = N % 10;
  b = (N / 10) % 10;
  c = (N / 100) % 10;
  d = (N / 1000) % 10;
  
  if (b == c) {
    if (a == b || c == d)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else
    cout << "No" << endl;
}

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

using namespace std;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


long long gcd(long long a, long long b){
	if(b == 0) return a;
	return gcd(b, a%b);
}
long long lcm(long long a, long long b){
	return a/gcd(a, b)*b; // Be careful not to overflow
}



int main(void){

	int N; cin >> N;
	vector<long long int> T(N);

	REP(i,N) cin >> T[i];

	long long ans = T[0];
	FOR(i,1,N) ans = lcm(ans, T[i]);

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;
int dx[] = {-1,0,0,1};
int dy[] = {0,-1,1,0};
int w,h;
int sx,sy,gx,gy;
vector< pair<int,int> > ma[5];
int dp[5][1000];
int num;

int dis(pair<int,int> s1,pair<int,int> s2){
    return abs(s1.first - s2.first) + abs(s1.second - s2.second);
}

int rec(int now,int java){
    if(dp[now][java]) return dp[now][java];
    int ret = 100000,next = (now+1) % 5;
    if(now == num) ret = dis(ma[now][java],pair<int,int>(gy,gx));
    else REP(i,ma[next].size()){
	ret = min (ret,rec(next,i) + dis(ma[now][java],ma[next][i]));
    }
    return dp[now][java] = ret;
}

int main(){

    while(true){
	cin >> w >> h;
	if(w == 0 && h == 0) break;
	memset(dp,0,sizeof(dp));
	REP(i,5) ma[i].clear();
	REP(i,h)REP(j,w){
	    char f;
	    cin >> f;
	    if(f == 'S'){
		sx = j;
		sy = i;
	    }else if(f == 'G'){
		gx = j;
		gy = i;
	    }else if(f != '.') ma[f-'1'].PB(pair<int,int>(i,j));
	}

	pair<int,int> ret = pair<int,int>(100000,100000);
	REP(i,5){
	    REP(j,5)
		REP(k,1000) dp[j][k] = 0;
	    num = (i + 4) % 5;
	    int next = (i + 1) % 5,tmp = 100000;
	    REP(j,ma[next].size()){
		ret = min( ret, pair<int,int>(rec(next,j) + dis(pair<int,int>(sy,sx),ma[next][j]),i+1));
	    }
	}
	if(ret.first == 100000) cout << "NA" << endl;
	else cout << ret.second << " " << ret.first << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
ll mem[105][100005];
int n,w;
int weight[100005];
int price[105];
int INF=1000000000;

ll dp(int id,int w){
    if(w==0||id==n+1)return 0;
    if(w<0)return -INF;
    if(mem[id][w]!=-1)return mem[id][w];
    mem[id][w]=max(dp(id+1,w),dp(id+1,w-weight[id])+price[id]);
    return mem[id][w];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(mem,-1,sizeof(mem));
    cin>>n;
    cin>>w;
    for(int i=0;i<n;i++){
        cin>>weight[i];
        cin>>price[i];
    }
    cout<<dp(0,w)<<endl;

    return 0;
}


Measured memory_bytes: 82304
from collections import deque

N = int(input())
conn = [[] for _ in range(N + 1)]
for i in range(N - 1):
    u, v, w = [int(x) for x in input().split()]
    conn[u].append([v, w])
    conn[v].append([u, w])

q = deque([1])
d = [-1]* (N + 1)
d[1] = 0
while q:
    u = q.popleft()
    for e in conn[u]:
        v, w = e[0], e[1]
        if d[v] == -1:
            d[v] = d[u] + w
            q.append(v)

for v in range(1, N + 1):
    print(d[v] % 2)

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

int main (int argc, char *argv[])
{
  int n;
  vector<int> v;
  
  scanf("%d", &n);
  if(n % 2 != 0)
  {
    printf("0");
    return 0;
  }
  
  for(int i = 0; i < n; ++i)
  {
    int t;
    scanf("%d", &t);
    v.push_back(t);
  }
  sort(v.begin(), v.end());
  printf("%d", v[n/2] - v[n/2-1]);
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
//https://qiita.com/ysuzuki19/items/d89057d65284ba1a16ac
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e) { std::cout << e << std::endl; }

template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}

template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
//yosupo
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

int main() {
    int N, K;
    cin >> N >> K;
    V<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    auto b_search = [](V<int>& v, int k) -> int {
        int ng = 0, ok = 1000000010;
        //int Iteration_num = 0;
        while (abs(ok - ng) > 1) {
            //debug(ng);
            //debug(ok);
            int mid = (ng + ok) / 2;
            long long s = 0;
            for (int Ai : v) {
                s += ((long long)Ai + mid - 1) / mid - 1;
            }
            if (s > k)
                ng = mid;
            else
                ok = mid;
            //debug(mid);
            //debug(s);
            //++Iteration_num;
        }
        //cout << Iteration_num << endl;
        return ok;
    };

    cout << b_search(A, K) << endl;
    return 0;
}

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

void call(int n){
	int i,x;
	for(i=1;i<=n;i++){
		x=i;
		if ( x % 3 == 0 ){
			cout << " " << i;
		}else if( x % 10 == 3 ){
			cout << " " << i;
		}else{
			while(x /= 10){
				if( x % 10 == 3 ){
					cout << " " << i;
					break;
				}
			}	
		}
	}
	cout << endl;
}

int main(){
	int n;
	cin>>n;
	call(n);
	return 0;
}

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

int main() {
  string X; cin >> X;
  int stack = 0,pop = 0;
  for ( int i = 0; i < X.length(); i++ ) {
    if ( X[i] == 'S' ) stack++;
    else if ( stack > 0  ) stack--, pop++;
  }

  int ans = X.length() - pop*2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
void chmax(T& m, T x) {
	m = std::max(m, x);
}

template <typename T>
void chmin(T& m, T x) {
	m = std::min(m, x);
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

struct Interval {
	int s;
	int e;
	Interval() {}
	Interval(int s, int e) : s(s), e(e) {}
};

bool operator<(const Interval& lhs, const Interval& rhs) {
	return lhs.e < rhs.e;
}

std::vector<Interval> interval_scheduling(std::vector<Interval> intervals) {
	int n = intervals.size();
	std::vector<Interval> schedule;
	sort(intervals.begin(), intervals.end());
	int time = -INF;
	for(Interval i : intervals) {
		if(i.s >= time) {
			schedule.push_back(i);
			time = i.e;
		}
	}
	return schedule;
}

int main() {
	int n;
	scanf("%d", &n);
	VI x(n);
	VI l(n);
	REP(i, n) { scanf("%d %d", &x[i], &l[i]); }
	vector<Interval> intervals(n);
	REP(i, n) { intervals[i] = Interval(x[i] - l[i], x[i] + l[i]); }
	vector<Interval> schedule = interval_scheduling(intervals);
	printf("%d\n", schedule.size());
	return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>


using namespace std;
typedef long long ll;

int main(){

    string s;
    cin >> s;

    ll mn = abs(stoi(s.substr(0,3)) - 753);
    for(ll i = 2; i < s.length(); i++){
        ll t = stoi(s.substr(i - 2,3));
        if(mn > abs(t - 753)){
            mn = abs(t - 753);
        }
    }

    cout << mn << endl;
}

Measured memory_bytes: 256
MOD = 1000000007

n, k = map(int, input().split())
ans = [0 for i in range(k+1)]
for i in range(k,0,-1):
    t = 0
    for j in range(2*i, k+1, i):
        t = (t + ans[j]) % MOD
    ans[i] = (pow(k//i, n, MOD) - t + MOD) % MOD
sm = 0
for i in range(1, k+1):
    sm = (sm + (i*ans[i]) % MOD) % MOD
print(sm % MOD)


Measured memory_bytes: 77348
#include <iostream>

using namespace std;

int main(){
    int n, m, a, b, i, j, g;
    
    while(cin >> n >> m){
        a=n;b=m;i=2;j=2;
        while(a!=b){
            if(a<b) a=n*i++;
            else b=m*j++;
        }
        g = n*((float)m/a);
        cout << g << " " << a << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    ll n, k;
    cin >> n >> k;
    ll now = 1;
    rep(i, n) {
        now = min(now + k, now * 2);
    }
    cout << now << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var a, b, c int
	fmt.Fscanf(r, "%d %d %d\n", &a, &b, &c)

	if a < b {
		if a <= c && c <= b {
			fmt.Fprintln(w, "Yes")
			return
		}
	}
	if b <= c && c <= a {
		fmt.Fprintln(w, "Yes")
		return
	}

	fmt.Fprintln(w, "No")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      long double a, b;
      cin >> a >> b;
      long long temp=a*b;
      long double c=a*b-temp;
      cout <<fixed << setprecision(0)<<a*b-c<< endl;
      return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<4;i++)
    {
       cout<<s[i];
    }
    printf(" ");
    for(int i=4;i<12;i++)
    {
        cout<<s[i];
    }
    printf("\n");
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<queue>
#include<math.h>
#define ll long long
using namespace std;
const int maxn=250000;
int l[maxn],r[maxn],tot;
int check[30]={0};
int main()
{
    char str[maxn];
    scanf("%s",str);
    int len=strlen(str);
    r[0]=len-1;
    int now=26;

    for(int i=len-1;i>=0;i--)
    {
        if(!check[str[i]-'a'])
        {
            check[str[i]-'a']=1;
            now--;
            if(now==0)
            {
                l[tot++]=i;
                r[tot]=i-1;
                now=26;
                memset(check,0,sizeof(check));
            }
        }
    }

    l[tot]=0;
    char ch;
    int last=0;
    for(int i=tot;i>=0;i--)
    {
        int now=26;
        memset(check,0,sizeof(check));
        for(int j=last;j<=r[i];j++) check[str[j]-'a']=1;
        for(int j=0;j<26;j++)
        if(!check[j])
        {
            printf("%c",j+'a');
            ch=j+'a';
            break;
        }
        for(int j=last;j<len;j++)
        if(ch==str[j])
        {
            last=j+1;
            break;
        }
    }
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	double A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;

	double difA = abs(A - B);

 	double difV = V - W;
	bool ok = true;
 	if (difV <= 0){
 		ok = false; 		
 	}

	if (ok){
		double time = difA / difV;
		if (time > T){
			ok = false;
		}
	}


	if (ok){
		cout << "YES" << "\n";
	} else {
		cout << "NO" << "\n";		
	}

	return 0;
}


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

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


Measured memory_bytes: 256
N = int(input())
H = [int(h) for h in input().split()]

water = 0 #水あげた回数
h1 = 0
for n in range(N):
  h2 = H[n]
  if h1 < h2:
    water += (h2 - h1)
  h1 = h2

print(water)

Measured memory_bytes: 3060
N = int(input())
S = []
T = []
for i in range(N):
    s, t = input().split()
    t = int(t)
    S += [s]
    T += [t]
X = input()
flag = False
ans = 0
for i in range(N):
    if flag:
        ans += T[i]
    if S[i] == X:
        flag = True
print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int f=0;
    for(int i=0;s[i];++i){
        if(i&1){
            if(s[i]=='R')f=1;
        }
        else if(s[i]=='L')f=1;
    }
    if(f)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
int main(){
  double a,b;
  cin>>a>>b;
  int m = max(a/0.08+1,b/0.10+1);
  for (int i=1;i<=m;i++){
      double j =i;
      if((i*0.08>=a && i*0.08<a+1) && (i*0.10>=b && i*0.10<b+1)){
          cout <<i;
          return 0;
      }
  }
  cout << "-1";
}


Measured memory_bytes: 256
inlist = input().split()
a1, a2, a3 = (int(x) for x in inlist)

# a = input()
# a = int(a)

if a1 > a2:
    sub = a1
    a1 = a2
    a2 = sub

if a2 > a3:
    sub = a2
    a2 = a3
    a3 = sub

if a1 > a2:
    sub = a1
    a1 = a2
    a2 = sub

print(a1,a2,a3)


Measured memory_bytes: 5604
#ifndef UNION_FIND_HPP
#define UNION_FIND_HPP

#include <vector>
#include <utility>

//===
struct UnionFind {
    std::vector<int> parent;

    UnionFind() = default;
    UnionFind(int nmemb) {
        init(nmemb);
    };

    void init(int nmemb) {
        parent.clear();
        parent.resize(nmemb, -1);
    };

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

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

        if (x == y) return;

        if (parent[y] < parent[x]) std::swap(x, y);

        parent[x] += parent[y];
        parent[y] = x;
        
        return;
    };
    
    bool same(int x, int y) {
        return root(x) == root(y);
    };
    int size(int x) {
        return -(parent[root(x)]);
    };
};
//===

#endif

#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64 (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

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

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);

    repeat(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
    }

    int ans = 0;
    repeat(i, n) {
        if (uf.root(i) == i) ans++;
    }

    ans--;
    cout << ans << endl;

    return 0;
};


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

using std::cin;
using std::cout;
using std::endl;

int main()
{
    std::ios::sync_with_stdio(false);
    uint64_t N;
    cin >> N;
    uint64_t size = 3 * N;
    std::vector<uint64_t> v(size);
    for (uint64_t i = 0; i < size; ++i)
        cin >> v[i];
    std::sort(v.begin(), v.end());
    uint64_t sum = 0;
    for (uint64_t i = 1; i <= N; ++i)
    {
        sum += v[size - 2 * i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 2560
n,a,b,k=map(int,input().split())
s=0
m=998244353
f=[1]
r=[1]
 
for i in range(1,n+1):
  f+=[i*f[i-1]%m]
  r+=[pow(f[i],m-2,m)]

cb=lambda x,y:f[x]*r[x-y]*r[y]

for i in range(n+1):
  c,d=divmod(k-a*i,b)
  if d==0 and 0<=c<=n:
    s=(s+cb(n,i)*cb(n,c))%m

print(s)

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

using namespace std;

int main(void) {
  long long X; cin >> X;
  vector<int> prime;
 
  prime.push_back(1);
  for (int i = 1; i * i <= X; i++) {
    if (X%i == 0) {
      prime.push_back(i);
      prime.push_back(X/i);
    }
  }
  prime.push_back(X);

  for (int i = 0; i < prime.size(); i++) {
    long long b = -1, a = b+prime[i];
    long long c = X/prime[i];
    for (int i = -4800; i < 4800; ++i) {
      if (c == (a+i)*(a+i)*(a+i)*(a+i) + (a+i)*(a+i)*(a+i)*(b+i)
              +(a+i)*(a+i)*(b+i)*(b+i) + (a+i)*(b+i)*(b+i)*(b+i)
              +(b+i)*(b+i)*(b+i)*(b+i)) {
        cout << a+i << " " << b+i << endl;
        return 0;
      }
    }
  }

  return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    ll count = 0;
    vector<ll> sides (n);
    for(int i=0;i<n;i++){
        cin>>sides[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(sides[i] != sides[j]){
                for(int k=j+1;k<n;k++){
                    if(sides[j] != sides[k] && sides[i] != sides[k]){
                        if((sides[k] < (sides[j] + sides[i])) && (sides[j] < (sides[i] + sides[k])) && (sides[i] < (sides[j] + sides[k]))){
                            count++;
                        }
                    }
                }
            }       
        }
    }
    cout<<count;
}

Measured memory_bytes: 3608
import sys
N = list(input())
komoji = 0
oomoji = 0
if N[0] == 'A':
    if N[1].islower():
        for i in range(2, len(N)-1):
            if N[i] == 'C':
                oomoji += 1
            if N[i].islower():
                komoji += 1
        if N[-1].islower():
            komoji += 1
if oomoji == 1 and komoji == len(N) - 3:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main{

    public static void main(String args[]) throws IOException {
        BufferedReader ln = new BufferedReader(new InputStreamReader(System.in));
        String[] str = ln.readLine().split("\\s");

        Stack<Integer> que = new Stack<Integer>();
        int a = 0;
        int b = 0;
        for (int i = 0; i < str.length; i++) {
            if (str[i].equals("+")) {
                a = que.pop();
                b = que.pop();
                que.add(b + a);
                continue;
            }
            if (str[i].equals("-")) {
                a = que.pop();
                b = que.pop();
                que.add(b - a);
                continue;
            }
            if (str[i].equals("*")) {
                a = que.pop();
                b = que.pop();
                que.add(b * a);
                continue;
            }
            if (str[i].equals("/")) {
                a = que.pop();
                b = que.pop();
                que.add(b / a);
                continue;
            }
            que.push(Integer.parseInt(str[i]));
        }
        System.out.println(que.pop());
    }
}




Measured memory_bytes: 24500
#include<iostream>
using namespace std;
int main(){
	int N,normal,wari;;
	cin >> N;
	for(int i = 0; i < N; i++){
		int x,y,b,p;
		cin >> x >> y >> b >> p;
		normal = x * b + y * p;
		if(b < 5){
			b = 5;
		}
		if(p < 2){
			p = 2;
		}
		wari = (x * b + y * p) *8/10;

	if(normal < wari){
			cout << normal << endl;
		}
	else{
		cout << wari << endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define N 200000
int main(){
 
  int i,j,R[N],n,maxv=0,minv;
 
  scanf("%d",&n);
 
  for(j=0;j<n;j++) scanf("%d",&R[j]);
 
  minv = R[0];
  maxv = R[1] - R[0];
  for(j=1;j<n;j++){
    if( maxv < R[j]-minv ) maxv = R[j] - minv;
    else maxv = maxv;
    if( minv < R[j] ) minv = minv;
    else minv = R[j];
  }
 
  printf("%d\n",maxv);
  return 0;
}

Measured memory_bytes: 2632
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] W = new int[N];
        int sum = 0;
        for(int i = 0; i < N; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        sc.close();

        System.out.println(Balance(N, W, 0, 0, sum));
    }
    public static int Balance(int N, int[] W, int index, int f_sum, int B_sum) {
        if (f_sum + W[index] >= B_sum - W[index]) {
            int distA = B_sum - f_sum;
            int distB = (f_sum + W[index]) - (B_sum - W[index]);
            if (distA > distB) {
                return distB;
            }
            return distA;
        }
        return Balance(N, W, index + 1, f_sum + W[index], B_sum - W[index]);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str1, str2;
    cin >> str1;
    cin >> str2;
    //cout << str2.substr(0,str2.size() - 1) << endl;
    if (str1 == str2.substr(0,str2.size() - 1))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;


int main() {

	char moji;
	cin >> moji;
	cout << ++moji << endl;
	
	return 0;
}

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

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 200005;

int n;
int a[N], b[N];

int get(int x){
  int res = (x * (x - 1)) / 2;
  return res;
}

int32_t main(){
  
  ios_base::sync_with_stdio(0); cin.tie(NULL);
  cin >> n; int mx = 0;
  for(int i = 0; i < n; ++i){
    cin >> b[i];
    a[b[i]]++;
  }
  int res = 0;
  for(int i = 0; i < 200001; ++i){
    res += get(a[i]);
  }
	for(int i = 0; i < n; ++i){
	  int ans = res - get(a[b[i]]) + get(a[b[i]] - 1);
	  cout << ans << '\n';
  }
	
	return 0;
}




Measured memory_bytes: 4736
#include<iostream>

using namespace std;

int main(){
    int n, i, a, b;
    int v[100001]={}, v_2[100001]={};
    cin >> n;
    for(i=0;i<n/2;i++){
        cin >> a;
        cin >> b;
        v[a]++;
        v_2[b]++;
    }
    int o_1=0,o_2=0,e_1=0,e_2=0;
    int o_index=0,e_index=0;
    for(i=0;i<100001;i++){
        if(v[i]>o_1){
            o_index=i;
            o_2=o_1;o_1=v[i];
        } else if(v[i]>o_2){
            o_2=v[i];
        }
        if(v_2[i]>e_1){
            e_index=i;
            e_2=e_1;e_1=v_2[i];
        } else if(v_2[i]>e_2){
            e_2=v_2[i];
        }
    }
    if(o_index!=e_index){
        cout << n-o_1-e_1;
    } else {
        cout << min(n-o_1-e_2, n-o_2-e_1);
    }
    return 0;
    
}


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

int main(){
  string S;
  cin >> S;
  int ans_a = 0;
  for(int i=0; i<S.size(); i++){
    if(i %2 == 0){
      if(S.at(i) == '0'){
        ans_a++;
      }
    }
    else{
      if(S.at(i) == '1'){
        ans_a++;
      }
    }
  }
  
  int ans_b = 0;
  for(int i=0; i<S.size(); i++){
    if(i %2 == 0){
      if(S.at(i) == '1'){
        ans_b++;
      }
    }
    else{
      if(S.at(i) == '0'){
        ans_b++;
      }
    }
  }
  cout << min(ans_a,ans_b) << endl;
}

Measured memory_bytes: 512
n = int(input())
uvw = [tuple(map(int,input().split())) for i in range(n-1)]
to_dist = [[] for i in range(n)]
for u,v,w in uvw:
    u,v = u-1,v-1
    to_dist[u].append((v,w))
    to_dist[v].append((u,w))

visited = [0]* n
visited[0] = 1
ans = [0]*n
start_vertexes = [0]
 
while start_vertexes:
    start_vertex = start_vertexes.pop()
    for to, dist in to_dist[start_vertex]:
        if visited[to]: continue
        ans[to] = (ans[start_vertex]+dist)%2
        visited[to] = 1
        start_vertexes.append(to)
print(*ans, sep='\n')

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int main(){
	int n;
	cin >> n;
	set<int> d;
	rep(i,0,n){
		int a;
		cin >> a;
		d.insert(a);
	}

	int count = d.size();
	pout(count);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    int counter = 0;
    for (int i = 0; i < n; i++) {
        int mini = i;
        for (int j = i; j < n; j++) {
            if (a[mini] > a[j])
                mini = j;
        }
        if (i != mini) {
            swap(a[i], a[mini]);
            counter++;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << a[i];
        if (i < n - 1)
            cout << " ";
    }
    cout << '\n' << counter << '\n';

    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
using namespace std;
#include<string>
#include<cstdlib>

class stack
{
    int S[101], top, MAX;
public:
    stack();
	void initialize(){ top = 0; MAX = 101; }
	bool isFull(){ return top >= MAX - 1; }
	bool isEmpty(){return top == 0; }
    void push(int);
    int pop();
};

stack::stack(){}

void stack::push(int x)
{
    if(isFull()){
        cout << "overflow" << endl;
        return;
    }
    top++;
    S[top] = x;
}

int stack::pop()
{
    if(isEmpty()){
        cout << "underflow" << endl;
        return -1;
    }
    top--;
    return S[top + 1];
}

int main()
{
    stack s = stack();
    string t;
    s.initialize();
    int a, b;

    while(cin >> t){
        if(t == "EOF") break;
        if(t[0] >= '0'){
            s.push(atoi(t.c_str()));
        }else{
            b = s.pop();
            a = s.pop();
            if(t[0] == '+') s.push(a + b);
            if(t[0] == '*') s.push(a * b);
            if(t[0] == '-') s.push(a - b);
        }
    };
    cout << s.pop() << endl;

    return 0;
}

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

using namespace std;

int n;

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

    cin >> n;

    long long sum = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
            sum += i;
    }

    cout << sum;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<string,int> P;
int N,Q,K,X,Y,W,Max,I,ans;
const int A=777777,B=223456;
const int INF=1000000009;
 
char C[A]; 
int parent[A],Parent[A],node[A],Node[A],O[30];
int G[B]; P H[B];
int J[B];
int JJ[A];
int Cnt[A];
int table[30][30]; 
vector<int> ch[A],L[A];
string S[B],T[B],U[B],V[B],R[B];
 
void dfs(int s,int e,int j,int p){
    int x=S[s][j]-'a'; int k=s;
  for(int i=s; i<=e; i++){
    if(x!=S[i][j]-'a'){
      dfs(k,i-1,j,p); k=i;
      x=S[i][j]-'a'; 
    }
  }
     //cout<<x<<" "<<j<<" "<<I++<<" "<<p<<endl;
     if(x<0) node[I]=26;
     else node[I]=x;
     if(j==0) parent[I]=A-10;
     else parent[I]=p;
     I++;
    if(x<0) return;
    if(j<Max) dfs(k,e,j+1,I-1);
    return;
}
int Pr(int k){
  int p=parent[k];
  if(p==A-10) return A-10;
  if(ch[parent[p]].size()==1){
    return Pr(p);
  }else{
    return p;
  }
}
int cnt(int k){
  if(L[k].size()==0){
    Cnt[k]=1;
    return 1;
  }
  for(int i=0; i<L[k].size(); i++){
    Cnt[k]+=cnt(L[k][i]);
  }
    return Cnt[k];
}
void make(int k){
  if(L[k].size()==0){
    J[X]=node[k]; JJ[X]=k;
    X++;
    return;
  }
  for(int i=0; i<L[k].size(); i++){
    make(L[k][i]);
  }
  return;
}
void Find(int k){
  if(W>=V[G[K-1]].size()) return;
  if(L[k].size()==0) return;
  int s;
  if(V[G[K-1]][W]-'a'>=0) s=V[G[K-1]][W]-'a'; 
  else s=-INF;
  int t;
  for(int i=0; i<L[k].size(); i++){
     if(s==node[L[k][i]]){
      t=L[k][i]; 
     }
     if(node[L[k][i]]<26&&table[s][node[L[k][i]]]==0){
      ans+=Cnt[L[k][i]];
     }
     if(node[L[k][i]]==26){
      ans++;
      Find(L[k][i]); 
     }
  }
  W++; Find(t); 
  return;
}
 
int main(){
 
cin>>N; 

for(int i = 0; i < N; i++){
  scanf("%s", C);
  S[i] = string(C);
  if(S[i].size()>Max) Max=S[i].size();
}

if(N>1){
 
for(int i = 0; i < N; i++) U[i]=S[i];
 
sort(S,S+N);
 
dfs(0,N-1,0,A-10);  
 
for(int i = 0; i < I; i++) ch[parent[i]].push_back(i);
 
for(int i = 0; i < I; i++){
  int p=parent[i];
  if(ch[p].size()==1) node[i]=-INF;
}
 
for(int i = 0; i < I; i++){
  if(node[i]!=-INF){
    Parent[i]=Pr(i);
  }else{
    Parent[i]=-INF;
  }
}
 
for(int i = 0; i < I; i++){
  if(Parent[i]>=0) L[Parent[i]].push_back(i);
}
 
make(A-10); 
for(int i=0; i<N; i++){
  if(J[i]<=25){
    char c='a'+J[i];
    V[i]=c;
  }
  if(J[i]==26){
    V[i]="";
  }
  int k=JJ[i];
  while(1){
    if(Parent[k]==A-10) break;
    char c='a'+node[Parent[k]];
    V[i]=c+V[i];
    k=Parent[k];
  }
}
 
sort(V,V+N); 
for(int i=0; i<N; i++){
  H[i].first=U[i];
  H[i].second=i;
}
sort(H,H+N);
for(int i=0; i<N; i++){
  G[H[i].second]=i;
}
 
cnt(A-10);

}
 
cin>>Q;
 
for(int i=0; i<Q; i++){
  scanf("%d %s",&K,C);
  T[i] = string(C);
  for(int j=0; j<26; j++){
    O[T[i][j]-'a']=j;
  }
 for(int k=0; k<26; k++){
  for(int j=0; j<26; j++){
    table[k][j]=0;
  }
 }
 for(int k=0; k<26; k++){
  for(int j=0; j<26; j++){
   if(O[k]<=O[j]){
    table[k][j]=1;
   }else{
    table[k][j]=0;
   }
  }
 }
  X=0; I=0; ans=0; W=0;
  if(N==1) printf("%d\n",1);
  else{ 
    Find(A-10);
    printf("%d\n",ans+1);
  }
}
 
return 0;
 
}

Measured memory_bytes: 87552
R, G, B, N = map(int, input().split())
ans = 0
for r in range(0, N + 1, R):
    if r > N :
        break
    for g in range(r, N + 1, G) :
        if g > N :
            break
        b = (N - g) / B
        if b >= 0 and b.is_integer() :
            ans += 1
print(ans)


Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    long[] xs, ys, zs;
    foreach (_; 0..N) {
        auto xyz = readln.split.to!(long[]);
        xs ~= xyz[0];
        ys ~= xyz[1];
        zs ~= xyz[2];
    }

    long max_p;
    foreach (x; 0..8) {
        auto a = x&1 ? 1 : -1;
        auto b = x&2 ? 1 : -1;
        auto c = x&4 ? 1 : -1;

        auto DP = new long[][](N, M+1);
        foreach (ref dp; DP) dp[] = -1;
        long solve(int i, int m) {
            if (m == 0) return 0;
            if (i == N) return long.min/3;

            if (DP[i][m] == -1) {
                DP[i][m] = max(solve(i+1, m), solve(i+1, m-1) + xs[i]*a + ys[i]*b + zs[i]*c);
            }
            return DP[i][m];
        }
        max_p = max(max_p, solve(0, M));
    }
    writeln(max_p);
}

Measured memory_bytes: 35452