akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll pow(ll a, ll n) {
    ll ret = 1;
    while(1) {
        if (n == 0) break;
        if (n&1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<int> num(1e7+1, 1);
    for (int i = 2; i <= 1e7; ++i) {
        int idx = i;
        while(1) {
            if (idx > 1e7) break;
            ++num[idx];
            idx += i;
        }
    }
    // for (int i = 0; i <= 20; ++i) {
    //     cout << num[i] << " ";
    // }
    // cout << endl;
    // vector<ll> beki(64, 0);
    // rep(i, 64) beki[i] = pow(2LL, (ll)i);
    // for (int i = 0; i <= 20; ++i) {
    //     cout << beki[i] << " ";
    // }
    // cout << endl;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        // cout << beki[(ll)(num[i] - 1)] << " ";
        // ans += (ll)i * beki[(ll)(num[i] - 1)];
        ans += (ll)i * (ll)(num[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 42324
import math


def main():
    n, d = map(int, input().split())
    ans = 0
    for _ in range(n):
        x, y = map(int, input().split())
        ans += 1 if math.sqrt(x**2 + y**2) <= d else 0

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#!/usr/bin/env python3

import sys


def main():
    def input(): return sys.stdin.readline().rstrip()
    def mi():    return map(int, input().split())


    def preprocess(s):
        x_command, y_command = [], []
        L = s.split('T')
        n = len(L)
        for i in range(n):
            if i % 2 == 0 and L[i]:
                x_command.append(L[i].count("F"))
            elif i % 2 == 1 and L[i]:
                y_command.append(L[i].count("F"))
        return x_command, y_command
    

    def valid_command(command, delta):
        # print(f"{command} {delta}")
        if not command:
            return delta == 0
        possible_num_set = set()
        n = len(command)
        for i in range(n):
            if i == 0:
                possible_num_set.add(command[0])
                possible_num_set.add(-command[0])
            else:
                num = command[i]
                new_set = set()
                for candidate in possible_num_set:
                    new_set.add(candidate + num)
                    new_set.add(candidate - num)
                possible_num_set = new_set
        # print(f"{command} {possible_num_set}")
        return delta in possible_num_set

    s = input()
    s.rstrip('T')
    n = len(s)
    x, y = mi()
    dx, dy = x, y
    tail_of_front_F = -1
    for i in range(n):
        if s[i] == 'F':
            tail_of_front_F = i
        else:
            break
    s = s[tail_of_front_F+1:]
    if tail_of_front_F >= 0:
        dx -= (tail_of_front_F + 1)
    

    x_command, y_command = preprocess(s)
    # print(x_command)
    # print(y_command)
    if valid_command(x_command, dx) and valid_command(y_command, dy):
        print("Yes")
    else:
        print("No")

    


if __name__ == "__main__":
    main()


Measured memory_bytes: 46044
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
LL dp[123456];

int main() {
    int N, W;
    scanf("%d %d", &N, &W);
    for (int i = 1; i <= N; i++) {
        int w, v;
        scanf("%d %d", &w, &v);
        for (int j = W; j >= w; j--) dp[j] = max(dp[j], dp[j - w] + v);
    }
    LL ans = 0;
    for (int i = 0; i <= W; i++) ans = max(ans, dp[i]);
    printf("%lld\n", ans);
    return 0;
}


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

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

    int odd = 0;
    int even = 0;
    for(int i = 0 ; i < n ; ++i){
        int a;
        cin >> a;
        if(a & 1){
            ++odd;
        }else{
            ++even;
        }
    }

    if(min(odd, even) == 0){
        cout << 0 << endl;
    }else if(odd & 1){
        cout << n - 1 << endl;
    }else{
        cout << n - 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
    ll n, t, y, x;
    cin >> n >> t;
    ll a[n];
    x = t;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }for (int i = 1; i < n; i++){
        y = a[i] - a[i - 1];
        if (y < t){
        x += y;
    }else{
        x += t;
    }
    }


    cout << x;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>

using namespace std;

void sort(int a[]) {
	for (int i=0; i<3; i++) {
		for (int j=i+1; j<3; j++) {
			if (a[i]>a[j]) {
				int dummy = a[i];
				a[i] = a[j];
				a[j] = dummy;
			}
		}
	}
}

int main() {
	int a[3];
	for (int i=0; i<3; i++) cin >> a[i];
	sort(a);

	for (int i=0; i<3; i++) {
		cout << a[i];
			if (2 != i) cout << " " ;
	}

	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

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

    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    int r = 0;
    for (int i = 0; i < n; i++) {
        r += a[i] * (i % 2 == 0 ? 1 : -1);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	
	
	int N;
	cin >> N;

	int l = len(N);

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (len(i) % 2 == 1)
			ans++;
	}

	cout << ans << endl;

ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}
/*

*/




Measured memory_bytes: 504
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    string s;
    cin>>s;
    if(s.size()>3 and s.substr(0,4)=="YAKI")	
		puts("Yes");
	else
		puts("No");
	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++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
inline int read(){
	char c=getchar();int t=0,f=1;
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n,k,mp[maxn][maxn],m;
int main(){
	n=read(),k=read();
	m=n*(n-1)/2;
	if(k>(n-1)*(n-2)/2){
		puts("-1");
		return 0;
	}
	m=n-1;
	for(int j=2;j<=n;j++)
		mp[1][j]=1;
	int tmp=0;
	if(tmp==(n-1)*(n-2)/2-k){
		printf("%d\n",m+tmp);
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(mp[i][j]){
					printf("%d %d\n",i,j);
				}
			}
		}
	return 0;
	}
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			mp[i][j]=1;
			tmp++;
			if(tmp==(n-1)*(n-2)/2-k)break;
		}
		if(tmp==(n-1)*(n-2)/2-k)break;
	}
	printf("%d\n",m+tmp);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(mp[i][j]){
				printf("%d %d\n",i,j);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>
#include <cstring>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for (int i = n-m; i >= 0; --i) {
        bool ok = true;
        rep(j, m) {
            if (s[i+j] != t[j] && s[i+j] != '?') {
                ok = false;
                break;
            }
        }
        if (ok) {
            //cout << i << endl;
            rep(j, n) {
                if (j >= i && j < i+m) {
                    cout << t[j-i];
                }
                else if (s[j] == '?') {
                    cout << 'a';
                }
                else {
                    cout << s[j];
                }
            }
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>


using namespace std;

enum animal{
  T,
  F
};

int
main(){
  int count;
  animal a=T;
  cin>>count;
  
  for(int i=0;i<count;i++){
    char input;
    animal next;
    cin>>input;

    next=input=='T'?T:F;

    if(a==T)
      a=next;
    else
      a=T;

  }

  cout<<((a==T)?'T':'F')<<endl;

  return 0;
}



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

int main() {
  string s, t;
  cin >> s >> t;
  bool ok = true;
  rep(i, s.size()) {
    if (s[i] != t[i]) ok = false;
  }
  if (s.size() + 1 != t.size()) {
    ok = false;
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	vector<int> num{ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;

	cout << num.at(k-1) << endl;

}

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

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()



int main()
{
	int n, k; cin >> n >> k;
	vector<int> h(n);
	rep(i, 0, n - 1)cin >> h[i];
	sort(all(h));
	int res = 1e9;
	for (int i = 0; i + k - 1 < n; ++i)
	{
		res = min(res, h[i + k - 1] - h[i]);
	}
	cout << res << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            int count=0;
            int []ans=new int[50];
            string str = Console.ReadLine();
            do
            {
                ans[count] = 0;
                int date = int.Parse(str);
                foreach (var n in Primes(date))
                    ans[count]++;
                count++;
                str = Console.ReadLine();
            }
            while (string.IsNullOrEmpty(str) == false);
            for (int n = 0; n < count; n++)
            {
                Console.WriteLine(ans[n]);
            }
        }
        static IEnumerable<int> Primes(int maxnum)
        {
            int[] primes = Enumerable.Range(0, maxnum + 1).ToArray();
            primes[1] = -1;
            int squareroot = (int)Math.Sqrt(maxnum);
            for (int i = 2; i <= squareroot; i++)
            {
                if (primes[i] > 0)
                    for (int n = i * 2; n <= maxnum; n += i)
                        primes[n] = -1;
            }
            return primes.Where(n => n > 0);
        }

    }
}

Measured memory_bytes: 26204
//Finite Disappointment and Infinite Hope
#include <bits/stdc++.h>
using namespace std;
#define help ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(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) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.first<<","<<v.second<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    for(auto &x:c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
const ll N=2e5+5,MOD=1e9+7;
int main(){
help
    ll n;cin>>n;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    ll cur = a[0],ans=1;
    for(ll i=1;i<n;i++){
        if(a[i]<=cur)ans++;
        cur = min(cur , a[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 1792
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    immutable MAX = 10 ^^ 5;
    auto S = new long[](MAX + 2);
    {
        auto sieve = new bool[](MAX + 1);
        sieve[] = true;
        sieve[0] = sieve[1] = false;
        foreach (i; 2 .. MAX + 1)
            if (sieve[i])
            {
                foreach (j; 2 .. MAX)
                    if (i * j < sieve.length)
                    {
                        sieve[i * j] = false;
                    }
                    else
                    {
                        break;
                    }
            }
        auto is2017 = new bool[](MAX + 1);
        foreach (i; 3 .. MAX + 1)
            if (i & 1)
            {
                is2017[i] = sieve[i] && sieve[(i + 1) / 2];
            }
        // is2017.take(20).writeln();
        foreach (i; 1 .. MAX + 1)
        {
            S[i] = S[i - 1] + is2017[i];
        }
        S[MAX + 1] = S[MAX];
        // S.take(20).writeln();
    }

    long Q = lread();
    foreach (_; 0 .. Q)
    {
        long l, r;
        scan(l, r);
        writeln(S[r] - S[l - 1]);
    }
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(15);

  double ans = w / 2.0 * h;
  cout << ans << " " << (w % 2 == 0 && h % 2 == 0 && w / 2  == x && h / 2 == y) << endl;

  return 0;
}


Measured memory_bytes: 3772
import java.util.*;
 
public class Main {
    static Scanner scanner = new Scanner(System.in);
 
    public static void main(String[]$) {
        int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt(), d = scanner.nextInt();
        System.out.println(Math.abs(a - b) <= d && Math.abs(b - c) <= d || Math.abs(a - c) <= d ? "Yes" : "No");
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll min_dif = 1e18;
    if ( a % 2 == 0 || b % 2 == 0 || c % 2 == 0 ) {
        cout << 0 << endl;
        return 0;
    }
    if ( a % 2 != 0 ) min_dif = min(min_dif, abs( ( a / 2 ) * b * c - ( a - a / 2 ) * b * c ) );
    if ( b % 2 != 0 ) min_dif = min(min_dif, abs( a * ( b / 2 ) * c - a * ( b - b / 2 ) * c ) );
    if ( c % 2 != 0 ) min_dif = min(min_dif, abs( a * b * ( c / 2 ) - a * b * ( c - c / 2 ) ) );
    cout << min_dif << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
vector<vector<bool>> used;
vector<bool> visited;
vector<bool> now;
ll N;
mat graph;
vector<pair<ll, ll>> edges;

void dfs (ll v, ll from) {
    Rep (i, N-1) {
        used[v][i] = now[i];
    }
    for (ll e : graph[v]) {
        ll nv;
        if (edges[e].first == v) nv = edges[e].second;
        else nv = edges[e].first;

        if (nv == from) continue;

        now[e] = true;
        dfs(nv, v);
        now[e] = false;
    }

    return;
}

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

    cin >> N;
    graph.assign(N, vec());
    edges.assign(N-1, pair<ll, ll>());
    Rep (i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(i);
        graph[b].push_back(i);
        edges[i] = {a, b};
    }

    used.assign(N, vector<bool>(N-1, false));
    visited.assign(N, false);
    now.assign(N-1, false);
    visited[0] = true;

    dfs(0, -1);

    // Rep (i, N) {
    //     Rep (j, N-1) {
    //         cout << used[i][j] << " \n"[j==N-2];
    //     }
    // }

    ll M;
    cin >> M;
    vec u(M), v(M);
    vector<vector<bool>> cond(M, vector<bool>(N-1, false));
    Rep (i, M) {
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
        Rep (j, N-1) {
            cond[i][j] = cond[i][j] ^ used[u[i]][j];
            cond[i][j] = cond[i][j] ^ used[v[i]][j];
        }
    }

    ll ans = 0;
    Rep (mask, 1 << M) {
        ll cnt = 0;
        ll tmp = 1;
        vector<bool> check(N-1, false);
        Rep (i, M) {
            if (mask & (1 << i)) {
                cnt++;
                Rep (j, N-1) {
                    check[j] = check[j] | cond[i][j];
                }
            }
        }

        Rep (j, N-1) {
            if (!check[j]) tmp *= 2;
        }

        if (cnt % 2 == 0) ans += tmp;
        else ans -= tmp;
    }

    cout << ans << "\n";

}

Measured memory_bytes: 256
#coding: utf-8

N = int(input())

dp = [i for i in range(N+1)]

dp[0] = 0

for i in range(N+1):
    for amount in (6, 9):
        a = amount 
        while i + a < len(dp):
            dp[i + a] = min(dp[i + a], dp[i] + 1)
            a *= amount

print(dp[N])



Measured memory_bytes: 12876
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  for (int i = M / N; i >= 1; --i) {
    if (M % i == 0) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

ll get_size(ll i, ll par[], ll size[]);
bool connected(ll i, ll j, ll par[], ll size[]);
void join(ll i, ll j, ll par[], ll size[]);
ll root(ll i, ll par[], ll size[]);
void init(ll par[], ll size[], ll n);

void init(ll par[], ll size[], ll n){
  for(ll i = 0; i < n; ++i){
    par[i] = i;
    size[i] = 1;
  }
}
ll root(ll i, ll par[], ll size[]){
  while(i != par[i]){
    par[i] = par[par[i]];
    i = par[i];
  }
  return i;
}
void join(ll i, ll j, ll par[], ll size[]){
  ll rooti = root(i, par, size);
  ll rootj = root(j, par, size);
  if(rooti == rootj) return;

  ll sizei = get_size(i, par, size);
  ll sizej = get_size(j, par, size);
  if(sizei < sizej){
    par[rooti] = rootj;
    size[rootj] += sizei;
  }else{
    par[rootj] = rooti;
    size[rooti] += sizej;
  }
}
bool connected(ll i, ll j, ll par[], ll size[]){
  return root(i, par, size) == root(j, par, size);
}
ll get_size(ll i, ll par[], ll size[]){
  ll r = root(i, par, size);
  return size[r];
}

void print_tables(ll par[], ll size[], ll n){
  for(ll i = 0; i < n; ++i){
    cout << par[i];
  }
  cout << endl;
  for(ll i = 0; i < n; ++i){
    cout << size[i];
  }
  cout << endl;
}


int main(){
  ll N, M;
  cin >> N >> M;
  ll A[M], B[M];
  for(ll i = 0; i < M; ++i){
    cin >> A[i] >> B[i];
  }
  
  ll par[N], size[N];
  init(par, size, N);
  ll ans[M+1];
  ans[M] = N * (N - 1) / 2;
  for(ll i = M - 1; 0 <= i; --i){
    ll a = A[i] - 1, b = B[i] - 1;
    ll sizeA = get_size(a, par, size);
    ll sizeB = get_size(b, par, size);
    if(connected(a, b, par, size)){
      ans[i] = ans[i+1];
    }else{
      ans[i] = ans[i+1] - sizeA * sizeB;
      join(a, b, par, size);
    }
    // print_tables(par, size, N);
  }
  for(ll i = 0; i < M; ++i){
    cout << ans[i+1] << endl;
  }
  return 0;
}

Measured memory_bytes: 5248
#include<stdio.h>
int main (void)
{
  int n,k;
  int keta=0;
  
  scanf("%d%d", &n, &k);
  
  while(1){
        n /= k;
        keta++;
        if (n == 0)
        break;
    }
 
    printf("%d", keta);
 
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define maxn 200010
#define ll long long
using namespace std;
ll n,a[maxn],ans;
bool cmp(int aa,int bb){return aa>bb;}
int main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	if(n&1){
		n=n/2;
		for(int i=1;i<=n;++i)
		ans+=(a[i]*2);
		ans-=a[1];
		ans+=a[n+1];
	}
	else{
		n=n/2;
		for(int i=1;i<=n;++i)
		ans+=(a[i]*2);
		ans-=a[1];
	}
	cout<<ans;
	return 0;
}

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


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

    vector<pair<int,int> >vec;

    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        vec.push_back(pair<int,int>(-b,a));
    }

    sort(vec.begin(),vec.end());
    cout<<vec[0].second<<" "<<-vec[0].first<<endl;
    return 0;
}

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

public class Main{
   	static void main() throws Exception{
   		long a=sc.nextLong();
   		char[]in=sc.next().toCharArray();
   		int num=Integer.parseInt(in[0]+"");
   		int dec=Integer.parseInt(in[2]+""+in[3]);
   		
   		long val=a*(num);
   		val+=a*dec/100;
   		pw.println(val);
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
		while(tc-->0)main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}


Measured memory_bytes: 37280
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld unsigned long long int
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
// ll mod=998244353;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }

ll dp[101][100001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,w;
	cin>>n>>w;
	for(ll j=1;j<=1000*n;j++) dp[0][j]=INF; dp[0][0]=0;
	for(ll i=1,wi,vi;i<=n;i++){
		cin>>wi>>vi;
		for(ll j=0;j<=1000*n;j++){
			if(j-vi>=0)
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-vi]+wi);
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	ll ans=0;
	for(ll i=0;i<=n*1000;i++){
		if(dp[n][i]<=w)
			ans=max(ans,i);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 79232
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

ll lcm(ll a, ll b){
  if(a<b){
    swap(a, b);
  }
  return ((a%b)? (lcm(b, a%b)): b);
}

void gcm(ll& a , ll b){
  a*=b/lcm(a, b);
}

int main(){

  int n;
  ll t, ans;
  cin >> n;
  cin >> ans;
  for(int i=1; i<n; i++){
    cin >> t;
    gcm(ans, t);
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int r;
  cin >> r;

  cout << 3 * r * r << endl;
}


Measured memory_bytes: 3600
import math

A, B, H, M = list(map(int, input().split()))

radA = (H + (M / 60)) / 12
radB = M / 60

rad = abs(radA - radB) * 2 * math.pi
#print(radA, radB, rad)

X = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad))

print(X)

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

i = n - 1
while i != 0:
	n = n * i
	i -= 1


def factorize(n):
	fct = list()
	base, exp = 2, 0
	while base * base <= n:
		while n % base == 0:
			n = n // base
			exp = exp + 1

		if exp > 0:
			fct.append((base, exp))
		
		base, exp = base + 1, 0
	if n > 1:
		fct.append((n, 1))
	return fct

fct = factorize(n)

x = 1
div_list = [exp + 1 for base, exp in fct]
for a in div_list:
	x = x * a

print(x % (10**9 + 7))

Measured memory_bytes: 3064
//my vegetable has exploded. :(
#include<bits/stdc++.h>
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define fi first
#define se second
#define int long long
using namespace std;

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x * f;
}
const int MAXN = 1e5+100;
int n,k,a[MAXN],b[MAXN],c1 = 0,c2 = 0,suma[MAXN],sumb[MAXN],ans = LLONG_MAX;
///------------------head------------------
signed main(signed argc, char *argv[]){
    n = read(),k = read();
    rep(i,1,n){
        int x = read();
        if (x < 0) a[++c1] = -x;
        else b[++c2] = x;
    }
    reverse(a+1,a+c1+1);
    rep(i,k-c2,c1)
        ans = min(ans,a[i] * 2 + b[k-i]);
    rep(i,k-c1,c2)
        ans = min(ans,b[i] * 2 + a[k-i]);
    printf("%lld\n",ans);
	return 0;
}

/* Examples: */
/*

*/

/*

*/


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<char,string>l;
  l['A']="BD";l['B']="AEC";l['C']="BF";
  l['D']="AEG";l['E']="BDFH";l['F']="CEI";
  l['G']="DH";l['H']="GEI";l['I']="FH";
  int p=1000;
  while(p--){
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++){
      string t=l[s[i]];
      int c=0;
      for(int j=0;j<t.size();j++)
        if(t[j]==s[i-1])c++;
      if(!c)goto L;
    }
    cout<<s<<endl;
    L:;
  }
}

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

#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define int long long
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1
#define endl "\n"

const int maxn = 5e4 + 10;
const int mod = 998244353;
const double pi = acos(-1);

int gcd(int a, int b)
{
  return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
  return a * b / gcd(a, b);
}

int qpow(int a, int n)
{
  int b = 1;
  while (n)
  {
    if (n & 1)
      b = a * b % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return b;
}

class Prime_Number
{
public:
  int prime[maxn], s, v[maxn];
  void prime_init(int n)
  {
    for (int i = 2; i <= n; i++)
    {
      if (!v[i])
      {
        prime[s++] = i;
        for (int j = 1; j * i <= n; j++)
          v[i * j] = 1;
      }
    }
  }
};

int p[maxn], a[maxn];
int v[maxn];
vector<int> huan[maxn];
int q[maxn * 2];
int js(int x, int k)
{
  int K = k;
  int sz = huan[x].size();
  q[0] = a[huan[x][0]];
  for (int i = 1; i < sz * 2; i++)
    q[i] = q[i - 1] + a[huan[x][i%sz]];
  int sum = -1e18;
  k=min(k,sz);
  for (int y = 0; y <= k; y++)
  {
    if (y == 0)
    {
      if (q[sz - 1] > 0 && K >= sz)
        sum = (K / sz) * q[sz - 1];
      continue;
    }
    for (int j = y; j < sz+y; j++)
    {
      if (q[sz - 1] > 0)
        sum = max(sum, q[j] - q[j - y] + ((K - y) / sz) * q[sz - 1]);
      else
        sum = max(sum, q[j] - q[j - y]);
    }
  }
  return sum;
}
void solve()
{
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++)
    sll(p[i]);
  for (int i = 1; i <= n; i++)
    sll(a[i]);
  int s = 0;
  for (int i = 1; i <= n; i++)
    if (!v[i])
    {
      int next = p[i];
      v[i] = 1;
      huan[s].push_back(i);
      while (!v[next])
      {
        v[next] = 1;
        huan[s].push_back(next);
        next = p[next];
      }
      s++;
    }
  int ans = -1e18;
  for (int i = 0; i < s; i++)
    ans = max(ans, js(i, k));
  printf("%lld\n", ans);
}
signed main()
{
  solve();
  return 0;
}


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

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

using namespace std;

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

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

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

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

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

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

	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	double maxd = -100.0;
	pii ans=mp(0,0);

	rep(i, 0, 31)rep(j, 0, 31)
	{
		int W = 100 * A*i + 100 * B*j;

		if (W > F)continue;

		int MAXS = min(W / 100 * E, F - W);
		vector<bool> dp(MAXS + 1, false);
		dp[0] = true;
		rep(k, 0, MAXS + 1)
		{
			if (dp[k] && k + C <= MAXS)
			{
				dp[k + C] = true;
			}
		}
		rep(k, 0, MAXS + 1)
		{
			if (dp[k] && k + D <= MAXS)
			{
				dp[k + D] = true;
			}
		}

		int S = 0;
		rrep(k, 0, MAXS + 1)
		{
			if (dp[k])
			{
				S = k;
				break;
			}
		}

		if (chmax(maxd, 100.0*S / (S + W)))
		{
			ans.first = S + W;
			ans.second = S;
		}
	}

	cout << ans.first << " " << ans.second << endl;

	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

int N;
vector<int> b[100000];
bool used[100000];
int ans[100000];

int f(int x) {
	int i = b[x].back();
	b[x].pop_back();
	if (b[x].empty()) {
		ans[x] = i + 1;
		return x;
	}
	int y = f(x);
	while (ans[y]) y = (y + 1) % N;
	b[y].pb(i);
	return f(y);
}

int main() {
	cin >> N;
	rep(i, N) {
		int x; scanf("%d", &x); x--;
		b[x].pb(i);
	}
	rep(x, N) if (b[x].size()) f(x);
	rep(x, N) printf("%d\n", ans[x]);
}

Measured memory_bytes: 14016
#include <iostream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <numeric>
#include <cmath>
#include <cctype>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

struct mn{
  int y,x,_y,_x;
};
int H,W,y,x,_y,_x; 
int a[1000][1000];
int ans = 0;
vector<mn> v;
void move(int y,int x,int _y, int _x, int a[][1000]){
  a[y][x] -= 1;
  a[_y][_x] += 1;
  ++ans;
  v.push_back( {y+1,x+1,_y+1,_x+1} );
}

int main(){
  cin>>H>>W;
  CINA2(a,H,W);
  
  for(y=0;y<H;++y){
    for(x=0;x<W-1;++x){
      if(a[y][x]%2==1){
        _y = y;
        _x = x+1;
        move(y,x,_y,_x,a);
      }
    }
    if(y+1==H){ break;}
    if(a[y][x]%2==1){
      _x = x;
      _y = y+1;
      move(y,x,_y,_x,a);
    }
    ++y;
    for(x=W-1;x>0;--x){
      if(a[y][x]%2==1){
        _y = y;
        _x = x-1;
        move(y,x,_y,_x,a);
      }
    }
    if(y+1==H){break;}
    if(a[y][x]%2==1){
      _x = x;
      _y = y+1;
      move(y,x,_y,_x,a);
    }
  }
  cout << ans << "\n";
  for(mn m:v){
    printf("%d %d %d %d\n",m.y,m.x,m._y,m._x);
  }
}

Measured memory_bytes: 6256
import heapq
from collections import deque

x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = sorted(list(map(lambda x:int(x),input().split())),reverse=True)

p = sorted(p)[a - x:a]
q = sorted(q)[b - y:b]
p+=q
p.sort()

for i in range(min(len(r),len(p))):
    p[i] = max(p[i],r[i])
print(sum(p))


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

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

    int n;
    cin >> n;
    unordered_map <int, int> F;
    for(int i = 0; i < n; i++){
        int num;
        cin >> num;
        F[num]++;
    }
    if(F.size() == n){
        cout << "YES";
    }
    else cout << "NO";
    cout << endl;

}

Measured memory_bytes: 8520
n=int(input())
s=list(input())
s+=s[0]+s[1]

# 決め打ちで作ってみる。
ANS=[list("SS"+"?"*(n)),list("WS"+"?"*(n)),list("SW"+"?"*(n)),list("WW"+"?"*(n))]
for ans in ANS:
    for i in range(2, n+2):
        if (ans[i - 2] == 'S' and s[i - 1] == 'o' and ans[i - 1] == 'S') or (
                ans[i - 2] == 'W' and s[i - 1] == 'o' and ans[i - 1] == 'W') \
                or (ans[i - 2] == 'S' and ans[i - 1] == 'W' and s[i - 1] == 'x') or (
                ans[i - 2] == 'W' and ans[i - 1] == 'S' and s[i - 1] == 'x'):
            ans[i] = 'S'
        else:
            ans[i] = 'W'
    if ans[:2]==ans[-2:]:
        print(''.join(ans[:-2]))
        exit()


print(-1)

Measured memory_bytes: 78360
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

int main()
{
  int h,n;
  cin>>h>>n;
  vector<int> a(n);
  REP(i,n) cin>>a[i];

  int suma=0;
  REP(i,n) suma+=a[i];

  cout<<((suma<h)? "No":"Yes")<<endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;

int gcm(int a, int b) {
	int x, y, r;
	if (a == b) return a;

	x = a > b ? a : b;
	y = a > b ? b : a;
	r = x % y;
	while (r > 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
long lcm(int a, int b){
	long l;
	l = a;
	l = l * b;
	l = l / gcm(a, b);
	return l;
}


int main()
{
	string str;
	getline(cin, str);
	istringstream iss(str);
	iss >> str;
	int N = stoi(str);
	iss >> str;
	int M = stoi(str);
	long L = lcm(N, M);

	getline(cin, str);
	string S = str;
	getline(cin, str);
	string T = str;

	map<int, char> mp;

	//cout << gcm(N, M) << endl;
	//cout << L << endl;

	for (int i = 0; i < N; i++) {
		char c;
		long idx;
		c = S[i];
		idx = (long)1 + (long)i * (long)(L / N);
		//cout << "add idx=" << idx << ", char=" << c << endl;
		mp[idx] = c;
	}
	int flag = 1;
	for (int i = 0; i < M; i++) {
		char c;
		long idx;
		c = T[i];
		idx = (long)1 + (long)i * (long)(L / M);
		//cout << "check idx=" << idx << ", char=" << c << endl;
		if (mp.count(idx) != 0) {
			//cout << "idx=" << idx << "exists" << endl;
			if (mp[idx] != c) {
				//cout << "S[" << idx << "]=" << mp[idx] << "does not equals T[" << idx << "]=" << c << endl;
				flag = 0;
				break;
			}
		}
		else {
			//cout << "mp[" << idx << "] does not exists" << endl;
			mp[idx] = c;
		}
	}
	if (flag) cout << L << endl;
	else cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 8320
N = int(input())
arr = list(map(int, input().split()))
four = 0
two = 0
for i in arr:
    if i % 4 == 0:
        four += 1
    elif i % 2 == 0:
        two += 1
if 2*four+1 == N:
    print('Yes')
    exit()
N -= four * 2
if N <= two:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62576
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 
#define P 998244353
#define G 3
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define fuck printf("FUCK!!\n");
using namespace std;

int n, q, ans, temp;
char s[200005], t[200005][2], d[200005][2];

bool check1(int pos)
{
    for(rint i=1; i<=q; ++i)
        if(s[pos]==t[i][0])
        {
            pos-=d[i][0]=='L'?1:-1;
            if(!pos) return true;
        }
    return false;
}

bool check2(int pos)
{
    for(rint i=1; i<=q; ++i)
        if(s[pos]==t[i][0])
        {
            pos-=d[i][0]=='L'?1:-1;
            if(pos==n+1) return true;
        }
    return false;
}

int main()
{
    scanf("%d%d", &n, &q);
    scanf("%s", s+1);
    for(rint i=1; i<=q; ++i) scanf("%s%s", t[i], d[i]);
    int l=1, r=n, ans=0;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check1(mid)) ans=mid, l=mid+1;
        else r=mid-1;
    }
    temp+=ans;
    l=1, r=n, ans=n+1;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(check2(mid)) ans=mid, r=mid-1;
        else l=mid+1;
    }
    temp+=n-ans+1;
    printf("%d\n", n-temp);
    return 0;
}

Measured memory_bytes: 1152
program reconciled;
uses math;
const
  md: int64 = 1000000007;
  f25000: int64 = 232201666;
  f50000: int64 = 737935835;
  f75000: int64 = 796945456;
function fact(n: int64): int64;
var
  i, k, f: int64;
begin
  f := f75000;
  k := 75001;
  if n < 75000 then
  begin
    f := f50000;
    k := 50001;
  end;
  if n < 50000 then
  begin
    f := f25000;
    k := 25001;
  end;
  if n < 25000 then
  begin
    f := 1;
    k := 1;
  end;
  for i := k to n do
    f := i*f mod md;
  fact := f;
end;
var
  n, m, x: int64;
begin
  read(n, m);
  if abs(n-m) > 1 then
  begin
    writeln(0);
    halt(0);
  end;
  x := ifthen(n = m, 2, 1);
  x := x*fact(n) mod md;
  x := x*fact(m) mod md;
  writeln(x);
end.

Measured memory_bytes: 128