akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long[] X = new long[N];
            long[] L = new long[N];
            for (int i = 0; i < N; i++) {
                X[i] = sc.nextLong();
                L[i] = sc.nextLong();
            }

            List<Robo> robos = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                robos.add(new Robo(i, X[i] - L[i], X[i] + L[i]));
            }

            Collections.sort(robos, new Comparator<Robo>() {
                @Override
                public int compare(Robo o1, Robo o2) {
                    int comp = Long.compare(o1.right, o2.right);
                    if (comp == 0) {
                        comp = Long.compare(o1.left, o2.left);
                    }
                    return comp;
                }
            });

            int ans = 0;
            long right = Long.MIN_VALUE;
            for (int i = 0; i < N; i++) {
                Robo robo = robos.get(i);

                if (robo.left < right) {
                    continue;
                }

                right = robo.right;
                ans++;
            }

            System.out.println(ans);
        }
    }

    static class Robo {

        int index;

        long left;

        long right;

        public Robo(int index, long left, long right) {
            this.index = index;
            this.left = left;
            this.right = right;
        }

    }

}


Measured memory_bytes: 87544
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int a, b;
   cin >> a >> b;
   cout << max({a+b, a-b, a*b});

   return 0;
}

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


int main(){
  string s;
  cin >> s;
  int n=s.size();
  vector<int> ans(n,0);
  for(int i=0;i<2;++i){
    int co=0;
    for(int i=0;i<n;++i){
      if(s[i]=='R') co++;
      else{
        ans[i]+=co/2;
        ans[i-1]+=(co+1)/2;
        co=0;
      }
    }
    reverse(ans.begin(),ans.end());
    reverse(s.begin(),s.end());
    for(int i=0;i<n;++i){
      if(s[i]=='L') s[i]='R';
      else s[i]='L';
    }
  }
  for(int i=0;i<n;++i){
    if(i!=n-1){
      cout << ans[i] << " ";
    }else{
      cout << ans[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;    
using pll = pair<ll, ll> ;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define ar array
#define endl '\n'
#define all(x) x.begin(), x.end()
#define sz(x) ((long long)x.size())
 
 
template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}
 
const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;
 
ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}
 
ll inv(ll n){
    return fast(n,mod-2);
}
 
void pre(){
    
    
 
}




void solve(){    

    int n;
    cin >> n;
    int a[n+1], b[n+1];
    vector<int> ma(n+1,0) , mb(n+1,0);
    for(int i=0;i<n;i++){
        cin >> a[i];
        ma[a[i]]++;
    } 
    for(int i=0;i<n;i++){
        cin >> b[i];
        mb[b[i]]++;
    }

    for(int i=0;i<=n;i++){
        if(ma[i] + mb[i] > n){
            cout << "No";
            return;
        }
    }
    reverse(b,b+n);
    int l=0,r=n-1;
    for(int i=0;i<n;i++){
        if(a[i] == b[i]){
            if(b[l] != a[i] and b[i] != a[l]){
                swap(b[i],b[l]);
                l++;
            }else if(b[r] != a[i] and a[r] != b[i]){
                swap(b[i],b[r]);
                r--;
            }else{
                cout << "No\n";
                return;
            }
        }
    }   
    for(int i=0;i<n;i++){
        if(a[i] == b[i]){
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
    for(int i=0;i<n;i++){
        cout << b[i] << " ";
    }

}
 
int32_t main(){
    #ifndef ONLINE_JUDGE
    freopen("input00.txt","r",stdin);
    freopen("output00.txt","w",stdout);
    #endif
    IOS;
    pre();
    ll T = 1;
    //cin >> T;
    while(T--){
        static int i=1;
        //cout << "Case #" << i << ": ";
        i++;
        solve();   
    }
    return 0;
} 

Measured memory_bytes: 6368
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>

using ll = long long;

int main(){
    int a,b;
    std::cin >>a >> b;
    std::string ans = "Impossible";
    if((a+b)%3==0){
        ans = "Possible";
    }
    else if(a%3==0){
        ans = "Possible";
    }
    else if(b%3==0){
        ans = "Possible";
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
const int INF = 100000;
ll a[100005];
priority_queue<int>pq;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    ll n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        pq.push(x);
    }
    for(int i=0;i<m;i++){
        ll k=pq.top();
        pq.pop();
        k/=2;
        pq.push(k);
    }
    ll ans=0;
    while(!pq.empty()){
        int p=pq.top();
        pq.pop();
        ans+=p;
    }
    cout<<ans;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);

  int L = 0;
  for(int i = 1; i <= N; i+=2) {
    L++;
  }

  if(L >= K) printf("YES\n");
  else printf("NO\n");
  
  return 0;
}


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

using namespace std;

int main() {
	int N;
	char S[112];
	scanf("%d", &N);
	scanf(" %s", S);

	if (N%2==1){
		puts("No");
		return 0;
	}
	int tam = N/2;
	for (int i = 0;i < N/2;i++){
		if (S[i] != S[i+tam]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#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,k = 0;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    bool flag = 1;

    int ans = 0;

    if (n==1) {
        flag = 0;
    }
    int dummy = 0;
    while(flag){
        flag = 0;
        rep(i,n-1){
            if (a[i] > a[i+1]){
                dummy = a[i];
                a[i] = a[i+1];
                a[i+1] = dummy;
                flag = 1;
            }

        }
    }
    rep(i,k)ans += a[i];
    cout << ans <<endl;
}

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


int main() {
  string S;
  string T;

  cin >> S;
  cin >> T;

  int ans = 0;

  for(int i=0; i<3; i++){
    if(S[i] == T[i]) ans++;
  }


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF const ll INF = 1001001001;
#define PI const ld PI = 3.14159265358979323846;


int main() {
    int R,G;
    cin>>R>>G;
    cout<<2*G-R<<endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if (a == 0) return b;
    if (b == 0) return a;

    ll quot = a/b;
    ll mod = a%b;
    
    if (mod == 0) {
        return b;
    } else {
        return gcd(b, mod);
    }

}

int main() { 
    int N; cin >> N;
    vector<ll> A;
    for (int i=0; i<N; i++) {
        ll a; cin >> a;
        A.push_back(a);
    }

    vector<ll> left(N+1, 0);
    vector<ll> right(N+1, 0);
    for (int i=0; i<N; i++) {
        left[i+1] = gcd(left[i], A[i]);
    }
    for (int i=N-1; i>=0; i--) {
        right[i] = gcd(right[i+1], A[i]);
    }

    ll maxGcd = 0;
    for (int i=0; i<N; i++) {
        maxGcd = max(maxGcd, gcd(left[i], right[i+1]));
    }

    cout << maxGcd << endl;
    
    return 0;
}

Measured memory_bytes: 2804
n=int(input())
a=list(map(int,input().split()))
a_=max(a)
con=[0]*(a_+1)
tou=[0]*(a_+1)
ans=[]
for i in range(len(a)):
    u=a[i]
    if u==0:
        con[0]+=1
        tou[0]+=1
        ans.append(4-con[0])

    else:
        con[u]+=1 
        tou[u]+=1  
        ans.append(tou[u-1]-con[u]+1)
c=1
for i in range(len(ans)):
    c*=ans[i]
    c=c%(10**9+7)
print(c%(10**9+7))   



Measured memory_bytes: 20628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  REP(i, 2) {
    REP(j, N) cin >> A[i][j];
  }
  int ans = -1;
  REP(i, N) {
    int cost = 0;
    REP(j, N) {
      if (j < i) cost += A[0][j];
      else if (i == j) cost += A[0][j] + A[1][j];
      else cost += A[1][j];
    }
    ans = max(ans, cost);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n;
    string s, t, v = "SW";
    cin >> n >> s;
    t = string(n, '?');
    for(int j=0;j<4;j++){
        t[0] = v[j/2];
        t[1] = v[j%2];
        for(int i=2;i<n+2;i++){
            int i1 = (i-1)%n, i2 = (i-2)%n;
            if((t[i1] == t[i2] && s[i1] == 'o') || (t[i1] != t[i2] && s[i1] == 'x')) t[i%n] = 'S';
            else t[i%n] = 'W';
        }
        if(t[0] == v[j/2] && t[1] == v[j%2]){
            cout << t << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

using namespace std;

long long int sosuu(long long int i){
	long long int s = sqrt(i);
	long long int j;
	if(i==1)
		return 0;
	if(i==2)
		return 0;
	if(i%2==0)
		return 0;
	for (j = 3; j <= s; j += 2) {
		if (i%j == 0)
			return 0;
	}
	return i;
}

int main() {
	vector<long long int>a, ax;
	int n, i, count = 0, maxcount=0;
	long long int x;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x;
		a.push_back(x);
	}
	
	for (i = 0; i < n; i++) {
		if (sosuu(a[i]) == 0) {
			ax.push_back(a[i]);
		}
	}
	n = ax.size();
	i = 0;
	while (i < n) {
		count = 0;
		while (ax[i] % 2 == 0) {
			ax[i] /= 2;
			count++;
		}
		maxcount += count;
		i++;
	}
	cout << maxcount;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)



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

    int len = (int)(str.length());

    rep(i, len) {
        cout << 'x';
    }

    cout << endl;
    return 0;
}
   

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


class FenwickTree {
    public:
        FenwickTree(int n) : N(n), data(N, 0) {

        }

        void reset() {
            fill(data.begin(), data.end(), 0);
        }

        void put(int x, int v) {
            for (; x < N; x |= x + 1) {
                data[x] += v;
            }
        }

        int get(int x) {
            int res = 0;
            for (; x >= 0; x = (x & (x + 1)) - 1) {
                res += data[x];
            }
            return res;
        }

    private:
        int N;
        vector<int> data;
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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


    vector<int> B(n, 0);

    int base = -n;

    FenwickTree ft(n * 2 + 123);


    long long tar = n * 1LL * (n + 1) / 2 / 2 + 1;
    // cout << tar << endl;
    auto ok = [&](int x) {
        for (int i = 0; i < n; ++i) {
            if (A[i] <= x) {
                B[i] = 1;
            } else {
                B[i] = -1;
            }
        }
        ft.reset();
        int sum = 0;
        ft.put(sum - base, 1);

        long long res = 0;
        for (auto x : B) {
            sum += x;
            res += ft.get(sum - base - 1);
            ft.put(sum - base, 1);
        }
        return res >= tar;
    };

    int mx = *max_element(A.begin(), A.end());
    long long lo = 0, hi = mx;

    while (lo < hi) {
        auto mi = (lo + hi) >> 1;
        if (ok(mi)) {
            hi = mi;
        } else {
            lo = mi + 1;
        }
    }

    cout << lo << '\n';

    return 0;
}

Measured memory_bytes: 1792
using System;

class Plogram
{
    static void Main()
    {

        string str = Console.ReadLine();
        string ans = "WA";
        int num =2;
        int count = 0;

        if(str.Substring(0,1) == "A")
        {
            for(int i= 2; i<str.Length-1;i++)
            {
                if(str.Substring(i,1)=="C")
                {
                    num = i;
                    count++;
                }
            }
            if(str.Substring(1,num-1) == str.Substring(1, num - 1).ToLower() &&
                str.Substring(num+1, str.Length - num - 1) == str.Substring(num+1, str.Length - num - 1).ToLower() &&
                count == 1)
            {
                ans = "AC";
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> B(N);
    
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        A[i]--;
    }
    
    sort( A.begin(), A.end() );
    
    int count = 1;
    int n = 1;
    for ( int i = 1; i < N; i++ ) {
        if ( A[i] == A[i-1] ) {count++;}
        else {
            B[A[i-1]] = count;
            count = 1;
            n++;
        }
    }
    B[A[N-1]] = count;
    
     priority_queue<int, vector<int>, greater<int> > queue;
    
    for ( int i = 0; i < N; i++ ) {
        if ( B[i] ) {
            queue.push(B[i]);
        }       
    }
    
    long long ans = 0;
     while ( n > K ) {
         ans += queue.top();
         queue.pop();
         n--;
     }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll X, A, B;
    cin >> X >> A >> B;
    if (A >= B)
    {
        puts("delicious");
    }
    else if (B - A <= X)
    {
        puts("safe");
    }
    else
    {
        puts("dangerous");
    }
    return 0;
}

Measured memory_bytes: 256
import math

x,y = map(int,input().split())
"""
値をどんどん2倍していって、それがyを超えないかを検証し、越えなければカウントを増やす
"""

count = 0
origin = x
while True:
  if origin <= y:
    count+=1
    origin = origin * 2
  else:
    break
    
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,k,b,i,j,c,d;
    cin>>a;
    int chart[3][a],happy[3][a];
    for(i=0;i<a;i++)
    cin>>happy[0][i]>>happy[1][i]>>happy[2][i];
    chart[0][0]=happy[0][0];
    chart[1][0]=happy[1][0];
    chart[2][0]=happy[2][0];
    for(i=1;i<a;i++){
        b=happy[2][i];
        c=chart[0][i-1];
        d=chart[1][i-1];
            if(c>d)
            chart[2][i]=b+c;
            else
            chart[2][i]=b+d;
        b=happy[1][i];
        c=chart[0][i-1];
        d=chart[2][i-1];
        
            if(c>d)
            chart[1][i]=b+c;
            else
            chart[1][i]=b+d;
       
        
        b=happy[0][i];
        c=chart[1][i-1];
        d=chart[2][i-1];
        
            if(c>d)
            chart[0][i]=b+c;
            else
            chart[0][i]=b+d;
        
        
        
    }
        
    if(chart[0][a-1]<=chart[2][a-1]&&chart[1][a-1]<=chart[2][a-1])
    cout<<chart[2][a-1]<<endl;
    else if(chart[0][a-1]<=chart[1][a-1])
    cout<<chart[1][a-1]<<endl;
    else
    cout<<chart[0][a-1]<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  string s;
  cin>>s;
  int n=s.size();
  reverse(s.begin(),s.end());
  vector<int>MOD(2019);
  int64_t x=1;
  int64_t sum=0,ans=0;
  for(int i=0;i<n;i++){
   MOD[sum]++;
   sum+=(s[i]-'0')*x;
   sum%=2019;
   ans+=MOD[sum];
   x=x*10%2019;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3716
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int p;
    int q;
}data;

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}
//構造体の.pを降順
int comp( const void *c1, const void *c2 )
{ data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.p;   /* b を基準とする */
  int tmp2 = test2.p;
    return tmp2 - tmp1;}




int main(){
    int x;
    scanf("%d",&x);
    char res[x][5];
    int ac=0,tle=0,wa=0,re=0;
    rep(i,x){
        scanf("%s",res[i]);
    }
    rep(i,x){
        if(res[i][0]=='A'){
            ac++;
        }else if(res[i][0]=='T'){
            tle++;
        }else if(res[i][0]=='W'){
            wa++;
        }else{
            re++;
        }
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d\n",re);
}


Measured memory_bytes: 2164
sx, sy, tx, ty = [int(x) for x in input().split()]
dx = tx - sx
dy = ty - sy
print('U' * dy + 'R' * dx + 'D' * dy + 'L' * dx + 'L' + 'U' * (dy + 1) + 'R' * (dx + 1) + 'D' + 'R' + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U')


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

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


Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
using namespace std;

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

	for (int target = 0; target < s.size(); target++) {
		char c = s[target];
		for (int watched = 0; watched < s.size(); watched++) {
			char cc = s[watched];
			if (target != watched && c == cc) {
				cout << "no";
				return 0;
			}
		}
	}

	cout << "yes";
	return 0;
}

Measured memory_bytes: 256
n=int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

res = num2alpha(n)

print(res.lower())

Measured memory_bytes: 9196
#include <stdio.h>

int main() {
    
    int x, y, t;
    while(1){
        scanf("%d %d", &x, &y);
        if (x == 0 && y==0) break;
        
        if (x > y){
            
            t = x;
            x = y;
            y = t;
            
        }
        
        printf("%d %d\n", x, y);
    }
 
 return 0;
    
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll X,Y;

int main() {
    cin >> X>>Y;
    cout << X + Y/2 << "\n";
}


Measured memory_bytes: 256
# inputs
_N = int(input())
order_list = input().split(" ")

# 出席した順番に並べた生徒番号が入るlist
ordered_id_list = [None for i in range(0, _N)]

for i,v in enumerate(order_list):
    _order = i + 1
    _id = int(v)
    ordered_id_list[(_id - 1)] = str(_order)

# 出力
print(" ".join(ordered_id_list))

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll h,w;cin >>h>>w;
    vector<string>s(h);
    for (int i = 0; i < h; ++i) {
        cin >>s[i];
    }
    vector<vector<ll>>cnt(h+1,vector<ll>(w+1,0));
    for (int i = 0; i < h; ++i) {
        ll now=0;
        for (int j = 0; j < w; ++j) {
            if(s[i][j]=='.')now++;
            else {
                cnt[i][j]=now;
                now=0;
            }
        }
        cnt[i][w]=now;
        ll k=0;
        for (int j = w; j>=0; --j) {
            if((j<w&&s[i][j]=='#')||j==w){
                k=cnt[i][j];
                cnt[i][j]=0;
            }
            else {
                cnt[i][j]+=k;
            }
        }
    }
    for (int i = 0; i < w; ++i) {
        ll now=0;
        for (int j = 0; j < h; ++j) {
            if(s[j][i]=='.')now++;
            else {
                cnt[j][i]=now;
                now=0;
            }
        }
        cnt[h][i]=now;
        ll k=0;
        for (int j = h; j>=0; --j) {
            if((j<h&&s[j][i]=='#')||j==h){
                k=cnt[j][i];
                cnt[j][i]=0;
            }
            else {
                cnt[j][i]+=k;
            }
        }
    }
    ll ans=0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans=max(ans,cnt[i][j]);
        }
    }
    ans--;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 35712
class UnionFind:
    def __init__(self,N):
        self.Parent=[-1]*N
    def unite(self,m,n):
        rm=self.root(m)
        rn=self.root(n)
        if rm==rn:
            return False
        else:
            if self.size(rm)<self.size(rn):
                rm,rn=rn,rm
            self.Parent[rm]+=self.Parent[rn]
            self.Parent[rn]=rm
            return True
    def root(self,n):
        if self.Parent[n]<0:
            return n
        else:
            self.Parent[n]=self.root(self.Parent[n])
            return self.Parent[n]
    def size(self,n):
        return -self.Parent[self.root(n)]
N,M,K=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
CD=[list(map(int,input().split())) for i in range(K)]
u=UnionFind(N)
f=[[] for i in range(N)]
k=[[] for i in range(N)]
for a,b in AB:
    u.unite(a-1,b-1)
    f[a-1].append(b-1)
    f[b-1].append(a-1)
for c,d in CD:
    k[c-1].append(d-1)
    k[d-1].append(c-1)
print(*[u.size(i)-len(f[i])-sum([1 for j in k[i] if u.root(i)==u.root(j)])-1 for i in range(N)])

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

N, Q = map(int, input().split())

ab_list = [list(map(int,list(input().split()))) for _ in range(N-1)]  
px_list = [list(map(int,list(input().split()))) for _ in range(Q)]  

graph = [[] for _ in range(N+1)]
point_list = [0] * (N+1)

for a, b in ab_list:
    graph[a].append(b)
    graph[b].append(a)
    
for p, x in px_list:
    point_list[p] += x
    
def add_point(num, root, point):
    point_list[num] += point
    for i in graph[num]:
        if i == root:
            continue
        add_point(i, num, point_list[num])

add_point(1, 0, 0)
 
print(*(point_list[1:]))

Measured memory_bytes: 300056
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input!(
        str : String,
    );

    let patterns = ["eraser", "erase", "dreamer", "dream"];
    let s = patterns.iter().fold(str, |s, x| s.replace(x, ""));
    println!("{}", if s.is_empty() { "YES" } else { "NO" })
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i, n, sum=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
            continue;
        else
            sum+=i;
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main()
{
    int n, i, j, data[10], a_index=0, b_index=0, check=0;
    int tube_a[10]={}, tube_b[10]={};
    scanf("%d", &n);
    for(i = 0; i < n; i++, check = 0, a_index=1, b_index=0){
        for(j = 0; j < 10; j++){
            scanf("%d", &data[j]);
        }
        tube_a[0] = data[0];
        for(j = 1; j < 10; j++){
            if(data[j] < tube_a[a_index - 1]){
                if(b_index == 0){
                    tube_b[b_index++] = data[j];
                }else if(tube_b[b_index - 1] < data[j]){
                    tube_b[b_index++] = data[j];
                }else{
                    printf("NO\n");
                    check = 1;
                    break;
                }
            }else{
                tube_a[a_index++] = data[j];
            }
        }
        if(check == 0) puts("YES");
    }
    return 0;
}

Measured memory_bytes: 1784
# coding: utf-8


def solve(*args: str) -> str:
    n, y = map(int, args[0].split())

    man = 0
    while man <= n and man*10000 <= y:
        gosen = 0
        while gosen <= n-man and (man*10000)+(gosen*5000) <= y:
            left = y-(man*10000)-(gosen*5000)
            sen = n-man-gosen
            if left < 0 or sen < 0:
                break
            if left == sen*1000:
                return '{} {} {}'.format(man, gosen, sen)

            gosen += 1
        man += 1

    return '-1 -1 -1'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int a[n];
  int i,j;
  int x;
  int count[100002]={};
  int ans=0;
  int tmp;
  
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    count[a[i]]++;   
  }
  
  for(i=0;i<n;i++)
  {
    x=a[i];
    if(x==0)
    {
     tmp=count[x]+count[x+1];
    }
    else
    {
     tmp=count[x-1]+count[x]+count[x+1];
    }
    if(ans<=tmp)
    {
      ans=tmp;
    }
  
  }
    
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 896
#include<cstdio>
using namespace std;
int main()
{
	int i,a,n,b,x[100000];
	scanf("%d %d",&a,&n);
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	b=0;
	for(i=0;i<n;i++){
		b+=x[i];
	}
	if(b>=a) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int A=1e6+100;

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

    int n;
    cin>>n;
    map<int,int> cnt;
    while(n--)
    {
        int a;
        cin>>a;
        cnt[a]++;
    }
    int ans=0;
    for(auto it=cnt.begin();it!=cnt.end();it++)
    {
        auto p=*it;
//        cout<<p.x<<" "<<p.y<<endl;
        int val=p.x;
        if(p.y==1)
            ans+=p.y;
        for(int mul=val*2;mul<=A;mul+=val)
            cnt.erase(mul);
    }
    cout<<ans;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, M, R;
vector<int> r, A, B, C;
vector<vector<int>> graph;

void wharshall(){
  REP(k, N){
    REP(i, N){
      REP(j, N){
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }
}
int main(){
  cin >> N >> M >> R;
  r.resize(R);
  REP(i, R){
    cin >> r[i];
    r[i]--;
  }
  A.resize(M), B.resize(M), C.resize(M);
  graph.resize(N, vector<int>(N, INF));
  REP(i, M){
    cin >> A[i] >> B[i] >> C[i];
    A[i]--, B[i]--;
    graph[A[i]][B[i]] = graph[B[i]][A[i]] = C[i];
  }
  wharshall();
  sort(r.begin(), r.end());
  ll ans = 1LL << 62;
  do{
    ll sum = 0;
    REP(i, R-1){
      sum += graph[r[i]][r[i+1]];
    }
    ans = min(ans, sum);
  }while(next_permutation(r.begin(), r.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 


//ei1333さんのGitHubから https://ei1333.github.io/luzhiled/

//グラフ用テンプレ
//edge := 重み付き辺
//Edges := 重み付き辺集合
//WeightedGraph := 重み付きグラフ
//UnWeightedGraph := 重みなしグラフ
//Matrix := 距離行列
template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int to, T cost) : src(-1), to(to), cost(cost) {}
	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
	
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
//テンプレここまで

//Dijkstra : E log(V)
template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
	const auto MINF = numeric_limits< T >::max();
	vector< T > dist(g.size(), MINF);

	using Pi = pair< T, int >;
	priority_queue< Pi, vector< Pi >, greater< Pi > > que;
	dist[s] = 0;
	que.emplace(dist[s], s);
	while(!que.empty()) {
		T cost;
		int idx;
		tie(cost, idx) = que.top();
		que.pop();
		if(dist[idx] < cost) continue;
		for(auto &e : g[idx]) {
			auto next_cost = cost + e.cost;
			if(dist[e.to] <= next_cost) continue;
			dist[e.to] = next_cost;
			que.emplace(dist[e.to], e.to);
		}
	}
	return dist;
}
//

int main() {
	int ans = 0;
	int tmp;
	int n, m;
	cin >> n >> m;
	int u, v;
	WeightedGraph<int> g(3*n+1);
	REP(i, m){
		cin >> u >> v;
		g[3*(u-1)+0].emplace_back(3*(v-1)+1, 0);
		g[3*(u-1)+1].emplace_back(3*(v-1)+2, 0);
		g[3*(u-1)+2].emplace_back(3*(v-1)+0, 1);
	}
	int s, t;
	cin >> s >> t;
	vector<int> res = dijkstra(g, 3*(s-1));
	if(res[3*(t-1)] < numeric_limits< int >::max() )cout << res[3*(t-1)] << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 17792
using System;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        string[] input = Console.ReadLine().Split(' ');
        int[] L = new int[N];
        for(int i = 0; i < N; i++)
        {
            L[i] = int.Parse(input[i]);
        }
        int max = 0;
        int sum = 0;
        for(int i = 0; i < N; i++)
        {
            sum += L[i];
            if (L[i] > max)
                max = L[i];
        }
        Console.WriteLine((sum > 2 * max) ? "Yes" : "No");
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    cout.precision(20);
    double a, b;
    cin >> a >> b;
    double c, d;
    cin >> c >> d;
    int m = c * 60 + d;
    double da = m / 2.0;
    double db = (m * 6) % 360;
    if(da == db){
        cout << abs(a - b) << endl;
        return 0;
    }

    double di = db - da;

    if(abs(di) == 180){
        cout << a + b << endl;
        return 0;
    }

    double ans = 0;

    if(di > 0){
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    else {
        di = da - db;
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int k = calc(a, b);

		if (k != -1) {
			System.out.println(k);
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}

	static int calc(int a, int b) {
		if (a - b == 0) {
			return a - b;
		}
		if ((a + b) % 2 == 0) {
			return (a + b) / 2;
		}
		return -1;
	}
}


Measured memory_bytes: 21844
fun main() = Thread(null, ::abc172a, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc172a() {
    val a = readLine()!!.toInt()

    val answer = a + a * a + a * a * a

    println(answer)
}


Measured memory_bytes: 34888
#include <bits/stdc++.h>
using namespace std;
int a[105];
int main(int argc, const char * argv[])
{
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    ans=a[n-1]-a[0];
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair



int main() {
  string s;
  cin >> s;
  int n = s.size();
  vi cnt(2);
  for (auto c: s) {
    cnt[c - '0']++;
  }
  cout << min(cnt[0], cnt[1]) * 2 << endl;
}



Measured memory_bytes: 512
//TaskB
/*N Rabbits, numbered, and given in order
    such that if the input is
    2 1 3
    3 is incorrect because it can't like itself
    the first rabbit likes '2'
    the second rabbit likes '1'
*/
#include <stdio.h>
#include <stdlib.h>

int main(){
    int N;
    scanf("%d",&N);
    int * rabbits = calloc(N,sizeof(int));
    int x = 0;
    while(x < N){
        scanf("%d",&rabbits[x]);
        x++;
    }
    //now to check for pairs
    int pairs = 0;
    x = 0;
    int m = 0;
    int n = 0;
    while(x < N){
        m = rabbits[x];
        n = rabbits[m-1];
        n--;
        if(n==x){
            pairs++;
        }
        x++;
    }
    printf("%d\n",pairs/2);
    return EXIT_SUCCESS;
}

Measured memory_bytes: 512
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1]*n 
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)      
        if x==y:
            return        
        if self.par[x] > self.par[y]:
            x, y = y, x       
        self.par[x] += self.par[y]
        self.par[y] = x

N, K, L = map(int, input().split())
Uni_1 = UnionFind(N)
Uni_2 = UnionFind(N)
D = {}
for _ in range(K):
  p,q = map(int, input().split())
  Uni_1.union(p-1, q-1)
for _ in range(L):
  p,q = map(int, input().split())
  Uni_2.union(p-1, q-1)
for i in range(N):
  k = (Uni_1.find(i), Uni_2.find(i))
  if k in D.keys():
    D[k] += 1
  else:
    D[k] = 1
for i in range(N):
  print(D[(Uni_1.find(i), Uni_2.find(i))], end=" ")

Measured memory_bytes: 43976
from operator import itemgetter


def main():
    N = int(input())
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # y 降順
    ab.sort(key=itemgetter(1), reverse=True)
    # x 昇順
    cd.sort(key=itemgetter(0))
    # ペアになった赤
    done = [False] * N
    for bx, by in cd:
        for k, ((rx, ry), d) in enumerate(zip(ab, done)):
            if not d and rx < bx and ry < by:
                done[k] = True
                break
    print(sum(done))
    return


main()


Measured memory_bytes: 3316
N = int(input())
stations = [list(map(int, input().split())) for _ in range(N-1)]

for idx, station in enumerate(stations):
  time = station[1] + station[0]
  for next in range(idx+1, N-1):
    if time < stations[next][1]:
      time = stations[next][1] + stations[next][0]
    elif (time-stations[next][1])%stations[next][2] == 0:
      time += stations[next][0]
    else:
      time += stations[next][2] - (time-stations[next][1])%stations[next][2] + stations[next][0]
  print(time)
print(0)
    


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

int main (void){
  int n,h,max = 0,ans = 0;
  cin >> n;

  for(int i = 0;i < n;i++){
    cin >> h;
    if(h >= max){
      max = h;
      ans++;
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main(){
	int d=100000;
	int i,n;
	scanf("%d", &n);
	for(i = 0;i < n;i++){
		d*=1.05;
		if(d%1000!=0)d=(d/1000+1)*1000;
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 588
#include <stdio.h>

int main(void) {
   int N;
   int i,j;
   int min, max, maxsub;

   scanf("%d", &N);
   int A[N];
   if(N >= 2 && N <= 100) {
      for(int i = 0; i < N; i++) {
         scanf("%d", &A[i]);
         if(A[i] < 1 && A[i] > 1000000000) {
            printf("error\n");
            return -1;
         }
      }
   } else {
      printf("error\n");
      return -1;
   }

   min = A[0];
   max = A[0];
   for (i = 0; i < N; i++) {
      if (A[i] > max) {
         max = A[i];
      } else if(A[i] < min) {
         min = A[i];
      }
   }
   maxsub = max -min;
   printf("%d\n", maxsub);

   return (0);
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	int N, K;
	cin >> N >> K;

	int a = 1;
	for (int i = 0; i < N; i++)
	{
		if (a * 2 - a < K)
		{
			a *= 2;
		}
		else
		{
			a += K;
		}
	}

	cout << a << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620