akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

int main(){

	int color[8][3] = {{0, 0, 0}, {0, 0, 255}, {0, 255, 0}, {0, 255, 255}, {255, 0, 0}, {255, 0, 255}, {255, 255, 0}, {255, 255, 255}};
	double d, f, p[3];
	string str, c;

	while(cin >> str){
		if(str[0] == '0') break;

		d = sqrt(3 * pow(255, 2));
		for(int j=0; j<3; j++){
			if(str[2*j+1] >= '0' && str[2*j+1] <= '9') p[j] = 16 * (str[2*j+1] - '0');
			else p[j] = 16 * (10.0 + str[2*j+1] - 'a');
				
			if(str[2*j+2] >= '0' && str[2*j+2] <= '9') p[j] += str[2*j+2] - '0';
			else p[j] += 10.0 + str[2*j+2] - 'a';
		}
		
		for(int i=0; i<8; i++){
			f = sqrt(pow(p[0] - color[i][0], 2) + pow(p[1] - color[i][1], 2) + pow(p[2] - color[i][2], 2));
			if(d > f){
				d = f;
				switch(i){
					case 0: c = "black"; break;
					case 1: c = "blue"; break;
					case 2: c = "lime"; break;
					case 3: c = "aqua"; break;
					case 4: c = "red"; break;
					case 5: c = "fuchsia"; break;
					case 6: c = "yellow"; break;
					case 7: c = "white"; break;
				}
			}
		}
		
		cout << c << endl;
	}

	return 0;

}

Measured memory_bytes: 1176
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] n = sc.next().toCharArray();
		sc.close();
		out.println(n[0]=='7'||n[1]=='7'||n[2]=='7'?"Yes":"No");
	}
}


Measured memory_bytes: 26996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		out.println(solve(ni()));
	}

	private long solve(int n) throws IOException {
		int a[] = nia(n);

		int ans = 0;
		for (int i = 0; i < n;) {
			int j = i;
			for (; j < n && a[j] == a[i]; j++)
				;
			ans += (j - i) / 2;
//			Helper.tr(i, j);
			i = j;
		}

		return ans;
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define MAX_V 100010
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

//int cost[MAX_V][MAX_V];
ll d[MAX_V];
//bool used[MAX_V];
int V;
struct edge {
	int to, cost;
};
vector<edge> G[MAX_V];

// O(ElogV)
void dijkstra(int s) {
	fill(d, d + V, INF);
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(make_pair(0, s)); // distance, index)

	while(!q.empty()) {
		P p = q.top();
		q.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		rep(i, 0, G[v].size()) {
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				q.push(P(d[e.to], e.to));
			}
		}
	}
}

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

	cin >> V;
	rep(i, 0, V - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		edge e, e2;
		e.to = b;
		e.cost = c;
		G[a].push_back(e);
		e2.to = a;
		e2.cost = c;
		G[b].push_back(e2);
	}

	int Q, K;
	cin >> Q >> K;
	dijkstra(K - 1);

	vector<ll> rsl;
	rep(i, 0, Q) {
		int x, y;
		cin >> x >> y;
		rsl.push_back(d[--x] + d[--y]);
	}

	rep(i, 0, Q) cout << rsl[i] << endl;
		
}


Measured memory_bytes: 10212
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	string s;
	cin >> s;

	int n = s.length() + 1;
	vector<ll> l(n), r(n);
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '<')
		{
			l[i + 1] = l[i] + 1;
		}
	}

	for (int i = n - 1; i >= 0; i--)
	{
		if (s[i] == '>')
		{
			r[i] =r[i + 1] + 1;
		}
	}
	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		res += max(l[i], r[i]);
	}

	cout << res << endl;
}

Measured memory_bytes: 8708
n = int(input())
X = list(map(int, input().split()))

x = list(enumerate(X))

x.sort(key=lambda x: x[1])
A = list(map(lambda x: x[1], x[n//2-1:n//2+1]))

for v in X:
    if v <= A[0]:
        print(A[1])
    else:
        print(A[0])


Measured memory_bytes: 40380
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int s[28] = {0};
int t[28] = {0};

int main(int argc, char* argv[]){
	string S, T;
	cin >> S;
	cin >> T;

	int N = S.size();
	int NG = 0;
	for(int i=0; i<N; i++){
		int u = S.at(i) - 'a';
		int v = T.at(i) - 'a';
		if(s[u] != 0 && s[u] != v){
			NG = 1;
			break;
		}
		s[u] = v;
		if(t[v] != 0 && t[v] != u){
			NG = 1;
			break;
		}
		t[v] = u;
	}
	if(NG == 1){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 776
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, a;

  scanf("%d", &n);

  bool f = false;
  
  for(int i=0;i<n;i++){
    scanf("%d", &a);
    f |= a%2;
  }

  if(f){
    puts("first");
  }else{
    puts("second");
  }
  
  
  return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    return N * (N-1) // 2 + M * (M - 1) // 2


def main():
    N, M = map(int, sys.stdin.readline().split())
    print(solve(N, M))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >>a>>b>>c;
  int ichi,ni,san;
  int saidai=max(a,max(b,c));
  if(a==saidai){
    int i=min(abs(saidai-b),abs(saidai-c));
    int j=abs(b-c);
    if(j%2==1)j+=2;
    cout<<i+(j+1)/2<<endl;  
  }else if(b==saidai){
    int i=min(abs(saidai-a),abs(saidai-c));
    int j=abs(a-c);
    if(j%2==1)j+=2;
    cout<<i+(j+1)/2<<endl;  
  }else if(c==saidai){
    int i=min(abs(saidai-b),abs(saidai-a));
    int j=abs(b-a);
    if(j%2==1)j+=2;
    cout<<i+(j+1)/2<<endl;  
  } 
  return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x <= 3) {
    ans += 100000 * (4 - x);
  }
  if (y <= 3) {
    ans += 100000 * (4 - y);
  }
  if (x + y == 2) {
    ans += 400000;
  }

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


Measured memory_bytes: 3568
n=int(input())
arr=list(map(int,input().split()))
arr=arr[::-1]
if arr[0]!=2:
  print(-1)
else:
  arr=arr[1:]
  l=2
  r=3
  for val in arr:
    if (l<=val*(l//val)<=r) or (l<=val*(r//val)<=r):
      if l%val!=0:
        l=val*(l//val+1)
      r=val*(r//val+1)-1
    else:
      print(-1)
      break
  else:
    print(l,r)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    long long int T;
    cin >> N >> T;
    long long int t[N];
    for(int i = 0;i < N;i++)
    {
        cin >> t[i];
    }
    long long int sum = 0;
    for(int i = 0;i < N - 1;i++)
    {
        sum += min(T,(t[i + 1] - t[i]));
    }
    cout << sum + T;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int h,w,d,n,q;
vi x,y;

int main(){
	cin>>h>>w>>d;
	n=h*w;
	x=y=vi(n);
	vi a(n);
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		int A;
		cin>>A;
		x[A-1]=i;y[A-1]=j;
	}
	for(int i=0;i<n;i++) if(i>=d) a[i]+=a[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d]);
	cin>>q;
	for(int i=0;i<q;i++){
		int l,r;
		cin>>l>>r;
		cout<<a[r-1]-a[l-1]<<endl;
	}
}

Measured memory_bytes: 2176
import bisect
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
bl.sort()
cl.sort()
ans = 0

for b in bl:
    ca = bisect.bisect_left(al, b)
    cc = n-bisect.bisect_right(cl, b)
    ans += ca*cc
print(ans)


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

int main(){
	int a,b,r;
	cin >> a >> b;
	if(a<b) swap(a,b);
		while(b>0){
			r =a%b;
			a = b;
			b = r;
		}
	cout << a << endl;
	return 0;
}

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

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

    vector<long long> A(n);
    vector<long long> B(n);
  
    ios::sync_with_stdio(false);
  
    for(long long i=1; i<n; i++){
        cin >> A.at(i);
        B.at(A.at(i)-1)+=1;
    }

    for(long long i=0; i<n; i++){
        cout << B.at(i) << endl;
    }
}


Measured memory_bytes: 6376
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int M=1003;
int dp[1<<14];
int n,m;
int a,b,c;
int main() {
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++) {
		int tmp=0;
		scanf("%d %d",&a,&b);
		for(int j=0;j<b;j++) {
			scanf("%d",&c);
			tmp|=(1<<(c-1));
		}
		for(int j=(1<<n)-1;j>=0;j--)
			dp[j|tmp]=min(dp[j|tmp],dp[j]+a);
	}
	if(dp[(1<<n)-1]==0x3f3f3f3f)
		printf("-1\n");
	else printf("%d\n",dp[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, readline().split())
sc = [tuple(map(int, readline().split())) for _ in range(M)]
sc = sorted(list(set(sc)))

ans = ["*"] * N
for s, c in sc:
    if ans[s - 1] != "*":
        print("-1")
        sys.exit()
    elif (N > 1) & (s == 1) & (c == 0):
        print("-1")
        sys.exit()
    else:
        ans[s - 1] = str(c)

for i, c in enumerate(ans):
    if c == "*":
        ans[i] = "0"

if len(ans) > 1:
    if ans[0] == "0":
        ans[0] = "1"
print("".join(ans))


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[3][100];
	long long int p[3][100],n,i,sum;
	while(scanf("%lld",&n)!=EOF)
	{
		sum=1;
		for(i=0;i<2;i++)
		scanf("%s",a[i]);
		for(i=0;i<n;)
		{
			if(a[0][i]==a[0][i+1])
			{
				p[0][i]=p[0][i+1]=p[1][i]=p[1][i+1]=2;
				i+=2;
			}
			else if(a[0][i]==a[1][i])
			{
				p[0][i]=p[1][i]=1;
				i++;
			}
		}
		//for(i=0;i<n;i++)
		//printf("%d",p[0][i]);
		//cout<<endl;
		//for(i=0;i<n;i++)
		//printf("%d",p[1][i]);
		//cout<<endl;
		for(i=0;i<n;)
		{
			if(p[0][i]==1)
			{
				if(i==0)sum*=3;
				else if(p[0][i-1]==1)
				sum*=2;
				else if(p[0][i-1]==2)
				sum*=1;
				
				i++;
			}
			else if(p[0][i]==2)
			{
				if(i==0)sum*=3*2;
				else if(p[0][i-1]==1)
				sum*=2;
				else if(p[0][i-1]==2)
				sum*=3;
				i+=2;
			}
			sum%=1000000007;
		}
		printf("%lld\n",sum);
	}
	return 0;
}

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

int main(){
	int N; cin>>N;
	set<string> s{"a"};
	while(--N){
		set<string>t; swap(s,t);
		for(auto pre:t){
			set<char> types{'a'}; for(auto c:pre) types.insert(c+1);
			for(auto c:types) s.insert(pre + c);
		}
	}
	for(auto x:s) cout<< x <<endl;
}

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

int bit_rank(long k) {
    int ret = 0;
    while (k > 0) {
        k >>= 1;
        ret++;
    }
    return ret;
}

int main() {
    int n;
    long k;
    cin >> n >> k;
    long a[n];
    int m = bit_rank(k);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long x = 0;
    for (int i = 1; i <= m; i++) {
        x <<= 1;
        int count_one = 0;
        for (int j = 0; j < n; j++) {
            count_one += ((a[j] >> (m - i)) & 1);
        }
        if (n - count_one > count_one && ((x | 1) << (m - i)) <= k) {
            x |= 1;
        }
    }
    long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[i] ^ x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, t;
    scanf("%d %d", &x, &t);
    int ans = x - t;
    if(ans > 0) printf("%d\n", ans);
    else printf("0\n"); 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1266666;
ll n,k,a[N],pos[N],nxt[N];
Pii s[N];int len;
int calc(int x){return x<=n?x:x-n;}
bool vis[N];int b[N],sz;
void ins(int x){
	if(!vis[x])vis[x]=1,b[++sz]=x;
	else{
		while(vis[x])vis[b[sz]]=0,sz--;
	}
}
int main() {
	read(n);read(k);rep(i,1,n)read(a[i]),a[n+i]=a[i];
	if(n==1){
		if(k&1)printf("%d ",a[1]);
		return 0;
	}
	per(i,2*n,1){
		nxt[i]=pos[a[i]]+1;
		pos[a[i]]=i;
	}
	s[++len]=Pii(0,1);
	while(len==1||s[len].se!=1){
		s[len+1]=Pii(s[len].fi+(nxt[s[len].se]>n),calc(nxt[s[len].se]));
		if(s[len+1].se>n)s[len+1].se-=n,s[len+1].fi++;
		len++;
	}
//	rep(i,1,len)cerr<<s[i].fi<<' '<<s[i].se<<endl;
	k%=s[len].fi;if(!k)k+=s[len].fi;int p=1;
	while(p+1<=len&&s[p+1].fi<k)p++;Pii cur=s[p];
	while(cur.fi<k){
		ins(a[cur.se]);
		cur.se++;if(cur.se>n)cur.se-=n,cur.fi++;
	}
	rep(i,1,sz)printf("%d ",b[i]);
	return 0;
}


Measured memory_bytes: 22784
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string n;
	cin>>n;
	if(n[0]=='7' or n[1]=='7' or n[2]=='7')
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3624
def walk_heap(A, idx, idx_format_map):
    if len(A) < idx:
        return
    idx_format = "node {}: ".format(idx)
    key_format = "key = {}, ".format(A[idx-1])
    parent_format = ""
    left_format = ""
    right_format = ""
    if idx > 1:
        parent_format = "parent key = {}, ".format(A[idx//2-1])
    if idx*2 <= len(A):
        left_format = "left key = {}, ".format(A[idx*2-1])
    if idx*2+1 <= len(A):
        right_format = "right key = {}, ".format(A[idx*2])
    answer_format = "{}{}{}{}{}".format(idx_format, key_format, parent_format, left_format, right_format)
    idx_format_map[idx] = answer_format
    walk_heap(A, idx*2, idx_format_map)
    walk_heap(A, idx*2+1, idx_format_map)
n = int(input())
A = list(map(int, input().split(' ')))
idx_format_map = {}
walk_heap(A, 1, idx_format_map)
for i in range(n):
    print(idx_format_map[i+1])


Measured memory_bytes: 5632
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;


int main(){
      ll n;
      cin>>n;
      ll a[n];
      rep0(i,n){
            cin>>a[i];
      }
      ll ans=0;
      rep0(i,n-1){
            if((a[i]%2)&&a[i+1]){
                  a[i]--;
                  a[i+1]--;
                  ans++;
            }
            ans+=a[i]/2;
      }
      ans+=a[n-1]/2;
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 1024
import java.io.*;

class Main {

	public static void main(String[] args) {
		int num;
		String buf;
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			buf = br.readLine();
			num = Integer.parseInt(buf);
			System.out.println(num * num * num);
		} catch(Exception e) {}
	}
}


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


bool chk[35] = { true };
bool dy[3010] = { true };
int main() {
	int A, B, C, D, E, F;
	scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
	for (int i = 0; i + A <= F/100+1; i++) {
		chk[i + A] |= chk[i];
	}
	for (int i = 0; i + B <= F/100+1; i++) {
		chk[i + B] |= chk[i];
	}
	for (int i = 0; i + C <= F; i++) {
		dy[i + C] |= dy[i];
	}
	for (int i = 0; i + D <= F; i++) {
		dy[i + D] |= dy[i];
	}
	int p = 0, q = 1;
	for (int i = 1; i <= 30; i++) {
		if (chk[i]) {
			for (int j = 0; j <= 3000; j++) {
				if (dy[j]) {
					int a = i * 100;
					int b = j;
					if (100 * p*a <= 100 * b*q && a+b<=F && b<=E*i) {
						p = b;
						q = a;
				//		printf("%d %d\n", p, q);
					}
				}
			}

		}
	}
	printf("%d %d", p+q, p);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
using namespace std;
int check(int a, int b, int c){
	return(a*1000000 + b *1000 + c);
}
	

int main(void){
	int n,h;
	while(cin >> n >> h){
		if (!n) break;
		int count = 0;
		set<int> hole;
		while(h--){
			int a,b;
			string c;
			cin >> c >> a >> b;
			for(int i=0;i<n;i++){
				if(c == "xy") hole.insert(check(a-1,b-1,i));
				else if(c == "xz") hole.insert(check(a-1,i,b-1));
				else hole.insert(check(i,a-1,b-1));
			}
		}
		cout << n*n*n - hole.size() << endl;
	}
	return (0);
}

Measured memory_bytes: 1984
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N;
   long long K;
   cin >> N >> K;
   int A[N];
   for(int i=0;i<N;i++){
      cin >> A[i];
      A[i]--;
   }
   int depth[N];
   memset(depth,-1,sizeof(depth));
   depth[0]=0;
   int cur = 0;
   bool trip=false;
   while(K>0){
      int nxt = A[cur];
      if(depth[nxt]>=0&&trip==false){
         int loopLen = depth[cur]-depth[nxt]+1;
         K%=loopLen;
         trip = true;
      }
      else{
         if(depth[nxt]==-1) depth[nxt]=depth[cur]+1;
         cur=nxt;
         K--;
      }
   }
   cout << cur+1 << endl;
   return 0;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  using namespace std;
  int n, m;
  cin>>n>>m;
  int a[m], b[m];
  REP(i, m){
    cin>>a[i]>>b[i];
    a[i]--; b[i]--;
  }
  
  UnionFind uf(n);
  REP(i, m) uf.connect(a[i], b[i]);
  vector<bool> visited(n, false);
  vector<int> ss;
  REP(i, n){
    if(visited[uf.root(i)]) continue;
    visited[uf.root(i)] = true;
    ss.push_back(uf.size(i));
  }
  sort(ALL(ss));
  queue<int> sq;
  for(int s: ss) sq.push(s);
  
  int ans = 0;
  while(!sq.empty()){
    int k = sq.size();
    int minus = -1;
    REP(i, k){
      int now = sq.front();
      sq.pop();
      if(i == 0) minus = now;
      if(now == minus) continue;
      int nx = now - minus;
      sq.push(nx);
    }
    ans += minus;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5700
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:1048576")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef tuple <int, int, int> t3;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 1234567890123456789ll;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)

class datax {
public:
	ll a, b, c;
	datax() {
		a = b = c = 0;
	}
	datax(ll a, ll b, ll c) : a(a), b(b), c(c) {}
};
datax in[100050];

ll v1[100050];
ll v2[100050];
int main() {
	int X, Y, Z, N, i;
	scanf("%d %d %d", &X, &Y, &Z);
	N = X + Y + Z;
	for (i = 1; i <= N; i++) scanf("%lld %lld %lld", &in[i].a, &in[i].b, &in[i].c);
	sort(in + 1, in + N + 1, [](datax a, datax b) {
		return a.b - a.c > b.b - b.c;
	});

	priority_queue <ll> Hx;
	for (i = 1; i <= Y; i++) {
		v1[Y] += in[i].b;
		Hx.push(in[i].a - in[i].b);
	}
	for (i = Y + 1; i <= N; i++) {
		v1[i] = v1[i - 1] + in[i].b;
		Hx.push(in[i].a - in[i].b);
		v1[i] += Hx.top();
		Hx.pop();
	}
	while (!Hx.empty()) Hx.pop();

	for (i = N; i > N - Z; i--) {
		v2[N - Z + 1] += in[i].c;
		Hx.push(in[i].a - in[i].c);
	}
	for (i = N-Z; i >= 1; i--) {
		v2[i] = v2[i + 1] + in[i].c;
		Hx.push(in[i].a - in[i].c);
		v2[i] += Hx.top();
		Hx.pop();
	}
	while (!Hx.empty()) Hx.pop();

	ll ans = 0;
	for (i = Y; i <= N - Z; i++) ans = max(ans, v1[i] + v2[i + 1]);
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 4344
#include<stdio.h>
#include<math.h>
 
int main(void)
{
    int n,a;
    double x[1000], y[1000], sum=0, sum2=0, sum3=0, sum4=0;
    scanf("%d", &n);
    for (a = 0; a < n; a++)
    {
        scanf("%lf", &x[a]);
    }
    for (a = 0; a < n; a++)
    {
        scanf("%lf", &y[a]);
        if (x[a] < y[a])
        {
            x[a] = -1 * x[a];
            y[a] = -1 * y[a];
            sum4 = x[a] - y[a];
        }
 
    }
    for (a = 0; a < n; a++)
    {
        sum =1.0*( sum + (x[a] - y[a]));
        sum2 = 1.0*(sum2 + ((x[a] - y[a])*(x[a] - y[a])));
        sum3 = 1.0*(sum3 + ((x[a] - y[a])*(x[a] - y[a])*(x[a] - y[a])));
        if ((x[a] - y[a]) > sum4)
        {
            sum4 = x[a] - y[a];
        }
    }
    printf("%f\n%f\n%f\n%f\n", sum, sqrt(sum2), pow(sum3, 1.0 / 3.0),sum4);
     
    return 0;
}


Measured memory_bytes: 2112
import java.util.*;

class Main{
  public static void main(String[] args){
     Scanner sc=new Scanner(System.in);
     String s=sc.next();
     for(int i=0;i<3;i++){
       if(s.charAt(i)=='1'){
         System.out.print(9);
       }else if(s.charAt(i)=='9'){
         System.out.print(1);
       }else{
          System.out.print(s.charAt(i));
       }
     }
  }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 110

void calc(int r0){
  int w0,c,r;

  cin >> w0 >> c >> r;

  // (r0 + r*x)/w0 > c
  // x > (c*w0 - r0)/r

  printf("%d\n",max(0,(c*w0 - r0 + (r-1)))/r);
}

int main(){

  int r;

  while(1){
    scanf("%d",&r);
    if(r == 0) break;
    calc(r);
  }
  
  
  return 0;
}

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

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

	int N;
	scanf("%d", &N);
	char dummy;
	scanf("%c", &dummy);
	vector<int> S(N);
	for (int i = 0; i < N; i++) {
		scanf("%c", &S[i]);
		S[i] -= '0';
	}

	int check, target;
	int ret = 0;
	for (int l_100 = 0; l_100 <= 9; l_100++) {
		for (int l_10 = 0; l_10 <= 9; l_10++) {
			for (int l_1 = 0; l_1 <= 9; l_1++) {
				// printf("check %d%d%d\n", l_100, l_10, l_1);
				check = 0;
				target = l_100;
				for (int i = 0; i < N; i++) {
					if (S[i] == target) {
						if (check == 0) {
							check = 1;
							target = l_10;
						} else if (check == 1) {
							check = 2;
							target = l_1;
						} else if (check == 2) {
							ret++;
							// printf("hit %d%d%d\n", l_100, l_10, l_1);
							break;
						}
					}
				}
			}
		}
	}
	printf("%d", ret);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a =sc.nextLong();
		long b = sc.nextLong();
		if(Math.abs(a-b)%2==0){
			long k=Math.abs(a-b)/2;
			if(a<b){
				System.out.println(k+a);
			}else{
				System.out.println(k+b);
			}
		}else{
			System.out.println("IMPOSSIBLE");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
 
int main() {
    int N, v, max_v = -1000000000, min_v;
    cin >> N >> min_v;
    for(int i=1; i<N; i++){
        cin >> v;
        max_v = max(max_v, v - min_v);
        min_v = min(min_v, v);
    }
    cout << max_v << endl;
}

Measured memory_bytes: 3048
#include <stdio.h>

int main(){
	
	int x1, x2, x3, x4, x5;
	scanf("%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);
	
	if(x1 == 0){
		printf("1");
	}
	
	else if(x2 == 0){
		printf("2");
	}
	
	else if(x3 == 0){
		printf("3");
	}
	
	else if(x4 == 0){
		printf("4");
	}
	
	else if(x5 == 0){
		printf("5");
	}
	
	return 0;
	
}

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


int8_t DP[1<<24];//LSB???i=0?????????
int X[24];
int Y[24];
int R[24];
int C[24];
int cover[24];//???????????????????????????
int n;

int rec(int E){
    if(~DP[E]) return DP[E];
    int maximum=0;
    for(int i=0;i<n;i++){
        if((E&(1<<i))==0) continue;
        if(cover[i]&E) continue;
        for(int j=i+1;j<n;j++){
            if((E&(1<<j))==0) continue;
            if(cover[j]&E) continue;
            if(C[i]==C[j]){
                maximum=max(maximum,rec(E^(1<<i)^(1<<j))+2);
            }
        }
    }
    DP[E]=maximum;
    return maximum;
}

int main(){
    while(cin>>n,n){
        for(int i=0;i<n;i++){
            cin>>X[i]>>Y[i]>>R[i]>>C[i];            
        }
        fill(cover,cover+24,0);
        for(int i=0;i<n;i++){//i???j???????????????????????????
            for(int j=i+1;j<n;j++){
                if(hypot(X[i]-X[j],Y[i]-Y[j])<R[i]+R[j]){
                    cover[j]|=1<<i;
                }
            }
        }
        fill(DP,DP+(1<<24),-1);
        DP[0]=0;
        cout<<rec((1<<n)-1)<<endl;
    }
}

Measured memory_bytes: 19508
N, M = map(int, input().split())

costs = [None for i in range(M)]
opens = [None for i in range(M)]

for i in range(M):
    costs[i] = list(map(int,input().split()))[0]
    o = list(map(int, input().split()))
    x = pow(2, 12)-1
    for item in o:
        x &= ~(1 << (item-1))
    opens[i] = x

dp = [-1 for i in range(pow(2, 12))]
dp[0] = 0

def recurse(required):
    if dp[required] != -1:
        return dp[required]

    totalCost = float('inf')
    for i in range(M):
        c = required & opens[i]
        if c == required:continue
        
        totalCost = min(totalCost, costs[i] + recurse(c))

    dp[required] = totalCost
    return totalCost


val = recurse(pow(2, N)-1)
if val == float('inf'):
    print(-1)
else:
    print(val)


Measured memory_bytes: 48472
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

ll modpow(ll x, ll n, const ll mo) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) (res *= x) %= mo;
		(x *= x) %= mo;
		n >>= 1;
	}
	return res;
}

ll inverse(ll x, const ll mo) {
	return modpow(x, mo - 2, mo);
}

int N;
vector<vector<int>> G;
vector<int> DP;
vector<int> PDP;
vector<int> PAR;
vector<map<int, int>> MDP;

int dfs(int idx, int par)
{
	PAR[idx] = par;
	int res = 1;
	for (auto e : G[idx])
	{
		if (e == par)continue;
		int tres = dfs(e, idx);
		MDP[idx][e] = tres;
		res += tres;
	}
	DP[idx] = res;
	return res;
}

void dfs2(int idx)
{
	if (PAR[idx] != -1)
	{
		DP[idx] += DP[PAR[idx]] - MDP[PAR[idx]][idx];
	}
	for (auto e : G[idx])
	{
		if (e == PAR[idx])continue;
		dfs2(e);
	}
}

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

	cin >> N;
	G.resize(N);
	DP.resize(N);
	MDP.resize(N);
	PAR.resize(N);

	int x, y;
	rep(i, 0, N - 1)
	{
		cin >> x >> y;
		x--, y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	dfs(0, -1);
	dfs2(0);

	int ans = 0;
	rep(i, 0, N)
	{
		ans += modpow(2, N - 1, MOD);
		ans %= MOD;
		ans = (ans - 1 + MOD) % MOD;
		for (auto p : MDP[i])
		{
			ans = (ans - ((modpow(2, p.second,MOD) - 1 + MOD)%MOD) + MOD) % MOD;
		}
		if (PAR[i] != -1)
		{
			int num = DP[PAR[i]] - MDP[PAR[i]][i];
			ans = (ans - ((modpow(2, num, MOD) - 1 + MOD) % MOD) + MOD) % MOD;
		}
	}

	ans = (ans*inverse(modpow(2, N, MOD), MOD)) % MOD;
	cout << ans << endl;

	return 0;
}

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

int main()
{
    int a[10];
    for(int i=0;i<10;i++)
        cin>>a[i];
    sort(a,a+10);
    for(int j=0;j<3;j++){
        cout<<a[9-j]<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 1176
const main = (input) => {
  const lines = input.trim().split("\n")
  const [N, K] = lines[0].split(" ").map(str => parseInt(str))
  let H = lines[1].split(" ").map(str => parseInt(str))
  H.sort((a, b) => a - b)

  if(K > 0) { H.splice(-K) }

  const sum = (arr: number[]) => {
    if(arr.length !== 0) {
      return arr.reduce((a:number , b: number) => a + b)
    }
    return 0
  }
  
  console.log(sum(H))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 37380
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	// 2018/05/29
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		Integer[] l = new Integer[N];
		for (int i=0; i<N; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l, Collections.reverseOrder());
		int res = 0;
		for (int i=0; i<K; i++) {
			int a = res += l[i];
			if ( a < 50 )  res = a;
		}
		System.out.println(res);
	}
}


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

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

int main(){
	scanf("%d", &n);
	for(int i=0;i<n-1;i++) scanf("%d", &b[i]);
	a[0] = b[0];
	for(int i=1;i<n-1;i++){
		a[i] = min(b[i-1], b[i]);
	}
	a[n-1] = b[n-2];
	printf("%d\n", accumulate(a, a+n, 0));
	return 0;
}

Measured memory_bytes: 764
import java.io.*;
import java.util.*;

public class Main {
	static final int MOD = (int)1e9+7;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		for(int i = 1; i <= 100_000; i++) {
			if((a*i)%b==c) {
				out.println("YES");
				return;
			}
		}
		out.println("NO");
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long factorial(int n) {
		long a;

		if(n > 0) {
			a = n * factorial(n - 1);
		}else{
			a = 1;
		}

		return a;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class UnionFind {
	int[] par;

	public UnionFind(int n) {
		par = new int[n];

		Arrays.fill(par, -1);
	}

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

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

		if(x == y) return false;

		if(size(x) < size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		par[x] += par[y];
		par[y] = x;

		return true;
	}

	boolean same(int x,int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

	int size(int a) {
		return -par[root(a)];
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <stack>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>


using namespace std;

int main()
{

	int n;
	int d = 0;
	int areaCount = 0;
	stack<int> stacks;
	stack<pair<int, int>> S2;
	long curarea = 0;
	char input;

	for (d = 0; cin >> input; d++) {
		if (input == '\\') {
			stacks.push(d);
		}
		else if (input == '/') {
			if (stacks.size() > 0) {
				int j = stacks.top();
				stacks.pop();
				curarea += (d - j);
				int a = d - j;
				while (S2.size()>0 && S2.top().first > j) {
					a += S2.top().second;
					S2.pop();
				}
				S2.push(make_pair(j, a));
			}
		}
	}
	vector<int> v1;
	while (S2.size() > 0) {
		v1.push_back(S2.top().second);
		S2.pop();
	}
	cout << curarea << endl;
	reverse(v1.begin(), v1.end());

	cout << v1.size();
	for (int i = 0; i < v1.size(); ++i) {
		cout << ' ';
		cout << v1[i] ;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3216
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    string s;cin >> s;
    int n=s.size();
    int w=0;
    for(int i = 0; i < n; i++) {
        if(s[n-1-i]=='B') w++;
        else break;
    }

    ll ans=0;
    int p=n-1-w;
    for(int i = p; i >=0; i--) {
        if(s[i]=='B'){
            ans += max(n-1-i-w,0) ;
            w++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using namespace std;

ll M = 1000000007;
const int maxh = 20, maxw = 20;

typedef pair<int, int> P;
vector<vector<char>> maze(maxh, vector<char>(maxw));
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int INF = 1e9;
int d[maxh][maxw];
int h, w;
int bfs(pair<int, int> st, pair<int, int> gl)
{
    queue<P> que;
    rep(i, h)
    {
        rep(j, w)
        {
            d[i][j] = INF;
        }
    }
    que.push(st);
    d[st.x][st.y] = 0;
    while (que.size())
    {
        P p = que.front();
        que.pop();
        if (p.first == gl.x && p.y == gl.y)
        {
            break;
        }
        rep(i, 4)
        {
            int nx = p.x + dx[i], ny = p.y + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && maze[nx][ny] != '#' && d[nx][ny] == INF)
            {
                que.push(P(nx,ny));
                d[nx][ny]=d[p.x][p.y]+1;
            }
        }
    }
    return d[gl.x][gl.y];
}
int main()
{
    cin >> h >> w;
    vector<vector<int>> isroad(h, vector<int>(w));
    deque<pair<int, int>> cand;
    rep(i, h)
    {
        rep(j, w)
        {
            cin >> maze[i][j];
            if (maze[i][j] == '.')
            {
                isroad[i][j] = 1;
                cand.push_back(make_pair(i, j));
            }
        }
    }
    int ans=0;
    //cout<<cand.size()<<endl;
    rep(i, cand.size())
    {
        FOR(j, i + 1, cand.size())
        {
            int tmp=bfs(cand[i],cand[j]);
            if(tmp!=INF)
            ans=max(ans,tmp);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
//#include <ctime>
using namespace std;
#define M(x,y,z) make_pair((x),make_pair((y),(z)))
typedef map<string,pair<string,string> > mspss;
typedef map<string,map<char,pair<char,string> > >  msmcpcs;
//http://www.kupc.jp/2013/editorial/K.pdf
mspss table1={
	M("A1","B1","B2"),M("A2","B3","B4"),M("A3","B5","B6"),
	M("B1","A1","A2"),M("B2","A3","C1"),M("B3","C2","C3"),M("B4","C4","E1"),M("B5","E2","E3"),M("B6","E4","E5"),
	M("C1","B1","B2"),M("C2","B3","B4"),M("C3","B5","B6"),M("C4","D1","D2"),
	M("D1","C1","C2"),M("D2","C3","C4"),
	M("E1","B1","B2"),M("E2","B3","B4"),M("E3","B5","B6"),M("E4","F1","F2"),M("E5","F3","F4"),
	M("F1","E1","E2"),M("F2","E3","E4"),M("F3","E5","G1"),M("F4","G2","G3"),
	M("G1","F1","F2"),M("G2","F3","F4"),M("G3","H1","H2"),
	M("H1","G1","G2"),M("H2","G3","I1"),
	M("I1","H1","H2"),
};
msmcpcs table2;
string trailing_paths[]={
	"HGFEBA","IHGFEB","BABABC","ABABCD","BABABE","ABABEF","BABEFG","ABEFGH","BEFGHI"
};
int main(){
	string trailing_path=trailing_paths[0];//time(NULL)/86400*86400%9]; //just for fun :p
	string s,t,r;
	int n,i=0;
	cin>>s>>n>>t;
	if(s[0]=='e'){
		// n=8
		// t=10111110
		s=string(1,trailing_path.back())+string(1,'1');
		for(i=0;i<n;i++){
			if(t[i]=='0')r+=(s=table1[s].first)[0];
			else r+=(s=table1[s].second)[0];
		}
		// s=G3
		// r=BABEFGHG
		t=trailing_path.substr(trailing_path.size()-(s[1]-'0'),s[1]-'0');
		// t=EBA
		cout<<t+r<<endl;
	}else{
		mspss::iterator it=table1.begin();
		for(;it!=table1.end();it++){
			table2[it->second.first][it->first[0]]=make_pair('0',it->first);
			table2[it->second.second][it->first[0]]=make_pair('1',it->first);
		}
		// n=11
		// t=EBABABEFGHG
		for(i=0;t[i]!=trailing_path.back();i++);
		n-=i;
		t=t.substr(i);
		s=string(1,t[n-1])+string(1,'1'+i);
		// n=9
		// t=ABABEFGHG
		// s=G3
		for(i=n-2;i>=0;i--){
			r+=table2[s][t[i]].first;
			s=table2[s][t[i]].second;
		}
		reverse(r.begin(),r.end());
		cout<<r<<endl;
	}
}

Measured memory_bytes: 2720
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int h1,m1,h2,m2,k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans;
    if((h2-h1)*60+(m2-m1)-k > 0) cout << (h2-h1)*60+(m2-m1)-k << ln; 
    else cout << 0 << ln;
    return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		swappingTwoNumbers();

	}
	
	public static void swappingTwoNumbers() {
		
		Scanner sc = new Scanner(System.in);
		
		while (true) {

			int x = sc.nextInt();
			int y = sc.nextInt();

			if (x == 0 && y == 0) {
				break;
			} else {
				if (x <= y) {
					System.out.println(x + " " + y);
				} else {
					System.out.println(y + " " + x);
				}				
			}
		}
	}
}


Measured memory_bytes: 35844