akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class graph
{
private:
	// construct a vector of vectors to represent an adjacency list
	vector<vector<int>> adjList;
	int v;
	int e;
	vector<bool> known_path_from;
	vector<int> best_path_from;
	// Graph Constructor
	void find_best_path_from(int x);
	void display();
	int get_longest_path();
public:
	graph();
};


graph::graph()
{
	cin >> v;
	cin >> e;
	adjList.resize(v);
	best_path_from.resize(v,0);
	known_path_from.resize(v,false); 
	for (int i=0;i<e;i++)
	{
	int src;
	int dest;
	cin >> src;
	cin >> dest;
	src--;
	dest--;//input is 1 indexed
	adjList[src].push_back(dest);

	}
	for (int i = 0; i < v; i++) {
		if (!known_path_from[i]) {
			find_best_path_from(i);
		}
	}
	display();
}
void graph::find_best_path_from(int x) {
	int opt = 0;
	vector<int> dests = adjList[x];
	for (int dest : dests) {
		int temp_path;
		if (known_path_from[dest]) {
			temp_path = best_path_from[dest] + 1;
			
		}
		else {
			find_best_path_from(dest);
			temp_path = best_path_from[dest] + 1;

		}
		if (temp_path > opt) {
			opt = temp_path;
		}
	}
	best_path_from[x] = opt;
	known_path_from[x] = true;
}

void graph::display() {
	int x = get_longest_path();
	cout << x;
}
int graph::get_longest_path() {
	return *max_element(begin(best_path_from), end(best_path_from));
}

int main(){
  graph* x= new graph();
  return 0;
}

Measured memory_bytes: 11648
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

total = 1
s_time = T[0]
count = 1
for i in range(1, N):
    count += 1
    if s_time + K < T[i] or count > C:
        s_time = T[i]
        count = 1
        total += 1
print(total)


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

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

    if(a <= b){
        for(int i=0; i<b; i++){
            cout << to_string(a);
        }
    }else{
        for(int i=0; i<a; i++){
            cout << to_string(b);
        }
    }
    cout << endl;   
}


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

int main()
{
	int N;
	string S1, S2;
	cin >> N;
	cin >> S1 >> S2;
	ll res = 1;
	bool f;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			if (S1[i] == S2[i]) {
				res = res * 3 % mod;
				f = true;
			}
			else {
				res = res * 6 % mod;
				i++;
				f = false;
			}
		}
		else if (S1[i] == S2[i]) {
			if (f) {
				res = res * 2 % mod;
			}
			else {
				;
			}
			f = true;
		}
		else {
			if (f) {
				res = res * 2 % mod;
			}
			else {
				res = res * 3 % mod;
			}
			f = false;
			i++;
		}
	}
	cout << res << endl;
	return 0;
}


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

int main(void){
  int a, b, cnt = 0;
  cin >> a >> b;
  for(int i = 1; i <= a; i++){
    if(i != a){
      for(int j = 1; j <= 31; j++){
	if(i == j)
	  cnt++;
      }
    }
    else{
      for(int j = 1; j <= b; j++){
        if(i == j)
	  cnt++;
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}


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


vector<int>solve2(const vector<int>&v,int from){
	vector<int>que;
	map<int,int>mp;
	for(int x=from;x<v.size();++x){
		if(mp.find(v[x])==mp.end()){
			que.emplace_back(v[x]);
			mp[v[x]]=que.size()-1;
		}else{
			while(true){
				int aback=que.back();
				
				mp.erase(aback);
				que.pop_back();
				if(aback==v[x])break;
			}
		}
	}
	return que;
}
vector<int> solve(int N,int K,vector<int>v,int start){
	
	vector<int>rs(N);

	{
		map<int,int>mp;
		for(int i=N-1;i>=0;--i){
			mp[v[i]]=N+i;
		}
		for(int i=N-1;i>=0;--i){
			rs[i]=mp[v[i]];
			mp[v[i]]=i;
		}
	}
	

	long long int ny=0,nx=start;
	map<int,long long int>mp;
	mp[start]=0;
	while(true){
		//cout<<nx<<ny<<endl;
		auto next_x=rs[nx];
		long long next_y=ny;
		//cout<<next_x<<' '<<next_y<<endl;
		if(next_x>=N){
			next_y++;
			next_x-=N;
		}
		next_x++;
		if(next_x>=N){
			next_y++;
			next_x-=N;
		}
		if(next_y>=K){
			
			if(K-1==next_y){
				v.insert(v.end(),v.begin(),v.end());
			}
			return solve2(v,nx);
		}else{
			ny=next_y;
			nx=next_x;

			if(mp.find(nx)==mp.end()){
				mp[nx]=ny;
			}else{
				long long sa=-(mp[nx]-ny);
				long long int rest=K-ny;
				rest%=sa;
				//cout<<rest<<endl;
				if(rest==0)rest=sa;

				long long xx=K%sa;
				if(xx==0)xx=sa;
				return solve(N,xx,v,0);
			}
		}
	}
	assert(false);
	
}
long long int sz=1e9;
void solve3(){
	long long int S;
	cin>>S;
	long long int x=(S-1)%sz;
	long long int y=(S-1)/sz+1;

	vector<long long int>v{0,0,sz,1,sz-1-x,y};
	for(int i=0;i<6;++i)cout<<v[i]<<' ';
	cout<<endl;
	return ;
}
int main() {
	solve3();
	return 0;
	int N;cin>>N;
	long long int K;cin>>K;
	vector<int>v;
	for(int i=0;i<N;++i){
		int a;cin>>a;
		v.push_back(a);
	}
	auto ans=solve(N,K,v,0);
	for(auto an:ans)cout<<an<<' ';
	cout<<endl;
	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define s size
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
int main()
{IOS;
ll t;
//cin>>t;
t=1;
while(t--)
{char a;
cin>>a;
if((int)a>=65 && (int)a<=90)cout<<'A';
else cout<<'a';
}
return 0;}


Measured memory_bytes: 3644
n = int(input())
a = [int(i) for i in input().split()]
num_4 = len([4 for a_ in a if (a_ % 4 == 0)])
num_2 = len([2 for a_ in a if (a_ % 4 == 2)])
num_0 = n - num_4 - num_2
if ((num_4 + num_2 > 0) & ((num_4 + 1 == num_0) & (num_2 == 0)) | (num_0 - num_4 <= 0)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const long long mod=1e9+7;
long long n,len,f[5005][5005]={0};
char s[5005];
long long qpow(long long x,long long y){
    long long res=1;
    while(y){
        if(y&1) res=(res*x)%mod;
        x=(x*x)%mod;
        y>>=1;
    }
	return res;
}
int main(){
    scanf("%d%s",&n,s);
    len=strlen(s);
    f[0][0]=1;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=i;j++){
            f[i+1][j+1]=(2*f[i][j]%mod+f[i+1][j+1])%mod;
            if(j>=1) f[i+1][j-1]=(f[i][j]+f[i+1][j-1])%mod;
            else f[i+1][0]=(f[i][j]+f[i+1][0])%mod;
        }
    long long ans=qpow(qpow(2,len),mod-2)*f[n][len]%mod;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 194048
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n, m; cin >> n >>m;
  vector<tuple<int, int ,int, int>> a(m);

  rep(i, m){
    int p, y; cin >> p >> y;
    p--;
    get<0>(a[i]) = p;
    get<1>(a[i]) = y;
    get<2>(a[i]) = i;
  }

  sort(ALL(a));

  vector<P> ans(n);
  int id = 0;
  int c = 0;
  rep(i, m){
    int b = get<0>(a[i]);
    get<0>(a[i]) = get<2>(a[i]);
    get<2>(a[i]) = b;
    if(id != b){
      id = b;
      c=1;
    }else{
      c++;
    }
    get<3>(a[i]) = c;
  }

  sort(ALL(a));

  rep(i, m){
    printf("%06d%06d\n",get<2>(a[i])+1,get<3>(a[i]));
  }

  return 0;
}


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

using namespace std;

typedef long long ll;

#define p(x) cout << x << endl
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define range(i, begin, end) for(int i = begin; i < (int)(end + 1); i++)
#define all(x) (x).begin(), (x).end()

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

    vector<int> as(n), bs(n);
    rep(i, n) { cin >> as[i] >> bs[i]; }

    map<int, vector<int>> a_to_b;
    rep(i, n) { a_to_b[as[i]].push_back(bs[i]); }

    int ans = 0;
    priority_queue<int> pq;
    rep(i, m) {
        int j = i + 1;
        rep(k, a_to_b[j].size()) { pq.push(a_to_b[j][k]); }
        if(pq.empty()) {
            continue;
        }
        ans += pq.top();
        pq.pop();
    }

    p(ans);

    return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	int sx,sy,tx,ty;

	cin >> sx >> sy >> tx >> ty;

	tx -= sx;
	sx = 0;
	ty -= sy;
	sy = 0;

	int u1 = ty;  //u1 = d1
	int r1 = tx;  //l1 = r1
	int l2 = 1;
	int u2 = ty + 1;
	int r2 = tx + 1;
	int d2 = 1;
	int r3 = 1;
	int d3 = ty + 1;
	int l3 = tx + 1;
	int u3 = 1;

	for(int i = 0; i < u1; i++)
	{
		cout << "U";
	}
	for(int i = 0; i < r1; i++)
	{
		cout << "R";
	}
	for(int i = 0; i < u1; i++)
	{
		cout << "D";
	}
	for(int i = 0; i < r1; i++)
	{
		cout << "L";
	}

		cout << "L";

	for(int i = 0; i < u2; i++)
	{
		cout << "U";
	}
	for(int i = 0; i < r2; i++)
	{
		cout << "R";
	}

		cout << "DR";
	
	for(int i = 0; i < d3; i++)
	{
		cout << "D";
	}
	for(int i = 0; i < l3; i++)
	{
		cout << "L";
	}

	cout << "U" << endl;

	return 0;
}
	

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

ll ans,k ;

void BFS(vvll &g,vll &used,int n,queue<int> &q){
	used.at(n) = 1 ;
	int cnt = 0 ;
	for(int i=0;i<g.at(n).size();i++){
		if(!used.at(g.at(n).at(i))){
			ans = ans*(k-2-cnt)%mod ;
			q.push(g.at(n).at(i)) ;
			cnt++ ;
		}
	}
	if(q.empty()) return ;
	n = q.front() ;
	q.pop() ;
	BFS(g,used,n,q) ;
}

int main(){
	ll n ;
	cin >> n >> k ;
	if(n==1){
		cout << k << endl ;
		return 0 ;
	}
	vvll g(n,vll(0)) ;
	for(int i=0;i<n-1;i++){
		int a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		g.at(a).emplace_back(b) ;
		g.at(b).emplace_back(a) ;
	}
	vll used(n,0) ;
	ans = k ;
	queue<int> q ;
	used.at(0) = 1 ;
	for(int i=0;i<g.at(0).size();i++){
		ans = ans*(k-1-i)%mod ;
		q.push(g.at(0).at(i)) ;
	}
	int s = q.front() ;
	q.pop() ;
	BFS(g,used,s,q) ;
	cout << ans << endl ;
}



Measured memory_bytes: 17012
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 500005


ll cal(ll x, ll y){
//	cout << x << " " << y << endl;
	if(x >= 0){
		if(abs(y) >= x) {
			if(y >= x)
				return y - x;
			else return (abs(y) - x) + 1;
		} else{
			return cal(-x, y) + 1;
		}
	} else{
		ll ret = (1ll << 60);
		if(y >= x) ret = y - x;
		if(abs(y) >= abs(x)){
			ret = min(ret, cal(-x, y) + 1);
		} else{
			if(y > 0){
				ret = min(ret, cal(x, -y) + 1);
			}
		}
//		cout << ret << endl;
		return ret;
	}
	return -1;
}

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x, y;
    cin >> x >> y;
    cout << cal(x, y) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    string s, t; cin >> s >> t;
    vector<string> v;
    FOR(i, 0, s.size()-t.size()) {
        // s[i] からt文字分を見たとき、ハテナ以外は一致しているか確認
        string sub = s.substr(i, t.size());
        bool ok = true;
        REP(j, t.size()) {
            if (sub[j] != '?' && sub[j] != t[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            // 元の文字列のiからt.size()個をtに置き換えた文字列を作る
            string m;
            if (i > 0) {
                m = s.substr(0, i) + t + s.substr(i+t.size());
            } else {
                m = t + s.substr(i+t.size());
            }
            replace(m.begin(), m.end(), '?', 'a');
            v.push_back(m);
        }
    }
    if (v.size() > 0) {
        sort(ALL(v));
        cout << v[0] << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<utility>
#include<string>
#include<iomanip>
#include<queue> 
#include<cmath>
#include<utility>
#include<set>
using namespace std;
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  string a, b, s;
  int x, y;
  cin >> a >> b >> x >> y >> s;
  if(s==a)
    cout << x-1 << ' ' << y << '\n';
  else
    cout << x << ' ' << y-1 << '\n';
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    // dp[i]に遷移するのはdp[i-1], dp[i-2],dp[i-3],dp[i-4],dp[i-5], dp[i-6],dp[i-36],..., dp[i-9],dp[i-81],...
    vector<ll> dp(100001, mod);
    vector<ll> fac6, fac9;
    fac6.push_back(1); fac9.push_back(1);
    rep(i, 10){
        fac6.push_back(fac6.back()*6);
        fac9.push_back(fac9.back()*9);
    }
    rep(i, 6) dp[i] = i;
    
    for(int i = 6; i <= N; i++){
        for(int j = 1; j <= 5; j++) dp[i] = min(dp[i], dp[i-j]+j);
        for(int j = 1; i-fac6[j] >= 0; j++) dp[i] = min(dp[i], dp[i-fac6[j]] + 1);
        for(int j = 1; i-fac9[j] >= 0; j++) dp[i] = min(dp[i], dp[i-fac9[j]] + 1);
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) :n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; i++) {
            if (f[i]) {
                continue;
            }
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) {
                    f[j] = i;
                }
            }
        }
    }

    bool isPrime(int x) {
        return f[x] == x;
    }

    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }

    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) {
            return {};
        }
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            }
            else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main() {
    Sieve sieve(100005);
    vector<int> cnt(100005, 0);
    rep(i, 100005){
        cnt[i] += cnt[i - 1];
        if(i % 2 == 0 || i == 1) continue;
        if(sieve.isPrime(i) && sieve.isPrime((i + 1) / 2)) cnt[i]++;
    }
    int q;
    cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << endl;
    }
    
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sandybridge __attribute__((optimize("Ofast"), target("arch=sandybridge")))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

int n, m, a, b, p[200005], sz[200005], ans;

int fs(int x) {
	if (p[x] == x) return x;
	return p[x] = fs(p[x]);
}

int main() {
	fastio; cin >> n >> m;
	FOR(i, 1, n) p[i] = i, sz[i] = 1;
	FOR(i, 1, m) {
		cin >> a >> b;
		if (fs(a) == fs(b)) continue;
		sz[fs(b)] += sz[fs(a)];
		p[fs(a)] = fs(b);
	}
	FOR(i, 1, n) ans = max(ans, sz[i]);
	cout << ans;
}


Measured memory_bytes: 5200
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num1 = scan.nextInt();
		int num2 = scan.nextInt();
		int num3 = scan.nextInt();
		int wk = 0;

		wk = num1;
		num1 = num2;
		num2 = wk;

		wk = num1;
		num1 = num3;
		num3 = wk;

		System.out.println(num1+" "+num2+" "+num3);
	}
}

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

struct Pt {
	int x;
	int y;
};

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

	int N, M;
	cin >> N >> M;

	vector<Pt> a( N );
	vector<Pt> b( M );
	for( auto& v: a ) { cin >> v.x >> v.y; }
	for( auto& v: b ) { cin >> v.x >> v.y; }

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

		for( int j = 0; j < M; ++j ) {
			int d = abs( a[i].x - b[j].x ) + abs( a[i].y - b[j].y );
			if( d < m ) {
				m = d;
				p = j+1;
			}
		}

		cout << p << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }




int main() {
	int n;
	cin >> n;
	int a[2][110];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; ++j) {
			cin >> a[i][j];
		}
	}
	int ans[2][110] = { 0 };
	ans[0][0] = a[0][0];
	for(int i = 1; i < n; ++i) {
		ans[0][i] = ans[0][i-1] + a[0][i];
	}
	ans[1][0] = ans[0][0] + a[1][0];
	for (int i = 1; i < n; ++i) {
		ans[1][i] = max((ans[1][i-1]+a[1][i]), ans[0][i] + a[1][i]);
	}
	cout << ans[1][n - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   998244353
#define    inf  9223372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(x==0)return 0;if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}





int main()
{       io 
int testcases=1;      //  cin>>testcases;
while(testcases--)
{


int n;
cin>>n;

int a[n],b[n];

for(int i=0;i<n;i++)
{
	cin>>a[i];
	b[i]=a[i];
}

sort(b,b+n);




for(int i=0;i<n;i++)
{
	if(a[i]!=b[n-1])
	cout<<b[n-1]<<"\n";
	else
	{
	cout<<b[n-2]<<"\n";
	}
}






}return 0;}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
    return 0;
}


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

int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int aa = a % 10; if (aa == 0)aa += 10;
	int bb = b % 10; if (bb == 0)bb += 10;
	int cc = c % 10; if (cc == 0)cc += 10;
	int dd = d % 10; if (dd == 0)dd += 10;
	int ee = e % 10; if (ee == 0)ee += 10;
	
	int	 x = min(aa, min(bb, min(cc, min(dd, ee))));
	
	while (a % 10 != 0)a++;
	while (b % 10 != 0)b++;
	while (c % 10 != 0)c++;
	while (d % 10 != 0)d++;
	while (e % 10 != 0)e++;
	//cout << a <<" "<< b << " " << c << " " << d << " " << e << " " << x << endl;////////////////////
	cout << a + b + c + d + e - (10-x)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b;
    char op;
    
    cin >> a >> op >> b;

    switch (op) {
        case '+':
            cout << a + b << endl;
            break;
        
        default:
            cout << a - b << endl;
            break;

    }
}

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

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i=0; i<n; i++) cin >> l[i];
    
    sort(l.begin(), l.end(), greater<int>());
    
    int ans = 0;
    for (int i=0; i<k; i++) {
        ans += l[i];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>

typedef struct {
	int s, v;
	long n;
} pair;

long dp[16][1024];
int _c = 0;
pair lazy[1000000];

int append(int s, int v, long n)
{
	lazy[_c++] = (pair){s, v, n};
	return (0);
}

int apply(void)
{
	int it = _c - 1;
	while (it >= 0){
		dp[lazy[it].s][lazy[it].v] += lazy[it].n;
		it--;
	}
	_c = 0;
	return (0);
}

int main(void)
{
	int i, j, k;
	int n, s;

	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (i = 0; i <= 100; i++){
		for (j = 0; j < 9; j++){
			for (k = 0; k <= 1000; k++){
				if (dp[j][k]) append(j + 1, k + i, dp[j][k]);
			}
		}
		apply();
	}

	while (scanf("%d %d", &n, &s), n + s){
		printf("%ld\n", dp[n][s]);
	}
	return (0);
}

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

int main() {
	int m,f,r;
	while(true){
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		else{
			if(m==-1||f==-1||m+f<30){
				cout<<"F"<<endl;
			}
			else if(m+f>=30&&m+f<50&&r<50){
				cout<<"D"<<endl;
			}
			else if(m+f>=30&&m+f<50&&r>=50){
				cout<<"C"<<endl;
			}
			else if(m+f>=50&&m+f<65){
				cout<<"C"<<endl;
			}
			else if(m+f>=65&&m+f<80){
				cout<<"B"<<endl;
			}
			else if(m+f>=80){
				cout<<"A"<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if (A > C) {
        swap(A, C);
        swap(B, D);
    }

    //ABCD
    if (B <= C)cout << 0 << endl;
    //ACBD
    else if (C < B&&B <= D)cout << B - C << endl;
    //ACDB
    else cout << D - C << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int key, id;
} data;

typedef struct {
	data obj[400001];
	int size;
} min_heap;

void push(data x, min_heap* h)
{
	int i = ++(h->size), j = i >> 1;
	data tmp;
	h->obj[i] = x;
	while (j > 0) {
		if (h->obj[i].key < h->obj[j].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j >>= 1;
		} else break;
	}
}

data pop(min_heap* h)
{
	int i = 1, j = 2;
	data output = h->obj[1], tmp;
	h->obj[1] = h->obj[(h->size)--];
	while (j <= h->size) {
		if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1;
		if (h->obj[j].key < h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
			j <<= 1;
		} else break;
	}
	return output;
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = r;
	while (r > 0) {
		sum -= BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, H, W, A, B;
	scanf("%d %d", &H, &W);
	
	int j, k, s[200002], left[200002], right[200002], BIT[200001] = {}, L, R, M, tmp;
	data d;
	min_heap h;
	h.size = 0;
	for (i = 0; i <= W + 1; i++) {
		s[i] = i;
		left[i] = i - 1;
		right[i] = i + 1;
	}
	for (i = 1, d.key = 0; i <= W; i++) {
		d.id = i;
		push(d, &h);
	}
	for (i = 1; i <= H; i++) {
		scanf("%d %d", &A, &B);
		tmp = sum_BIT(BIT, B);
		if (sum_BIT(BIT, A - 1) == tmp) {
			printf("%d\n", h.obj[1].key + i);
			continue;
		}
		
		if (s[B+1] < 0) {
			L = A;
			R = B;
			while (L != R) {
				M = (L + R) / 2;
				if (sum_BIT(BIT, M) != tmp) L = M + 1;
				else R = M;
			}
			s[B+1] = s[L];
			right[B+1] = right[L];
			left[right[L]] = B + 1;
			
			d.key = B + 1 - s[B+1];
			d.id = B + 1;
			push(d, &h);
			add_BIT(W, BIT, B + 1, -1);
		} else L = left[B+1];
		
		for (j = L; j >= A; j = left[j]) {
			s[j] = -1;
			add_BIT(W, BIT, j, 1);
		}
		left[B+1] = j;
		right[j] = B + 1;
		
		while (h.size > 0 && s[h.obj[1].id] != h.obj[1].id - h.obj[1].key) pop(&h);
		if (h.size > 0) printf("%d\n", h.obj[1].key + i);
		else break;
	}
	for (; i <= H; i++) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 6492
#include <iostream>

int main(){
    int N,T;
    int c[100] = {0};
    int t[100] = {0};
    std::cin >> N >> T;
    for (int i=0;i<N;i++){
        std::cin >> c[i] >> t[i];
    }
    int min = 10000;
    int res = -1;
    printf("\n");
    for (int i=0;i<N;i++){
        std::cerr << c[i] << " " << t[i] << " " << min << " " << res << std::endl;
        if(t[i] <= T){
            if(c[i] < min){
                min = c[i];
                res = c[i];
            }
        }
    }
    std::cerr << res << std::endl;
    if(res >= 0){
        std::cout << res << std::endl;
    }else{
        std::cout << "TLE" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int X, A;

	cin >> X >> A;

	if (X < A)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 10 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int m, n, i, j, be = 1, ans = 0, t;
  scanf("%d%d", &n, &m);
  for(i = 0; i < m; ++i) {
    scanf("%d", &t);
    if(!i) ans = t - 1;
    else if((t - be) / 2 > ans) ans = (t - be) / 2;
    be = t;
  }
  if(n - be > ans) ans = n - be;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2748
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmax(T &a, T b) { return a < b && (a = b, true); }

int main() {

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

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int len) {

		unordered_map<string, int> mp;
		for (int j = 0; j <= N - len; j++) {
			string tmp = s.substr(j, len);
			auto itr = mp.find(tmp);
			if (itr == mp.end()) mp.emplace(tmp, j);
			else if (j - itr->second >= len) return true;
		}
		
		return false;
	};

	vector<int> len(N/2 + 2);
	iota(len.begin(), len.end(), 0);
	cout << *partition_point(len.begin(), len.end(), check) - 1 << endl;

	return 0;
}


Measured memory_bytes: 6696
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
l = [None] * n
for i in range(n):
    k, *l[i] = list(map(lambda x: int(x) - 1, input().split()))
uf = UnionFind(m)
for row in l:
    for i in range(len(row) - 1):
        uf.unite(row[i], row[i + 1])
s = set()
for row in l:
    for x in row:
        s.add(uf.find(x))
if len(s) == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 70488
#include <stdio.h>

int main(void) {
	int A, B, C, D;
	scanf("%d%d%d%d", &A, &B, &C, &D);

	int E = A < B ? A : B;
	int F = C < D ? C : D;

	printf("%d\n", E + F);

	return 0;
}

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

int main(){
  
  int n,ans=0;
  cin>>n;
  while(n--){
    int a;
    cin>>a;
    int i=2;
    while(i*i<=a && a%i)i++;
    if(a%i||a==2)ans++; 
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <climits>
using namespace std;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}


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

    cout << k*int(pow(k-1,n-1)) << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int get(int n){
	int s = 0;
	while(n!=0){
		s+=n%10;
		n/=10;
	}
	return s;
}
void solve(){
	int n, a, b;
	cin>>n>>a>>b;
	int ans = 0;
	rep(i,1,n+1)
		if(get(i) >= a && get(i) <= b)
			ans += i;
	cout<<ans<<endl;

}
	
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
  t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    int n,m;
    int[] h,w;

    void solve(){
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	while(n!=0){
	    m = sc.nextInt();
	    h = new int[n];
	    w = new int[m];
	    for(int i=0; i<n; i++){h[i] = sc.nextInt();}
	    for(int i=0; i<m; i++){w[i] = sc.nextInt();}

	    int max = 1000*1500+1;
	    int[] hlist = new int[max];
	    int[] wlist = new int[max];

	    for(int i=0; i<n; i++){
		int sum = 0;
		for(int j=i; j<n; j++){
		    sum += h[j];
		    hlist[sum]++;
		}
	    }
	    for(int i=0; i<m; i++){
		int sum = 0;
		for(int j=i; j<m; j++){
		    sum += w[j];
		    wlist[sum]++;
		}
	    }

	    int count = 0;
	    for(int i=0; i<hlist.length; i++){
		count += hlist[i]*wlist[i];
	    }
	    
	    System.out.println(count);
	    
	    n = sc.nextInt();
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 24000
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;

string solve() {
    stringstream res;
    for (int i = 0; i < 4; i++) res << s[i];
    res << ' ';
    for (int i = 4; i < 12; i++) res << s[i];
    
    return res.str();
}

void input() {
    cin >> s;
}

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

    input();
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
    int n,a[100001],i,m=999999999;
    bool f=1;
    long long int r=0;
    cin >> n;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]<0){
            f^=1;
            a[i]=-a[i];
        }
        if(m>a[i])m=a[i];
        r+=a[i];
    }
    printf("%lld\n",r-2*m*(1-f));
}

int abs(int x){
    if(x<0)return -x;
    return x;
}

Measured memory_bytes: 640
from itertools import groupby
from collections import deque
N, K = map(int, input().split())
S = [len(list(g)) for k, g in groupby(input())]
S = deque(S)
i = 0
while i < K and len(S) > 2:
    S.append(S.pop() + S.pop() + S.pop())
    i += 1
if i < K and len(S) == 2:
    S.append(S.pop() + S.pop())
print(sum(S) - len(S))


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

int main() {

	int S_num, T_num;
	std::string S_sec, T_sec;

	std::string S, T;

	std::cin >> S >> T;

	S_num = int(S.length());
	T_num = int(T.length());

	S_sec = S.substr(0, S_num);
	T_sec = T.substr(0, T_num - 1);

	if (S_sec == T_sec && S_num + 1 == T_num) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		scn.nextLine();
		HashMap<String, Integer> S = new HashMap<String, Integer>();
		for (int i = 0; i < N; i++) {
			char[] ch = scn.nextLine().toCharArray();
			String s = makeString(ch);
			if(S.containsKey(s)) {
				S.put(s, S.get(s)+1);
			}else {
				S.put(s, 1);
			}
		}
		long ans = 0;
		for(long num:S.values()) {
			ans += (num-1) * num /2;
		}
		System.out.println(ans);
	}

	public static String makeString(char[] ch) {
		String s = "";
		Arrays.sort(ch);
		for (int i = 0; i < ch.length; i++) {
			s += ch[i];
		}
		return s;
	}
}


Measured memory_bytes: 157788
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// B - Bitter Alchemy
int main(){
    int N, X;
    cin >> N >> X;
    
    int ans = 0;
    int powder = X;
    vector<int> donut;
    for (int i=0;i<N;++i){
        int m;
        cin >> m;
        donut.push_back(m);
        powder -= m;
        ++ans;
    }

    int min = *min_element(donut.begin(), donut.end());
    ans += (powder/min);

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




Measured memory_bytes: 256
N = int(input())
p = list(map(int,input().split()))

now = count = 0
while(now<N):
    if p[now]==now+1:
        if now+1 != N:
            tmp = p[now]
            p[now] = p[now+1]
            p[now+1] = tmp
            now -= 1
            count += 1
            continue
        else:
            tmp = p[now]
            p[now] = p[now-1]
            p[now-1] = tmp
            now -= 1
            count += 1
            continue
    now += 1
print(count)


Measured memory_bytes: 14008
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string a , b , c;
  cin >> a >> b >> c;
  int k = a.size() - 1;
  int l = b.size() - 1;
  if(a[k] == b[0] && b[l] == c[0])cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
const int MAX_V = 1000000;
int main() {
	int prime[MAX_V+1];
    int i, k, v,a=0,n;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1;
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0;
            }
            
        } 
        
    }
    while(1){
      scanf("%d",&n);
      if(n==0)break;
      for(i=0;i<=n-2;i++){
          int isprime = prime[i];
          int isprimex = prime[i+2];
          if(isprime && isprimex){
             if(a<i)a=i;
          }
        }
        printf("%d %d\n",a,a+2);
    	a=0;
    }
    return 0; 
    
}

Measured memory_bytes: 5584
n = int(input())
t_p = 0
h_p = 0
for i in range(n):
    t, h = input().split()
    if t > h:
        t_p += 3
    elif t < h:
        h_p += 3
    else:
        t_p += 1
        h_p += 1
print(t_p, h_p)



Measured memory_bytes: 5596
import java.awt.Polygon;
import java.awt.geom.Point2D;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			Polygon polygon = new Polygon();
			for (int i = 0; i < 3; i++) {
				int x = scanner.nextInt();
				int y = scanner.nextInt();
				polygon.addPoint(x, y);
			}
			Point2D.Double[] points = new Point2D.Double[2];
			boolean[] b = new boolean[2];
			for (int i = 0; i < 2; i++) {
				points[i] = new Point2D.Double(scanner.nextDouble(),
						scanner.nextDouble());
				b[i] = polygon.contains(points[i]);
			}
			System.out.println(b[0] ^ b[1] ? "OK" : "NG");

		}
	}
}

Measured memory_bytes: 67204
n = int(input())
s = []
a = 0
for i in range(n):
    s.append(int(input()))
    a += s[i]
ans = 0
for i in range(n):
    if s[i] % 10 == 0:
        continue
    ans = max(ans, a - s[i])
if not a % 10 == 0:
    print(a)
else:
    print(ans)

Measured memory_bytes: 3060
#include<vector>
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int &i : v) cin >> i;
    int T;
    cin >> T;
    while (T--) {
        int b, e, t;
        cin >> b >> e >> t;
        // auto it = v.begin();
        for (int k = 0; k < e - b; k++) {
            swap(v[b+ k], v[t + k]);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << v[i];
        if (i!=n-1) cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3088
N = int(input())
Cs = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    adj[a - 1].append(b - 1)
    adj[b - 1].append(a - 1)

degs = [0] * N
clusters = [[] for _ in range(N)]


def go(curr, fro):
    col = Cs[curr] - 1
    deg = 1
    clust = {}
    for n in adj[curr]:
        if n == fro:
            continue
        ch_deg, ch_clust = yield go(n, curr)
        clusters[col].append(ch_deg - ch_clust.get(col, 0))
        if len(ch_clust) > len(clust):
            clust, ch_clust = ch_clust, clust
        for k, v in ch_clust.items():
            clust[k] = clust.get(k, 0) + v
        deg += ch_deg
    clust[col] = deg
    return deg, clust


def tramp(gen):
    stack = [gen]
    val = None
    while stack:
        try:
            stack.append(stack[-1].send(val))
            val = None
        except StopIteration as e:
            stack.pop()
            val = e.value
    return val


_, root_clust = tramp(go(0, -1))
for i in range(N):
    clusters[i].append(N - root_clust.get(i, 0))


for clust in clusters:
    tot = (N * N + N) // 2
    for cnt in clust:
        tot -= (cnt * cnt + cnt) // 2
    print(tot)


Measured memory_bytes: 253168
local n = io.read("*n")
local sum = {}
sum[1] = io.read("*n")
for i = 2, n do
  local a = io.read("*n")
  sum[i] = a + sum[i - 1]
end
local mab, mmi = math.abs, math.min
local ret = mab(sum[n] - sum[1] - sum[1])
for i = 2, n - 1 do
  ret = mmi(ret, mab(sum[n] - sum[i] - sum[i]))
end
print(ret)


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

using namespace std;

typedef long long int64;

int main()
{
  int64 N, M, A, B, P, Q;

  cin >> N >> M >> A >> B >> P >> Q;

  if(A == 1 && B == 1) {
    int64 T = P + Q;
    if(N < (M + T - 1) / T) {
      cout << M - T * N << endl;
    } else {
      cout << min(M % T, T - M % T) << endl;
    }
  } else {
    int64 PA = P, QB = Q;
    vector< int64 > vs;
    for(int i = 0; i < min(42LL, N); i++) {
      vs.push_back(PA + QB);
      if((double) PA * A + QB * B > 1e18) break;
      PA *= A;
      QB *= B;
    }

    int mid = vs.size() / 2;
    int rest = vs.size() - mid;
    vector< int64 > ss(1 << mid, 0);
    for(int i = 0; i < (1 << mid); i++) {
      for(int j = 0; j < mid; j++) {
        if((i >> j) & 1) ss[i] += vs[j];
      }
    }
    sort(begin(ss), end(ss));
    ss.erase(unique(begin(ss), end(ss)), end(ss));

    int64 ret = 1LL << 60;
    for(int i = 0; i < (1 << rest); i++) {
      int64 now = 0;
      for(int j = 0; j < rest; j++) {
        if((i >> j) & 1) now += vs[mid + j];
      }
      auto ptr = lower_bound(begin(ss), end(ss), M - now);
      if(ptr != ss.end()) ret = min(ret, llabs(M - now - *ptr));
      if(ptr != ss.begin()) ret = min(ret, llabs(M - now - *--ptr));
    }

    cout << ret << endl;

  }
}

Measured memory_bytes: 19252