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

using namespace std;


int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n,m,a,b,c,flag,fa,fb,fc,fd;
    int x,y;
    flag = 0;
    a = -1; b = -1; c = -1;

    cin>>n>>m;

    for(int i=0;i<m;i++){

        cin>>x>>y;

        if(x==1){
            if(a==-1){
                a = y;
            } else {
                if(a != y) flag = 1;
            }
        }

        if(x==2){
            if(b==-1){
                b = y;
            } else {
                if(b != y) flag = 1;
            }
        }

        if(x==3){
            if(c==-1){
                c = y;
            } else {
                if(c != y) flag = 1;
            }
        }
    }

    if(flag){
        cout<<-1<<endl;
        return 0;
    }

    if(n==1){
        if(a==-1) a = 0;

        cout<<a<<endl;
        return 0;
    }

    if(n==2){
        if(b==-1) b=0;
        if(a==-1) a = 1;
        if(a==0){
            cout<<-1<<endl;
            return 0;
        }else{
            cout<<a<<b<<endl;
            return 0;
        }
    }

    if(a==-1) a = 1;
    if(b==-1) b = 0;
    if(c==-1) c = 0;

    if(a==0){
        cout<<-1<<endl;
        return 0;
    }

    cout<<a<<b<<c<<endl;

    return 0;
}


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

struct CARDS{
    char c;
    int n,in;
};

int partition(CARDS A[],int p,int r){
    int x = A[r].n;
    int i = p-1;
    for(int j=p;j<=r-1;j++){
        if(A[j].n<=x){
            i = i+1;
            CARDS s = A[i];
            A[i] = A[j];
            A[j] = s;
        }
    }
    CARDS c = A[i+1];
    A[i+1] = A[r];
    A[r] = c;
    return i+1;
}

void quicksort(CARDS A[],int p,int r){
    if(p<r){
        int q = partition(A,p,r);
        quicksort(A,p,q-1);
        quicksort(A,q+1,r);
    }
}

int main(){
    bool sta(true);
    int n;
    cin >> n;
    CARDS A[n];
    for(int i=0;i<n;i++){
        cin >> A[i].c >> A[i].n;
        A[i].in = i;
    }

    quicksort(A,0,n-1);

    for(int i=1;i<n;i++){
        if(A[i].n==A[i-1].n&&A[i].in<A[i-1].in){
            sta = false;    break;
        }
    }

    if(sta){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

    for(int i=0;i<n;i++){
        cout << A[i].c << " " << A[i].n << endl;
    }

    return 0;
}


Measured memory_bytes: 4264
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int n=0,s=0,sum=0;
            boolean end=false;
            while ((line = br.readLine()) != null) {
            	n=Integer.parseInt(line);
            	for(int i=1;i<n+1;i++){
            		int x=i;
            		while(true){
            			if(x%10==3){
            				System.out.print(" "+i);
            				break;
            			}else if(i%3==0){
                			System.out.print(" "+i);
                			break;
                		}
            			x/=10;
            			if(x==0)break;
            		}
            	}
            	System.out.println();
            	break;
            }
        }
    }

}

Measured memory_bytes: 26556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;

inline ll read()
{
	ll x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

const int N=100009;

ll n,l,mp;
ll a[N];

int main()
{
	n=read();
	l=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<n;i++)
	{
		if(a[i]+a[i+1]>=l)
		{
			puts("Possible");
			for(int j=1;j<i;j++)
				printf("%d\n",j);
			for(int j=n-1;j>=i;j--)
				printf("%d\n",j);
			return 0;
		}
	}

	puts("Impossible");
	return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h> 
#define MAX(a,b) ((a)>(b)?(a):(b)) 


int main()
{
	
	int pos[105];
	int n;
	int i,j,k;
	int sum=0,minsum=2147483647,min=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&pos[i]);
	for(i=1;i<=100;i++)
	{
		for(j=1;j<=n;j++)
		{
			sum+=(pos[j]-i)*(pos[j]-i);
		}
		if(sum<minsum)minsum=sum;
		sum=0;
	}
	printf("%d",minsum);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		while(true) {
			LinkedList<Integer> ans = new LinkedList<Integer>();
			for(int i=a;i<=b;i++) {
				if(i%400 == 0) ans.add(i);
				else if(i%100 != 0 && i%4 == 0) ans.add(i);
			}
			if(ans.isEmpty()) System.out.println("NA");
			else {
				for(int i:ans) {
					System.out.println(i);
				}
			}
			a = sc.nextInt();
			b = sc.nextInt();
			if( a == 0 && b == 0) break;
			System.out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#define ll long long int
using namespace std;

int main() {
	int N, K, test[200020];
	cin >> N >> K ;
	for (int i = 0; i < N; i++){
		cin >> test[i];
	}
	for (int i = 0; i < (N - K); i++){
		if (test[K + i] > test[i]){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll a, b;
    cin >> a >> b;
    cout << a * b << " " << 2 * (a + b) << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll h[101];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>h[i];

    ll cnt=0;
    ll l, r, mn;
    while(1){
        l=-1;
        REP(i, 0, n){
            if(h[i]!=0){
                l=i;
                break;
            }
        }

        if(l==-1){
            break;
        }
        mn=101;
        r=-1;
        REP(i, l, n){
            if(h[i]==0){
                r=i;
                break;
            }
            mn=min(mn, h[i]);
        }
        if(r==-1) r=n;

        REP(i, l, r){
            h[i]-=mn;
        }
        cnt+=mn;
    }

    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=4002;
int a[M],pos[2][M],dp[M][M];
char c[M];
std::vector<int> vec[2][M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=2*n;i++)
	{
		cin>>c[i]>>a[i];
		vec[0][i]=vec[0][i-1];
		vec[1][i]=vec[1][i-1];
		if(c[i]=='B')
			vec[0][i].pb(a[i]);
		else
			vec[1][i].pb(a[i]);
		sort(all(vec[0][i]));
		sort(all(vec[1][i]));
		if(c[i]=='B')
			pos[0][a[i]]=i;
		else
			pos[1][a[i]]=i;
	}
	dp[0][0]=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(i+j)
				dp[i][j]=1e9;
			// (i-1,j)
			if(i)
			{
				int z = pos[0][i];
				int x = (int)(upper_bound(all(vec[0][z]),i-1)-vec[0][z].begin());
				int	y = (int)(upper_bound(all(vec[1][z]),j)-vec[1][z].begin());
				int res = dp[i-1][j]+i-1-x+sz(vec[0][z])-x+j-y+sz(vec[1][z])-y;
				dp[i][j]=min(dp[i][j],res-1);
			}
			if(j)
			{
				int z = pos[1][j];
				int x = (int)(upper_bound(all(vec[0][z]),i)-vec[0][z].begin());
				int	y = (int)(upper_bound(all(vec[1][z]),j-1)-vec[1][z].begin());		
				int res = dp[i][j-1]+i-x+sz(vec[0][z])-x+j-1-y+sz(vec[1][z])-y;
				dp[i][j]=min(dp[i][j],res-1);
			}
		}
	}
	cout<<dp[n][n]/2<<"\n";
	return 0;
}

Measured memory_bytes: 78336
#include <iostream> 
using namespace std; 
int Min,Max;
long Sum;
int N,A[10000];
int main() 
{
   cin >> N;
   for (int i=0; i<N; ++i)
      cin >> A[i];
    Min=Max=Sum=A[0];
    for (int i=1; i<N; ++i)
    {
        if(Min>A[i])
          Min=A[i];
        if(Max<A[i])
          Max=A[i];
        Sum=A[i]+Sum;
    }
    cout << Min << ' ' << Max << ' ' << Sum << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(char c = 'a'; c <= 'z'; c++) {
        if(count(ALL(s), c) == 0) {
            cout << c << "\n";
            return 0;
        }
    }
    cout << "None\n";
}

Measured memory_bytes: 3784
n = int(input())
a = list(map(int,input().split()))
b = {}
for i in a:
    if i in b.keys():
        b[i] += 1
    else:
        b[i] = 1
c = sorted(b.items())
m = len(c)
if m == 1:
    print(c[0][1])
elif m == 2:
    if c[1][0] - c[0][0] < 3:
        print(c[0][1] + c[1][1])
    else:
        print(max(c[0][1],c[1][1]))
else:
    s = 0
    for i in range(m-2):
        t = c[i][1]
        if c[i+2][0] - c[i][0] < 3:
            t += (c[i+1][1] + c[i+2][1])
        elif  c[i+1][0] - c[i][0] < 3:
            t += c[i+1][1]
        if t > s:
            s = t
    print(s)


Measured memory_bytes: 15520
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        for(int i = 0; i < Math.max(a, b); i++){
            System.out.print(Math.min(a, b));
        }
        scan.close();
    }
}

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


int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    ll x,y;
    cin>>x>>y;
    ll min=2*x;
    ll max=4*x;
    if(y%2==0 &&(y>=min && y<=max))
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
	return 0;
}
	

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

const int MAXN = 2e5 + 10;
const int MAXM = 4e5 + 10;

struct Node {
	int pos, id;
	bool operator < (const Node & obj) {return pos < obj.pos;}
} a[MAXN], b[MAXN];

struct Edge {
	int u, v, w;
	bool operator < (const Edge & obj) {return w < obj.w;}
} e[MAXM];
int tot;

inline void addEdge (int u, int v, int w) {
	e[++tot] = (Edge){u,v,w};
}

int fa[MAXN];
int findSet (int x) {return fa[x] == x ? x : fa[x] = findSet(fa[x]);}
void unionSet (int x, int y) {int xx = findSet(x), yy = findSet(y); if (xx != yy) fa[yy] = xx;}
void initSet (int n) {for (int i = 1; i <= n; i++) fa[i] = i;}

long long kruskal (int n) {
	initSet(n);
	sort(e+1,e+tot+1);

	long long ret = 0;
	for (int i = 1, cnt = 0; i <= tot; i++) {
		int xx = findSet(e[i].u);
		int yy = findSet(e[i].v);
		if (xx != yy) {
			fa[yy] = xx;
			ret += e[i].w;
			if (++cnt == n - 1) return ret;
		}
	}
	return ret;
}

int main (void) {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &a[i].pos, &b[i].pos);
		a[i].id = b[i].id = i;
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	for (int i = 1; i <= n; i++) {
		if (i + 1 <= n) {
			addEdge(a[i].id,a[i+1].id,a[i+1].pos - a[i].pos);
			addEdge(a[i+1].id,a[i].id,a[i+1].pos - a[i].pos);
			addEdge(b[i].id,b[i+1].id,b[i+1].pos - b[i].pos);
			addEdge(b[i+1].id,b[i].id,b[i+1].pos - b[i].pos);
		}
		if (i - 1 >= n) {
			addEdge(a[i].id,a[i-1].id,a[i].pos - a[i-1].pos);
			addEdge(a[i-1].id,a[i].id,a[i].pos - a[i-1].pos);
			addEdge(b[i].id,b[i-1].id,b[i].pos - b[i-1].pos);
			addEdge(b[i-1].id,b[i].id,b[i].pos - b[i-1].pos);
		}	
	}
	printf("%lld\n", kruskal(n));
}

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

void maxHeapify(vector<int> &A,int H,int i){
    int l=i*2;
    int r=i*2+1;
    int largest;
    if(l<=H&&A[l]>A[i]){
        largest=l;
    }
    else{
        largest=i;
    }
    if(r<=H&&A[r]>A[largest]){
        largest=r;
    }
    if(largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A,H,largest);
    }
}

void buildMaxHeap(vector<int> &A,int H){
    for(int i=H/2;i>0;i--){
        maxHeapify(A,H,i);
    }
}

int main(){
    int H;
    cin>>H;
    vector<int> A(500001);
    for(int i=1;i<H+1;i++){
        cin>>A[i];
    }

    buildMaxHeap(A,H);

    for(int i=1;i<H+1;i++){
        cout<<' '<<A[i];
    }
    cout<<endl;
}


Measured memory_bytes: 4688
import sys
input = sys.stdin.readline  # NOQA
sys.setrecursionlimit(10 ** 7)  # NOQA


def dfs(G, v, p, counter):
    """G: graph, v: vertex, p: parent"""
    # Loop for each child
    counter_v = counter[v]
    for c in G[v]:
        if c == p:
            continue  # Avoid multiple access to parent
        counter[c] += counter_v
        dfs(G, c, v, counter)


def main():
    N, Q = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)

    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    dfs(G, 0, -1, counter)
    # print(*counter)
    print(" ".join(map(str, counter)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 232212
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int n, m;

int main(void){
	
	scanf("%d %d", &n, &m);
	printf("%d\n", (n - 1) * (m - 1));
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vstr(v,n) vector<string> v(n); REP(i,n) scanf("%lld", &v[i]);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}
//階乗
int factorial(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
int k=0,n=0, m=0, l=0,r=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    cin >> n;
    k = factorial(n);
    vector<int> v(n);
    vint(P,n);
    vint(Q,n);
    REP(i, n)
    {
        v[i] = i + 1;
    }
    do{
       ans++;
       if(v==P){
           a = ans;
       }
       if(v==Q){
           b = ans;
       }
   } while (std::next_permutation(v.begin(), v.end()));

   cout << abs(a - b);
}

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


void solve() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

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


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

int main () {
	int n;
	int m;
	cin >> n >> m;
	int height[n + 1];
	bool ans[n + 1];
	for(int i = 1; i <= n; i++) {
		ans[i] = true;
		cin >> height[i];
	}
	for(int i = 0; i < m; i++) {
		int a;
		int b;
		cin >> a >> b;
		if(height[a] >= height[b]) {
			ans[b] = false;
		}
		if(height[b] >= height[a]) {
			ans[a] = false;
		}
	}
	int res = n;
	for(int i = 1; i <= n; i++) {
		if(ans[i] == false) res -= 1;
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 4124
import java.util.*;

class Main{
    public static void main(String arg[]){
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
      
        int sum = A + B;
        int difference = A - B;
        int product = A * B;
        
        //上記の最大値を出力
        System.out.println(Math.max(product, Math.max(sum, difference)));
    }
}

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

int main(){
  double n; int a=0, b=0; cin >>n;
  vector<int>v(n);
  for(int i=0; i<n; i++)
  {cin >>v[i]; a+=v[i];}

  double c=a/n; int p;
  if(c-floor(c)<0.5){p=floor(c);}
  else{p=floor(c)+1;}

  for(int i=0; i<n; i++)
  {b+=(v[i]-p)*(v[i]-p);}

  cout <<b;

return 0;
}

Measured memory_bytes: 256
n = int(input())
HH = list(map(int, input().split()))
cnt = 0
for i,H in enumerate(HH):
    flg = True
    if i == 0:
        pass
    else:
        for H2 in HH[:i]:
            if H < H2:
                flg = False
                break
    
    if flg:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>
#define MAX 100000
#define SEN 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX/2 + 2], R[MAX/2 + 2];

int partition(struct Card A[], int p, int r)
{
    int i, j;
    struct Card x = A[r];
    struct Card t;
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    return i + 1;
}

void quick_sort(struct Card A[], int p, int r)
{
    if (p < r) {
        int q = partition(A, p, r);
        quick_sort(A, p, q-1);
        quick_sort(A, q+1, r);
    }
}

void merge(struct Card A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1].value = R[n2].value = SEN;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
    }
}

void merge_sort(struct Card A[], int left, int right)
{
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int is_stable(struct Card C1[], struct Card C2[], int n)
{
    for (int i = 0; i < n; i++) {
        if (C1[i].suit != C2[i].suit) return 0;
    }
    return 1;
}

int main(int argc, char const *argv[])
{
    int n;
    struct Card C1[MAX];
    struct Card C2[MAX];
    char S[10];
    int v;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s %d", S, &v);
        C1[i].suit  = S[0];
        C1[i].value = v;
        C2[i].suit  = S[0];
        C2[i].value = v;
    }
    merge_sort(C1, 0, n);
    quick_sort(C2, 0, n - 1);
    if (is_stable(C1, C2, n)) {
        printf("Stable\n");
    } else {
        printf("Not stable\n");
    }
    for (int i = 0; i < n; i++) {
        printf("%c %d\n", C2[i].suit, C2[i].value);
    }

    return 0;
}




Measured memory_bytes: 4036
N = int(input())
a = list(map(int, input().split()))
a1 = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
    if i % 2 == 0:
        Alice += a1[i]
    else:
        Bob += a1[i]
print(Alice - Bob)

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

int main(){
  int d, ans;
  while(scanf("%d", &d)!=EOF){
    ans=0;
    for(int i=d; i<600; i+=d) ans+=pow((double)i, 2.0)*d;
    printf("%d\n", ans);
  }
  return 0;
}

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

int main(){
  int r, D, x[100];
  cin >> r >> D >> x[0];
  
  for (int i=0; i<10; i++){
    x[i+1] = r*x[i] - D;
    cout << x[i+1] << endl;
  }
  
  return 0;
}

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

using namespace std;



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

	int n;
	cin >> n;

	string res = "";

	while (n != 0) {
		int rem = n % (-2);
		n /= -2;

		if (rem < 0) {
			rem += 2;
			++n;
		}

		res = to_string(rem) + res;
	}

	if (res == "") res = "0";
	cout << res << "\n";

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//トライ木って何よ
int T[100001][2];
char D[100001];

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


	int N;
	ll L;
	scanf("%d", &N);
	scanf("%lld", &L);
	getchar_unlocked();
	int k = 0;
	rep(i, N) {
		int mae = 0;
		ll d = L;
		char c;
		while ((c = getchar_unlocked()) >= '0') {
			int C = c - '0';
			if (!T[mae][C]) {
				T[mae][C] = ++k;
				D[k] = __builtin_ctzll(d);
			}
			mae = T[mae][C];
			d--;
		}
	}
	ll kotae = 0;
	rep1(i, k) {
		kotae ^= 1ll << D[i];
	}

	if (kotae) printf("Alice\n");
	else printf("Bob\n");

	Would you please return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun



int main() {
	
	unsigned char c;
	cin >> c;
	if (c >= 97) cout << "a" << endl;
	else cout << "A" << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>

int main(void){
	
	int x,y;
	scanf("%d %d",&x,&y);
	
	int a,b;
	
	if(x>y){
		a=x;
		b=y;
	}
	else{
		a=y;
		b=x;
	}
	
	int c;
	
	while(a%b!=0) {

		c = b;
		b = a%b;
		a = c;

	}
	
	printf("%d\n",b);

	
	return 0;

}


Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;


int main() {
    int x, y;
    cin >> x >> y;
    vector<int> a{1,3,1,2,1,2,1,1,2,1,2,1};
    if (a.at(x - 1) == a.at(y - 1)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int n; cin >> n;
  vector<int> vec(n);
  for (int& h: vec) cin >> h;
  reverse(vec.begin(), vec.end());
  
  int ans = 0, len = 0, prev = 0;
  for (int h: vec) {
    if (h < prev) len = 0;
    prev = h;
    len++;
    ans = max(ans, len);
  }
  ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
integer N,K
character,allocatable,dimension(:)::a
read*,N,K
allocate(a(k))
read*,a

do
  if(check(N,a))exit
  N=N+1
end do

print"(i0)",N

contains
pure function check(N,a)
  integer,intent(in)::N
  character,intent(in)::a(:)
  character(6)B
  logical check
  check=.TRUE.
  write(B,"(i0)")N
  do i=1,size(a)
    if(index(B,a(i))/=0)check=.false.
  end do
end function check
end

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

map<int,int> m;

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

    int N;
    std::cin >> N;

    ll res = 1ll;

    for(int j=1;j<=N;++j){
        int n = j;
        
        for(int i=2;i*i<=n;++i){
            while(n % i == 0){
                n /= i;
                ++m[i];
            }
        }

        if(n > 1){++m[n];}
    }

    for(auto &p : m){
        int x;
        tie(ignore, x) = p;

        res = res * (x + 1) % (1000000000ll + 7);
    }
    
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;
ll MOD = 1000000007;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

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

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// ***************************************


int main(void) {

	ll N, X, Y;
	cin >> N >> X >> Y;

	vector<ll> ans(N-1);
	FOR(i, 1, N) {
		FOR(j, i + 1, N + 1) {
			ll d = min(j - i, abs(X - i) + abs(Y - j) + 1);
			ans[d - 1]++;
		}
	}

	for(auto& a: ans) {
		cout << a << endl;
	}


	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp12            make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq1             priority_queue<int>
#define pqr1            priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int modInv(int a,int b,int m){int res=1;a=a%m;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b=b>>1;}return res;}
int dp[100005];

int dfs(int src,vector<int> g[]){
    if(dp[src]!=-1) return dp[src];

    int ans=0;
    for(auto x:g[src]){
        ans=max(ans,dfs(x,g));
    }
    return dp[src]=ans+1;
}

void solve(){
	int n,m;
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    vector<int> g[n+1];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
    }
    int ans=0;
	for(int i=1;i<=n;i++){
        ans=max(ans,dfs(i,g));
    }
    cout<<ans-1;
}
    

int32_t main()
{
    //FIO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    solve();


    return 0;
}


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

int h, n, x, e, w;
int main() {
	scanf("%d%d", &h, &n);
    for (register int i=1; i<=n; ++i) {
        scanf("%d", &x); w += x;
    }
	cout << ((w >= h) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main(){
  int n, a, b;
  string s;
  int cnt=0;
  int cnt_b=0;
  cin >> n >> a >> b;
  cin >> s;
  
  rep(i, (int)s.length()){
    if(s[i] == 'a'){
      if(a + b > cnt){
	cnt++;
	cout << "Yes" << '\n';
      }else{
	cout << "No" << '\n';
      }
    }else if(s[i] == 'b'){
      if(a + b > cnt && b > cnt_b){
	cnt++;
	cnt_b++;
	cout << "Yes" << '\n';
      }else{
	cout << "No" << '\n';
      }
    }else{
      cout << "No" << '\n';
    }
  }
}


Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	long long int x, y;
	cin >> x >> y;
	int ans = 0;
	while(x <= y){
		x *= 2;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  set<int> S;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    v[i] = a - 1;
  }
  int now = 0;
  int res = -1;
  int cnt = 0;
  while (S.find(v[now]) == S.end()) {
    S.insert(v[now]);
    now = v[now];
    cnt++;
    if (now == 1) res = cnt;
  }
  cout << res << endl;
}

Measured memory_bytes: 5376
import std.array;
import std.conv;
import std.string;
import std.algorithm;
import std.stdio;

void main() {
	auto length = readln.chomp.to!uint;
	auto a = readln.chomp.split(" ").map!(to!uint).array;
	assert(length >= 1);
	assert(a.length == length);

	a.sort;

	if (a[0] == 1) {
		if (a.length >= 2 && a[1] == 1) {
			writeln("0");
			return;
		} else {
			writeln("1");
			return;
		}
	}

	auto sieve = new bool[1000008];

	foreach (size_t i, e;a) {
		if (i >= 1 && e == a[i - 1]) {
			sieve[e] = true;
			continue;
		}
		for (uint j = e + e;j < sieve.length;j += e) {
			sieve[j] = true;
		}
	}

	uint answer;
	foreach (e;a) {
		if (!sieve[e]) {
			++answer;
		}
	}
	writeln(answer);
}


Measured memory_bytes: 11924
#include <iostream>

using namespace std;

int main()
{
    int a[5];
    int ans = 0;
    for (int i = 0;i < 5;i++){
        cin >> a[i];
        if (a[i] == 0) ans = i + 1;
    }
    cout << ans <<endl;
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> v(N, 0);
  for(int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for(int j = 0; j < d; j++) {
      int n;
      cin >> n;
      v[n-1]++;
    }
  }
  int ans = 0;
  for(const auto& e: v) {
    if(e==0) ans++;
  }
  
  cout << ans << endl;
 return 0; 
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);


		String str = sc.next();

		if(str.length() == 3) {
			StringBuffer reverseStr = new StringBuffer(str);
	         str = reverseStr.reverse().toString();
		}

		System.out.println(str);

	}
}

Measured memory_bytes: 21716
n = int(input())
a = list(map(int,input().split()))
q = int(input())
b,c = [0]*q,[0]*q
for i in range(q):
  b[i],c[i] = map(int,input().split())
numdic = {}
for i in range(n):
  if a[i] in numdic:
    numdic[a[i]] += 1
  else:
    numdic[a[i]] = 1
sum = 0
for x in numdic:
  sum += x*numdic[x]
for i in range(q):
  if b[i] in numdic:
    sum += (c[i]-b[i]) * numdic[b[i]]
    if c[i] in numdic:
      numdic[c[i]] += int(numdic[b[i]]) 
    else:  
      numdic[c[i]] = int(numdic[b[i]])
    del numdic[b[i]]
  print(sum)

Measured memory_bytes: 26892
#include <stdio.h>
int main (void){
  int a[10];
  scanf("%5d",&a[0]);
  scanf("%5d",&a[1]);
  scanf("%5d",&a[2]);
  if((a[0]==a[1] && a[0]!=a[2] && a[1]!=a[2])||
     (a[0]!=a[1] && a[0]==a[2] && a[1]!=a[2])||
     (a[0]!=a[1] && a[0]!=a[2] && a[1]==a[2])){
  printf("Yes");
  }else{
  printf("No");}
	return(0);
}

Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

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

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

    if(a * b % 2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
// glory be to the sky
#include<bits/stdc++.h> 
#define pb push_back
using namespace std;
	
typedef long long ll; 


int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);

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

	if ((a[(int)a.length() - 1] == b[0]) && b[(int) b.length() - 1] == c[0]) cout << "YES";
	else cout << "NO";
	return 0;	
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int gcd(int a, int b) {
    int t = a % b;
    while (t) {
        a = b;
        b = t;
        t = a % b;
    }
    return b;
}
int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);//incompatible with `while (cin >> ...)'
    int N, X;
    cin >> N >> X;
    int x[N];
    map<int, int> diff;
    map<int, int>::iterator it;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
        diff.insert(pair<int, int>(abs(X - x[i]), 0));
    }
    int size = diff.size();
    it = diff.begin();
    int a = it -> first;
    it++;
    for (int i = 1; i < size; i++) {
        int b = it -> first;
        a = gcd(a, b);
        it++;
    }
    cout << a << endl;
    return 0;
}

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

struct union_find{
	int N;
	vector<int> parent;
	vector<int> siz;

	union_find(int N) : parent(N), siz(N, 1){
		for (int i = 0; i < N; i++) parent[i] = i;
	}

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

	void merge(int x, int y){
		x = root(x), y = root(y);
		if(x == y) return;
		if(siz[x] < siz[y]) swap(x, y);
		parent[y] = x;
		siz[x] += siz[y];
		siz[y] = 0;
	}

	bool are_same(int x, int y){
		return root(x) == root(y);
	}

	int size(int x){
		return siz[root(x)];
	}
};

signed main(){
	int N, H, W, i, ans = 0;
	scanf("%lld%lld%lld", &N, &H, &W);
	vector<pair<int, pair<int, int>>> ARC(N);
	for(i = 0; i < N; i++){
		int r, c, a;
		scanf("%lld%lld%lld", &r, &c, &a);
		r--;
		c--;
		ARC[i].first = a;
		ARC[i].second.first = r;
		ARC[i].second.second = c;
	}
	sort(ARC.begin(), ARC.end());
	union_find uf(H + W);
	vector<int> finish(H + W, 0);
	for(i = N - 1; i >= 0; i--){
		int a = ARC[i].first, r = ARC[i].second.first, c = ARC[i].second.second;
		if(uf.are_same(r, c + H)){
			if(finish[uf.root(r)] == 0){
				ans += a;
				finish[uf.root(r)] = 1;
			}
		}
		else{
			int f1 = finish[uf.root(r)];
			int f2 = finish[uf.root(H + c)];
			if(f1 == 0 && f2 == 0){
				ans += a;
				uf.merge(r, c + H);
			}
			else if(f1 == 1 && f2 == 1){
				continue;
			}
			else{
				ans += a;
				uf.merge(r, c + H);
				finish[uf.root(r)] = 1;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_156_Beginner
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long N = inputLongArray[0];
            long R = inputLongArray[1];
            long result;
            if (N < 10)
            {
                result = R + 100 * (10 - N);
            }
            else
            {
                result = R;
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28188
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scn = new Scanner(System.in);
        String s = scn.nextLine();
        String ans = "ABC";
        if(s.equals("ABC")){
            ans = "ARC";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, a = 0, w = 0, t = 0, r = 0;
    cin >> n;
    string s;
    for (long long q = 0; q < n; q++)
    {
        cin >> s;
        if (s == "AC")
            a++;
        else if (s == "WA")
            w++;
        else if (s == "TLE")
            t++;
        else if (s == "RE")
            r++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int isMultiplesOfThree(int n);

int isIncludingOfThree(int n);

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if (isMultiplesOfThree(i) || isIncludingOfThree(i)) {
            cout << " " << i;
        }
    }

    cout << endl;
    return 0;
}

int isMultiplesOfThree(int n) {
    if (n % 3 == 0) {
        return true;
    } else {
        return false;
    }
}

int isIncludingOfThree(int n) {
    while (n) {
        if (n % 10 == 3) {
            return true;
        }
        n /= 10;
    }
    return false;
}

Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;static char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())s=s*10+(c^48);
	x=s*f;
}
const int MAXN=1e5+7;
const long long inf=1e9+7;
static long long in[MAXN],n,m,e,dis[MAXN],head[MAXN];
static struct edge
{
	int v,nxt;
	long long w;
}p[MAXN<<1];
inline void add(int u,int v,long long w)
{p[++e].v=v;p[e].w=w;p[e].nxt=head[u];head[u]=e;}
inline void End(){printf("No\n");exit(0);}
void dfs(int u)
{
	for(register int v=head[u];v;v=p[v].nxt)
	{
		if(dis[p[v].v]!=inf&&dis[p[v].v]!=dis[u]+p[v].w)End();
		dis[p[v].v]=dis[u]+p[v].w;
		if(dis[p[v].v]>1e9)End();
		if(!(--in[p[v].v]))dfs(p[v].v);
	}
}
static int root[MAXN],tt;
int main()
{
	read(n);read(m);
	if(!m){printf("Yes\n");return 0;}
	static int u,v;
	static long long w;
	dis[0]=inf;
	Rep(i,1,m)read(u),read(v),read(w),add(u,v,w),++in[v],dis[u]=dis[v]=inf;
	Rep(i,1,n)if(dis[i]==inf&&!in[i])root[++tt]=i;
	if(!tt)End();
	while(tt)
	{dis[root[tt]]=0;
	dfs(root[tt--]);}
	Rep(i,1,n)if(dis[i]>1e9)End();
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 10368
N = int(input())

a = [0]

i = 0
L = 26
while True:
    if a[i] < N <= a[i] + L**(i + 1):
        break
    a.append(a[i] + L**(i + 1))
    i += 1


N -= a[i] + 1

for j in range(i, -1, -1):
    if j > 0:
        print(chr(N // L**(j) + ord('a')), end="")
    else:
        print(chr(N + ord('a')), end="")
    N = N % L**(j)


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

int main(){
  int a,b; cin>>a>>b;
  if(a==1 && b==1){
    cout<<1000000<<endl;
  }else{
    int ans=0;
    if(a==1 || b==1){
      ans+=300000;
    }if(a==2){
      ans+=200000;
    }if(b==2){
      ans+=200000;
    }if(a==3){
      ans+=100000;
    }if(b==3){
      ans+=100000;
    }
    cout<<ans<<endl;
  }
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()


bool to[110][110];

int main(int argc, char **argv)
{
	ll N; cin >> N;
	memset(to, 0, sizeof to);
	ll NN = N;

	vector<vector<ll>> t;
	if (N&1)
	{
		vector<ll> tmp{N};
		t.push_back(tmp);
		--N;
	}

	ll l{1}, r{N};

	while (r - l >= 1)
	{
		vector<ll> tmp{l, r};
		t.push_back(tmp);
		++l;
		--r;
	}

	// std::cout << "t : " << t.size() << std::endl;

	ll M = t.size();

	REP(i, M)
	{
		vector<ll> &v1 = t[i];
		vector<ll> &v2 = t[(i+1)%M];

		for (auto &e : v1)
		{
			for (auto &e1 : v2)
			{
				to[e][e1] = true;
			}
		}
	}


	ll res{0};
	for (ll i = 1; i <= NN; ++i)
	{
		for (ll k = 1; k <= NN; ++k)
		{
			if (to[i][k])
			{
				++res;
				to[k][i] = false;
			}
		}
	}

	std::cout << res << std::endl;
	for (ll i = 1; i <= NN; ++i)
	{
		for (ll k = 1; k <= NN; ++k)
		{
			if (to[i][k])
			{
				std::cout << i << " " << k << std::endl;
			}
		}
	}
}


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

using namespace std;
typedef long long ll;
const int N = 200;
bool win[N][N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    ll a, b;
    cin >> a >> b;
    ll res = a - b;
    if (res >= -1 && res <= 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

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

# 方針
# なるべくパーを出した方がいい
# len(s)の半分をパーにすれば条件は満たされる
# あとはポイントを計算する
# （自分のパーの数） - （相手のパーの数）

def main():
  s=S()

  g=s.count('g')
  p=len(s)-g

  myp=len(s)//2
  myg=len(s)-myp

  return myp-p

print(main())


Measured memory_bytes: 5672
N = int(input())
A = list(map(int, input().split()))

money = 1000
stack = 0

for i in range(N-1):
    if A[i] < A[i+1]:
        stack = money // A[i]
    money += (A[i+1] - A[i]) * stack
    stack = 0
print(money)


Measured memory_bytes: 9024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<int> right(n);
  right[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    right[i] = __gcd(right[i + 1], a[i]);
  }
  int ans = right[1], left = a[0];
  FOR(i, 1, n - 1) {
    ans = max(ans, __gcd(left, right[i + 1]));
    left = __gcd(left, a[i]);
  }
  ans = max(ans, left);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define fi  first
#define se second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define dub(x) cerr<<#x<<" "<<x;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define forn(i,n) for(int i = 0;i <(int)(n);++i)
#define fora(i,a,b) for(int i = (int)(a); i<=(int) (b); ++i)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int count=0,i,j;
    for (i = 0,j=s.size()-1; i < j; i++,j--)
    {
    	if(s[i]!=s[j])
    		count++;
    }
    cout<<count<<"\n";
}

Measured memory_bytes: 256