akhauriyash/Code-Regression huggingface dataset:
import qualified Data.Map as M
import Data.List (sort)

split2 :: [a] -> ([a], [a])
split2 ns = helper ([], []) ns
  where helper (as, bs) (x:y:zs) = helper (x:as, y:bs) zs
        helper all _ = all

toMap :: [Int] -> M.Map Int Int
toMap ns = foldr (\a b -> M.insertWith (+) a 1 b) M.empty ns

mosts :: (Ord k, Ord v) => M.Map k v -> [(v, k)]
mosts m = reverse . sort $ map (\(a,b) -> (b,a)) (M.assocs m)

count :: Eq a => [(Int, a)] -> [(Int, a)] -> Int
count [] (b:bs) = fst b
count (a:as) [] = fst a
count (a:as) (b:bs) = if (snd a /= snd b)
                      then fst a + fst b
                      else max (count (a:as) bs) (count as (b:bs))

doMain :: String -> Int
doMain line = 2 * (length as) - (count as' bs')
  where (as, bs) = split2 . map read $ words line ::([Int], [Int])
        as' = mosts $ toMap as
        bs' = mosts $ toMap bs

main = do
  n <- getLine
  if (n == "2")
    then do
      [a, b] <- words <$> getLine
      if a == b then print 1 else print 0
    else do
      line <- getLine
      print $ doMain line


Measured memory_bytes: 47484
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;

    int a,pd=1;
    while (n--)
    {
        cin>>a;
        if (a%2==0)
            if (a%3==0||a%5==0) continue;
            else pd=0;
    }

    if (pd) cout<<"APPROVED\n";
    else cout<<"DENIED\n";
    return 0;
}

Measured memory_bytes: 256
def read_valus():
    return map(int, input().split())


def read_list():
    return list(read_valus())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N, M = read_valus()
    L = read_lists(N)

    F = [
        lambda l: l[0] + l[1] + l[2],
        lambda l: - l[0] + l[1] + l[2],
        lambda l: l[0] - l[1] + l[2],
        lambda l: l[0] + l[1] - l[2],
        lambda l: - l[0] - l[1] + l[2],
        lambda l: - l[0] + l[1] - l[2],
        lambda l: l[0] - l[1] - l[2],
        lambda l: - l[0] - l[1] - l[2],
    ]

    res = 0
    for f in F:
        T = [f(l) for l in L]
        T.sort(reverse=True)
        tmp = sum(T[:M])
        res = max(res, tmp)
    
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

struct DisjointSet {
   DisjointSet(Int n)
      : ps(n, -1), ns(n, 1) {}
   std::vector<Int> ps, ns;
   Int find(Int x) {
      if( ps[x] == -1 ) return x;
      return ps[x] = find(ps[x]);
   }
   void unite(Int x, Int y) {
      x = find(x), y = find(y);
      if( x == y ) return;
      if( ns[x] > ns[y] ) std::swap(x, y);
      ps[x] = y;
      ns[y] += ns[x];
   }
   bool same(Int x, Int y) {
      return find(x) == find(y);
   }
};

int main() {
   Int n, q;
   std::cin >> n >> q;
   std::vector<Int> ps(n, -1), ns(n);
   DisjointSet dset(n);
   rep(i,q) {
      Int c, x, y;
      std::cin >> c >> x >> y;
      if( c == 0 ) {
         dset.unite(x, y);
      }
      else {
         puts(dset.same(x, y)?"1":"0");
      }
   }
}



Measured memory_bytes: 3284
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val a = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()

    val b = readLine()!!.split(" ").map { it.toInt() }.toTypedArray()

    var ans = 0L

    for(i in 0 until n){
        val left = Math.min(a[i], b[i])
        ans += left
        a[i] -= left
        b[i] -= left

        val right = Math.min(a[i+1], b[i])
        ans += right
        a[i+1] -= right
    }

    println(ans)
}

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

int main(){
    int n,t;
    cin>>n>>t;
    int p[n];
    for(int i=0;i<n;i++)
    cin>>p[i];
    int ans=t;
    for(int i=1;i<n;i++){
        if(p[i]-p[i-1]>=t){
            ans+=t;
        }
        else
        {
            int a=t-(p[i]-p[i-1]);
            ans+=t;
            ans-=a;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	int D;
	cin >> D;

	string ans = "Christmas";
	for (int i = 0; i < 25 - D; i++) ans += " Eve";

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, W, *WV = map(int, read().split())
    weight = WV[::2]
    value = WV[1::2]

    w_min = min(weight)
    items = [[] for _ in range(4)]
    for w, v in zip(weight, value):
        items[w - w_min].append(v)

    for i in range(4):
        items[i].sort(reverse=True)

    csums = [0] * 4
    for i in range(4):
        csums[i] = [0]
        csums[i].extend(accumulate(items[i]))

    def rec(i, w, v):
        if i == 4:
            if w <= W:
                return v
            else:
                return -1
        ans = 0
        for j in range(len(csums[i])):
            w_next = w + (w_min + i) * j
            if w_next > W:
                break
            ans = max(ans, rec(i + 1, w_next, v + csums[i][j]))

        return ans

    print(rec(0, 0, 0))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
def main(A, B, C, X):
    # type: (int, int, int, int) -> None
    coins = [
        (a,b,c)
        for a in range(0,A+1)
        for b in range(0,B+1)
        for c in range(0,C+1)
        if 500*a + 100*b + 50*c == X
    ] # type: List[Tuple[int, int, int]]
    print(len(coins))

if __name__ == '__main__':
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())
    main(A,B,C,X)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int n, a[N];
ll ans(LLONG_MAX);

int getCst(int a, int b){
    return (a - b) * (a - b);
}

void check(int x){
    ll ret = 0;
    for(int i = 0 ; i < n ; ++i)
        ret += getCst(x, a[i]);
    ans = min(ans, ret);
}

int main(){
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", a + i);

    int mn = *min_element(a, a + n);
    int mx = *max_element(a, a + n);

    for(int x = mn ; x <= mx ; ++x)
        check(x);
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
X = int(input())
# Xの素因数分解をうまくつかう
# A^5 - B^5 =(A-B)(A^4+A^3B+A^2B^2+AB^3+B^4)
# どっちが正負かは決まらない
# AB(A^2+B^2)+(A^2+B^2)^2-A^2B^2
# AB((A-B)^2+2AB)+((A-B)^2+2AB)^2 - A^2B^2
# A-B = P
# AB = Q
# A^5-B^5 = P(Q(P^2+2Q)+(P^2+2Q)^2-Q^2) = P(P^4+5P^2Q+5Q^2) = P(5Q^2+5P^2Q+P^4)
# Qは整数解なので
# 5Q^2+5P^2Q+P^4が整数解を持つ楽な方法は(Q+P)^2の形の時、つまり2P = P^2+2, 
# X = PRとする
# R-P^4は5の倍数になる

#Aの上限を求める
# X<10^9
# A-B = 1がAを最大にできる

maxA = 126
maxX = pow(10, 9)

flag = 0
for A in range(-126, 126):
    for B in range(-127, A):
        result = pow(A, 5) - pow(B, 5)
        if result > maxX:
            next
        if result == X:
            print(A, B)
            flag = 1
            break
    if flag == 1:
        break

Measured memory_bytes: 65408
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main() {
    int n;
    cin>>n;
    cout<<n*n<<endl;
}

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

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

    int a_sum = b[n - 2];
    for (int i = 0; i < n - 1; i++){
        if (i == 0){
            a_sum += b[i];
        }
        else{
            a_sum += min(b[i], b[i - 1]);
        }
    }
    cout << a_sum << endl;

    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val s = StdIn.readLine()
  
  def loop(s: String, before: String): String = {
    if(s.isEmpty) before
    else {
      val next = s.head match {
        case '0' => before + "0"
        case '1' => before + "1"
        case 'B' if before.length >= 1 => before.init
        case _ => before
      }
      loop(s.tail, next)
    }
  }
  println(loop(s, ""))

}


Measured memory_bytes: 25536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
int inf = 2e9, mod = 1e9 + 7;

struct Pnt{int v; double t;}q[1000000];

void merge(Pnt &a, Pnt b){
    a.t = (a.t * a.v + b.t * b.v) / (a.v + b.v);
    a.v += b.v;
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(10);
    int n, L; cin >> n >> L;
    int volume = 0; double temp = 0;
    for(int i=0,l=n,r=n-1,t,v;i<n;i++){
        cin >> t >> v;
        while(volume + v > L){
            int dec = min(q[r].v, volume + v - L);
            volume -= dec;
            temp -= dec * q[r].t;
            q[r].v -= dec;
            if(q[r].v == 0) r--;
        }
        volume += v;
        temp += v * t;
        cout << temp / L << '\n';
        q[--l].v = v, q[l].t = t;
        for(; l < r && q[l].t < q[l+1].t; l++) merge(q[l+1], q[l]);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 18688
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int num_ac = 0, num_wa = 0, num_tle = 0, num_re = 0;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if (s == "AC")
			num_ac++;
		else if (s == "WA")
			num_wa++;
		else if (s == "TLE")
			num_tle++;
		else if (s == "RE")
			num_re++;
	}
	cout << "AC x " << num_ac << "\n";
	cout << "WA x " << num_wa << "\n";
	cout << "TLE x " << num_tle << "\n";
	cout << "RE x " << num_re << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3656
#include <stdio.h>

int main() {
    int n, m, total, i;
    int a[10000];

    total = 0;

    scanf("%d %d", &n, &m);
    
    for(i=0; i<m; i++){
        scanf("%d", &a[i]);
    }
    
    for(i=0; i<m; i++) {
        total += a[i];
    }

    if(total > n) {
        printf("-1\n");
    } else {
        printf("%d\n", n - total);
    }

    return 0;

}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int a[1000000];
map<int,int> mp;

int binary_search(int v[],int x,int n){
  int l = 0;
  int r = n-1;

  while(r > l){
    int m = (r+l)/2;
    if(v[m] == x) return m;
    else if(v[m] > x) r = m-1;
    else l = m+1;
  }

  if(v[r]==x) return r;
  if(v[l]==x) return l;
  return -1;
}


int f(int a){
  int b = a;
  int res=0;
  int k=1;

  while(b&a){

    if(b&k){
      b+=k;
      res+=k;
    }
    k*=2;
  }

  return res;
}


signed main(){

  int n;
  cin>>n;

  rep(i,n){
    cin>>a[i];
    mp[a[i]]++;
  }

  sort(a,a+n);
  int ans=0;


  rrep(i,n-1){
    if(!mp[a[i]]) continue;
    int k = binary_search(a,f(a[i]),n);
    if(k!= -1){
      if(a[i] == f(a[i])){
        if(mp[a[i]]>=2){
          mp[a[i]]-=2;
          ans++;
        }
      }
      else{
        if(mp[a[k]]>=1){
          mp[a[i]]--;
          mp[a[k]]--;
          ans++;
        }
      }
    }
  }




  cout<<ans<<endl;
}

Measured memory_bytes: 14336
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define SZ(x) (int)(x).size()
#define lowbit(x) ((x) & -(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YEE ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define F first
#define S second
#define MP make_pair
#define EB emplace_back
#define PB push_back
#define INS insert
#define maxn
using namespace std;
typedef long long loli;
typedef pair<int, int> pii;

loli f(loli x) {
    if(x < 5) return 0;
    return (x / 5) / 2 + f(x / 5);
}

loli x;

int main() {
    while(~scanf("%lld", &x)) {
        if(x & 1) puts("0");
        else printf("%lld\n", f(x));
    }
    return 0;
}




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

int main(){
	char t1,t2;
	map<char,int> mp;
	mp['A']=1;
	mp['B']=0;
	mp['C']=0;
	while(scanf("%c,%c",&t1,&t2)>0){
		swap(mp[t1],mp[t2]);
	}
	if(mp['A']==1) printf("A\n");
	if(mp['B']==1) printf("B\n");
	if(mp['C']==1) printf("C\n");
	return 0;
}

Measured memory_bytes: 992
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

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


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>


using namespace std;

int main()
{
	int dp[201][201];
	int k; cin >> k;
	for(int i = 0; i <= k; ++i)
	{
		for(int j = 0; j <= k; ++j)
		{
			dp[i][j] = gcd(i, j);
		}
	}

	int ans = 0;
	for(int a = 1; a <= k; ++a)
	{
		for(int b = 1; b <= k; ++b)
		{
			int pre = gcd(a, b);
			for(int c = 1; c <= k; ++c)
			{
				ans += gcd(pre, c);
			}
		}
	}
	cout << ans;
	return 0;
}


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

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

    long long c = a + b;

    long long div = n/c;

    long long amari = n%c;

    long long ans = 0;

    long long ans1 = 0;
    long long ans2 = 0;

    ans1 = div * a;
    if(amari > a){
        ans2 = a;
    }
    else{
        ans2 = amari;
    }
    
    if(a == 0){
        ans = 0;
    }
    else{
        ans = ans1 + ans2;
    }
    


    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    if a > b * 2 {
        println!("{}", a - b * 2);
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double



int32_t main()
{
	IOS
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+')cout<<a+b<<endl;
	else cout<<a-b<<endl;
}
	
		
		
			
			
	
	
	

	
			
	
	
	
	
	

	

	

	
		


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m, k = sc.nextInt()
  val uf = UnionFind(n)
  val ans = new Array[Int](n)
  for (i <- 0 until m) {
    val a, b = sc.nextInt() - 1
    uf.unite(a, b)
    ans(a) = ans(a) - 1
    ans(b) = ans(b) - 1
  }
  for (i <- 0 until n) {
    ans(i) = ans(i) + uf.size(i) - 1
  }
  for (i <- 0 until k) {
    val c, d = sc.nextInt() - 1
    if (uf.same(c, d)) {
      ans(c) = ans(c) - 1
      ans(d) = ans(d) - 1
    }
  }
  for (i <- 0 until n) {
    print(ans(i))
    if (i < n - 1) print(" ")
  }
  println()
  case class UnionFind(val n: Int) {
    val par = Array.fill(n)(-1)
    val sz = Array.fill(n)(1)
    def find(x: Int): Int = {
      if (par(x) == -1) par(x) = x
      if (par(x) != x) {
        par(x) = find(par(x))
      }
      par(x)
    }
    def unite(x: Int, y: Int): Unit = {
      val a = find(x)
      val b = find(y)
      if (a == b) return
      if (sz(a) > sz(b)) {
        sz(a) += sz(b)
        par(b) = par(a)
      } else {
        sz(b) += sz(a)
        par(a) = par(b)
      }
    }
    def same(x: Int, y: Int): Boolean = {
      find(x) == find(y)
    }
    def size(x: Int): Int = {
      sz(find(x))
    }
  }
}


Measured memory_bytes: 117060
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
#define dwn(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int H, W, K;
	cin >> H >> W >> K;

	K--;

	ll dp[111][11];
	fill(dp[0], dp[H + 1], 0);
	dp[0][0] = 1;
	//dp[h][k] = 横線h段、1がkに来るものの数

	for (int h = 0; h < H; h++) {
		for (int b = 0; b < (1 << (W - 1)); b++) {

			//横線が隣り合っていないか
			bool judge = true;
			for (int i = 0; i < W - 2; i++) {
				//末尾が11のとき
				if ((b >> i) % 4 == 3) judge = false;
			}
			if (!judge) continue;

			//始点がどこに移動するか
			int perm[11];
			for (int i = 0; i < W; i++) perm[i] = i;

			for (int i = 0; i < W - 1; i++) {
				//線があるとき、位置を変える(あみだくじ)
				if ((b >> i) & 1) swap(perm[i], perm[i + 1]);
			}

			//下段に配っていく
			for (int i = 0; i < W; i++) {
				dp[h + 1][perm[i]] += dp[h][i];
				dp[h + 1][perm[i]] %= MOD;
			}
		}
	}
	cout << dp[H][K] << endl;
	return 0;
}

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

struct UnionFind
{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    return sizes[find(x)];
  }
};

int main(){
    int n,m;cin>>n>>m;
    UnionFind u(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        u.unite(x,y);
    }
    int ans=0;
    rep(i,n){
        ans=max(ans,u.size(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second
#define pl cout<<endl;
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
        return os<<"("<< p.first << "," << p.second<<")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
os << "{";
typename vector< T > :: const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
}
return os << "}";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
os << "[";
typename set< T > :: const_iterator it;
for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
os << *it;
}
return os << "]";
}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
        os << "[";
        typename map< F , S >::const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) {
if( it != v.begin() ) os << ", ";
os << it -> first << " = " << it -> second ;
}
return os << "]";
}
#define deb(x) cout << #x << " = " << x << endl;

#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
 
void fast()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
 
 
int main()
{
    ll n;
    cin>>n;
    vl v(n);
    invec(v,n);
    vl dp(n);
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    
    for(ll i=2;i<n;i++)
    {
        dp[i]=min(abs(v[i]-v[i-2])+dp[i-2],abs(v[i]-v[i-1])+dp[i-1]);
    }       
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#BITを使ってみる
n, k = map(int, input().split())
lr = []
for _ in range(k):
    l, r = map(int, input().split())
    lr.append((l, r))
mod = 998244353
class BinaryIndexedTree():
    def __init__(self, n, mod=None):
        self.n = n
        self.mod = mod
        self.bit = [0]*n
    
    def add(self, i, w):
        x = i+1
        while x<=self.n:
            self.bit[x-1] += w
            if self.mod is not None:
                self.bit[x-1] %= mod
            x += x & -x
    
    def sum(self, l, r):
        return self._sum(r-1) - self._sum(l-1)

    def _sum(self, i):
        ret = 0
        x = i+1
        while x>0:
            ret += self.bit[x-1]
            if self.mod is not None:
                ret %= self.mod
            x -= x & -x
        return ret
bit = BinaryIndexedTree(2*n+1, mod)
bit.add(n+1, 1)
for i in range(n+2, 2*n+1):
    for l, r in lr:
        bit.add(i, bit.sum(i-r, i-l+1))
print(bit.bit[2*n])

Measured memory_bytes: 77644
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()
  dp=[inf]*100010

  dp[0]=0
  dp[1]=abs(l[1]-l[0])

  for i in range(2,n):
    dp[i]=min(dp[i-2]+abs(l[i]-l[i-2]),dp[i-1]+abs(l[i]-l[i-1]))

  return dp[n-1]

print(main())


Measured memory_bytes: 16712
#include <cstdio>

int main()
{
  char s[200001];
  scanf("%s", s);
  long long pos = 0;
  long long ans = 0;
  for (long long i = 0; s[i]; ++i)
  {
    if (s[i] == 'W')
    {
      ans += i - pos;
      ++pos;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 384
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int N, K; cin >> N >> K;
    int val = 1;
    rep(i,0,N) {
        val = min(val * 2, val + K);
    }
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	count := 0
L:
	for {
		for i := 0; i < n; i++ {
			if a[i]%2 == 1 {
				break L
			} else {
				a[i] /= 2
			}
		}
		count++
	}
	fmt.Println(count)
}


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

int main(){
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  double res = (double)(W) * H / 2;
  cout << fixed << setprecision(12) << res << " ";
  if (x * 2 == W && y *2 == H) cout << 1 << endl;
  else cout << 0 << endl;
  
  
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll A, B, N;
  scanf("%lld %lld %lld", &A, &B, &N);

  ll x;

  if (B == 1) {
    x = 1;
  } else if (B > N) {
    x = N;
  } else {
    x = B - 1;
  }

  // x = 9;
  // cout << "x:" << x << endl;

  ll value1 = A * x / B;
  ll value2 = A * (x / B);

  ll ans = value1 - value2;

  cout << ans << endl;
}


Measured memory_bytes: 3660
#include <cstdio>

const int N = 1e5 + 5;

int a[N];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", a + i);
	int ans = 0;
	int o = 0;
	int j = -1;
	for (int i = 1; i <= n; i++) {
		if (i == n) {
			if (j != n - 1) {
				++ans;
			}
		}
		else {
			if (o == 0) {
				if (a[i - 1] < a[i]) {
					o = 1;
				}
				if (a[i - 1] > a[i]) {
					o = 2;
				}
			}
			else if (o == 1) {
				if (a[i - 1] > a[i]) {
					o = 0;
					j = i - 1;
					++ans;
				}
			}
			else if (o == 2) {
				if (a[i - 1] < a[i]) {
					o = 0;
					j = i - 1;
					++ans;
				}
			}
		}
	}
	printf("%d", ans);
	return 0;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll X,Y;
    cin >> X >> Y;
    ll now = X;
    ll cnt = 0;
    while(now <= Y){
        cnt++;
        now *= 2;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3588
input()
a=list(map(int,input().split()))
l=[1 if i%2==1 else 4 if i%4==0 else 2 for i in a]
print('YNeos'[(2 in l and l.count(1)>l.count(4)) or (2 not in l and l.count(1)>l.count(4)+1)::2])

Measured memory_bytes: 63640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
using namespace std;

typedef vector<int> Ivec;

int main() {
	int n, p;

	while (scanf("%d %d", &n, &p)) {
		if (n == 0)
			return 0;

		int turn = 0, wan = p;
		array<int, 50> mayer = {};
		while (1) {

			if (wan == 0) {
				wan = mayer[turn];
				mayer[turn] = 0;
			}
			else if (wan == 1 && mayer[turn]+1 == p) 
				break;
			else {
				wan--;
				mayer[turn]++;
			}
			turn++;
			turn -= ((int)(turn / n) * n);
		}
		printf("%d\n", turn);
	}

	return 0;
}

Measured memory_bytes: 3152
d = input()
d = d.split(" ")
a = int(d[0])
b = int(d[1])


if a < b :
    a = str (a)
    x = ""
    for i in range (b):
        x += a
    print (x)
else:
    b = str (b)
    y = ""
    for i in range(a):
        y += b
    print(y)
        

Measured memory_bytes: 2940
#include<iostream>
#include <string>
#include<vector>

using namespace std;

int main(){

	int a, b;
	cin >> a >> b;
	if( a == 1 ){
		if(b == 1){
			cout << "Draw" << endl;
		}
		else{
			cout << "Alice" << endl;
		}
	}
	else if( b == 1 ){
		cout << "Bob" << endl;
	}
	else{
		int ma = max(a,b);
		if(a == b){
			cout << "Draw" << endl;
		}
		else if(ma == a){
			cout << "Alice" << endl;
		}
		else{
			cout << "Bob" << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 256
S = input().split('T')
x, y = map(int, input().split())

X = []
Y = []
for i, s in enumerate(S):
    if i % 2 == 0:
        X.append(len(s))
    else:
        Y.append(len(s))

if sum(X) < abs(x) or sum(Y) < abs(y):
    print('No')
    exit()

pos = set([X[0]])
for i in range(1, len(X)):
    d = X[i]
    npos = set()
    for p in pos:
        npos.add(p + d)
        npos.add(p - d)
    pos = npos
flag_x = x in pos

pos = set([0])
for i in range(len(Y)):
    d = Y[i]
    npos = set()
    for p in pos:
        npos.add(p + d)
        npos.add(p - d)
    pos = npos
flag_y = y in pos

if flag_x and flag_y:
    print('Yes')
else:
    print('No')


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

int main()
{
    int lower=0,c=0;
    string s;
    cin>>s;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C'){
            c++;
        }
    }
    for(int j=0;j<s.size();j++){
        if(islower(s[j])){
            lower++;
        }
    }
    if(s[0]=='A'&&c==1&&lower==s.length()-2){
        cout<<"AC";
    }
    else{
        cout<<"WA";
    }
    return 0;
}


Measured memory_bytes: 256
main(){float f,g;for(;~scanf("%f%f",&f,&g);)puts(f<35.5&&g<71?"AAA":f<37.5&&g<77?"AA":f<40&&g<83?"A":f<43&&g<89?"B":f<50&&g<105?"C":f<55&&g<116?"D":f<70&&g<148?"E":"NA");exit(0);}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <map>
#define ll long long

using namespace std;

int main(void){
    ll n;
    cin >> n;
    vector<ll> diff;
    vector<ll> a;
    ll count = 0;
    for(ll i = 0; i < n; i++){
        ll x; cin >> x;
        if(i==0 || a[count-1] != x){
            a.push_back(x);
            count++;
        }

    }
    ll ans = 1;
    for(ll i = 0; i < a.size()-1; i++)
        diff.push_back(a[i+1]-a[i]);
    for(ll i = 1; i < a.size()-1; i++){
        if(diff[i]*diff[i-1]<0){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2548
#include <cstdio>
#include <algorithm>
#define max_n 100000
using namespace std;
int a[max_n+1];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0; ++i<=n; scanf("%d",a+i));
	stable_sort(a+1,a+n+1),a[0]=0;
	int t=lower_bound(a+1,a+n+1,a[n]>>1)-a;
    printf("%d %d\n",a[n],a[n]>a[t]+a[t-1]?a[t]:a[t-1]);
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>

#define N 36

typedef struct {
	char moji[3];
	int value;
} Roll;
	

int main()
{
Roll Bcard[N],Scard[N];
int i,j,num,kari,soeji[N],flag,stabflag,min;

scanf("%d",&num);
for(i=0; i<num; i++){
	scanf("%s",Bcard[i].moji);
	Bcard[i].value = Bcard[i].moji[1];
}
flag =1;
stabflag = 1;

for(i=0; i<num; i++){
	Scard[i] = Bcard[i];
	soeji[i] = i;
}

/*BubbleSort*/
for(i=0; flag==1; i++){
flag = 0;
for(j=num-1; j>=i+1; j--){
if(Bcard[j].value < Bcard[j-1].value){
kari = Bcard[j].value;
Bcard[j].value = Bcard[j-1].value;
Bcard[j-1].value = kari;
flag = 1;
			kari = soeji[j];
			soeji[j] = soeji[j-1];
			soeji[j-1] = kari;
		}
	}
}
for(i=0; i<num-1; i++){
printf("%s ",Bcard[soeji[i]].moji);
}
printf("%s\n",Bcard[soeji[num-1]].moji);

for(i=0; i<num-1; i++){
if(	Bcard[soeji[i]].moji[1] == Bcard[soeji[i+1]].moji[1] && soeji[i] > soeji[i+1] ) stabflag=0;
}
if(stabflag==0) printf("Not stable\n");
else printf("Stable\n");


/*SelectSort*/
stabflag = 1;
for(i=0; i<num; i++){
	soeji[i] = i;
}

for(i=0; i<num; i++){
min = i;
for(j=i; j<num; j++){
if(Scard[j].value < Scard[min].value){
min = j;
}
}
kari = Scard[min].value;
Scard[min].value = Scard[i].value;
Scard[i].value = kari;
kari = soeji[min];
soeji[min] = soeji[i];
soeji[i] = kari;
}

for(i=0; i<num-1; i++){
printf("%s ",Scard[soeji[i]].moji);
}
printf("%s\n",Scard[soeji[num-1]].moji);

for(i=0; i<num-1; i++){
if(	Scard[soeji[i]].moji[1] == Scard[soeji[i+1]].moji[1] && soeji[i] > soeji[i+1] ) stabflag=0;
}
if(stabflag==0) printf("Not stable\n");
else printf("Stable\n");

return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
#define MAX 500
static const int INFTY = (1<<21);
  
int main(){
  int i,j,n,e,k,a,v1;
  int key,p[MAX],v[MAX],u,c[MAX],m[MAX][MAX];
    
  scanf("%d", &n);
  for (i=0; i<n; i++){
    for (j=0; j<n; j++){
      m[i][j] = INFTY;
    }
  }
    
  for (i=0; i<n; i++){
    scanf("%d %d",&u,&k);
    for (j = 0; j<k; j++){
      scanf("%d %d", &v1,&a);
      m[u][v1] = a;
    }
  }
  for(i=0;i<n;i++){
    v[i]=0;
    c[i]=INFTY;
    p[i]=-1;
  }
  c[0]=0;
  
  while(1){
    key=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(key>c[i] && !v[i]){
    u=i;
    key=c[i];
      }
    }
    if(u==-1)break;
    v[u]=1;
    
    for(j=0;j<n;j++){
      if(m[u][j] + c[u] < c[j] && !v[j]){
    c[j]=c[u]+m[u][j];
    p[j]=u;
      }
    }
  }
    
  for (i=0; i<n; i++){
    printf("%d %d\n", i, (c[i]==INFTY?-1:c[i]));
  }

  return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, A, B;
	cin >> N;
	if (N == 1) cout << "Hello World\n";
	else {
		cin >> A >> B;
		cout << A + B << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        while(true)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int h = int.Parse(inputs[0]);
            int w = int.Parse(inputs[1]);
            if (h == 0 && w == 0) break;
            
            for (int i = 0; i < w; i ++)
            {
                Console.Write("#");
            }
            Console.WriteLine();
            string text = new String('.', w - 2);
            for (int i = 0; i < h - 2; i ++)
            {
                Console.WriteLine("#" + text + "#");
            }
            for (int i = 0; i < w; i ++)
            {
                Console.Write("#");
            }
            Console.WriteLine();
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13900
#include<stdio.h>

int main(){

  int n,i,j,k,temp,x[100],min,flag=0;

  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    min = x[i];
    k = i;
    for(j=i+1;j<n;j++){
      if(x[j] < min){
       	min = x[j];
	k = j;
      }
    }
    if(k!=i){
      temp = x[i];
      x[i] = x[k];
      x[k] = temp;
      flag++;
    }
  }

  for(i=0;i<n;i++){
    printf("%d",x[i]);
    if(i==n-1){
      break;
    }
      printf(" ");
  }
  printf("\n");
  printf("%d",flag);
  printf("\n");

  return 0;
}

Measured memory_bytes: 604
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 c = Integer.parseInt(sc.next());

        int tmp = a;
        a = b;
        b = tmp;

        tmp = a;
        a = c;
        c = tmp;

        int answer[] = {a, b, c};

        for(int i : answer) {
            System.out.println(i);
        }
        sc.close();
    }
}


Measured memory_bytes: 21716
#include<stdio.h>
int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(a < b){
		printf("a < b\n");
	}
	if(a > b){
		printf("a > b\n");
	}
	if(a == b){
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  map<int, int> cnt;
  ll ans = 0;
  REP(i,N) {
    int A; cin>>A;
    cnt[A]++;
    ans += (ll) A;
  }
  int Q; cin>>Q;
  while(--Q >= 0) {
    int B, C;
    cin >>B>>C;
    int d = cnt[B];
    ans += (ll)d * (ll)(C - B);
    cnt[C] += d;
    cnt[B] -= d;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 7588
def inp() a=gets.chomp.split(" ").map(&:to_i)end 
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b = na(a.max+1); a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def uf(a,x)
  return x if (a[x] == x)
  a[x] = uf(a,a[x])
end
def ufa(a,x,p,rank)
  root  = uf(a,x)
  connect  = uf(a,p)
  return if root == connect
  if rank[root] > rank[connect]
    a[connect] = root
  elsif rank[root] == rank[connect]
    a[connect] = root
    rank[root] += 1
  else
    a[root] = connect
  end
end
h = {}
n,k,l = inp
dk = na2(n+1,0)
da = na(n+1)
dl = na2(n+1,0)
db = na(n+1)
ra = na(n+1)
rb = na(n+1)
(n+1).times do |i|
  da[i] = i
  db[i] = i
end
(k).times do |i|
  d = inp
  ufa(da,d[1],d[0],ra)
end
(l).times do |i|
  d = inp
  ufa(db,d[1],d[0],rb)
end
(1..n).each do |i|
  uf(db,i)
  uf(da,(i))
end
(1..n).each do |i|
  h[[da[i],db[i]]] = 0 if(h[[da[i],db[i]]] == nil)
  h[[da[i],db[i]]] += 1
end
(1..n-1).each do |i|
  print "#{h[[da[i],db[i]]]} " 
end
puts h[[da[n],db[n]]]
=begin
max = c if max < c 
=end

Measured memory_bytes: 60668
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int c = 0;
		int prev = 0;
		int max = 0;
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			if (prev >= b) {
				c++;
				max = Math.max(c, max);
			} else {
				c = 0;
			}
			prev = b;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 48772
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    int N = nextInt();
	    double M = nextDouble();
	    int[] A = new int[N];
	    double max_vote = 0;
 
	    for(int i=0; i<N; i++){
	        A[i] = nextInt();
	        max_vote += A[i];
	    }
	    
	    int count = 0;
	    String flg = "No";
	    
	    for(int i=0; i<N; i++){
    	    if(A[i] >= (double)max_vote/(4*M)){
    	        count++;
    	    }
    	    if(count>=M){
    	        flg = "Yes";
    	        break;
    	    }
	    }
	    
        out.print(flg);
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int d, t, s;
    cin >> d >> t >> s;

    cout << (s * t >= d ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<int>())
#define pb push_back
#define ll long long

int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
}
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
}
int cel(int a,int b){return((a-1)/b+1);} 
int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a,int b){
    return (a*b)/gcd(a,b);
}
void dfs(int u,vi &visited,vi adj[]) {
    visited[u] = 1; 
	for (int i=0; i<adj[u].size(); i++) 
		if (visited[adj[u][i]] == 0) 
			dfs(adj[u][i],visited,adj); 
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll k,c=7,n=1,f=0,x,y;
    cin>>k;
    if(k%2==0||(k%5==0))cout<<-1;
    else{
        vi v(k+1,0);v[0]=1;
        while(1){
            if(c%k==0)break;
            if(v[c%k]==1){n=-1;break;}
            v[c%k]=1;
            c=c%k;c=(c*10)+7;
            n++;
        }
        cout<<n;
    }
    return 0;
}

Measured memory_bytes: 7136
#include <stdio.h>
int main(){
	int i=0;
	int ans =1;
	char s[110];
	scanf("%s",s);

	while(s[i] != '\0'){
		if(s[i]=='\0'){break;}
			if(s[i] =='L' && i % 2 ==0){
				
				ans =0;
			}
			if(s[i] == 'R' && i % 2 == 1){
				ans = 0;
			}
			i++;
		}

	
		if(ans){
			printf("Yes\n");
		}else{
			printf("No\n");
	}

	return 0;
	}

Measured memory_bytes: 128