akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int double

signed main(){

  int n; cin >> n;
  int T,A; cin >> T >> A;

  int ans = 0;

  int res  = 1145141919;
  for(int i = 0; i < n; i++){
    int h; cin >> h;
    if(res > abs(T - h*0.006 - A)){
      res = abs(T - h*0.006 - A);
      ans = i;
    }
  }
  cout << ans+1 << endl;

  return 0;
}


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

long long n;
vector<vector<long long>> g;
vector<long long> a, res, lst;
vector<stack<long long>> ary;

void solve();
void dfs(int id, int bf = -1);

int main() {
  cin >> n;
  g.resize(n);
  res.resize(n);
  a.resize(n);
  lst.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n - 1; ++i) {
    long long u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  solve();
  for (int i = 0; i < n; ++i) cout << res[i] << endl;
  return 0;
}

void solve() { dfs(0); }

void dfs(int id, int bf) {
  long long l = -1, r = (int)ary.size();
  while (r - l > 1) {
    long long mid = (l + r) / 2;
    if (ary[mid].top() < a[id])
      l = mid;
    else
      r = mid;
  }
  if (r == ary.size()) ary.push_back(stack<long long>());
  ary[r].push(a[id]);
  res[id] = ary.size();
  lst[id] = r;
  for (auto to : g[id])
    if (bf != to) dfs(to, id);
  ary[r].pop();
  if (ary[r].size() == 0) ary.pop_back();
}

Measured memory_bytes: 122424
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("in","r",stdin);
		freopen("out","w",stdout);
	#endif

	string s,t;cin>>s>>t;
	vector<int> id[26];
	int n=s.length();int m=t.length();
	for(int i=0;i<n;i++)
	{
		id[s[i]-'a'].push_back(i+1);
	}

	for(auto i:t){if(id[i-'a'].size()==0){cout<<-1;return 0;}}


	int cnt=1,ans=0;
	

	for(auto i:t)
	{
		int now=i-'a';
		auto it=lower_bound(id[now].begin(),id[now].end(),cnt);
		if(it==id[now].end())
		{
			ans+=(n-cnt+1);
			cnt=1;
		}
		it=lower_bound(id[now].begin(),id[now].end(),cnt);
		ans+=*it-cnt+1;
		cnt=*it+1;
	}
	cout<<ans;

}

Measured memory_bytes: 4652
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
 
int main(){
    int N, X, Y;
    cin >>  N >> X >> Y;
    X--;
    Y--;

    int dist_count[N]={};
    for(int i=0;i < N;i++){
        for(int j=i+1; j<N; j++){
            // int inf = 999999999;
            // int dist = min(j-i, inf);
            int dist = min(j-i, abs(X-i)+abs(Y-j)+1);
            dist_count[dist]++;
            // cout << "i: " << i << " j: " << j << endl;
            // cout << "X: " << X << " Y: " << Y << endl;
            // cout << "dist: " << dist << " dist_count[dist]: " << dist_count[dist] << endl;
            // cout << "j-i: " << j-i << " abs(X-i)+abs(Y-i)+1: " << abs(X-i)+abs(Y-i)+1 << endl;
        }
    }

    for(int i=1;i<N;i++){
        cout << dist_count[i]<< endl;
    }

    return 0;
}

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

ll solve() {
    ll A, B;
    cin >> A >> B;
    if ( B == 1 ) return 0;
    ll ans = (B + A - 3) / (A-1);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
*a, = sorted(map(int, input().split()))

r = [0, 0]

_a = a[0]
for i in range(1, n):
    if _a == a[i]:
        r.append(a[i])
        _a = -1
    else:
        _a = a[i]

print(r[-1] * r[-2])


Measured memory_bytes: 14252
#include<stdio.h>
int main()
{
	long long n,a,b,x,s=0,y;
	scanf("%lld %lld %lld",&n,&a,&b);
	x=n/(a+b);
	s+=a*x;
	y=n-(a+b)*x;
	if(y<=a)
		s+=y;
	else 
		s+=a;
	printf("%lld",s);
}

Measured memory_bytes: 128
#include <iostream>

int main(int argc, char **argv)
{
        int num = 0, answer=0;
        std::cin >> num;
        for(int i = 1; i <=num; i++)
        {
                int keta = 0;
                int iBuff = i;
                while(iBuff != 0)
                {
                        iBuff /= 10;
                        keta++;
                }
                answer += keta % 2;
        }
        std::cout << answer << std::endl;
        return 0;
}


Measured memory_bytes: 256
def create_hole(A: list, b:list):

    N = len(A)
    Hole = [[0 for i in range(N)] for j in range(N)]
    for i in range(3):
        for j in range(3):
            for value in b:
                if A[i][j] == value: Hole[i][j] = 1

    return Hole


def check_bingo(H: list):

    N = len(H)
    rowsum = sum([sum(row) == N for row in H])
    colsum = sum([sum(row) == N for row in map(list, zip(*H))])
    digsum = sum([H[i][i] for i in range(N)]) == N
    tdigsum = sum([H[i][N-i-1] for i in range(N)]) == N

    return rowsum + colsum + digsum + tdigsum > 0


def resolve():

    A = [list(map(int, input().split())) for i in range(3)]
    N = int(input())
    b = [int(input()) for i in range(N)]
    print('Yes' if check_bingo(create_hole(A, b)) else 'No')
    
resolve()

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

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

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

int main(void){

    int n;
    cin >> n;

    map<string, int> mp;

    roop(i, n){
        string s; cin >> s;
        mp[s]++;
    }

    cout << mp.size() << endl;

    return 0;
}


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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M /* your task */; }
int h2(int key){ return 1 + (key % (M - 1))/* your task */; }

int find(char str[]){
  /* your task */
  long long key, h, i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}


int insert(char str[]){
  /* your task */
  long long key,h,i;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



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

int main(){
  int i,j,k,cnt;
  int n;
  cin>>n;
  int a,b,c,d;
  a=n/1000,b=(n/100)%10,c=(n/10)%10,d=n%10;
  int sum;
  for(i=0;i<=1;i++){
    for(j=0;j<=1;j++){
      for(k=0;k<=1;k++){
        sum=a;
        if(i)sum+=b;
        else sum-=b;
        if(j)sum+=c;
        else sum-=c;
        if(k)sum+=d;
        else sum-=d;
        if(sum==7){
          string s="";
          s+=(char)(a+'0');
          if(i)s+='+';
          else s+='-';
          s+=(char)(b+'0');
          if(j)s+='+';
          else s+='-';
          s+=(char)(c+'0');
          if(k)s+='+';
          else s+='-';
          s+=(char)(d+'0');
          s+="=7";
          cout<<s;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
N = int(input())
X = [int(x) for x in input().split()]
a = sum(X) // N
b = a + 1
ans1 = 0
ans2 = 0
for x in X:
    ans1 += (x - a) ** 2
    ans2 += (x - b) ** 2
print(min(ans1, ans2))

Measured memory_bytes: 3060
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

int main() {
	int grade[5];
	int sum = 0;
	for (int i = 0; i < 5; i++) {
		cin >> grade[i];
		if (grade[i] < 40) {
			grade[i] = 40;
		}
		sum += grade[i];
	}
	cout << sum / 5 << endl;
}


Measured memory_bytes: 3100
import collections
from math import factorial
n = int(input())
strs = ["".join(sorted(input())) for i in range(n)]
c = collections.Counter(strs)
ans = 0
for key, val in c.items():
	if val < 2:
		continue
	elif val == 2:
		ans += 1
	else:
		ans += factorial(val) // (2 * factorial(val - 2))
print(ans)


Measured memory_bytes: 19756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i=0; i<n; i++){
    cin >> v[i];
  }
 
  sort(v.begin(), v.end());
  
  vector<double> sum(n);
  sum[0] = (v[0] + v[1])/2.0;
  
  for(int j=0; j<n-2; j++){
    sum[j+1] = (sum[j] + v[j+2])/2.0;
  }
  
  cout << sum[n-2] << endl;
  
}

Measured memory_bytes: 3812
#include <stdio.h>
int main(void){
    int n,m,x,y,i,cnt=0;
    scanf("%d%d",&n,&m);
    int a[n],h[n];
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
        a[i]=0;
    }
    for(i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        if(h[x-1]>=h[y-1]) a[y-1]=1;
        if(h[x-1]<=h[y-1]) a[x-1]=1;
    }
    for(i=0;i<n;i++){
        if(a[i]==0) cnt++;
    }
    printf("%d",cnt);
    return 0;
}

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

using ll = long long;

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

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

vector<vector<ll>> G;

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> A(N);
	REP(i, N) cin >> A[i], --A[i];

	vector<ll> f(N, -1);

	ll t = 0;
	ll i = 1;
	f[t] = i;
	for (; i <= K;)
	{
		t = A[t];
		if (f[t] != -1) break;
		f[t] = ++i;
	}
	
	// std::cout << t << std::endl;
	// std::cout << "f[t] : " << f[t]  << "\ti : " << i << std::endl;

	K -= f[t]-1;
	K %= (i - f[t] + 1);
	for (ll i = 0; i < K; ++i)
	{
		t = A[t];
	}

	std::cout << t + 1 << std::endl;

}


Measured memory_bytes: 6424
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

int main(int argc,char** argv){
  int N;
  cin >> N;
  if(N == 0){
    cout << 0 << endl;
    return 0;
  }
  string s = "";
  while(N!=0){
    int a = N % -2;
    N /= -2;
    if(a == 0){
      s = "0" + s;
    }else if(a == 1){
      s = "1" + s;
    }else if(a == -1){
      s = "1" + s;
      N++;
    }
  }

  cout << s << endl;

  return 0;
}


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

int main()
{
    int X,Y;
    int count;

    cin>>X>>Y;
    for(int i = 0; i <= X; i++)
    {
        count = (2 * i) + (4 * (X - i));
        if(count == Y)
        {
            cout<<"Yes"<<endl;
            //_getch();
            return 0;
        }
    }

    cout<<"No"<<endl;
    //_getch();
    return 0;
}

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

typedef long long ll;
int main(){
  ll n,m;
  cin>>n>>m;
  if(n==1&&m==1) cout<<1<<"\n";
  else if(n==1||m==1) cout<<max(n,m)-2<<"\n";
  else cout<<(n-2)*(m-2)<<"\n";
}


Measured memory_bytes: 256
#include <iostream>

const int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

using namespace std;

int main(){
  int K;
  cin >> K;
  cout << arr[K - 1] << endl;
  return 0;
}

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

int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	string s;
	int n,k;
	cin >> n >> k;
	cin >> s;
	s[k-1] = 'a' - 'A' + s[k-1];
	cout << s << endl;
}


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

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

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int N, T, L, B;
int mass[105];
ld prob = ld(1.0) / 6;
ld cp[105][105];

ld dfs(int s, int t, bool wt){
	if(s == N) return 1.0;
	if(t <= 0) return 0;
	if(mass[s] == -1 and wt) return dfs(s, t-1, false);
	if(mass[s] == -2) return dfs(0, t, true);
	if(cp[s][t] != -1) return cp[s][t];
	ld p = 0.0;
	if(s > N-6){
		int left = N-s;
		REP(i, left) p += prob * dfs(s+i+1, t-1, true);
	  for(int i=left; i<6; i++) p += prob * dfs(N+left-1-i, t-1, true);
		return cp[s][t] = p;
	}
	REP(i, 6) p += prob * dfs(s+i+1, t-1, true);
	return cp[s][t] = p;
}

int main(){
	while(cin >> N >> T >> L >> B and N + L + T + B){
		memset(mass, 0, sizeof(mass));
		REP(i, 105) REP(j, 105) cp[i][j] = -1;
		int tmp;		
		REP(i, L) { cin >> tmp; mass[tmp] = -1; }
		REP(i, B) { cin >> tmp; mass[tmp] = -2; }
		cout << setprecision(10) << fixed;
		cout << dfs(0, T, true) << endl;
	}
	return 0;
}

Measured memory_bytes: 3308
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int N;
  cin >> N;

  if (N % 2) return cout << 0 << endl, 0;

  int ans = 0;
  for (int i = 5; i <= N; i *= 5) {
    ans += N / 2 / i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int N, ans = 1, loop = 0, num = 1, now = 1 ;
  long long int K ;
  cin >> N >> K ;
  int A[N+1], visited[N+1] = {} ;
  for(long long int i=1;i<N+1;i++) cin >> A[i] ;
  visited[1] = 1 ;
  while(loop == 0){
    if(visited[A[now]] == 0){
      num++ ;
      now = A[now] ;
      visited[now] = num ;
    }
    else{
      num++ ;
      now = A[now] ;
      loop = num - visited[now] ;
    }
  }
  while(K>0ll){
    if(ans != now){
      ans = A[ans] ;
      K-- ;
    }
    else{
      K = K % loop ;
      while(K>0ll){
        ans = A[ans] ;
        K-- ;
      }
    }
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 5200
#include<stdio.h>
#include<string.h>
int main(void){
    char str[1000]={},order[10]={},p[1001]={},cpy[1000]={};
    int q,i=0,a,b,number=0,number1=0;
    scanf("%s",str);
    scanf("%d",&q);
    while(scanf("%s",order)==1){
         scanf("%d %d",&a,&b);
        if(i==q) break;
    if(strcmp(order,"print")==0){
        for(number=a;number<=b;number++){
            printf("%c",str[number]);
        }
        printf("\n");
        if(i==q-1) break;
    }
    else if(strcmp(order,"reverse")==0){//間違えてる
         strcpy(cpy,str); 
        for(number=a,number1=b;number<=b;number++,number1--){
            str[number]=cpy[number1];
        }
    }
    else{
        scanf("%s",p);
        strncpy(str+a,p,b-a+1);
        //printf("str1=%s\n",str);
    }
    i++;
    }
    //printf("\n");
    return 0;
}


Measured memory_bytes: 2108
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;

int main() {
	ll N;
	cin >> N;
	vector<ll> L(N);
	rep(i, N) cin >> L[i];
	if (N == 1 || N == 2) {
		cout << "0" << endl;
		return 0;
	}
	ll ans = 0;
	ll mae = 0;
		for (ll a = 0; a <= N - 3; a++) {
			for (ll b = a + 1; b <= N - 2; b++) {
				for (ll c = b + 1; c <= N - 1; c++) {
					if (L[a] != L[b] && L[b] != L[c] && L[a] != L[c]
						&& (L[a] + L[b]) > L[c] && (L[b] + L[c]) > L[a] && (L[a] + L[c] > L[b])) ans++;

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) ans++;
    }  
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int[][] students = new int[n][n];
			boolean[][] tallest = new boolean[n][n];
			boolean[][] shortest = new boolean[n][n];
			int[][] x = new int[n][n];
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					students[i][j] = sc.nextInt();
				}
			}
			
			for(int i = 0; i < n; i++){
				int columnMax = -1, maxj = -1;
				for(int j = 0; j < n; j++){
					if(columnMax < students[j][i]){
						columnMax = students[j][i];
                        maxj = j;
                    }
//					columnMax = Math.max(columnMax, students[j][i]);
				}
				for(int j = 0; j < n; j++){
					if(columnMax == students[j][i]){
						tallest[j][i] = true;
						x[j][i] |= 2;
					}
				}
			}
			for(int i = 0; i < n; i++){
				int rowMin = Integer.MAX_VALUE, minj = -1;
				for(int j = 0; j < n; j++){
					if(rowMin > students[i][j]){
						rowMin = students[i][j];
                        minj = j;
                    }
//					rowMin = Math.min(rowMin, students[i][j]);
//					minj = j;
				}
				if(rowMin == students[i][minj]){
					shortest[i][minj] = true;
					x[i][minj] |= 1;
				}
/*				for(int j = 0; j < n; j++){
					if(rowMin == students[i][minj]){
						shortest[i][minj] = true;
						x[i][minj] |= 1;
					}
				}
*/			}
			
			Set<Integer> both = new HashSet<Integer>();
            for(int i = 0;i < n;i++){
                for(int j = 0;j < n;j++){
                    if(x[i][j] == 3){
                        both.add(students[i][j]);
                    }
                }
            }
			
            if(both.size() == 1){
            	StringBuilder sb = new StringBuilder();
                for(int v : both){
                    sb.append(v + " ");
                }
                sb.deleteCharAt(sb.length() - 1);
                System.out.println(sb);
            }else{
            	System.out.println(0);
            }
/*			boolean noAns = true;
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(shortest[i][j] && tallest[i][j]){
						sb.append(students[i][j] + " ");
						noAns = false;
					}
				}
			}
			
			if(noAns){
				System.out.println(0);
			}else{
				sb.deleteCharAt(sb.length() - 1);
				System.out.print(sb);
			}
*/		}
		
	}
}

Measured memory_bytes: 19428
#include <iostream>
#include <vector>
#include <array>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, p;
    cin >> n >> p;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    array<ll, 2> np = {1, 0};
    REP(i, n){
        if(a.at(i) % 2 == 0){
            np = {np[0] * 2, np[1] * 2};
        }else{
            np = {np[0] + np[1], np[0] + np[1]};
        }
    }
    cout << np[p] << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    string t; cin >> t;
    
    vector<char> vS(s.size()); for(uint i=0; i<s.size(); ++i){ vS[i]=s[i]; } sort(vS.begin(), vS.end());
    vector<char> vT(t.size()); for(uint i=0; i<t.size(); ++i){ vT[i]=t[i]; } sort(vT.begin(), vT.end(), greater<char>());
    
    for(uint i=0; i<vS.size(); ++i){ s[i]=vS[i]; }
    for(uint i=0; i<vT.size(); ++i){ t[i]=vT[i]; }
    cout << (s < t ? "Yes":"No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

ll a,b,c,x,y;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>a>>b>>c>>x>>y;
    ll ans = 0;
    if((a+b) >= 2*c){
        ll z = min(x,y);
        ans += 2*c*(z);
        x -= z; y -= z;
        ans += x*min(2*c,a);
        ans += y*min(2*c,b);
    }else{
        ll z = min(x,y);
        ans += a*z;
        ans += b*z;
        x -= z; y -= z;
        ans += x*min(2*c,a);
        ans +=y*min(2*c,b);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    [n,a,b] <- map read . words <$> getLine    
    putStrLn (show $ godFizzNa n a b)  

goffi :: Int -> Int
goffi n = (div n 10000) + (div n 1000 - 10 * div n 10000) + (div n 100 - 10 * div n 1000) + (div n 10 - 10* div n 100)+ div n 1 - 10* div n 10

pittan :: Int -> Int -> Int -> Bool
pittan i a b =  if a<=i && i<=b then True
                else False

pikosan :: Int -> Bool -> Int
pikosan x y =   if y then x
                else 0

godFizzNa :: Int -> Int -> Int -> Int
godFizzNa n a b =   if n == -1 then 0
                    else pikosan n (pittan (goffi n) a b) + godFizzNa (n-1) a b

Measured memory_bytes: 636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  int ans=1e9+1;
  sort(H.begin(),H.end());
  for(int i=0;i<=N-K;i++){
    ans=min(ans,H[i+K-1]-H[i]);
  }
  cout << ans << endl;
}

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

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

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

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

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 200000

int main(void){
    int n,q;
    static int parent[N+1] = {};
    static int plus[N+1] = {};
    static int counter[N+1] = {};
    int i,a,b,p,x;
    
    scanf("%d %d", &n, &q);
    
    for(i = 0; i < n-1; i++){
        scanf("%d %d", &a, &b);
        parent[b] = a;
    }
    
    for(i = 0; i < q; i++){
        scanf("%d %d", &p, &x);
        plus[p] += x;
    }
    
    for(i = 1; i <= n; i++){
        counter[i] += plus[i];
        if(parent[i] != 0){
            counter[i] += counter[parent[i]];
        }
    }
    
    for(i = 1; i <= n; i++){
        printf("%d ", counter[i]);
    }
    
    return 0;
}

Measured memory_bytes: 4480
import collections
def main():
    N, M = map(int, input().split())
    graph = collections.defaultdict(list)
    for _ in range(M):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)

    cur = [1]
    visited = set([1])
    for _ in range(2):
        temp = []
        for i in cur:
            for j in graph[i]:
                if j not in visited:
                    temp.append(j)
                    visited.add(j)
        cur = temp
    if N in cur:
        return "POSSIBLE"
    return "IMPOSSIBLE"
if __name__ == '__main__':
    print(main())


Measured memory_bytes: 56716
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, M;
    cin >> N >> M;
    cout << (M == N ? "Yes": "No") << endl;
    return 0;
};

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

int main() {
  ll N, A;
  cin >> N;
  vector<ll> vec, ret;
  vec.reserve(N);
  ret.reserve(N);
  for (auto i = 0;i < N;i ++) {
    cin >> A;
    vec.push_back(A);
    ret.push_back(A);
  }
  bool flag = true;
  ll n = 2;
  ll re = 0;
  while (flag) {
    flag = false;

    ll count = 0;
    for (auto i = 0;i < N;i ++) {
      if (vec[i] % 2 == 1) {
        flag = true;
        count ++;
      }
      vec[i] /= 2;
    }
    if (count % 2) {
      re += (n/2);
    }
    n *= 2;
  }
  for (auto i = 0;i < N-1;i ++) {
    ll r = ret[i] ^ re;
    cout << r << " ";
  }
  ll r = ret[N - 1] ^ re;
  cout << r << endl;


  return 0;
}

Measured memory_bytes: 6320
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int N = 3;

int a[N][N];
int used[N][N];

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

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (a[i][j] == x) {
					used[i][j] = 1;
				}
			}
		}
	}
	if (used[0][0] && used[1][1] && used[2][2]) {
		cout << "Yes\n";
		return 0;
	}
	if (used[0][2] && used[1][1] && used[2][0]) {
		cout << "Yes\n";
		return 0;
	}
	for (int i = 0; i < 3; i++) {
		int c = 0;
		for (int j = 0; j < 3; j++) c += used[i][j];
		if (c == 3) {
			cout << "Yes\n";
			return 0;
		}
	}
	for (int i = 0; i < 3; i++) {
		int c = 0;
		for (int j = 0; j < 3; j++) c += used[j][i];
		if (c == 3) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}


Measured memory_bytes: 256
from __future__ import print_function
from collections import deque
from bisect import bisect_left as bl
input = raw_input
range = xrange

def goto(fr, to):
    i = bl(occ[to], fr+1)
    if i == len(occ[to]): return n+1
    return occ[to][i]

s = [-1]+[ord(c)-97 for c in input()]
n = len(s)-1
occ = [[] for i in range(26)]
for i in range(1, n+1):
    occ[s[i]].append(i)
visit = [None]*(n+2)
visit[0] = (-1, -1) # letter, lastindex
Q = deque()
Q.append(0)

while len(Q):
    p = Q.popleft()
    if p == n+1: break
    for q in range(26):
        qi = goto(p, q)
        if visit[qi]: continue
        visit[qi] = (q, p)
        Q.append(qi)
stack = []
i = n+1
while visit[i][0] != -1:
    stack.append(visit[i][0])
    i = visit[i][1]

for i in reversed(stack):
    print(chr(97+i), end='')

Measured memory_bytes: 49564
using System;
using System.Collections.Generic;
using System.Linq;

class PaizaSample
{

    class Point
    {
        public int x = 0;
        public int y = 0;

        public Point(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }



    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        string[] ab = Console.ReadLine().Split(' ');
        int a = int.Parse(ab[0]);
        int b = int.Parse(ab[1]);

        string[] cd = Console.ReadLine().Split(' ');
        int c = int.Parse(cd[0]);
        int d = int.Parse(cd[1]);

        int min = n * 2;

        for (int i = 0; i < n - 1; i++)
        {
            Point pa = new Point((a - 1) % (n - i), (a - 1) / (n - i));
            Point pb = new Point((b - 1) % (n - i), (b - 1) / (n - i));
            Point pc = new Point((c - 1) % (n - i), (c - 1) / (n - i));
            Point pd = new Point((d - 1) % (n - i), (d - 1) / (n - i));

      //      Console.WriteLine("({0},{1})({2},{3})({4},{5})({6},{7})", pa.x, pa.y, pb.x, pb.y, pc.x, pc.y, pd.x, pd.y);

            int distance = Math.Abs(pa.x - pb.x) + Math.Abs(pa.y - pb.y) + Math.Abs(pc.x - pd.x) + Math.Abs(pc.y - pd.y);

            if (min > distance)
            {
                min = distance;
            }

        }

        Console.WriteLine(min);

 //       Console.ReadKey();

    }
}

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define PI acos(-1.0)

typedef long long ll;
const int maxn=1e6+10;
vector<ll> a[maxn],b[maxn];
ll f[maxn];
ll ww;
ll q,k;
ll flag;

void dfs(ll u,ll w,ll v)
{
    f[u]=w;
    for(int i=0;i<a[u].size();i++)
    {
        if(a[u][i]==v)
            continue;
        dfs(a[u][i],w+b[u][i],u);
    }
}

int main()
{
    ll n;
    scanf("%lld",&n);
    for(ll i=0;i<n-1;i++)
    {
        ll x,y,w1;
        scanf("%lld%lld%lld",&x,&y,&w1);
        a[x].push_back(y);
        b[x].push_back(w1);
        a[y].push_back(x);
        b[y].push_back(w1);
    }
    scanf("%lld%lld",&q,&k);
    memset(f,0,sizeof(f));
    dfs(k,0,-1);
    for(ll i=0;i<q;i++)
    {
        ll xx,yy;
        scanf("%lld%lld",&xx,&yy);
        printf("%lld\n",f[xx]+f[yy]);
    }
    return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

class UnionFind {
public:
   vector<int> parent, rank;

   UnionFind(){}

   UnionFind(int size) {
      parent.resize(size, 0);
      rank.resize(size, 0);
      for (int i = 0; i < size; i++) {
         parent[i] = i;
      }
   }

   void init(int size) {
      parent.resize(size, 0);
      rank.resize(size, 0);
      for (int i = 0; i < size; i++) {
         parent[i] = i;
      }
   }

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

   void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return;

      if (rank[x] < rank[y]) {
         parent[x] = y;
      } else {
         parent[y] = x;
         if (rank[x] == rank[y]) rank[x]++;
      }
   }

   bool same(int x, int y) {
      return find(x) == find(y);
   }
};

int main() {
   int n, k, l;
   cin >> n >> k >> l;
   UnionFind s, t;
   s.init(n), t.init(n);
   rep (i, k) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      s.unite(a, b);
   }
   rep (i, l) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      t.unite(a, b);
   }

   map<pair<int, int>, int> m;
   rep (i, n) {
      m[{s.find(i), t.find(i)}]++;
   }
   rep (i, n) {
      printf("%d%c", m[{s.find(i), t.find(i)}], i == n-1? '\n':' ');
   }

   return 0;
}

Measured memory_bytes: 15104
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String line = sc.nextLine();
            String answer = "";
            int length = line.length();
            for (int i = 0; i < length; i++) {
                char ch = line.charAt(i);
                if (Character.isLowerCase(ch) == true) {
                    ch = Character.toUpperCase(line.charAt(i));
                } else if (Character.isLowerCase(ch) == false){
                    ch = Character.toLowerCase(line.charAt(i));
                }
                answer = answer + ch;
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 31212
# 入力の取得
i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

if ao == 0:
    print(0)
    exit()

#商の分を計算
aa = ao * answer[0]

#あまりの分を計算
if answer[1] == 0:
    print(aa)
    exit()

#あまり6で、青が6なら
# あまりが青より多いなら(あまり4、青2)
if answer[1] >= ao:
    aa += ao
#あまりが青より少ないなら(あまり1、青3)
else:
    aa += answer[1]
print(aa)

Measured memory_bytes: 3064
def bubble_sort(num_list):
    cnt = 0
    flag = 1

    while flag:
        flag = 0
        for i in range(len(num_list)-1,0,-1):
            if num_list[i] < num_list[i-1]:
                num_list[i],num_list[i-1] = num_list[i-1],num_list[i]
                cnt += 1
                flag = 1
    return cnt

n = input()
num_list = list(map(int,input().split()))

ans = bubble_sort(num_list)
ans_list = [str(i) for i in num_list]
print(' '.join(ans_list))
print(ans)


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

int main(){
  using point= pair<int64_t, int64_t>;
  int N,K;
  cin >> N >> K;
  const int Kin= K-2;

  vector<point> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i).first >> data.at(i).second;
  }
  sort(data.begin(), data.end());

  int64_t ans= INT64_MAX;
  for(int j1=0; j1<N; j1++){
    for(int j2=j1+1; j2<N; j2++){
      point p1= data.at(j1);
      point p2= data.at(j2);
      int64_t ymax= max(p1.second, p2.second);
      int64_t ymin= min(p1.second, p2.second);
      int64_t xmax_cand= max(p1.first, p2.first);
      int64_t xmin_cand= min(p1.first, p2.first);

      if(Kin==0){
        int64_t xmax= xmax_cand;
        int64_t xmin= xmin_cand;

        ans= min(ans, (xmax- xmin)*(ymax- ymin));
      }
      else{
        vector<int64_t> Xs_in_Yrange;
        for(int i=0; i<N; i++){
          if(i==j1 || i==j2){ continue; }
          else{
            if(ymin <= data.at(i).second && data.at(i).second <= ymax){
              Xs_in_Yrange.emplace_back(data.at(i).first);

              int Nin= Xs_in_Yrange.size();
              if(Nin >= Kin){
                int64_t xmax= max(Xs_in_Yrange.back()     , xmax_cand);
                int64_t xmin= min(Xs_in_Yrange.at(Nin-Kin), xmin_cand);

                ans= min(ans, (xmax- xmin)*(ymax- ymin));
              }
            }
          }
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }

// * ALways PASS arrays, strings etc to functions BY REFERENCE

int main() {
    int t = 1;
    // cin >> t;
    
    while(t--) {
        ll n, d;
        cin >> n >> d;
        d = d * d;
        
        ll cnt = 0, x, y;
        for (int i = 0; i < n; i++) {
            cin >> x >> y;
            if ((x*x + y*y) <= d)
                ++cnt;
        }
        
        cout << cnt << endl;
    }

	return 0;
}

Measured memory_bytes: 3612
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

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

int main(){
    std::ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    UnionFind uf(m+1);
    ll k, tmp, prev = -1;
    ll need_bridge[m+1] = {};
    for(int i=0;i<n;++i)
    {
        cin >> k;
        prev = -1;
        for(int j=0;j<k;++j)
        {
            cin >> tmp;
            if(prev != -1)
            {
                uf.unite(prev, tmp);
            }
            need_bridge[tmp] = 1;
            prev = tmp;
        }
    }

    ll root = -1;
    bool ret = true;
    // for(int i=1;i<=m;++i)
    // {
    //     cerr << uf.root(i) << endl;
    // }
    for(int i=1;i<=m;++i)
    {
        if(need_bridge[i] == 1)
        {
            if(root == -1)
            {
                root = uf.root(i);
            }
            else
            {
                if(root != uf.root(i)) ret = false;
            }
            
        }
    }

    cout << (ret ? "YES" : "NO") << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> C(10001, 0);
  rep(i, 100) rep(j, 100) rep(k, 100) {
    if (i == 0 || j == 0 || k == 0) continue;
    int n = i * i + j * j + k * k + i * j + j * k + k * i;
    if (n > 10000) continue;
    C.at(n)++;
  }
  rep(i, N) {
    cout << C.at(i + 1) << endl;
  }
}


Measured memory_bytes: 3612
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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


int main() {
    string O,E;
    cin >> O >> E;

    
    ll sizeO = O.size(), sizeE = E.size();
    if(sizeO == sizeE){
        rep(i,sizeE){
            cout << O[i] << E[i];
        }
    }else{
        rep(i,sizeE){
            cout << O[i] << E[i];
        }
        cout << O[sizeO-1];
    }

    cout << endl;


}



Measured memory_bytes: 3596
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B) {
    return B % A == 0 ? A + B : B - A;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B);
    else
        solve(A, B).writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <cstdio>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	int k, a, b;
	cin >> k >> a >> b;
	if (b < a+2) {
		cout << k + 1 << '\n';
	}
	else {
		long long res = 1;
		if (k >= a-1) {
			res = a;
			k-= a-1;
		}
		res += 1ll*(b-a)*(k/2);
		res += k%2;
		cout << res << '\n';
	}
	return 0;
}

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

int main(int argc, char const* argv[])
{
    int n, r;
    while (cin >> n >> r) {
        if (n == 0 and r == 0) break;
        vector<int> cards(n);
        for (int i = 0; i < n; i++) {
            cards[i] = n - i;
        }
        for (int i = 0; i < r; i++) {
            int p, c;
            cin >> p >> c;
            rotate(cards.begin(), cards.begin() + p - 1, cards.begin() + p -1  + c);
        }
        cout << cards[0] << endl;
    }
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Edge{
public:
	int from,to,weight;
	Edge()=default;
	Edge(int f,int t,int w):from(f),to(t),weight(w){}
};

class Graph{
public:
	vector<vector<Edge>> graph;
	Graph(int node_num){
		graph.resize(node_num);
	}
	void AddConnection(ll u,ll v,ll w){
		graph[u].emplace_back(u,v,w);
		graph[v].emplace_back(v,u,w);
	}
	void AddConnection2(ll u,ll v,ll w){
		graph[u].emplace_back(u,v,w);
		graph[v].emplace_back(v,u,-w);
	}
};

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddConnection2(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,-w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

vector<int> node_dist,visit;
bool dfs(ConnectNodeInfo& connect,ll from,ll dist){
	if(visit[from]){
		if(node_dist[from]!=dist){
			return false;
		}
		return true;
	}

	visit[from] = 1;
	node_dist[from] = dist;
	for(int i=0;i<connect[from].size();i++){
		if(!dfs(connect,connect[from][i].first,dist+connect[from][i].second)){
			return false;
		}
	}
	return true;
};

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

	int N=in(),M=in();
	Graph G(N);
	ConnectNodeInfo connect(N);

	REP(i,M){
		int u=in()-1,v=in()-1,w=in();
		connect.AddConnection2(u,v,w);
		G.AddConnection2(u,v,w);
	}
	
	node_dist.resize(N,0),visit.resize(N,0);

	for(int i=0;i<connect.size();i++){
		if(!visit[i] && !dfs(connect,i,0)){
			out("No");
			return 0;
		}
	}
	
	out("Yes");
	return 0;
}


Measured memory_bytes: 26624
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>

typedef long long ll;
using namespace std;

int main()
{
	int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	string week[] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};

	int a,b;
	while(~scanf("%d %d",&a,&b)){
		if(a==0 && b==0) break;

		int passed=0;
		for(int i=0;i<a - 1;i++){
			passed += days[i];
		}

		passed += b;
		cout << week[(passed - 1) % 7] << endl;
	}
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner scanner = new Scanner(System.in)) {
			String data1 = scanner.nextLine();

			String[] arr = data1.split(" ");

			int N = Integer.parseInt(arr[0]);
			int D = Integer.parseInt(arr[1]);

			List<String> list = new ArrayList<String>();
			for (int i = 0; i < N; i++) {
				String data = scanner.nextLine();
				list.add(data);
			}

			int ans = 0;
			for (int i = 0; i < list.size(); i++) {

				String[] arr1 = list.get(i).split(" ");
				double x = Double.parseDouble(arr1[0]);
				double y = Double.parseDouble(arr1[1]);

				double xx = Math.pow(x, 2);
				double yy = Math.pow(y, 2);

				double s = Math.sqrt(xx + yy);
				if (s <= D) {
					ans++;
				}
			}

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 75992