akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

vector<pair<long long, long long> > prime_factorize(long long n) {
	//計算量は√N!!!
	vector<pair<long long, long long> > res;
	for (long long p = 2; p * p <= n; ++p) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

signed main(){
	int N;
	cin >> N;
	int now = N;
	auto p = prime_factorize(N);
	int ans = 0;
	for(auto [val,cnt]:p){
		int now = 1;
		while(now <= cnt){
			cnt -= now;
			++ans;
			++now;
		}
	}
out(ans);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r,d,x,now;cin>>r>>d>>x;
  now=r*x-d;
  cout<<now<<endl;
  for(int i=1;i<10;i++){
    cout<<r*now-d<<endl;
    now=r*now-d;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	int cnt=0;
	while (cnt<=1000000&&a%2==0&&b%2==0&&c%2==0){
		int aa=a,bb=b,cc=c;
		a=bb/2+cc/2;
		b=aa/2+cc/2;
		c=aa/2+bb/2;
		cnt++;
	}
	if (cnt<=1000000)printf("%d\n",cnt);
	else puts("-1");
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
theta_A = 30 * H + 0.5 * M
theta_B = (6 * M) % 360
theta = (theta_A - theta_B) * math.pi / 180
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)))

Measured memory_bytes: 9404
import heapq
Q = int(input())
L = []
R = []
ans = []
min = 0
for _ in range(Q):
    q, *c = map(int, input().split())
    if q == 1:
        a, b = c
        min += b
        heapq.heappush(L, -a)
        heapq.heappush(R, a)
        if -L[0] > R[0]:
            x = -heapq.heappop(L)
            y = heapq.heappop(R)
            heapq.heappush(L, -y)
            heapq.heappush(R, x)
            min += abs(x-y)
    else:
        ans.append((-L[0], min))
for x in ans:
    print(*x)

Measured memory_bytes: 27796
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    string alts = "";
    int n = s.size();
    bool block = false;
    rep(i, n) {
        if (s[i] == 'A') {
            alts.push_back('a');
            block = false; 
        } 
        else {
            if (!block && i < n - 1 && s[i] == 'B' && s[i+1] == 'C') {
                alts.push_back('x');
                ++i; 
            } else {
                if(!block) alts.push_back('b');
                block = true;
            }

        }
    }
    ll cnta = 0, ans = 0; 
    for (char c : alts) {
        if (c == 'a') ++cnta;
        else if (c == 'x') ans += cnta;
        else cnta = 0; 
    }
    cout << ans << endl;
    return 0;
}

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

int main () {
    long N;
    scanf("%ld", &N);
    long *A = malloc((N + 2) * sizeof(long));
    long *B = malloc((N + 1) * sizeof(long));

    for (long i = 1; i <= N + 1; i++) {
        scanf("%ld", &A[i]);
    }

    for (long i = 1; i <= N; i++) {
        scanf("%ld", &B[i]);
    }

    long ans = 0;
    // initialize
    if (A[1] > B[1]) {
        ans += B[1];
    } else {
        ans += A[1];
        if ((A[2] - (B[1] - A[1])) > 0) {
            A[2] -= (B[1] - A[1]);
            ans += (B[1] - A[1]);
        } else {
            ans += A[2];
            A[2] = 0;
        }
    }

    for (long i = 2; i <= N; i++) {
        if (A[i] > B[i]) {
            ans += B[i];
        } else {
            ans += A[i];
            if ((A[i+1] - (B[i] - A[i])) > 0) {
                A[i+1] -= (B[i] - A[i]);
                ans += (B[i] - A[i]);
            } else {
                ans += A[i+1];
                A[i+1] = 0;
            }
        }
    }

    printf("%ld\n", ans);

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int mod = 998244353;
const int maxn = 100000 + 5;

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

int a, b, k;

int main() {
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
            if (k == 0) return cout << i << endl, 0;
        }
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static llong MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


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

  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
    string s;
    cin >> s;
    int max = 0,min = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'A' && min == 0) {
            min = i+1;
        }
        if(s[i] == 'Z' && i >= max) {
            max = i+1;
        }
    }
    cout << max - min + 1;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int maxn=1e5+5;
int main()
{
    int a,c,b;
    cin>>a>>b>>c;
    int max1=max(a,max(b,c));
    int sum=max1*10+a+b+c-max1;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll vecmax(vector<ll> &vec){
  if(vec.size() ==0) return 0;
  ll x=vec.at(vec.size()-1);
  vec.pop_back();
  return max(x, vecmax(vec));
}

int main(){
  int n, w;
  cin >> n >> w;
  vector<ll> vec(w+1);
  for(int i=0; i<n; ++i){
    int wi=0, vi=0;
    cin >> wi >> vi;
    for(int j=w; j-wi>=0; --j){
      vec.at(j) = max(vec.at(j), vec.at(j-wi)+vi);
    }
  }
  cout << vecmax(vec) << endl;
}

Measured memory_bytes: 2560
using System;

namespace ABC030_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);

            Console.WriteLine((B - A) * (B - A + 1) / 2 - B );


        }
    }
}

Measured memory_bytes: 11092
ABC = list(map(int, input().split()))
n_odd = sum([Xi % 2 for Xi in ABC])

ans = 0
if n_odd == 1:
    ans += 1
    ABC[0] += int(ABC[0] % 2 == 0)
    ABC[1] += int(ABC[1] % 2 == 0)
    ABC[2] += int(ABC[2] % 2 == 0)
elif n_odd == 2:
    ans += 1
    ABC[0] += int(ABC[0] % 2 == 1)
    ABC[1] += int(ABC[1] % 2 == 1)
    ABC[2] += int(ABC[2] % 2 == 1)

ABC.sort()
ans += (ABC[2] - ABC[0]) // 2
ans += (ABC[2] - ABC[1]) // 2

print(ans)

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

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

bool check(string s) {
    int l = s.length();

    rep(i, l / 2) {
        if (s[i] != '#' && s[l - 1 - i] != '#' && s[i] != s[l - 1 - i]) return true;
    }
    return false;
}

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

    bool ac = false;

    rep(i, s.length() - 1) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            ac = true;
            break;
        }
    }

    Yes(ac);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

struct Node
{
    int key;
    Node *parent, *left, *right;
};

class Tree
{
    Node *root;

public:
    Tree()
    {
        init();
    }

    void insert(int key)
    {
        Node *node = (Node *)malloc(sizeof(Node));
        node->key = key;
        node->parent = NULL;
        node->left = NULL;
        node->right = NULL;

        if (root == NULL)
        {
            root = node;
        }
        else
        {
            Node *target = root;

            while (target != NULL)
            {
                if (node->key < target->key)
                {
                    if (target->left == NULL)
                    {
                        target->left = node;
                        node->parent = target;

                        target = NULL;
                    }
                    else
                    {
                        target = target->left;
                    }
                }
                else
                {
                    if (target->right == NULL)
                    {
                        target->right = node;
                        node->parent = target;

                        target = NULL;
                    }
                    else
                    {
                        target = target->right;
                    }
                }
            }
        }
    }

    void init()
    {
        root = NULL;
    }

    void print()
    {
        printInorder(root);
        cout << endl;
        printPreorder(root);
        cout << endl;
    }

    void printPreorder(Node *u)
    {
        if (u == NULL)
            return;

        cout << " " << u->key;

        if(u->left != NULL)
            printPreorder(u->left);

        if (u->right != NULL)
            printPreorder(u->right);
    }

    void printInorder(Node *u)
    {
        if (u == NULL)
            return;

        if(u->left != NULL)
            printInorder(u->left);

        cout << " " << u->key;

        if (u->right != NULL)
            printInorder(u->right);
    }
};

int main()
{
    int M;

    cin >> M;

    vector<int> keys;

    for (int i = 0; i < M; i++)
    {
        string message;
        cin >> message;

        if (message == "insert")
        {
            int key;
            cin >> key;
            keys.push_back(key);
        }
        else if (message == "print")
        {
            Tree * tree = new Tree();

            for (int key : keys)
            {
                tree->insert(key);
            }

            tree->print();
        }
    }
    return 0;
}


Measured memory_bytes: 28172
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  string S;
  int N;
  cin >> N >> S;
  int T;
  T = S.size();
  for(int i=0;i<T;i++)
  {
    S[i] = (S[i]-'A'+N)%26+'A';
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
int main() {
    Int n;
    cin >> n;
    auto v = vector<Int>(0);
    rep(i, n) {
        Int a;
        cin >> a;
        auto itr = upper_bound(ALL(v), a, greater<Int>());
        if (itr == v.end()) {
            v.PB(a);
        } else {
            auto d = distance(v.begin(), itr);
            v[d] = a;
        }
    }
    PUTS(SZ(v));
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
#define Rep(i,a) for(int i = 0; i < a; i++)
using namespace std;
typedef long long LL;
const int N = 1010, mod = 1e9 + 7;
int n, m; LL k;
char s[N][N];

bool check_vertical() {
	rep(i,1,m) if (s[1][i] == '#' && s[n][i] == '#') return true;
	return false;
}

bool check_horizontal() {
	rep(i,1,n) if (s[i][1] == '#' && s[i][m] == '#') return true;
	return false;
}

struct mat{ int a[2][2]; }; 
mat operator * (const mat &a, const mat &b) {
	static mat w;
	Rep(i,2) Rep(j,2) w.a[i][j] = 0;
	Rep(i,2) Rep(j,2) Rep(k,2) w.a[i][k] = (w.a[i][k] + 1LL * a.a[i][j] * b.a[j][k]) % mod;
	return w;
}
mat pw(mat a, LL b) {
	mat w; Rep(i,2) Rep(j,2) w.a[i][j] = (i == j);
	for(;b;b >>= 1, a = a * a) if (b & 1) w = w * a;
	return w;
}

int main() {
	scanf("%d%d%lld",&n,&m,&k);
	rep(i,1,n) scanf("%s",s[i] + 1);
	bool t1 = check_vertical(), t2 = check_horizontal();
	if ((t1 && t2) || (k <= 1)) printf("1\n");
	else {
		int cnt = 0, tot = 0, c2 = 0;
		rep(i,1,m) if (s[1][i] == '#' && s[n][i] == '#') cnt++;
		rep(i,1,n) if (s[i][1] == '#' && s[i][m] == '#') cnt++;

		rep(i,1,n) rep(j,1,m) if (s[i][j] == '#') tot++;

		if (t1) {
			rep(i,2,n) rep(j,1,m) if (s[i - 1][j] == '#' && s[i][j] == '#') 
				c2++;
		} else if (t2) {
			rep(i,1,n) rep(j,2,m) if (s[i][j - 1] == '#' && s[i][j] == '#') 
				c2++;
		}

		mat a; 
		a.a[0][0] = tot, a.a[0][1] = mod - c2;
		a.a[1][0] = 0, a.a[1][1] = cnt;
		a = pw(a, k - 1);
		int ans = (a.a[0][0] + a.a[0][1]) % mod;
		if (ans < 0) ans += mod;
		printf("%d\n",ans);
	}
	return 0;	
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>

using namespace std;

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

  int ans = 0;
  int minv = 1000000;
  for (int i = 0; i < n; i++) {
    int p; cin >> p;
    if (p < minv) { ans++; }
    minv = min(minv, p);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]_){Scanner S=new Scanner(System.in);double o=1e4,a,b,c,n[]=new double[6],l[];for(int i,m=S.nextInt();m-->0;System.out.printf("%.3f %.3f %.3f\n",n[3]/o,n[4]/o,n[5]/o)){l=n.clone();for(i=0;i<6;)n[i++]=S.nextDouble();for(i=0;(i+=2)<5;l[i+1]=2*(n[i+1]-n[1]))l[i]=2*(n[i]-n[0]);l[0]=n[0]*n[0]+n[1]*n[1]-n[2]*n[2]-n[3]*n[3];l[1]=n[0]*n[0]+n[1]*n[1]-n[4]*n[4]-n[5]*n[5];n[3]=(l[3]*l[1]-l[5]*l[0])/(l[2]*l[5]-l[4]*l[3])*o;n[4]=(l[0]*l[4]-l[1]*l[2])/(l[2]*l[5]-l[4]*l[3])*o;n[5]=Math.hypot(n[3]/o-n[0],n[4]/o-n[1])*o;}}}

Measured memory_bytes: 12000
#include <set>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 200005
#define M 800005
#define inf 0x3f3f3f3f
int tar[M], nex[M], cap[M], fir[N], cnt = 1;
int n, m, dis[N], now[N], use[N][2];
vector<int>A[N];
set<int>S[N];
queue<int>Q;
void add(int a, int b, int c)
{
	++cnt;
	tar[cnt] = b;
	cap[cnt] = c;
	nex[cnt] = fir[a];
	fir[a] = cnt;
}
void Add(int a, int b)
{
	add(a, b, 1);
	add(b, a, 0);
}
int aug(int s, int b, int e, int g, int augco)
{
	if (s == e)
		return augco;
	int augc = augco;
	for (int &i = now[s]; i; i = nex[i])
	{
		int v = tar[i];
		if (cap[i])
		{
			if (dis[v] == dis[s] + 1)
			{
				int delta = aug(v, b, e, g, min(augc, cap[i]));
				cap[i] -= delta;
				cap[i ^ 1] += delta;
				augc -= delta;
				if (!augc)
					return augco;
			}
		}
	}
	return augco - augc;
}
bool Bfs(int s, int t)
{
	memset(dis, 0x3f, sizeof(dis));
	dis[s] = 0;
	queue<int>que;
	que.push(s);
	while (!que.empty())
	{
		int x = que.front();
		now[x] = fir[x];
		que.pop();
		for (int i = fir[x]; i; i = nex[i])
		{
			int v = tar[i];
			if (!cap[i])
				continue;
			if (dis[x] + 1 < dis[v])
			{
				dis[v] = dis[x] + 1;
				que.push(v);
			}
		}
	}
	return dis[t] != inf;
}
int sap(int b, int e, int g)
{
	int flow = 0;
	while (Bfs(b, e))
		flow += aug(b, b, e, g, inf);
	return flow;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i < n; i++)
	{
		int t;
		scanf("%d", &t);
		for (int j = 1; j <= t; j++)
		{
			int x;
			scanf("%d", &x);
			S[x].insert(i);
			A[i].push_back(x);
			if (x != 1)
				Add(i, n + x);
		}
	}
	for (int i = 1; i <= n; i++)
	{
		Add(2 * n + 1, i);
		Add(n + i, 2 * n + 2);
	}
	int ans = sap(2 * n + 1, 2 * n + 2, 2 * n + 2);
	if (ans < n - 1)
	{
		puts("-1");
		return 0;
	}
	for (int i = 1; i < n; i++)
	{
		for (int j = fir[i]; j; j = nex[j])
		{
			int v = tar[j];
			if (v > n && !cap[j])
				use[i][0] = v - n;
		}
	}
	Q.push(1);
	while (!Q.empty())
	{
		int x = Q.front();
		m++;
		Q.pop();
		set<int>::iterator it = S[x].begin();
		for (; it != S[x].end(); it++)
		{
			if (!use[*it][1])
			{
				use[*it][1] = x;
				Q.push(use[*it][0]);
			}
		}
	}
	if (m < n)
	{
		puts("1");
		return 0;
	}
	for (int i = 1; i < n; i++)
		printf("%d %d\n", use[i][0], use[i][1]);
}


Measured memory_bytes: 42380
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    s = input()

    r = s.count("R")
    g = s.count("G")
    b = s.count("B")

    temp = r * g * b
    minus = 0
    for i in range(1, n):
        for j in range(1, min(i + 1, abs(n - i))):
            if len(set([s[i], s[i - j], s[i + j]])) == 3:
                minus += 1

    return temp - minus


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using Edge = pair<ll,ll>;
using Graph =vector<vector<ll>>;
Graph G;
vector<int> color;
bool dfs(int v,int c=0){
  color[v]=c;
  for(auto p:G[v]){
    if(color[p]!=-1){
      if(color[p]==color[v])return false;
    }else{
      if(!dfs(p,1-c)){
        return false;
      }
    }
  }
  return true;
}
int main() {
  ll n,m;
  cin>>n>>m;
  G.resize(n);
  rep(i,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  color.resize(n,-1);
  if(!dfs(0))cout<<n*(n-1)/2-m<<endl;
  else{
    ll a=0,b=0;
    rep(i,n){
      if(color[i]==0)a++;
      else if(color[i]==1)b++;
      }
      cout<<a*b-m<<endl;
    }
}



Measured memory_bytes: 7040
class DisjoinSet:
    def __init__(self, N):
        self.par = [-1] * N
        self.sz = [1] * N

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a == b:
            return
        if self.sz[a] > self.sz[b]:
            a, b = b, a
        self.par[a] = b
        self.sz[b] += self.sz[a]

    def same(self, a, b):
        return self.root(a) == self.root(b)

    def size(self, x):
        return self.sz[self.root(x)]

    def __str__(self):
        clusters = defaultdict(list)
        for x in range(N):
            clusters[self.root(x)].append(x)
        return str(list(clusters.values()))


N, M = map(int, input().split())
dsu = DisjoinSet(N)
for _ in range(M):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    dsu.unite(x, y)

ans = max([dsu.size(x) for x in range(N)])
print(ans)

Measured memory_bytes: 90816
num = [int(i) for i in input()]
a, b, c, d = num[0], num[1], num[2], num[3]

if a + b + c + d == 7:
    print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a + b + c - d == 7:
    print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a + b - c + d == 7:
    print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a + b - c - d == 7:
    print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a - b + c + d == 7:
    print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a - b + c - d == 7:
    print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a - b - c + d == 7:
    print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a - b - c - d == 7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))


Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
a = [0] + a

dam1=[]
dam2=[]
for i in range(1,n+1):
    if i%2==1:
        dam1.append(a[i])
    else:
        dam2.append(a[i])

if n%2==0:
    dam2.reverse()
    out=dam2 + dam1
elif n%2==1:
    dam1.reverse()
    out=dam1 + dam2
print(*out)


Measured memory_bytes: 117104
H = int(input())
W = int(input())
N = int(input())
if H >= W:
    if N % H == 0:
        print(N // H)
    else:
        print(N // H + 1)
else:
    if N % W == 0:
        print(N // W)
    else:
        print(N // W + 1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int> b(m,0);
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    int a[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int cnt=0;
    int sum=0;
    for(int i=0;i<n;i++){
        sum=0;
        for(int j=0;j<m;j++){
            sum+=a[i][j]*b[j];
        }
        sum+=c;
        if(sum>0) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b,k=map(int,input().split())
ans=0
comb=[1]
c=1
mod=998244353
for i in range(1,n+1):
  c*=n-i+1
  c*=pow(i,mod-2,mod)
  c%=mod
  comb.append(c)
for s in range(n+1):
  if k<a*s:
    break
  bt=k-a*s
  if bt%b==0 and 0<=bt//b<=n:
    t=bt//b
    ans=(ans+comb[s]*comb[t])%mod
print(ans)

Measured memory_bytes: 73704
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<tuple>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans;
	ll A[5];
int main(){
	ios_base::sync_with_stdio(false);
	REP(i,3)cin>>A[i];
	sort(A,A+3);
	ans+=(A[2]-A[1])/2+(A[2]-A[0])/2;
	A[1]+=((A[2]-A[1])/2)*2;A[0]+=((A[2]-A[0])/2)*2;
	if(!(A[0]==A[2]&&A[1]==A[2])){
			if(A[0]==A[1])ans++;
			else ans+=2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long ll; typedef long double ld ;using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define ALL(name) (name).begin(),(name).end()
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){ios::sync_with_stdio(0);cin.tie(nullptr); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  string s;
  cin>>s;
  char a='a';
  REP(i,26){
    if(s.find(a)==string::npos){
      cout<<a<<endl;
      return 0;
    }
    a++;
  }
  cout<<"None"<<endl;

}


Measured memory_bytes: 512
N,Y = map(int,input().split())

damm = 0

for i in range(N+1):
    for j in range(N+1-i):
        k = N - i - j
        test = i*10000 + j*5000 + k*1000
        if test == Y:
            print(i,j,k)
            damm = 1
            break
    if damm == 1:
        break

a = -1

if damm == 0:
    print(a,a,a)


Measured memory_bytes: 3060
open Printf
open Scanf

let num () = scanf "%d\n" (fun x -> x)
let num2 () = scanf "%d %d\n" (fun x y -> (x, y))
let num3 () = scanf "%d %d %d\n" (fun x y z -> (x, y, z))

let str () = scanf "%s\n" (fun s -> s)

let cmp s t =
  let m = String.length s in
  let n = String.length t in
  let count_diff i =
    let rec loop j c =
      if j=n then
        c
      else if s.[i+j] = t.[j] then
        loop (j+1) c
      else
        loop (j+1) (c+1)
    in loop 0 0
  in
  let rec loop i mc =
    if i > m - n then
      mc
    else
      let c = count_diff i in
      loop (i+1) (if mc < c then mc else c)
  in
  loop 0 m

let () =
  let s = str() in
  let t = str() in
  let c = cmp s t in
  printf "%d\n" c



Measured memory_bytes: 3864
N, M, C = map(int, input().split(" "))
Bs = list(map(int, input().split(" ")))
c = 0
for i in range(N):
    Ais = map(int, input().split(" "))
    if sum([a*b for a, b in zip(Ais, Bs)]) + C > 0:
        c+=1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>

int f(int k, std::vector<int> l) {
    std::priority_queue<int> q;
    for (int i = 0; i < l.size(); i++) {
        q.push(l[i]);
    }

    int res = 0;
    while (k--) {
        res += q.top();
        q.pop();
    }

    return res;
}

int main() {

    int n, k;
    std::cin >> n >> k;

    std::vector<int> l;
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        l.push_back(tmp);
    }

    int res = f(k, l);
    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 632
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if((g*10+b)%4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    char c;
    cin >> c;

    if ( c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
module Main (main) where

main :: IO ()
main = do
  x <- readLn :: IO Integer
  putStrLn $ fromTime $ time x

time :: Integer -> [Integer]
time x = [h,m,s]
  where
    h = div x 3600
    remXdh = rem x 3600
    m = div remXdh 60
    remXdm = rem remXdh 60
    s = remXdm

fromTime :: [Integer] -> String
fromTime [h,m,s] =
  (show h) ++ ":" ++ (show m) ++ ":" ++ (show s)

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
char s[51],h[51];
int a,b,i,j;
int main()
{
	scanf("%s%s",s+1,h+1);
	a=strlen(s+1);
	b=strlen(h+1);
	if(a==b)
	{
		for(i=1;i<=a;++i)
		{
			printf("%c%c",s[i],h[i]);
		}
	}
	else 
	{
		for(i=1;i<=b;++i)
		printf("%c%c",s[i],h[i]);
		printf("%c",s[a]);
	}
	printf("\n");
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
	int N,Q;
	while(~scanf("%d %d",&N,&Q)){
		if(N==0 && Q==0) break;
		map<int,int> freq;
		for(int i=0;i<N;i++){
			int num;
			scanf("%d",&num);

			for(int j=0;j<num;j++){
				int day;
				scanf("%d",&day);
				freq[day]++;
			}
		}

		int maxv=0;
		int min_day=INF;
		for(map<int,int>::iterator it = freq.begin(); it!=freq.end();it++){
			if(it->second >= Q){
				if(maxv < it->second){
					maxv = it->second;
					min_day=it->first;
				}
				else if(maxv == it->second){
					min_day=min(min_day,it->first);
				}
			}
		}

		printf("%d\n",min_day >= INF ? 0 : min_day);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <sstream>
#include <cctype>
#include <cmath>
#include <cstdio>
using namespace std;


int main(){

	double x1, y1, x2, y2;
	double l;
	cin >> x1 >> y1 >> x2 >> y2;

	l = sqrt(pow(x2 - x1,2) + pow(y2 - y1,2));

	printf("%f\n", l);

	return 0;
}


Measured memory_bytes: 3272
#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; 
typedef long long ll;
typedef unsigned long long int ull;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>  
#define ff first
#define ss second
#define pb push_back
#define Inf  1e18
#define inf -1e18
#define mod 1000000007
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll,ll>;
using umll = unordered_map<ll,ll>;
using sll = set<ll>;
using msll = multiset<ll>;
 
 
ll MUL(ll A,ll B){
  return (A%mod*B%mod)%mod;
}
 
ll ADD(ll A,ll B){
  return (A%mod+B%mod)%mod;
}
 
ull power(ll A,ll B) { 
    ull RES = 1;      
    while (B > 0) 
    { 
        if (B & 1) 
            RES = RES*A;  
        B = B>>1;  
        A = A*A;  
    } 
  return RES; 
}

 
void testcases(int cases){
  
 int N;
  cin >> N;
  mll MAP;
  ll SUM = 0;
  ll arr[N+2];
  for(int i = 1 ;i <= N ; i ++){
    cin >> arr[i];
    MAP[arr[i]]++;
    SUM+=arr[i];
    }
  int Q;
  cin >> Q;
  while(Q--){
    ll B,C;
    cin >> B >> C;
    ll CNT = MAP[B];
    SUM-=B*CNT;
    SUM+=C*CNT;
    MAP[C]+=CNT;
    MAP[B]=0;
    cout << SUM << "\n";
  }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
   // cin >> t;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}

Measured memory_bytes: 10348
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int inp[] = new int[333];
        int n = in.nextInt();
        int ans = (int)1e9;
        for(int i = 1; i <= n; i++){
            inp[i] = in.nextInt();
            int tmp = 0;
            while(inp[i] % 2 == 0){
                tmp++;
                inp[i] /= 2;
            }
            ans = Math.min(ans, tmp);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n; cin >>n;
    vector<vector<ll> > u(n, vector<ll>(3, 0));
    REP(i,n) cin >> u[i][0] >> u[i][1] >> u[i][2]; 

    vector<vector<ll> > dp(100100, vector<ll>(3, 0));
    dp[1][0] = u[0][0];
    dp[1][1] = u[0][1];
    dp[1][2] = u[0][2];
    for (int i = 2; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + u[i-1][j]);
                } 
            }
        }
    }

    ll ans = max(dp[n][0], max(dp[n][1], dp[n][2]));

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



Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

vvi n(10,vi(10,0));
string str;

int main(){
	while(cin>>str){
		for(int i=0;i<10;i++) n[0][i]=str[i]-'0';
		for(int i=1;i<10;i++){
			for(int j=0;j<10-i;j++) n[i][j]=(n[i-1][j]+n[i-1][j+1])%10;
		}
		cout<<n[9][0]<<endl;
	}
}

Measured memory_bytes: 1196
//Five Variables
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
const int INF = 1 << 29;
int main ()
{
    int x[5];
    for (int i = 0; i < 5; i++) {
        cin >> x[i];
        if (x[i] == 0) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int maxtime(int x) {
  return (x+9)/10*10;
}

int retime(int x) {
  return maxtime(x) - x;
}

int main() {
  vi X(5); rep(i,X.size()) cin >> X.at(i);
  
  int sum = 0;
  rep(i,X.size()) sum += maxtime(X.at(i));
  
  int max_re = 0;
  rep(i,X.size()) max_re = max(max_re, retime(X.at(i)));
  
  sum -= max_re;
  
  cout << sum << endl;
}

Measured memory_bytes: 256
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    n = sc.intarr()[0]
    array = []
    for i in range(n):
        array.append(sc.intarr()[0])
    sorted_array = sorted(array)
    maximum = sorted_array[-1]

    for i in array:
        if i == maximum:
            print(sorted_array[-2])
        else:
            print(maximum)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


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

int main() {
  int n, k, s = 0;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  rep(i, n) s += min(v[i], k-v[i]);
  cout << s*2 << endl;
  return 0;
}

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

int max(int x, int y){
  if(x < y){
    return y;
  }else{
    return x;
  }
}

int min(int x, int y){
  if(x < y){
    return x;
  }else{
    return y;
  }
}

int main(){
  int N,M;
  cin >> N >> M;
  int lmax = 0,rmin = 1000000;
  for(int i = 0; i < M; i++){
    int l,r;
    cin >> l >> r;
    l > lmax ? lmax = l:1;
    r < rmin ? rmin = r:1;
  }

  cout << max(0,rmin-lmax+1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N, K;
  cin >> N >> K;
  if ((N+1)/2 >= K)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
SX,SY,TX,TY=map(int,input().split())

dt={'U':'D','D':'U','L':'R','R':'L'}

def f(s):
    t=''
    for a in s:
        t+=dt[a]
    return t

vx=TX-SX
vy=TY-SY

ans1=''
ans1=('U' if 0<=vy else 'D')*abs(vy)
ans1+=('R' if 0<=vx else 'L')*abs(vx)
ans1+=f(ans1)

ans2=''
ans2=('R' if 0<=-vx else 'L')
ans2+=('U' if 0<=vy else 'D')*abs(vy+1)
ans2+=('R' if 0<=vx else 'L')*abs(vx+1)
ans2+=('U' if 0<=-vy else 'D')
ans2+=f(ans2)
print(ans1+ans2)


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k; cin>>n>>k;
    vector<ll> h(n);
    REP(i,n) cin>>h[i];
    sort(all(h));
    ll ans = linf;
    ll temp;
    for(ll i = 0; i+k<=n;i++){
        temp = h[i+k-1] - h[i];
        ans = min(ans,temp);
    }
    print((ll)ans);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define INF 100000000


int min(int a,int b,int c) {
  int answer = a <= b && a <= c 
    ? a 
    : b <= a && b <= c 
      ? b 
      : c;
  return answer;
}

int min(int a,int b,int c,int d) {
  int answer = a <= b && a <= c && a <= d
    ? a 
    : b <= a && b <= c && b <= d 
      ? b 
      : c <= a && c <= b && c <= d
        ? c
        : d;
  return answer;
}

int gcm(int a,int b);

int main(){
  int N,A,B,C;
  cin >> N >> A >> B >> C;
  vint l(N);
  rep(i,N) cin >> l[i];
  function<int(int,int,int,int)> dfs = [&] (int cur,int a,int b,int c){
    if(cur == N){
      if(min(a,b,c) > 0){
        return abs(a - A) + abs(b - B) + abs(c - C) - 30;
      }
      else{ 
        return INF;
      }
    }
    int ret0 = dfs(cur+1,a,b,c);
    int ret1 = dfs(cur+1,a + l[cur],b,c) + 10;
    int ret2 = dfs(cur+1,a,b + l[cur],c) + 10;
    int ret3 = dfs(cur+1,a,b,c + l[cur]) + 10;
    return min(ret0,ret1,ret2,ret3);
  };
  cout << dfs(0,0,0,0) << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> as(n);
    for(int i = 0; i < n; i++){
        cin >> as[i];
    }
    unordered_map<int, int> memo;
    function<int(int, int, int)> solve = [&](int op, int idx, int sign){
        if(memo.count(idx * sign)){ return memo[idx * sign]; }
        int ret = -M;
        for(int i = idx; i < n - 1; i++){
            ret = max(ret, sign * solve(as[i], i + 1, -sign));
            // printd(i, ret, sign);
        }
        ret = max(ret, sign * abs(op - as.back()));
        return memo[idx * sign] = sign * ret;
    };
    cout << solve(w, 0, 1) << '\n';
}


Measured memory_bytes: 888
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var tmp = input[0].split(" ");
  var tmp2 = input[1].split(" ");
  var bounding = 0;
  var count = 1;
  
  for(var i=0; i < tmp[0]; i++){
    bounding = bounding + Number(tmp2[i]);
    if(Number(tmp[1]) < bounding){
      break;
    }else{
      count = count + 1;
    }
  }
 	//出力
 	console.log(count);
 }
 //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
 Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22084
#include<bits/stdc++.h>
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-10;
long long h, w;
long long ans = llINF;
long long s1, s2, s3;
void update()
{
    ans = min(ans, max(max(s1, s2), s3) - min(min(s1, s2), s3));
}
int main(int argc, char const *argv[])
{
    scanf("%lld%lld", &h, &w);
    long long s = h * w;
    for (int i = 1; i <= h; i++) //两个横线
    {
        s1 = 1ll * i * w;
        s2 = (h - i) / 2 * w;
        s3 = s - s1 - s2;
        update();
    }
    for (int i = 1; i <= w; i++) //两个竖线
    {
        s1 = 1ll * i * h;
        s2 = (w - i) / 2 * h;
        s3 = s - s1 - s2;
        update();
    }
    for (int i = 1; i <= w; i++) //竖的贯穿+横线
    {
        s1 = 1ll * i * h;
        s2 = (w - i) * (h / 2);
        s3 = s - s1 - s2;
        update();
    }
    for (int i = 1; i <= h; i++) //横线贯穿+竖线
    {
        s1 = 1ll * i * w;
        s2 = (h - i) * (w / 2);
        s3 = s - s1 - s2;
        update();
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%I64d", &x)
#define ss(s) scanf("%s", s)
#define pb push_back
#define em emplace_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define clr(x) memset(x, 0, sizeof(x))
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1e9 + 7;
int epow(int base, int pow)
{
    int result = 1;
    while (pow)
    {
        if (!(pow % 2))
        {
            base = (base * base) % mod;
            pow /= 2;
        }
        else
        {
            result = (result * base) % mod;
            pow--;
        }
    }
    return result;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    si(n);
    double d = 2 * n * PI;
    cout << setprecision(24) << d << endl;
}

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

using namespace std;

int main(){
   vector<int> a(3);
    cin >> a[0]>> a[1]>> a[2];
    sort(a.begin(),a.end());
    cout << abs(a[1]-a[0]) + abs(a[2]-a[1]) << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *   author: bholuakku
**/

#include <bits/stdc++.h>
#define For(i,a,b) for(i=(a); i<(b); i++)
#define rep(i,n) for(i=0; i<(n); i++)
#define Nfor(i,a,b) for(i=(a)-1; i>=(b); i--)
#define dep(i,n) for(i=(n-1);i>=0; i--)
#define mp make_pair
#define pb push_back
#define Auto(a) for(auto &val : a)
#define X first
#define Y second
#define MOD 1000000007
#define MOD1 998244353
#define iterate(A, i) for(auto i = A.begin(); i!=A.end(); i++)
#define mset(A,val,n) memset(A, val, n*sizeof(int))
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<bool> vb;
typedef vector<vector<bool> > vvb;
typedef pair<int, int> pii;
typedef vector<vector<pair<int, int> > > vvp;

int power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y>0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x)%p;} return res;}
int modInverse(ll n) {ll p = MOD;return power(n, p-2, p);}
int min(int a, int b, int c) { return min(a, min(b, c)); }
int max(int a, int b, int c) { return max(a, max(b, c)); }
inline void swap(int &a, int &b) { int t = a; a = b; b = t;}
bool cmp(int a, int b){return a>b;}
const int N = 3001;
double p[N+10], dp[N+10][N+10], ans = 0;
int main(){
    int n, i, j;
    cin>>n;
    rep(i,n) cin>>p[i];
    dp[0][0] = 1;
    rep(i,n){
        dp[0][i+1] = dp[0][i]*p[i];
        dp[i+1][0] = dp[i][0]*(1.0-p[i]);
    }
    ans+=dp[0][n];
    For(i,1,n+1){
        For(j,1,n+1){
            if(i+j-1>=n) continue;
            dp[i][j] = dp[i-1][j]*(1-p[i+j-1]) + dp[i][j-1]*p[i+j-1];
            if(i+j==n&&j>i) ans+=dp[i][j];
        }
    }
    // rep(i,n+1){
    //     rep(j, n+1){
    //         cout<<dp[i][j]<<"\t";
    //     }Endl;
    // }
    /*i = n/2;
    ans = 0;
    j = 0;
    k = n;
    while(i--){
        ans+=dp[j][k];
        j++; k--;
    }*/
    cout<<setprecision(13)<<ans;
    return 0;
}


Measured memory_bytes: 70016
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define r(i,n) for (int i=0; i < (n); i++)
main(){
	int n,k,x[222],y[222],xx[222],yy[222],ans=(1e18)*4;
	cin>>n>>k;
	r(i,n)cin>>x[i]>>y[i];
	r(i,n)xx[i]=x[i],yy[i]=y[i];
	sort(xx,xx+n);
	sort(yy,yy+n);
	for(int xi=0;xi<n;xi++)
		for(int xj=xi+1;xj<n;xj++)
			for(int yi=0;yi<n;yi++)
				for(int yj=yi+1;yj<n;yj++){
					int lx=xx[xi];
					int rx=xx[xj];
					int ly=yy[yi];
					int ry=yy[yj];
					int sum=0;
					for(int i=0;i<n;i++){
						if(lx<=x[i]&&x[i]<=rx)
							if(ly<=y[i]&&y[i]<=ry) sum++;
					}
					if(sum>=k)ans=min(ans,(rx-lx)*(ry-ly));
				}
	cout<<ans<<endl;
}

Measured memory_bytes: 256