akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a);
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i));
        pro/=(i+1);
    }
    return pro;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n==25) cout<<"Christmas";
    else if(n==24) cout<<"Christmas Eve";
    else if(n==23) cout<<"Christmas Eve Eve";
    else if(n==22) cout<<"Christmas Eve Eve Eve";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.charAt(s.length()-1) == 's') {
            System.out.print(s + "es");
        } else {
            System.out.print(s + "s");
        }
    }
}


Measured memory_bytes: 38484
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
constexpr string join(const V &v, const string &sep) {
  stringstream ss;
  if (v.size()) ss << v[0].se;
  loop(i, 1, v.size()) ss << sep << v[i].se;
  return ss.str();
}

void solve() {
  int n, m;
  while (cin >> n >> m, n) {
    vpii v(m);
    rep(i, m) v[i].se = i + 1;
    while (n--) {
      rep(i, m) {
        int x;
        cin >> x;
        v[i].fi += x;
      }
    }
    stable_sort(all(v), [](auto a, auto b) {
      if (a.fi != b.fi) return a.fi > b.fi;
      return a.se < b.se;
    });
    cout << join(v, " ") << endl;
  }
}

Measured memory_bytes: 3144
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int fa[MAXN],ind[MAXN],oud[MAXN],v1[MAXN],v2[MAXN];
int n,h;
bool flag[MAXN];
int get_fa(int x){
	if(fa[x]==0)
		return x;
	fa[x]=get_fa(fa[x]);
	return fa[x];	
}
int main(){
	SF("%d%d",&n,&h);
	int x,y,a,b;
	for(int i=1;i<=n;i++){
		SF("%d%d%d%d",&x,&y,&a,&b);
		int u,v;
		if(a==0)
			u=x+200;
		else
			u=a;
		if(b==0)
			v=y;
		else
			v=b+200;
		flag[u]=flag[v]=1;
		oud[u]++;
		ind[v]++;
		if(get_fa(u)!=get_fa(v))
			fa[get_fa(u)]=get_fa(v);
	}
	for(int i=1;i<=400;i++){
		if(ind[i]>oud[i]){
			v1[get_fa(i)]++;
			if(i>200){
				PF("NO");
				return 0;
			}
		}
		if(ind[i]<oud[i]){
			v2[get_fa(i)]++;
			if(i<=200){
				PF("NO");
				return 0;
			}
		}
	}
	for(int i=1;i<=400;i++)
		if(fa[i]==0)
			if(v1[i]==0&&v2[i]==0&&flag[i]){
				PF("NO");	
				return 0;
			}
	PF("YES");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){

    double n, m;
    cin >> n >> m;

    long long t=pow(2,m);
    long long x = (1900*m + 100*(n-m));

    cout << x*t << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * @Author:      H S-J
 * @DateTime:    2017-12-22 21:16:07
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
int f(int n) {
	int res = 0;
	while(n) {
		res += n%10;
		n /= 10;
	}
	return res;
}
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	long double x, y;
	cin >> x >> y;
	long double t = y/x;
	long double ans = log2(t);
	cout << (LL)ans+1 << endl;
	return 0;
}

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

#define ff              first
#define ss              second
//#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mci             map<char,int>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(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)            long long x; cin>>x; while(x--)
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
#define ll long long 
//template <typename T> 

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

long N;
cin>>N;
string s1;
int arr[4]={0};
while(N--)
{
   cin>>s1;
   if(s1.compare("AC")==0)
   	arr[0]++;
   else if(s1.compare("WA")==0)
   	arr[1]++;
   else if(s1.compare("TLE")==0)
   	arr[2]++;
   else if(s1.compare("RE")==0)
   	arr[3]++;

}
cout<<"AC x "<<arr[0]<<endl;
cout<<"WA x "<<arr[1]<<endl;
cout<<"TLE x "<<arr[2]<<endl;
cout<<"RE x "<<arr[3]<<endl;
 cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;



return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i];
  for (int i = 0; i < N; ++i) {
    if (A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int h,w,a[100][100],b[100][100];
bool dp[81][81][16200];

void solve(){
    cin >> h >> w;
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cin >> b[i][j];
        }
    }
    dp[0][0][abs(a[0][0]-b[0][0])]=true;
    rep(i,h){
        rep(j,w){
            rep(k,16200){
                if (!dp[i][j][k]) continue;
                if (i+1<h){
                    int d=a[i+1][j]-b[i+1][j];
                    dp[i+1][j][abs(k+d)]=true;
                    dp[i+1][j][abs(k-d)]=true;
                }
                if (j+1<w){
                    int d=a[i][j+1]-b[i][j+1];
                    dp[i][j+1][abs(k+d)]=true;
                    dp[i][j+1][abs(k-d)]=true;
                }
            }
        }
    }
    rep(k,16200){
        if (dp[h-1][w-1][k]) {
            cout << k << endl;
            break;
        }
    }
}

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

Measured memory_bytes: 101632
#include <iostream>
#include <vector>

using namespace std;

// #define ff first
// #define ss second
// #define mp( a, b ) make_pair( a, b )
// #define pb( a ) push_back( a ) cout.tie( 0 )
// #define check( x ) cout << #x << " : " << ( x ) << endl
// #define all( v ) v.begin(), v.end()
// #define allr( v ) v.rbegin(), v.rend()
// //#define endl '\n'
typedef long long ll;
// typedef unsigned long long ull;
// typedef vector<ll> edge;
// typedef pair<ll, ll> mypair;
// typedef priority_queue<ll> max_heap;
// typedef priority_queue<ll, vector<ll>, greater<ll>> min_heap;
// ll mod = 1e9 + 7;
// const ll inf = 1e15 + 10;
// const ll N = 3e6;

long long MOD = 1000000007;

struct matrix
{
    vector<vector<ll>> mat;
    ll row;
    ll col;

    void resize( ll row, ll col, ll initial )
    {
        this->row = row;
        this->col = col;
        mat.resize( row, vector<ll>( col, initial ) );
    }
    void identity() // first resize with initial = 0
    {
        for ( ll i = 0; i < (ll)mat.size(); i++ ) mat[i][i] = 1;
    }

    matrix operator+( matrix &b ) const
    {
        matrix temp;
        temp.resize( row, col, 0 );

        for ( ll i = 0; i < row; i++ )
        {
            for ( ll j = 0; j < col; j++ )
            {
                temp.mat[i][j] = ( mat[i][j] % MOD ) + ( b.mat[i][j] % MOD );
                temp.mat[i][j] %= MOD;
            }
        }
        return temp;
    }

    matrix operator*( matrix &b ) const
    {
        matrix temp;
        ll ro, co;

        temp.resize( row, b.col, 0 );
        for ( ll i = 0; i < row; i++ )
        {
            for ( ll j = 0; j < b.col; j++ )
            {
                for ( ll k = 0; k < col; k++ )
                {
                    temp.mat[i][j] +=
                        ( ( mat[i][k] % MOD ) * ( b.mat[k][j] % MOD ) );
                    temp.mat[i][j] %= MOD;
                }
            }
        }
        return temp;
    }

    matrix power( ll b )
    {
        matrix a = matrix( *this );
        matrix ans;

        ans.resize( row, col, 0 );
        ans.identity();

        while ( b )
        {
            if ( b & (ll)1 ) { ans = ans * a; }
            a = a * a;
            b >>= 1;
        }
        return ans;
    }
};

int main()
{
    ll l, a, b, m;
    cin >> l >> a >> b >> m;

    MOD = m;
    matrix ans;
    ans.resize( 1, 3, 0 );
    ans.mat[0][0] = a % MOD;
    ans.mat[0][1] = ( a + b ) % MOD;
    ans.mat[0][2] = 1;
    ll term = 1, d = 10;
    while ( term < l )
    {
        ll lo = max( (ll)0, ( ( d / 10 - 1 ) - a ) / b );
        ll hi = min( l - 1, max( ( d - 1 - a ) / b, (ll)0 ) );
        ll now = hi - lo;

        term += hi - lo;

        matrix temp;
        temp.resize( 3, 3, 0 );
        temp.mat[0][0] = d % MOD;
        temp.mat[1][0] = 1;
        temp.mat[1][1] = 1;
        temp.mat[2][1] = b % MOD;
        temp.mat[2][2] = 1;

        temp = temp.power( now );
        ans = ans * temp;

        d *= 10;
    }

    cout << ans.mat[0][0] << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

public class Main {

	int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	
	void submit() {
		int n = nextInt();
		int m = nextInt();
		String s = nextToken();
		String t = nextToken();
		
		int g = gcd(n, m);
		
		for (int i = 0; i < g; i++) {
			int x = n / g * i;
			int y = m / g * i;
			if (s.charAt(x) != t.charAt(y)) {
				out.println("-1");
				return;
			}
		}
		
		out.println((long)n * m / g);
	}

	void test() {

	}

	void stress() {
		for (int tst = 0;; tst++) {
			if (false) {
				throw new AssertionError();
			}
			System.err.println(tst);
		}
	}

	Main() throws IOException {
		is = System.in;
		out = new PrintWriter(System.out);
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();
	static final int C = 5;

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	private InputStream is;
	PrintWriter out;

	private byte[] buf = new byte[1 << 14];
	private int bufSz = 0, bufPtr = 0;

	private int readByte() {
		if (bufSz == -1)
			throw new RuntimeException("Reading past EOF");
		if (bufPtr >= bufSz) {
			bufPtr = 0;
			try {
				bufSz = is.read(buf);
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
			if (bufSz <= 0)
				return -1;
		}
		return buf[bufPtr++];
	}

	private boolean isTrash(int c) {
		return c < 33 || c > 126;
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isTrash(b))
			;
		return b;
	}

	String nextToken() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	String nextString() {
		int b = readByte();
		StringBuilder sb = new StringBuilder();
		while (!isTrash(b) || b == ' ') {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

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

	char nextChar() {
		return (char) skip();
	}

	int nextInt() {
		int ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}

	long nextLong() {
		long ret = 0;
		int b = skip();
		if (b != '-' && (b < '0' || b > '9')) {
			throw new InputMismatchException();
		}
		boolean neg = false;
		if (b == '-') {
			neg = true;
			b = readByte();
		}
		while (true) {
			if (b >= '0' && b <= '9') {
				ret = ret * 10 + (b - '0');
			} else {
				if (b != -1 && !isTrash(b)) {
					throw new InputMismatchException();
				}
				return neg ? -ret : ret;
			}
			b = readByte();
		}
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<deque>
#include<stdio.h>

class Mass{
	public:
		std::vector<std::vector<bool>> data;
		int H;
		int W;
		int n;
		Mass(int H_=0,int W_=0,int n_=0,std::vector<std::vector<bool>> *datap=NULL){
			this->H=H_;
			this->W=W_;
			this->n=n_;
			if(datap!=NULL)
				this->data=*datap;
			else{
				std::vector<bool> tmp;
				this->data.clear();
				for(int i=0;i<H_;++i){
					for(int j=0;j<W_;++j)
						tmp.push_back(false);
					this->data.push_back(tmp);
				}
			}
		}
		Mass(const Mass &dst){
			this->data=dst.data;
			this->H=dst.H;
			this->W=dst.W;
			this->n=dst.n;
		}
		Mass paint(int n,bool rows=true){//true 
			std::vector<std::vector<bool>> data_=this->data;
				if(rows)
					for(int i=0;i<W;++i)
						data_[n][i]=true;
				else
					for(int i=0;i<H;++i)
						data_[i][n]=true;
			return Mass(this->H,this->W,this->n+1,&data_);
		}
		bool operator==(const Mass &dst){
			for(int i=0;i<H;++i)
				for(int j=0;j<W;++j)
					if(this->data[i][j]!=dst.data[i][j])
						return false;
			return true;
		}
		int count(){
			int res=0;
			for(int i=0;i<this->H;++i)
				for(int j=0;j<this->W;++j)
					if(data[i][j])
						res++;
			return res;
		}
};

void printmass(const Mass &m){
	for(int i=0;i<m.H;++i){
		for(int j=0;j<m.W;++j)
			std::cout<<(m.data[i][j]?"■ ":"□ ");
		std::cout<<std::endl;
	}
}

std::pair<int,bool> counts(const Mass &m){//bool is rows.
	int n1=~0xffff,n2=~0xffff;
	int pos1,pos2;
	int count;
	for(int i=0;i<m.H;++i){
		count=0;
		for(int j=0;j<m.W;++j)
			if(!m.data[i][j])
				count++;
		n1=std::max(n1,count);
		if(n1==count)
			pos1=i;
	}
	for(int j=0;j<m.W;++j){
		count=0;
		for(int i=0;i<m.H;++i)
			if(!m.data[i][j])
				count++;
		n2=std::max(n2,count);
		if(n2==count)
			pos2=j;
	}
	if(n1>n2)
		return std::make_pair(pos1,true);
	return std::make_pair(pos2,false);
}

int solve(int H,int W,int N){
	using namespace std;
	std::deque<Mass> frontier;
	std::vector<Mass> explored;
	frontier.push_front(Mass(H,W));
	Mass now,tmp;
	int result=0xffff;
	bool in_explored;
	while(!frontier.empty()){
		now=frontier.back();
		frontier.pop_back();
//cout<<"n:"<<now.n<<endl;
//cout<<"now:"<<endl;
//printmass(now);
		if(now.count()>=N)
			return now.n;
		else{
			auto hint=counts(now);
			frontier.push_back(now.paint(hint.first,hint.second));
		}
	}
	return result;
}

int main(){
	using namespace std;
	int H;
	int W;
	int N;
	cin>>H>>W>>N;
	if(H<1||H>100||W<1||W>100||N<1||N>H*W)
		return -1;
	//cout<<"solve:"<<solve(H,W,N)<<endl;
	cout<<solve(H,W,N)<<endl;
}


Measured memory_bytes: 500
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;

bool is_prime(int x){
    if(x<=1)
        return false;
    for (int i = 2; i * i <= x; i++){
        if(x%i == 0)
            return false;
    }
    return true;
}

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

    int p = X;
    while(!is_prime(p))
        p++;
    cout << p << endl;
    return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

int dsu[200005], r[200005], c[200005];

void dsu_clear(){
    for(int i = 0; i < 200004; ++i){
        dsu[i] = i; r[i] = 0;
    }
}

int find(int node){
    if(node == dsu[node]) return node;
    return dsu[node] = find(dsu[node]);
}

void combine(int a, int b){
    a = find(a); b = find(b);
    if(a == b) return;
    if(r[a] <= r[b]){
        dsu[a] = b; r[b] += r[a];
    } else if(r[b] < r[a]){
        dsu[b] = a; r[a] += r[b];
    }
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

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

    dsu_clear();

    for(int i = 0; i < k; ++i){
        cin >> a >> b; --a; --b;
        combine(a, b);
    }

    for(int i = 0; i < n; ++i)
        c[i] = find(i);

    dsu_clear();

    for(int i = 0; i < l; ++i){
        cin >> a >> b; --a; --b;
        combine(a, b);
    }

    vector<vector<int>> states;

    for(int i = 0; i < n; ++i)
        states.push_back({c[i], find(i), i});

    sort(states.begin(), states.end());

    vector<int> cur;
    cur.push_back(states[0][2]);

    for(int i = 1; i < n; ++i){
        if(states[i][0] != states[i - 1][0] || states[i][1] != states[i - 1][1]){
            for(int node : cur)
                r[node] = cur.size();
            cur.clear();
        }
        cur.push_back(states[i][2]);
    }

    for(int node : cur)
        r[node] = cur.size();

    for(int i = 0; i < n; ++i)
        cout << r[i] << " ";

    return 0;

}


Measured memory_bytes: 15148
l = list(map(int,input().split()))
m = list(range(l[1],l[2]+1))

def digitsum(n):
    s = str(n)
    ary = list(map(int,list(s)))
    return sum(ary)

k = []
for i in range(l[0]+1):
    if digitsum(i) in m :
        k.append(i)
print(sum(k))


Measured memory_bytes: 3424
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    // 配るDP
    int N, W; cin >> N >> W;
    vi w(N);
    vi v(N);
    rep(i, N) {
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    rep(i, N) {
        rep(j, W + 1) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + w[i] <= W) {
                dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}


int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int tmp = i;
		int cnt = 0;
		while (tmp > 0) {
			tmp /= 10;
			cnt += 1;
		}
		if (cnt & 1)ans += 1;
	}
	cout << ans << '\n';






}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import           Data.List             (unfoldr)
import           Data.Vector.Unboxed   ((//))
import qualified Data.Vector.Unboxed   as V

main :: IO ()
main = do
  n <- readLn
  as <- readIntsLn
  putStrLn . unwords . map show $ solve n as

solve :: Int -> [Int] -> [Int]
solve n as = V.toList $ V.replicate n 0 // [(a - 1, i) | (a, i) <- zip as [1 ..]]

readIntsLn :: IO [Int]
readIntsLn = unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine


Measured memory_bytes: 4476
#include<bits/stdc++.h>
#define ALL(v) v.begin(),v.end()
typedef long long int ll;
using namespace std;
#define rep(i, n) for(long long int i = 0; i < (n); i++)
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  for(ll i=0;i<n;i++){
  	cin>>a[i];
  }
  for(ll i=0;i<n;i++){
  	cin>>b[i];
  }
  for(ll i=0;i<n;i++){
  	cin>>c[i];
  }
  sort(ALL(a)),sort(ALL(b)),sort(ALL(c));
  ll cnt=0;
  for(ll i=0;i<n;i++){
    ll x = (ll)(lower_bound(ALL(a),b[i])-a.begin());
    ll y = (ll)(c.end()-upper_bound(ALL(c),b[i]));
    cnt+=x*y;
  }
  cout<<cnt<<endl;


}


Measured memory_bytes: 2560
n = int(input())
string = list(input())
#print(ord("Z"))
for e,i in enumerate(string):
    val = ord(str(i)) + n
    if (val > 90):
        val = 64 + (val - 90)
    string[e] = chr(val)
mojiretu = ''
for x in string:
    mojiretu += x
    
print(mojiretu)
#print(str(string))

Measured memory_bytes: 3060
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		StringBuilder ans = new StringBuilder();
		while(N > 0) {
			N--;
			ans.append((char)(N % 26 + 'a'));
			N /= 26;
		}
		System.out.println(ans.reverse());
	}

}

Measured memory_bytes: 35788
#include <iostream>

using namespace std;

int cnt[3][30];

int main(){
    int N, C;
    int ans = INT32_MAX;
    cin >> N >> C;
    int D[30][30];
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            cin >> D[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            int c;
            cin >> c;
            c--;
            cnt[(i+j)%3][c]++;
        }
    }
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            if(j == i) continue;
            for(int k = 0; k < C; k++){
                if(k == j || k == i) continue;
                int tmp_ans = 0;
                for(int l = 0; l < C; l++){
                    tmp_ans += cnt[0][l]*D[l][i];
                    tmp_ans += cnt[1][l]*D[l][j];
                    tmp_ans += cnt[2][l]*D[l][k];
                }
                ans = min(ans, tmp_ans);
            }
        }
    }
    cout << ans << endl;
}

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

const int N = 2e5 + 5;
typedef long long LL;

int n, a[N], ans = 1e9 + 8, f[N];

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		f[a[i]] = 1 + f[a[i] - 1];
		ans = min(ans, n - f[a[i]]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{
 int n;cin>>n;
 int ans=n%1000;
 if(ans==0)
 cout<<ans<<endl;
 else
 cout<<(1000-ans)<<endl;
 
}


int32_t main()
{
    rapido;
    int t;
    t=1;
    while(t--) 
    {
        solve();
    }
}

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

int main(){
  vector<vector<int>> v(5,vector<int>(2, 0));
  for(int i = 0; i < 5; i++){
    cin >> v[i][0];
    v[i][1] = v[i][0] % 10;
    if(v[i][1] == 0) v[i][1] += 10;
    swap(v[i][0], v[i][1]);
  }

  sort(v.begin(), v.end());
  int sum = v[0][1];

  for(int i = 1; i < 5; i++){
    if(v[i][0] != 10){v[i][1] += 10-v[i][0];}
    sum += v[i][1];
  }

  cout << sum << endl;





}       

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    string s; cin >> s;
    ll k; cin >> k;
    REP(i, 0, s.size()){
        int mid = s[i] - 'a';
        if(mid == 0){
            continue;
        }else{
            if(k >= 26 - mid){
                k -= (26-mid);
                s[i] = 'a';
            }
        }
    }
    int mid = s.back() - 'a';
    s.back() = alpha[(mid + k) % 26];
    cout << s << endl;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

N, Ma, Mb = map(int, input().split())

d = []
for i in range(N):
    a, b, c = map(int, input().split())
    d.append((a, b, c))

# 全探索だとTLEなのでDPを用いる

# dp[i][ca][cb] := i-1番目までの組み合わせでAがca,Bがcbとなるときの最小コスト

INF = float('inf')
g_max = 10 * N
dp = [[[INF for cb in range(g_max+1)] for ca in range(g_max+1)] for i in range(N+1)]

dp[0][0][0] = 0

for i in range(N):
    for ca in range(g_max+1):
        for cb in range(g_max+1):
            if dp[i][ca][cb] == INF:
                continue
            a, b, c = d[i]
            # i番目の薬品を選ばない場合
            dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
            # i番目の薬品を選ぶ場合
            dp[i+1][ca+a][cb+b] = min(dp[i+1][ca+a][cb+b], dp[i][ca][cb]+c)

ans = -1
for ca in range(g_max+1):
    for cb in range(g_max+1):
        c = dp[N][ca][cb]
        if c == INF:
            continue
        if ca*Mb == cb*Ma and c > 0:
            if ans < 0 or c < ans:
                ans = c

print(ans)

Measured memory_bytes: 60012
#include <stdio.h>

int main(int argc, const char * argv[]){
    int r,c,i,j;
    static int s[101][101];
    
    scanf("%d%d",&r,&c);
    
    for(i=0;i<=r;i++){
        for(j=0;j<c;j++){
            scanf("%d", &s[i][j]);
            printf("%d ", s[i][j]);
            s[i][c] += s[i][j];
            s[r][j] += s[i][j];
        }
        printf("%d\n",s[i][c]);
    }
    return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    char str[15]={0};
    scanf("%s", str);

    str[3]='8';

    printf("%s\n", str);

    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b, c; cin >> a >> b >> c;
	for (int i = 1; i < 10000; ++i) {
		if (i*a%b == c) {
			cout << "YES";
			return;
		}
	}
	cout << "NO";
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;


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

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

int a[5];

int main() {
    rep(i, 1, 3) cin >> a[i];
    sort(a + 1, a + 4);
    if ((a[1] == a[2] && a[2] != a[3]) || (a[1] != a[2] && a[2] == a[3])) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
h, n = map( int, input().split() )
a = []
b = []
for _ in range( n ):
    a_i, b_i = map( int, input().split() )
    a.append( a_i )
    b.append( b_i )

dp = [ float( "Inf" ) ] * ( h + 1 )
# dp[ d ] = dを与える最小マナ
dp[ 0 ] = 0
for i in range( h ):
    for j in range( n ):
        update_index = min( i + a[ j ], h )
        dp[ update_index ] = min( dp[ update_index ], dp[ i ] + b[ j ] )

print( dp[ h ] )

Measured memory_bytes: 68244
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    if (s.find('R') != -1)
        cnt = 1;
    int mx = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == 'R' && s[i + 1] == 'R')
            cnt++;
    }
    cout << cnt << endl;
}

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

int main(){
  int N;
  string s;
  cin >> N >> s;
  int C[4] = {};
  for(auto c : s){
    if(c >= 'A' and c <= 'M') ++C[0];
    else if(c >= 'N' and c <= 'Z') ++C[1];
    else if(c >= 'a' and c <= 'm') ++C[2];
    else ++C[3];
  }
  string ans;
  if(C[0] > C[1]){
    ans += string(C[0]-C[1],'A');
  }else if(C[0] < C[1]){
    ans += string(C[1]-C[0],'N');
  }
  if(C[2] > C[3]){
    ans += string(C[2]-C[3],'a');
  }else if(C[2] < C[3]){
    ans += string(C[3]-C[2],'n');
  }
  cout << ans.length() << endl;
  cout << ans << endl;
}



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

signed main()
{  
   int N; cin>>N;
   vector<int> a(N);
   REP(i,N) cin>>a[i];
   
   int sum=accumulate(a.begin(),a.end(),0LL);
   int K=N*(N+1)/2;
   
   if(sum%K!=0){
      cout<<"NO"<<endl;
      return 0;
   }
   
   int C=sum/K;
   vector<int> b(N);
   REP(i,N){
      if(C+a[i]-a[(i+1)%N]<0 or (C+a[i]-a[(i+1)%N])%N!=0){
         cout<<"NO"<<endl;
         return 0;
      }
      b[i]=(C+a[i]-a[(i+1)%N])/N;
   }
   cout<<"YES"<<endl;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int H;
	int W;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);

		H = Integer.parseInt(strArr[0]);
		W = Integer.parseInt(strArr[1]);

		if (H % 3 == 0) {
			System.out.println("0");
			return;
		}
		if (W % 3 == 0) {
			System.out.println("0");
			return;
		}

		long l;
		long m;
		// if (H > W) {
		// l = (long) H;
		// m = (long) W;
		// } else {
		// l = (long) W;
		// m = (long) H;
		// }

		long l1;
		long m1;
		long l2;
		long m2;
		long l3;
		long m3;
		long min = Long.MAX_VALUE;

		l = (long) H;
		m = (long) W;
		// 1辺3分割
		for (int i = 1; i <= l; i++) {
			l1 = i;
			m1 = m;
			l2 = (l - l1) / 2;
			m2 = m;
			l3 = l - l1 - l2;
			m3 = m;
			// if (l1 > 0 && m1 > 0 && l2 > 0 && m2 > 0 && l3 > 0 && m3 > 0)
			min = Long.min(min, diffMaxMin(l1 * m1, l2 * m2, l3 * m3));
		}

		// 2辺２分割
		for (int i = 1; i <= l; i++) {
			l1 = i;
			m1 = m;
			l2 = l - l1;
			m2 = m / 2;
			l3 = l - l1;
			m3 = m - m2;
			// if (l1 > 0 && m1 > 0 && l2 > 0 && m2 > 0 && l3 > 0 && m3 > 0)
			min = Long.min(min, diffMaxMin(l1 * m1, l2 * m2, l3 * m3));
		}

		l = (long) W;
		m = (long) H;
		// 1辺3分割
		for (int i = 1; i <= l; i++) {
			l1 = i;
			m1 = m;
			l2 = (l - l1) / 2;
			m2 = m;
			l3 = l - l1 - l2;
			m3 = m;
			// if (l1 > 0 && m1 > 0 && l2 > 0 && m2 > 0 && l3 > 0 && m3 > 0)
			min = Long.min(min, diffMaxMin(l1 * m1, l2 * m2, l3 * m3));
		}

		// 2辺２分割
		for (int i = 1; i <= l; i++) {
			l1 = i;
			m1 = m;
			l2 = l - l1;
			m2 = m / 2;
			l3 = l - l1;
			m3 = m - m2;
			// if (l1 > 0 && m1 > 0 && l2 > 0 && m2 > 0 && l3 > 0 && m3 > 0)
			min = Long.min(min, diffMaxMin(l1 * m1, l2 * m2, l3 * m3));
		}
		System.out.println(min);

	}

	private long diffMaxMin(long s1, long s2, long s3) {
		long min = s1;
		long max = s1;
		if (min > s2)
			min = s2;
		if (max < s2)
			max = s2;
		if (min > s3)
			min = s3;
		if (max < s3)
			max = s3;
		return max - min;
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {
	}
}


Measured memory_bytes: 23252
import java.util.Random;
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Random rand = new Random();
    Scanner stdIn = new Scanner(System.in);

    int n = stdIn.nextInt();
    int[] a = new int[n];

    for (int i = 0; i < n; i++) {
      a[i] = stdIn.nextInt();
    }

    for (int i = n-1; i >= 0 ; i--) {
      System.out.print(a[i]);
      if (i != 0)
      System.out.print(" ");
    }
    System.out.println();
  }
}


Measured memory_bytes: 26396
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;

const int mx = 100003;

int main() {
    int x;
    cin >> x;
    int ans;
    vector<bool> isPrime(mx+1,true);
    for(int i = 2; i <= mx; ++i) {
        if(!isPrime[i]) continue;
        if(i >= x) {
            ans = i;
            break;
        }
        for(int j = i * 2; j <= mx; j += i) isPrime[j] = false;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d >> n;
    //1Lの最小金額
    ll l = min(s,min(2*h,4*q));
    ll a = min(l*2,d);
    cout << n/2*a+n%2*l << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int ans;
  scanf("%d", &ans);
  while( 1 ) {
    char s;
     int n;
     scanf("%c", &s);
     scanf("%c", &s);
     if(s == '=') break;
     scanf("%d", &n);
     if(s == '+') ans += n;
     else if(s == '-') ans -= n;
     else if(s == '*') ans *= n;
     else ans /= n;
  }
  printf("%d\n", ans); 
  return 0;
}


Measured memory_bytes: 2728
import java.util.*;


public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
    static long mod = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();
        int ans = 1001;
        for(int i=0;i<S.length-T.length+1;i++){
            int tempAns=0;
            for(int j=0;j<T.length;j++){
                if(S[i+j] != T[j]){
                    tempAns++;
                }
            }
            ans = Math.min(ans,tempAns);
        }
        System.out.println(ans);

    }

}




Measured memory_bytes: 35796
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9+7;

int frac(int n){
    int ans = 1;
    for(int i = 1; i <= n; i++){
        ans *= i;
        ans %= MOD;
    }
    return ans;
}

signed main(){
    int N, M; cin >> N >> M;
    if(abs(N - M) > 1) cout << 0 << endl;
    else{
        if(N == M){
            int ans = frac(N) * frac(N) * 2;
            cout << ans%MOD << endl;
        }
        if(N == M + 1 || N + 1 == M){
            int ans = frac(N) * frac(M);
            cout << ans%MOD << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
const int max_N=1e5+10;
int main(void)
{
  ll r,D;
  ll x[15];
  cin >> r >> D >> x[1];
  for (int i = 1; i <= 10; ++i)
    {
      x[i+1]=r*x[i]-D;
    }
  for (int i = 2; i <= 11; ++i)
    {
      cout << x[i] << endl;
    }
  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++) scanf("%d", &a[i]);
    int pos = N-1;
    while (pos >= 0) {
        printf("%d " , a[pos]);
        pos -= 2;
    }
    if (pos == -1) pos = 0;
    else pos = 1;
    while (pos <= N-1) {
        printf("%d", a[pos]);
        pos += 2;
        if (pos <= N-1) printf(" ");
        else printf("\n");
    }
}

Measured memory_bytes: 2944
X = int(input())

B_max = int(X**(0.25))

def get_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=(n//i):
                divisors.append(n//i)
    divisors.sort()
    return divisors

divisors = get_divisors(X)

flg = False
for div in divisors:
    for B in range(-B_max, B_max+1):
        A = B + div
        A4_B4 = A**4 + A**3 * B + A**2 * B**2 + A * B**3 + B**4
        
        if (div * A4_B4 == X):
            flg = True
            break
    
    if flg:
        break


print("{} {}".format(A, B))

Measured memory_bytes: 9352
#include <iostream>

using namespace std;

int main()
{
    int a , b ;
    cin >> a >> b;
    if(a > 0 && b > 0)
    {
        cout << "Positive" ;
        return 0;
    }
    if(a <= 0 && b >= 0)
    {
        cout << "Zero";
        return 0;
    }
    if((abs(b) - (abs(a) - 1)) % 2 == 0)
    {
        cout << "Positive";
        return 0;
    }
    cout << "Negative";
    return 0;
}


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

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int a[n],pos=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>=0){
            pos++;
        }
    }
    int i;
    if(pos>=k){
        i=lower_bound(a,a+n,0)-a;
    }
    else{
        i=n-k;
    }
    int left=a[i],right=a[i+k-1];
    long long ans=0ll;
    if(1ll*left*right>=0ll){
        ans=max(abs(left),abs(right));
    }
    else{
        ans=2ll*min(abs(left),abs(right))+max(abs(left),abs(right));
    }
    while(i>0 && a[i+k-1]>0){
        // cout<<ans<<endl;
        i--;
        left=a[i];
        right=a[i+k-1];
        if(1ll*left*right>=0ll){
            ans=min(ans,1ll*max(abs(left),abs(right)));
        }   
        else{
            ans=min(ans,2ll*min(abs(left),abs(right))+1ll*max(abs(left),abs(right)));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int n,ans;
string s;

int main(){
    cin>>n;
    
    while(n--){
        cin>>s;
        mp[s]=1;
    }
    
    for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++) ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 19120
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin >>s;

  int ans=0;
  for(int i=1;i<n;i++){
     int cnt=0;
     for(char c='a';c<='z';c++){
       bool right=false;
       bool left=false;
       /* whether left seqence has c*/
       for(int j=0;j<i;j++)
         if(s[j]==c) left=true;

       /* whether right sequence has c*/
      for(int j=i;j<n;j++)
         if(s[j]==c) right=true;
      /*if left and right are true, then cnt++ */
      if(left && right) cnt++;
     }
    if(ans<cnt) ans=cnt;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <stack>
#include <map>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int P[10010];
void init(int N){ 
	for (int i=0; i<N; ++i) P[i] = i;
}

int root(int a){
	if(P[a] == a)return a;
	return (P[a]=root(P[a]));
}

void unite(int a, int b) {
	P[root(a)]=root(b);
}

int main() 
{
	//配列を求めておく
	int fib[1002]={0};
	fib[0]=1;
	fib[1]=1;
	for(int i=2;i<1000+2;i++){
		fib[i]=(fib[i-2]+fib[i-1])%1001;
	}
	
	int n,m;
	while(cin>>n>>m)
	{
		init(n);
		REP(i,n)REP(j,n)if(max(fib[i+2]-fib[j+2],-fib[i+2]+fib[j+2])<m)unite(i,j);
		
		int ans(0);
		REP(i,n)if(i==P[i])ans++;
		
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1172
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M := sc.nextInt(), sc.nextInt()
	un := NewUnionFind(N + 1)
	P := sc.nextIntSlice(N)
	for i := 0; i < M; i++ {
		x, y := sc.nextInt()-1, sc.nextInt()-1
		un.unite(P[x], P[y])
	}
	ans := 0
	for i := 0; i < N; i++ {
		if un.isSame(i+1, P[i]) {
			ans++
		}
	}

	fmt.Fprintln(wtr, ans)
}

type UnionFind struct {
	parent []int
	size   []int
}

func NewUnionFind(n int) *UnionFind {
	p := make([]int, n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = i
		s[i] = 1
	}
	return &UnionFind{p, s}
}

func (a *UnionFind) root(x int) int {
	if a.parent[x] == x {
		return x
	} else {
		a.parent[x] = a.root(a.parent[x])
		return a.parent[x]
	}
}

func (a *UnionFind) isSame(x, y int) bool {
	return a.root(x) == a.root(y)
}

func (a *UnionFind) unite(x, y int) {
	x = a.root(x)
	y = a.root(y)
	if x == y {
		return
	} else {
		a.parent[x] = y
		a.size[y] += a.size[x]
	}
}

func (a *UnionFind) getSize(x int) int {
	return a.size[a.root(x)]
}


Measured memory_bytes: 4736
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll rui[101010];
ll nxt[3][101010];
ll eq[101010];
ll dp[101010];
int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)rui[i + 1] = (rui[i] + s[i] - 'a' + 1) % 3;
	nxt[0][s.size()] = nxt[1][s.size()] = nxt[2][s.size()] = eq[s.size()] = eq[s.size() - 1] = s.size() + 10;
	nxt[rui[s.size()]][s.size()] = s.size();
	for (int i = s.size() - 1; i >= 0; i--)
	{
		if (i != 0 && s[i] == s[i - 1])eq[i - 1] = i;
		else if (i != 0)eq[i - 1] = eq[i];
		for (int j = 0; j < 3; j++)
		{
			if (rui[i] == j)nxt[j][i] = i;
			else nxt[j][i] = nxt[j][i + 1];
		}
	}
	dp[0] = 1;
	for (int i = 0; i < s.size(); i++)
	{
		int a, b;
		if (s[i] == 'a')a = i + 1;
		else if (eq[i] <= s.size())a = nxt[(rui[i] + 1) % 3][eq[i] + 1];
		else a = -1;
		if (s[i] == 'b')b = i + 1;
		else if (eq[i] <= s.size())b = nxt[(rui[i] + 2) % 3][eq[i] + 1];
		else b = -1;
		if (a != -1)dp[a] = (dp[a] + dp[i]) % mod;
		if (b != -1)dp[b] = (dp[b] + dp[i]) % mod;
		//printf("%d %d\n", a, b);
		//for (int j = 0; j <= s.size(); j++)printf("%lld ", dp[j]); printf("\n");
	}
	ll r = 0;
	if (eq[0] <= s.size())
	{
		for (int i = 1; i <= s.size(); i++)if (rui[i] == rui[s.size()])r += dp[i];
	}
	else r += dp[s.size()];
	printf("%lld\n", r%mod);
}

Measured memory_bytes: 5248