akhauriyash/Code-Regression huggingface dataset:
//    Unmesh Kumar
//    CSE'22 IIT Roorkee

#include <iostream>
#include <bits/stdc++.h>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <map>
#include <iterator>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>

using namespace std;
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) rep(i,n) cin>>arr[i]
#define carr2(arr,n,m) rep(i,n) rep(j,m) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
typedef pair<int,int> ii;
typedef vector<ii> vii;

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

bool comp(ll a,ll b)
{
  return a>b;
}

ll arr[1000005];
ll a[1000005];
ll b[1000005];

int main()
{
  fast;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cout<<setprecision(10)<<fixed;
  c(n);
  cc(a,b);
  ll total=0;
  total+=(n/(a+b))*a;
  ll res=n%(a+b);
  if(res>=a) total+=a;
  else total+=res;
  cout<<total<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n;
  cin>>n;
  vin a(n);
  rep(i,0,n)cin>>a[i];
  vin b(n);
  b=a;
  sort(all(b));
  int cet=b[n/2-1];
 rep(i,0,n){
   if(a[i]>cet){
    cout<<cet<<endl; 
   }
   else{
     
       cout<<b[n/2]<<endl;
     
     
   }
 }
}


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

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();

		char chr ;

		StringBuilder build = new StringBuilder();

		for(int i=0; i<str.length(); i++){

			chr = str.charAt(i);
			if(Character.isLowerCase(chr)){
				build.append(Character.toUpperCase(chr));
			}else {
				build.append(Character.toLowerCase(chr));

			}
		}


		System.out.print(build.toString()+"\n");

	}
}

Measured memory_bytes: 24136
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll x[100010];
int main()
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> x[i];
	ll ans = INF;
	for (int i = 0; i < N - K + 1; i++) {
		if (x[i] * x[i + K - 1] < 0) {
			ans = min(ans, 2 * min(abs(x[i]), abs(x[i + K - 1])) + max(abs(x[i]), abs(x[i + K - 1])));
		}
		else {
			if (x[i] < 0) ans = min(ans, abs(x[i]));
			else ans = min(ans, abs(x[i + K - 1]));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, h, w;

  cin >> n >> h >> w;

  ll a[n], b[n];

  ll ans = 0;

  REP(i, n){
    cin >> a[i] >> b[i];
    if(a[i] >= h && b[i] >= w) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np

n=int(input())
print(int((n-1)*n//2))
"""
if n==1:
    print(0)
else:
    plist=list(range(1,n+1))
    qlist=list(range(2,n+1))
    qlist.append(1)
    parray=np.array(plist)
    qarray=np.array(qlist)
    rarray=parray%qarray
    sm=rarray.sum()
    print(sm)
"""

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

int main() {
  int A, B;
  string op;
  cin >> A >> op >> B;
  if (op[0] == '+')
    cout << A+B << endl;
  else
    cout << A-B << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <map>

using namespace std;

const int INF = numeric_limits<int>::max() / 2;

template<typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main(){
    int n;
    cin >> n;
    vector<long long> plus, minus;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        if(a > 0) plus.push_back(a);
        else minus.push_back(a);
    }
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end(), greater<long long>());

    long long ans = 0;
    if(minus.size() == 0){
        for(long long a: plus) ans += a;
    }else if(minus.size() % 2 == 0){
        for(long long a: plus) ans += a;
        for(long long a: minus) ans += -1 * a;
    }else{
        if(plus.size() == 0){
            for(long long a: minus) ans += -1 * a;
            ans += 2 * minus[0];
        }else{
            for(long long a: plus) ans += a;
            for(long long a: minus) ans += -1 * a;
            ans -= 2 * min(plus[0], -1 * minus[0]);
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main(){
   int n, x;
   cin >> n >> x;
   int ans = 1;
   int d = 0;
   rep(i, n){
      int l;
      cin >> l;
      d += l;
      if(d > x) continue;
      ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
fn concent(w: usize, s: usize) -> f64 {
    if w == 0 || s == 0 {
        0.0
    } else {
        s as f64 / w as f64
    }
}

fn main() {
    let (a, b, c, d, e, f) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        let v: Vec<usize> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
        (v[0], v[1], v[2], v[3], v[4], v[5])
    };

    let mut water: Vec<usize> = Vec::new();
    let mut sugar: Vec<usize> = Vec::new();

    for i in 0..50 {
        for j in 0..50 {
            let x = a * i + b * j;
            if x * 100 > f {
                break;
            }

            water.push(x);
        }
        if a * i > f {
            break;
        }
    }

    for i in 0..5000 {
        for j in 0..5000 {
            let x = c * i + d * j;
            if x > f {
                break;
            }

            sugar.push(x);
        }
        if c * i > f {
            break;
        }
    }

    let mut ans_water = a;
    let mut ans_sugar = 0;
    for &w in water.iter() {
        for &s in sugar.iter() {
            let total = w * 100 + s;
            let c = concent(w, s);
            if total > f {
                continue;
            }
            if c > e as f64 {
                continue;
            }

            if c > concent(ans_water, ans_sugar) {
                ans_water = w;
                ans_sugar = s;
            }
        }
    }

    println!("{} {}", ans_sugar + ans_water * 100, ans_sugar);
}


Measured memory_bytes: 6396
using System;

class Program
{
    static int Main()
    {
        string s = Console.ReadLine();
        int cnt = 0;
        for(var i=0; i<s.Length; i++)
        {
            cnt += (i % 2) ^ int.Parse(s[i].ToString());
        }
        Console.WriteLine((cnt * 2 < s.Length ? cnt : s.Length - cnt).ToString("d"));
        return 0;
    }
}

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

int main() {
	string s; cin >> s;
	string t; 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: 764
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

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


using namespace std;
int main()
{
   
   
    int n;
    string p;
    cin >> n >> p;


    for (int i = 0; i < p.size() - 1; i++)if (p[i] == p[i + 1])n--;

    cout << n << endl;
    
    

    return 0;

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
int k;
using ll = long long ;

int a[22], top;
ll dp[30][12][2][2];

ll rec (int pos, int last, bool eq, bool zero) {
    if (dp[pos][last][eq][zero] != -1)
        return dp[pos][last][eq][zero];

    if (pos == top)
        return 1;


    ll &res = dp[pos][last][eq][zero];
    res = 0;

    if (eq) {
        for (int add = 0 ; add <= a[pos] ; ++ add) {
            if ((pos != 0) && (!zero) && abs(add - last) > 1) continue;

            bool new_zero = zero & (add == 0);

            if (add != a[pos]) {
                res += rec(pos + 1, add, false, new_zero);
            } else {
                res += rec(pos + 1, add, true, new_zero);
            }
        }
    } else {
        for (int add = 0 ; add <= 9 ; ++ add) {
            if ((pos != 0) && (!zero) && abs(add - last) > 1) continue;

            bool new_zero = zero & (add == 0);

            res += rec(pos + 1, add, false, new_zero);
        }
    }

    return res;
}

bool test (ll x) {
    top = 0;
    while (x > 0) {
      a[top ++] = x % 10;
      x /= 10;
    }
    reverse(a, a + top);

  /*  for (int j = 0 ; j < top ; ++ j)
        printf("%d", a[j]);
    printf("\n");*/

    memset(dp, -1, sizeof(dp));


    return (rec(0, 0, true, true) - 1) >= k;
}

int main () {

    scanf("%d", &k);
    ll l = 1, r = 3234566667, ans = -1;

    while (l <= r) {
        ll mid = l + r >> 1;

        if (test(mid)) {
            ans = mid;
            r = mid - 1;
        } else l = mid + 1;
    }

    printf("%lld\n", ans);
}
/*
    Good Luck
        -Lucina
*/


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

const int maxN = 100010;

int cnt[2][maxN], st[maxN];

int main (){
	int n, i, j, k, ans;
	scanf("%d", &n); ans = n;
	for(i = 0; i < n; ++i){
		j = i & 1;
		scanf("%d", &k);
		++cnt[j][k];
	}
	for(i = 0; i < maxN; ++i) st[i] = cnt[1][i];
	sort(st, st + maxN);
	reverse(st, st + maxN);
	for(i = 0; i < maxN; ++i){
		j = st[0];
		if(cnt[1][i] == j) j = st[1];
		if(ans > n - j - cnt[0][i])
			ans = n - j - cnt[0][i];
	}
	printf("%d\n", ans);
	return 0;
}


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



int main(void)
{
	int n,x;
	bool f;

	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		x = i;
		if (x % 3 == 0)
		{
			cout << " " << x;
			continue;
		}
		while (x)
		{
			if (x % 10 == 3)
			{
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;
	return 0;
}


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

int main(){
	int x;
	int sum = 0;
	
	for (;;){
		cin >> x;
		if ( x == 0 ) break;
			sum += 1;
			cout << "Case " << sum << ": " << x << endl;
			
	}
	
return 0;
}


Measured memory_bytes: 3016
#include <cstdio>
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
typedef long long ll;

int N, A[110], cnt;

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

  cin>> N;
  REP(i,N) cin >> A[i];
  bool flag = true;
  while (flag) {
    flag = false;
    RFOR(j,1,N){
      if (A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        flag = true;
        ++cnt;
      }
    }
  }

  REP(i,N){
    cout << A[i];
    if (i != N-1) {
      cout << " ";
    } else {
      cout << "\n";
    }
  }
  cout << cnt << endl;

  return 0;
}

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

void solve()
{
ll n,i;
    cin>>n;
    vector<ll>a(n);
    ll ans=0;
    unordered_map<ll,ll>mp;
    for(ll &x:a)
    {
     cin>>x;
        mp[x]++;
        ans+=x;
    }
    ll q;
    cin>>q;
    while(q--)
    {
     ll r,s;
        cin>>r>>s;
        
        if(mp[r])
        {
         int cnt=mp[r];
            ans+=cnt*(s-r);
            mp.erase(r);
            mp[s]+=cnt;
            
            cout<<ans<<endl;
        }
        else cout<<ans<<endl;
    }
}


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

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    ll k;
    cin >> k;
    string s = "FESTIVAL";
    vector<int> a(5000,0),c(5000,0);
    vector<ll> dp(8,0),b(5000,0);
    dp[0] = 1;
    int cnt = 0,n = 300;
    for (int i = 0;i < 7;++i) {
        for (int j = 1;j < 8;++j) a[cnt] = j,cnt++;
        for (int j = 0;j < n;++j) a[cnt] = i+1,cnt++;
    }
    for (int i = 0;i < cnt;++i) {
        dp[a[i]] += dp[a[i]-1];
        if (a[i] == 7) b[i] = dp[7];
    }
    for (int i = 4999;i > 0;--i) if (b[i]) while (k >= b[i]) k -= b[i],c[i]++;
    string ans = "";
    for (int i = 0;i < cnt;++i) {
        ans += s[a[i]-1];
        for (int j = 0;j < c[i];++j) ans += 'L';
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int n, A[2000];
int solve(int, int);

int main()
{
  int i, j, a, q, Q[2000];

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for(j = 0 ; j < q ; j++){
    scanf("%d",&Q[j]);
  }

  for(i = 0 ; i < q ; i++){
    a = solve(0,Q[i]);
    if(a == 1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
}

int solve(int i, int m)
{
  int res;
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

Measured memory_bytes: 588
#include <iostream>

#include <string.h>

using namespace std;

int main()

{

	char dick[6];	cin>>dick;

	if(dick[2]==dick[3]&&dick[4]==dick[5])

	{

		cout<<"Yes"<<endl;

	}

	else{

		cout<<"No"<<endl;

	}

	return 0;

}

	

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

const int maxn = 1e5 + 5;
int a[maxn],b[maxn];

int main(){
	int n;scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d",&b[i]);
		a[i] = b[i];
	}
	sort(a + 1,a + 1 + n);
	int mid = a[n] / 2,pos,mi = a[n];
	for(int i = 1;i <= n;i++){
		if(b[n] % 2 == 0){
			if(abs(b[i] - mid) < mi && b[i] < a[n]){
				mi = abs(b[i] - mid);
				pos = i;
			}
		}
		else{
			if(abs(b[i] - mid) < mi && b[i] < a[n]){
				mi = abs(b[i] - mid);
				pos = i;
			}
			if(abs(b[i] - mid - 1) < mi && b[i] < a[n]){
				mi = abs(b[i] - mid - 1);
				pos = i;
			}
		}
	}
	printf("%d %d\n",a[n],b[pos]);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
typedef long long ll;
typedef long double ld;
#define trace(x)  cerr << #x << ": " << x << endl;
#define rep(i,a)  for(ll i=0; i< a; i++)
#define pb push_back
#define vl vector<ll>
void __print(ll x) {cerr << x;}
void __print(ld x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int N = 2*1e5+5;
const ll mod=1e9+7;
struct vertex{
    ll parent;
    ll rank;
    ll comp;
    vl vec;
};
 
typedef struct vertex vertex;
 
vertex ver[N];
 
ll find(ll n){
    ll x= n;
    while(x != ver[x].parent){
        x = ver[x].parent;
    }
    ll y = n;
    ll z= ver[y].parent;
    while(y!=z){
        ver[y].parent = x;
        y = z;
        z = ver[z].parent;
    }
    return x;
}
 
void makeset(ll n){
    ver[n].rank = 0;
    ver[n].parent = n;
    ver[n].comp = 1;
    ver[n].vec.pb(n);
}

void initiate(ll n){
    rep(i, n)   makeset(i);
}
 
void join(vl& x, vl& y){
    x.insert(x.end(), y.begin(), y.end());
}
 
void uni(ll x,ll y){
    ll px = find(x);
    ll py = find(y);
    if(px == py )   return;
    else if(ver[px].rank > ver[py].rank){ver[py].parent = px; ver[px].comp += ver[py].comp;join(ver[px].vec, ver[py].vec);}
    else if(ver[py].rank > ver[px].rank){ver[px].parent = py; ver[py].comp += ver[px].comp;join(ver[py].vec, ver[px].vec);}
    else{
        ver[py].parent = px;
        ver[px].rank++;
        ver[px].comp += ver[py].comp;
        join(ver[px].vec, ver[py].vec);
    }
}

int main()
{
	fast;
	ll n;cin>>n;initiate(n);ll m;cin>>m;
	for(ll i=0;i<m;i++)
	{
		ll u,v;cin>>u>>v;
		u--;v--;
		ll pu=find(u);ll pv=find(v);
		if(pu==pv)continue;
		uni(pu,pv);
	}
	ll ans=0;
	for(ll i=0;i<n;i++)
		if(find(i)==i){ans=max(ans,ver[i].comp);}
	cout<<ans;

}

Measured memory_bytes: 26408
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = [0] * N
for i in range(N):
    a = I()
    A[i] = a
cnt = 0

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v

def shellSort(A, n):
    cnt = 0
    G = [1]
    j = 0
    while G[j] <= N:
        G.append(3 * G[j] + 1)
        j += 1
    m = len(G) - 1
    E = []
    for i in range(1, len(G)):
        E.append(G[len(G) - 1 - i])
    for i in range(len(G) - 1):
        insertionSort(A, n, E[i])
    print(m)
    print(' '.join(map(str, E)))


shellSort(A, N)

print(cnt)
for i in range(N):
    print(A[i])



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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    double sum = T + 0.5;
    int count = 0;
    sum -= A;
    while(sum >= 0){
        sum -= A;
        count += B;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let A: usize = sc.get();
    let B: usize = sc.get();
    for i in 1..100*B+1 {
        if (0.08 * i as f64).floor() as usize == A && (0.1 * i as f64).floor() as usize == B {
            println!("{}", i);
            return;
        }
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    lint n, a[5];
    scanf("%lld", &n);
    rep(i, 5) scanf("%lld", &a[i]);
    printf("%lld\n", 5 + (n-1) / *min_element(a, a+5));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
typedef long long ll;
typedef long double ld;
#define rep(i,a)  for(ll i=0; i< a; i++)
#define pb push_back
#define vl vector<ll>
#define trace(x)  cerr << #x << ": " << x << endl;
const ll N=1e5+5;ll mod=1e9+7;
int main()
{
	map<ll,ll> mp;ll k;cin>>k;
	ll p=0;ll t=0;
	while(1)
	{
		t++;
		p=(10*p+7)%k;
		if(p==0){cout<<t;return 0;}
		if(mp[p]){cout<<"-1";return 0;}
		mp[p]++;

	}
}

Measured memory_bytes: 66084
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int n,h,w;
	cin>>n;cin>>h;cin>>w;
	cout<<(n-h+1)*(n-w+1)<<endl;
}


Measured memory_bytes: 256
a,b,c=list(map(float,input().split()))
import math
print(math.sin((2*c*math.pi)/360)*a*b*(1/2))
print(math.sqrt(a**2+b**2-2*a*b*math.cos(2*c*math.pi/360))+a+b)
print(math.sin(2*c*math.pi/360)*b)

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)

/////////////////////////////////////////////////////////

void Main(){
  ll N; cin >> N;
  map<ll, ll> fac;
  rep(n, 1, N + 1){
    ll tmp = n;
    ll cnt = 2;
    while(tmp > 1){
      if(tmp % cnt == 0){
        fac[cnt]++;
        tmp /= cnt;
      }else{
        cnt++;
      }
    }
  }

  ll res = 1;
  for(auto f : fac){
    res *= f.second + 1;
    res %= MOD;
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        char text[1000];
        int i = 0, count=0;

        gets(text);

        while(1)
        {
                if(text[count] == '\0')
                {
                        break;
                }
                count++;
        }

        for(i = 0; i<count; i++)
        {
                if(0x61<=text[i] && text[i] <= 0x7a)
                {
                        text[i] = text[i] - 32;
                }
        }
        printf("%s\n",text);


        return 0;
}

Measured memory_bytes: 524
//Inbornhandsome
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define endl '\n'
#define int long long

const int N = (int) 1e5;
int w[107], v[107], n, W, memory[107][N];

int dp(int l, int val)
{
    if(val == 0) return 0;

    if(val < 0) return INT_MAX;

    if(l == n+1) return INT_MAX;

    int &ans = memory[l][val];
    if(ans != -1) return ans;

    ans = min(dp(l+1, val), w[l] + dp(l+1, val-v[l]));
    return ans;

}

int32_t main()
{
    IOS; //FIO;

    memset(memory, -1, sizeof(memory));

    cin >> n >> W;

    for(int i = 1; i <= n; i ++) 
        cin >> w[i] >> v[i];
    
    int res = 0;

    for(int i = 1; i <= 1e5; i ++) {
        int temp = dp(1, i);
        if(temp <= W) 
            res = i;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 83840
#include <cstdio>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

ll vs[55];

int main(void) {
  ll k;
  scanf("%lld", &k);

  int n = 50;
  REP(i, n) {
    vs[i] = n-1; // 終状態
  }
  REP(i, n) {
    vs[i] += k / n;
  }
  k %= n;
  REP(i, k) {
    vs[i] += n;
    REP(j, n) {
      if(i != j) {
        vs[j]--;
      }
    }
  }

  printf("%d\n", n);
  REP(i, n) {
    printf("%lld%c", vs[i], i == n-1 ? '\n' : ' ');
  }
  
  
  return 0;
}


Measured memory_bytes: 128
import sys

stra = input()
strb = input()
strc = input()

flag = 1

while True:
    if flag == 1:
        if len(stra) == 0:
            print("A")
            sys.exit()
        if stra[0:1] == 'a':
            flag = 1
        elif stra[0:1] == 'b':
            flag = 2
        elif stra[0:1] == 'c':
            flag = 3
        stra = stra[1:len(stra)]
    elif flag == 2:
        if len(strb) == 0:
            print("B")
            sys.exit()
        if strb[0:1] == 'a':
            flag = 1
        elif strb[0:1] == 'b':
            flag = 2
        elif strb[0:1] == 'c':
            flag = 3
        strb = strb[1:len(strb)]
    elif flag == 3:
        if len(strc) == 0:
            print("C")
            sys.exit()
        if strc[0:1] == 'a':
            flag = 1
        elif strc[0:1] == 'b':
            flag = 2
        elif strc[0:1] == 'c':
            flag = 3
        strc = strc[1:len(strc)]


Measured memory_bytes: 3064
function Main(input) {
  const splited = input.split(' ');
  const a = splited[0];
  const b = splited[1];
  const ret = (a * b) % 2 === 0 ? 'Even' : 'Odd';
  console.log(ret);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define lld long long int
#define pb push_back
#define in insert
#define mod 1000000007
#define pi 3.14159265358979

using namespace std;

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

    lld n,a,b;
    cin>>n>>a>>b;

    if((abs(a-b)-1)%2==0)cout<<"Borys"<<"\n";
    else cout<<"Alice"<<"\n";
}


Measured memory_bytes: 3600
# ABC 88, B - card game for two
n = int(input())
A = [int(el) for el in input().split(' ')]

alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += max(A)
    else:
        bob += max(A)
    A.remove(max(A))
print(alice - bob)


Measured memory_bytes: 2940
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int INF = 1e9 + 5;

int N, H, K, Q;
vector<int> V, W;
vector<vector<array<int, 2>>> options;

int level(int x) {
    return 31 - __builtin_clz(x);
}

vector<array<int, 2>> generate_options(vector<int> v, vector<int> w) {
    assert(v.size() == w.size());
    int n = int(v.size());
    vector<array<int, 2>> opts(1 << n, {0, 0});
    vector<array<int, 2>> buffer(1 << n);

    for (int bit = 0; bit < n; bit++) {
        for (int mask = 0; mask < 1 << bit; mask++)
            opts[(1 << bit) + mask] = {opts[mask][0] + w[bit], opts[mask][1] + v[bit]};

        merge(opts.begin(), opts.begin() + (1 << bit), opts.begin() + (1 << bit), opts.begin() + (2 << bit), buffer.begin());
        swap(opts, buffer);
    }

    vector<array<int, 2>> new_opts;
    int best_v = -1;

    for (auto &opt : opts)
        if (opt[1] > best_v) {
            best_v = opt[1];
            new_opts.push_back(opt);
        }

    return new_opts;
}

int query(int v, int L) {
    auto it = upper_bound(options[v].begin(), options[v].end(), array<int, 2>{L, INF});

    if (it == options[v].begin())
        return -INF;

    it--;
    return (*it)[1];
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    cin >> N;
    H = 32 - __builtin_clz(N);
    K = max(2 * H / 3, 1);
    V.assign(N + 1, 0);
    W.assign(N + 1, 0);

    for (int i = 1; i <= N; i++)
        cin >> V[i] >> W[i];

    options.resize(N + 1);
    options[0] = {{0, 0}};

    for (int i = 1; i <= N; i++) {
        vector<int> v, w;
        int cutoff = level(i) < K ? level(i) : level(i) - K;

        for (int d = 0; d <= cutoff; d++) {
            v.push_back(V[i >> d]);
            w.push_back(W[i >> d]);
        }

        options[i] = generate_options(v, w);
    }

    cin >> Q;

    for (int q = 0; q < Q; q++) {
        int v, L;
        cin >> v >> L;
        int best = -INF;

        if (level(v) < K) {
            best = query(v, L);
        } else {
            int above = v >> (level(v) - K + 1);

            for (auto &opt : options[v])
                if (opt[0] <= L)
                    best = max(best, opt[1] + query(above, L - opt[0]));
        }

        cout << best << '\n';
    }
}


Measured memory_bytes: 185560
# ABC131D - Megalomania
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = sorted(
        [tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[1]
    )
    tasks = 0
    for task, deadline in A:
        tasks += task
        if tasks > deadline:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

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

void solve() {
    int N; cin >> N;
    vector<int> B(N);
    for(auto &e : B) cin >> e;
    vector<int> A;
    while(!B.empty()) {
        for(int i = B.size() - 1; i >= 0; --i) {
            if(B[i] > i + 1) {
                cout << -1 << '\n';
                return;
            }
            if(B[i] == i + 1) {
                B.erase(B.begin() + i);
                A.push_back(i + 1);
                break;
            }
        }
    }
    reverse(A.begin(), A.end());
    rep(i, N) cout << A[i] << '\n';
}

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


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


bool upd[(1<<18)];
int val[(1<<18)];

void Set(int a,int b,int x,int k=0,int l=0,int r=(1<<17)){
	if(b<=l || r<=a)return;

	if( r-l>1 && upd[k] ){
		upd[k*2+1] = upd[k*2+2] = 1;  
		val[k*2+1] = val[k*2+2] = val[k];
	}
	upd[k]=0;

	if(a<=l && r<=b){
		upd[k]=1;
		val[k]=x;
	}
	else{
		Set(a,b,x,k*2+1,l,(l+r)/2);
		Set(a,b,x,k*2+2,(l+r)/2,r);
		val[k]=min(val[k*2+1],val[k*2+2]);
	}
}
int Find(int a,int b,int k=0,int l=0,int r=(1<<17)){
	if(b<=l || r<=a)return INT_MAX;

	if( r-l>1 && upd[k] ){
		upd[k*2+1] = upd[k*2+2] = 1;  
		val[k*2+1] = val[k*2+2] = val[k];
	}
	upd[k]=0;

	if(a<=l && r<=b) return val[k];
	else{
		int L = Find(a,b,k*2+1,l,(l+r)/2);
		int R = Find(a,b,k*2+2,(l+r)/2,r);
		return min(L,R);
	}
}

int n,m,a,b,c,d;

int main(){
	memset(upd,0,sizeof(upd));
	fill(val,val+(1<<18),INT_MAX);
	cin>>n>>m;
	while(m--){
		cin>>a>>b;
		if(a){
			cout<<Find(b,b+1)<<endl;
		}
		else{
			cin>>c>>d;
			Set(b,c+1,d);
		}
	}
}


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

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

using namespace std;

int dist[2 * 1000];

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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  --X, --Y;

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


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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >>m;
    map<int,vector<int>> graph;
    vector<int> h(n,0);
    vector<int> connect(n,0);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin >>a >> b;
        a--;
        b--;
        connect[a]++;
        connect[b]++;
        graph[a].push_back(b);
    }
    int total=0;
    vector<int> ans(n,0);

    for(auto it: graph){
        int obs=it.first;
        for(auto ele: it.second){
            if(h[obs]>h[ele]){
                ans[obs]++;
            }else if(h[obs]<h[ele]){
                ans[ele]++;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(connect[i]==ans[i] || (connect[i]==0 && ans[i]==0)){
            total++;
        }
    }
    cout << total;
    return 0;
}



Measured memory_bytes: 11012
import java.lang.StringBuilder

fun main(args: Array<String>) {
    val minimumS: String = StringBuilder().append(readLine()?.toCharArray()?.apply { sort() }).toString()
    val maximumT: String = StringBuilder().append(readLine()?.toCharArray()?.apply { sortDescending() }).toString()
    println(if (minimumS < maximumT) "Yes" else "No")
}

Measured memory_bytes: 32276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+10;
ll ans[2];
int main()
{
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    ll x=n,y=n;
    if(c>0)x=abs(a-b)/c;
    if(d>0)y=abs(a-b)/d;
    n--;
    int f=1;
    if(y>n)f=0;
    else
    {
        if(x%2!=n%2)x++;
        if(y%2!=n%2)y++;if(x>n&&y>n)f=0;
        if(abs(abs(a-b)-x*c)>(n-x)/2*(d-c)&&abs(abs(a-b)-y*d)>(n-y)/2*(d-c))f=0;
    }
    if(f)cout<<"YES";
    else cout<<"NO";
    return 0;
}


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

using namespace std;

#define int long long
#define MOD 1000000007


#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#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 all(i) (i).begin(),(i).end()å
#define rall(i) (i).begin(),(i).end(),greater<int>()


#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T> void print(T x) { std::cout << x << '\n'; }
 
//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

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

   if(a<c&&c<b){
       cout << "Yes"<<endl;
   }

    else if(a>c&&c>b){
        cout <<"Yes"<<endl;
    }

    else{
        cout <<"No"<<endl;
    }


    return 0;
 
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
class Main {
 public static void main(String[] args){
  Scanner s = new Scanner(System.in);
  int x = 0;
  int y = 0;
  while(true){
   x = s.nextInt();
   y = s.nextInt();
   if(x == 0 && y == 0) break;
   if(x > y) System.out.println(y + " " + x);
   else System.out.println(x + " " + y);
  }
 }
}

Measured memory_bytes: 27220
#include <stdio.h>

int main(int argc, char const *argv[])
{
  int a, b, c, ans=0;
  scanf("%d %d %d", &a, &b, &c);

  while(a <= b)
  {
    if((c % a++) == 0)
      ans++;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 596
import sys
sys.setrecursionlimit(10**6)

N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

par = [n+1 for n in range(N)]
rank = [0 for _ in range(N)]
size = [1 for _ in range(N)]

# 木の根を求める
def find(x):
  if par[x-1] != x:
    par[x-1] = find(par[x-1])
  return par[x-1]
# x, y の属する集合を併合
def unite(x, y):
  rx = find(x)
  ry = find(y)
  if rx == ry:
    return
  if rank[rx-1] < rank[ry-1]:
    rx, ry = ry, rx
  par[ry-1] = rx
  size[rx-1] += size[ry-1]
  if rank[rx-1] == rank[ry-1]:
    rank[rx-1] += 1
# x, y が同じ集合に属するか否か
def same(x, y):
  return find(x) == find(y)
def getsize(x):
  return size[find(x)-1]

friends = [0 for _ in range(N)]
for A, B in AB:
  unite(A, B)
  friends[A-1] += 1
  friends[B-1] += 1

ans = [0 for _ in range(N)]

for n in range(N):
  ans[n] = getsize(n+1) - friends[n] -1

for C, D in CD:
  if same(C, D):
    ans[C-1] -= 1
    ans[D-1] -= 1
print(' '.join(map(str, ans)))

Measured memory_bytes: 129752
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        
        String symbol = "#";
        String dot = ".";
        
        while (true) {
            String[] ary = br.readLine().split(" ");
            int numH = Integer.parseInt(ary[0]);
            int numW = Integer.parseInt(ary[1]);
            
            if(numH == 0 && numW == 0){
                break;
            }
            
            Rectangle rt = new Rectangle(numH, numW);
            System.out.print(rt.makeCheck(symbol, dot));
        }
        
        System.out.print(sb);
    }
}

class Rectangle {
    private int hight;
    private int wide;
    
    Rectangle(int hight, int wide){
        this.hight = hight;
        this.wide = wide;
    }
    
    String makeFrame(String symbol, String dot) {
        StringBuilder sb = new StringBuilder();
        
        for (int i = 0; i < hight; i++) {
            for (int j = 0; j < wide; j++) {
                if (i == 0 || i == (hight - 1) || j == 0 || j == (wide - 1)) {
                    sb.append(symbol);
                } else {
                    sb.append(dot);
                }
            }
            sb.append("\n");
        }
        sb.append("\n");
        
        return sb.toString();
    }
    
    String makeRectangle(String symbol){
        StringBuilder sb = new StringBuilder();
        
        for (int i = 0; i < hight; i++) {
            for (int j = 0; j < wide; j++) {
                sb.append(symbol);
            }
            sb.append("\n");
        }
        sb.append("\n");
        
        return sb.toString();
    }
    
    String makeCheck (String symbol, String dot) {
        StringBuilder sb = new StringBuilder();
        
        for (int i = 0; i < hight; i++) {
            for (int j = 0; j < wide; j++) {
                if (j % 2 == 0 && i % 2 == 0) {
                    sb.append(symbol);
                } else if (j % 2 == 1 && i % 2 == 1) {
                    sb.append(symbol);
                } else {
                    sb.append(dot);
                }
            }
            sb.append("\n");
        }
        sb.append("\n");
        
        return sb.toString();
    }
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s;


// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll dp(n+1);
	ll cc;
	dp[0] = 0;
	for(ll i=1;i<6;i++) dp[i] = i;
		dp[6] = 1;
	for(ll i=7;i<=n;i++) {
		dp[i] = dp[i-1]+1;
		cc = 6;
		while(i >= cc) { dp[i] = min(dp[i],dp[i-cc]+1); cc*=6; }
		cc = 9;
		while(i >= cc) { dp[i] = min(dp[i],dp[i-cc]+1); cc*=9; }
	}
	cout<<dp[n];
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0;i<N;i++)
    cin >> a.at(i);
  
  // バブルソート
  for (int i=0;i<N;i++) {
    for (int j=i;j<N;j++) {
      if (a.at(i)<a.at(j)) {
        int tmp = a.at(i);
        a.at(i) = a.at(j);
        a.at(j) = tmp;
      }
    }
    
  }
  
  int sum_A = 0, sum_B = 0;
  for (int i=0;i<N;i++) {
    if (i%2 ==0 ){
      sum_A += a.at(i);
    }
    else {
      sum_B += a.at(i);
    }
  }
  cout << sum_A-sum_B << endl;
}


Measured memory_bytes: 256