akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve();
		return;
	}

	private void solve() {
		// 入力
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		// 計算
		int count = 0;
		String first;
		String last;
		for (int i = A; i <= B; i++) {
			String value = String.valueOf(i);
			if (value.length() % 2 == 0) {
				first = value.substring(0, value.length() / 2);
				last = value.substring(value.length() / 2);
			} else {
				first = value.substring(0, (value.length() + 1) / 2);
				last = value.substring(value.length() / 2);
			}
			StringBuffer lastBuf = new StringBuffer(last);
			if (first.equals(lastBuf.reverse().toString())) {
				count++;
			}
		}

		// 出力
		System.out.println(count);

		return;
	}


}


Measured memory_bytes: 37544
import java.util.Scanner;

class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int N = sc.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        int[] arr2 = new int[N];
        for (int i = 1; i < N; i++) {
            arr2[i-1] = arr[i]-arr[i-1];
            K -= arr2[i-1];
        }
        arr2[N-1] = K;

        int sum = 0;
        for (int i = 0; i < N-1; i++) {
            sum += arr2[i];
        }
        
        int ans = sum;
        for (int i = 1; i < N; i++) {
            sum -= arr2[i-1];
            sum += arr2[(N-2+i)%N];
            ans = Math.min(ans, sum);
        }

        System.out.println(ans);

        sc.close();
	}
}

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

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

	//string s;
	int a,b;

	cin >> a >> b;
	//cin >> n;
	
	//string ans="Yes";
	
	int ans=0;
	int p=1;//plug

	while(p<b){
		p+=(a-1);
		ans++;
	}
	
	cout << ans << "\n";
	
	
	return 0;

    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

vector<int> a;
vector<int> groupNum;
vector<int> groupMem[100010];

void merge(int x, int y) {
	int gnx = groupNum[x];
	int gny = groupNum[y];

	if (gnx == gny) return;

	if (groupMem[gnx].size() > groupMem[gny].size()) {
		swap(x, y);
		swap(gnx, gny);
	}

	for (int num : groupMem[gnx]) {
		groupNum[num] = gny;
	}
 
	groupMem[gny].insert(groupMem[gny].end(), all(groupMem[gnx]));
	groupMem[gnx].clear();
}

struct Info {
	priority_queue<int> aq;

	Info(vector<int> v) {
		for (int num : v) {
			aq.push(-a[num]);
		}
	}

	bool operator< (const Info &x) const {
		return aq.top() < x.aq.top();
	}
};

string imp = "Impossible";
priority_queue<Info> infoq;

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

	groupNum.resize(N);
	inputVector(a, N);

	rep(i, N) {
		groupNum[i] = i;
		groupMem[i].push_back(i);
	}

	rep(i, M) {
		int x, y;
		cin >> x >> y;

		merge(x, y);
	}

	int ret = 0;
	int treeNum = 0;
	int maxNum = 0;
	vector<int> lonely;
	priority_queue<int> q;
	rep(i, N) {
		if (groupMem[i].empty()) continue;
		if (groupMem[i].size() == 1) {
			lonely.push_back(a[groupMem[i][0]]);
		} else {
			treeNum++;
			priority_queue<int> tmpq;
			for (int num : groupMem[i]) {
				tmpq.push(-a[num]);
			}

			ret += -tmpq.top(); tmpq.pop();

			while (!tmpq.empty()) {
				q.push(tmpq.top()); tmpq.pop();
			}
		}
	}

	if (treeNum == 0) {
		if (lonely.size() == 1) {
			cout << 0 << endl;
		} else if (lonely.size() == 2) {
			cout << lonely[0] + lonely[1] << endl;
		} else {
			cout << imp << endl;
		}
		return 0;
	}

	rep(i, treeNum - 2) {
		ret += -q.top(); q.pop();
	}

	if (treeNum == 1) {
		q.push(-ret);
		ret = 0;
	}

	for (int num : lonely) {
		if (q.empty()) {
			cout << imp << endl;
			return 0;
		}

		ret += num;
		ret += -q.top(); q.pop();
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 11848
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  llong X, t;
  cin >> X >> t;
  llong zero = 0;
  cout << max(X - t, zero) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

#define ma 212345

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

    int n, q, s[ma], t[ma], x[ma], d[ma];

    V v;

    set<int> st;

    V ro[ma + ma][2];

    cin >> n >> q;
    REP(i, n)
    {
        cin >> s[i] >> t[i] >> x[i];
        s[i] -= x[i];
        t[i] -= x[i];

        if (st.count(s[i]) == 0)
            v.push_back(s[i]);
        if (st.count(t[i]) == 0)
            v.push_back(t[i]);

        st.insert(s[i]);
        st.insert(t[i]);
    }
    REP(i, q)
    cin >> d[i];

    v.push_back(1e9 + 1111);
    v.push_back(-100);

    SORT(v);

    map<int, int> mp;
    REP(i, v.size())
    {
        mp[v[i]] = i;
    }

    REP(i, n)
    {
        ro[mp[s[i]]][0].push_back(i);
        ro[mp[t[i]]][1].push_back(i);
    }

    int di[412345];
    REP(i, v.size())
    di[i] = 1e9 + 100;

    priority_queue<P> qu;

    bool use[ma];
    fill(use, use + n + 1, false);

    use[n] = true;
    qu.push({-1e9 + 100, n});

    REP(i, v.size())
    {
        for (int j : ro[i][0])
        {
            use[j] = true;
            qu.push({-x[j], j});
        }
        for (int j : ro[i][1])
        {
            use[j] = false;
        }

        while (qu.size() && !use[qu.top().second])
            qu.pop();

        di[i] = -qu.top().first;
    }

    REP(i, q)
    {
        int l = 0;
        int r = v.size();

        while (r - l > 1)
        {
            int mid = (l + r) / 2;

            if (v[mid] <= d[i])
                l = mid;
            else
                r = mid;
        }

        //cout << l << " ";

        if (-di[l] == -1e9 + 100)
            cout << -1 << endl;
        else
            cout << di[l] << endl;
    }

    /*
    REP(i, v.size())
    cout << di[i] << " ";
    cout << endl;

    REP(i, v.size())
    cout << v[i] << " ";
    cout << endl;
    */

    return 0;
}

Measured memory_bytes: 79856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; ++i) {

    if (i % k == 0) {
      cout << "OK\n";
      return 0;
    }
  }

  cout << "NG" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    deque<int> que;
    for (int i = 0; i < N; i++) {
        auto it = lower_bound(que.begin(), que.end(), A[i]);
        if (it == que.begin()) que.push_front(A[i]);
        else *(it - 1) = A[i];
    }
    cout << sz(que) << '\n';
    return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)

signed main() {
	
	string s;

	cin >> s;


	for (ll i = 0; i < s.size();) {
		if (s[i] == 'L') {
			cout << "No" << endl;
			return 0;
		}
		i++;
		i++;
	}
	for (ll i = 1; i < s.size();) {
		if (s[i] == 'R') {
			cout << "No" << endl;
			return 0;
		}
		i++;
		i++;
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
A, B = [], []
for _ in range(n):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

x = np.median(A)
y = np.median(B)
if n%2==0:
    print(int((y-x)/0.5+1))
else:
    print(int(y-x+1))

Measured memory_bytes: 45708
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

mycounter = Counter(A)
count = 0
for item in mycounter.items():
    if item[0] < item[1]:
        count += item[1] - item[0]
    elif item[1] < item[0]:
        count += item[1]

print(count)


Measured memory_bytes: 18676
/* Simplicity and Goodness */
 
#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 tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int h, w;
    scn(h); scn(w);

    string s[h];

    rep(i, 0, h)
    cin >> s[i];

    vector<vi> dp(h, vi(w));

    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            if(i + j == 0) {
                dp[0][0] = s[i][j] == '#';
            } else {
                dp[i][j] = (int) 1e9;

                if(i > 0)
                    dp[i][j] = min(dp[i][j], dp[i-1][j] + (s[i-1][j] == '.' && s[i][j] == '#'));
                if(j > 0)
                    dp[i][j] = min(dp[i][j], dp[i][j-1] + (s[i][j-1] == '.' && s[i][j] == '#'));
            }
        }
    }
    prin(dp[h-1][w-1]);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3808
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<stack>
#include<cmath>
#include<map>
#include<vector>
#define ll long long
#define inf 0x3f3f3f3f
#define bug1 cout<<"bug1"<<endl;
#define bug2 cout<<"bug2"<<endl;
#define bug3 cout<<"bug3"<<endl;
using namespace std;

int main(){
    int w,a,b;
    scanf("%d%d%d",&w,&a,&b);
    int al=a,ar=a+w,bl=b,br=b+w;
    if(br<al)cout<<al-br<<'\n';
    else if(ar<bl)cout<<bl-ar<<'\n';
    else cout<<0<<'\n';
            

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int T[2000005]={0};
const int MAX = 2000005;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];
ll A[MAX] = { 0 };
ll B[MAX] = { 0 };
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  int x;int y;
  cin>>x>>y;
  int s=2*x-y;int t=2*y-x;
  if(s%3!=0||t%3!=0||s<0||t<0)cout<<0<<endl;
  else cout<<COM(s/3+t/3,s/3)<<endl;
}


Measured memory_bytes: 49408
import java.util.*;
public class Main {
	void doIt(){
		Scanner sc = new Scanner(System.in);
		Person pa[] = new Person[24];
		int cnt = 0;
		for(int i = 0;i < 3;i++){
			for(int k = 0;k < 8;k++){
				pa[i * 8 + k] = new Person(sc.nextInt(), sc.nextDouble(), true);
			}
			Arrays.sort(pa, i * 8, i * 8 + 7);
			for(int k = 0;k < 2;k++){
				System.out.println(pa[i * 8 + k].number + " " + pa[i * 8 + k].time);
				pa[i * 8 + k].flag = false;
			}
		}
		Arrays.sort(pa);
		for(int i = 0;i < 24;i++){
			if(pa[i].flag == true){
				System.out.println(pa[i].number + " " + pa[i].time);
				cnt++;		
			}
			if(cnt == 2) break;
		}
	}
	public static void main(String args[]){
		new Main().doIt();
	}
	class Person implements Comparable<Person>{ 
		int number;
		Double time;
		boolean flag;
		Person(int number, double time, boolean flag){
			this.number = number;
			this.time = time;
			this.flag = flag;
		}
		@Override
		public int compareTo(Person p){
			return time.compareTo(p.time);
		}
	}
}

Measured memory_bytes: 27976
n;//ACe
char s[101][101];//ACe¼
p[101];//wü¿i
r[101];//VsÌCfbNX(-1=BàsÂ)
k[100];//[i]:ACeiÌBàÉKvÈACe
q[100][100];//[i][j]:ACeiÌBàÉKvÈACeXg
G(){//ACe¼ðüÍµAACeCfbNXðÔ·
	int i;
	char t[101];
	scanf("%s",t);
	for(i=0;i<n;i++)
		if(strcmp(s[i],t)==0)
			return i;
	return n;
}
R(o){//ACeoÌÅ¬Ìli
	int m,i;
	if(r[o]!=-1){
		m=0;
		for(i=0;i<k[r[o]];i++)
			m+=R(q[r[o]][i]);
	}else
		m=p[o];
	if(p[o]<m)
		m=p[o];
	return m;
}
main(){
	int i,j,m;
	for(;scanf("%d",&n),n;){
		memset(r,-1,sizeof(r));
		for(i=0;i<n;i++){
			scanf("\n%s%d",s[i],p+i);
		}
		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf("\n");
			r[G()]=i;
			scanf("%d",k+i);
			for(j=0;j<k[i];j++){
				scanf(" ");
				q[i][j]=G();
			}
		}
		printf("%d\n",R(G()));
	}
	exit(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long
signed main(){
    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vector<int> a(n),b;
    for(auto& i:a) cin >> i;
    sort(a.begin(), a.end());
    b = a;
    for (int i = 1; i < n;++i) b[i] += b[i-1];
    auto f = [&](int mid) {
        int lwc = upper_bound(a.begin(), a.end(), a[mid]) - a.begin() - 1;
        int mv = m * (v - (lwc + p));
        int cons = (n - p - mid) * (a[mid] + m) - (b[n - p] - b[mid]);
        return mv <= cons && a[mid]+m >= a[n-p];
    };
    int l = 0, r = n - p;
    while(l+1<r){
        int mid = (l + r) / 2;
        (f(mid)?r:l) = mid;
    }
    if(r==1&&f(0)) r = 0;
    cout << n - r << endl;
}


Measured memory_bytes: 1792
n = int(input())
l = [2] * n
l[0] = 1
for i in range(1, n):
    for j in range(i, n, i + 1):
        if j == i:continue
        l[j] += 1
cnt = 0
for i in range(n):
    cnt = cnt + (i + 1) * l[i]
print(cnt)


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int ans = 0;
    int N, A, B; cin >> N >> A >> B;
    for(int i = 1; i <= N; i++){
        int val = i;
        int acc = 0;
        while(val > 0){
            acc += val % 10;
            val /= 10;
        }
        if(A <= acc && acc <= B) ans+=i;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){   
    ll h, n;
    cin >> h >> n;

    ll sum = 0;
    rep(i, n){
        ll a;
        cin >> a;
        sum += a;
    }
    if(sum >= h)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
n = int(input())
t_point = 0
h_point = 0
for i in range(n):
	cards = input().split()
	t = cards[0]
	h = cards[1]
	if t == h:
		t_point += 1
		h_point += 1
	elif t < h:
		h_point += 3
	else:
		t_point += 3
print(t_point, h_point)


Measured memory_bytes: 5596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll x;
    cin >> x;
    map<ll, ll> mp;
    for(ll i = - 200; i <= 200; i++){
        mp[i * i * i * i * i] = i;
    }
    for(ll i = - 200; i <= 200; i++){
        if(mp.count(x+ i * i * i * i * i)){
            cout << mp[x + i * i * i * i * i] << " " << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    vector<int> a(4);
    for (int i = 0; i < 4; i++) {
        cin >> a[i];
    }
    sort(ALL(a));
    cout << min(abs(a[3] - a[2] - (a[1] - a[0])), abs(a[3] - a[1] - (a[2] - a[0]))) << endl;
    return 0;
}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	bool f = false;
	rep(i, 1, 10) {
		if (N%i == 0 and N / i <= 9) {
			f = true;
		}
	}
	Yes(f);

	return 0;
}


Measured memory_bytes: 256
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * (10 ** 5 + 2)
    m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38524
#include <iostream>
using ll = long long;
using namespace std;

int main() {
    string s;
    ll k;
    cin >> s >> k;
    for (int i = 0; i < min(k , (ll)s.length()); ++i) {
        char e = s[i];
        if(e != '1') {
            cout << e << "\n";
            return 0;
        }
    }
    cout << s[min(k-1 , (ll)s.length()-1)] << "\n";
    return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
suslik = sum(B)
for i in range(n):
    if A[i] >= B[i]:
        A[i] -= B[i]
        B[i] = 0
    else:
        B[i] -= A[i]
        A[i] = 0
        if A[i + 1] >= B[i]:
            A[i + 1] -= B[i]
            B[i] = 0
        else:
            B[i] -= A[i + 1]
            A[i + 1] = 0
print(suslik - sum(B))

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

#define fi first
#define se second
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define debug(x) cout<<#x": "<<x<<'\n';
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=100010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

template<class T> inline void gmax(T &A,T B)
{
    (A<B)&&(A=B);
}
template<class T> inline void gmin(T &A,T B)
{
    (A>B)&&(A=B);
}

template<class T> inline bool re(T &ret)
{
    char c;
    int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}

int n,k;
int a[111],sum[N],dp[2][N];

inline int add(int a, int b)
{
    int t=a+b;
    if(t>=mod) t-=mod;
    return t;
}

inline int sub(int a, int b)
{
    int t=a-b;
    if(t<0) t+=mod;
    return t;
}

int main()
{
#ifdef local
    //freopen("in.txt", "r", stdin);
#endif
    IOS;
    cin>>n>>k;
    for(int i=1; i<=n; i++) cin>>a[i];
    dp[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=k+1; j++) sum[j]=add(sum[j-1],dp[(i-1)&1][j-1]);
        for(int j=0; j<=k; j++)
            dp[i&1][j]=sub(sum[j+1],sum[max(j-a[i],0)]);
    }
    cout<<dp[n&1][k];
    return 0;
}


Measured memory_bytes: 1408
/*
  
  Author: Arnab Sinha
	
  ███████╗██╗  ██╗███████╗██████╗         ██╗      ██████╗  ██████╗██╗  ██╗███████╗██████╗  █████╗  █████╗ 
  ██╔════╝██║  ██║██╔════╝██╔══██╗        ██║     ██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██╔══██╗██╔══██╗██╔══██╗
  ███████╗███████║█████╗  ██████╔╝        ██║     ██║   ██║██║     █████╔╝ █████╗  ██║  ██║╚██████║╚██████║
  ╚════ █║██╔══██║██╔══╝  ██╔══██╗        ██║     ██║   ██║██║     ██╔═██╗ ██╔══╝  ██║  ██║ ╚═══██║ ╚═══██║
  ███████║██║  ██║███████╗██║  ██║███████╗███████╗╚██████╔╝╚██████╗██║  ██╗███████╗██████╔╝ █████╔╝ █████╔╝
  ╚══════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚══════╝╚══════╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝╚══════╝╚═════╝  ╚════╝  ╚════╝                                                                                                        
*/

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define li long long int
#define ld long long double
#define all(v) v.begin(),v.end()
#define sort(a) sort(all(a))
#define rev(a) reverse(all(a))
#define pb push_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define vli vector<li>
#define MAXN 1e5+10
const li mod = 1e9+7;
using namespace std;

li power(li a, li b) { a%=mod; li ret = 1; while(b){ if(b&1) ret*=a; a*=a;; if(ret>=mod) ret%=mod; if(a>=mod) a%=mod; b>>=1; } return ret; }

template <class T> void read(T& x){
	cin>>x;
}

template <class T, class... U> void read(T& x, U&... u){
	read(x);
	read(u...);
}

template <class A> void read(vector<A>& v){
	for(auto &it:v)
		read(it);
}

template <class A> void print(A x){
	cout<<x;
}

template <class A> void printl(A x){
	cout<<x<<endl;
}

template <class A> void print(vector<A>& v)
{
	for(auto &it:v){
		print(it);
		cout<<' ';
	}
	cout<<'\n';
}

void solve()
{
	li n;
	cin>>n;

	vli v(n);
	read(v);

	vli pref(n+1,0);

	pref[n] = 0;
	for(li i=n-1;i>=1;i--)
	{
		pref[i] = (pref[i+1] + v[i])%mod;
	}

	li sum = 0;

	for(li i=0;i<n-1;i++)
	{
		sum = (sum + (v[i]*pref[i+1])%mod)%mod;
	}

	cout<<sum<<endl;
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	IOS;

	solve();

	return 0;
}

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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    vector<ll> v;
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        if (a == (ll)0)
        {
            ans = 0;
            break;
        }
        v.push_back(a);
    }
    if (ans == 0) 
    {
        cout << 0 << endl;
        return 0;
    }
    for (ll i: v)
    {
        if (ans <= (ll)(1e18) / i)
        {
            ans *= i;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4156
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N,M;
int table[55];

int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){

		table[i] = 0;
	}

	int from,to;

	for(int i = 0; i < M; i++){

		scanf("%d %d",&from,&to);
		from--;
		to--;

		table[from]++;
		table[to]++;
	}

	for(int i = 0; i < N; i++){

		printf("%d\n",table[i]);
	}

	return 0;
}


Measured memory_bytes: 3828
using System;
					
public class Program
{
	public static void Main()
	{
		int a;
		int b;
        string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        a = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
        b = int.Parse(str[1]);
		int res;
		if(a==b){
			res = a*2;
		}else{
		res = a < b ? b*2 - 1: a*2 - 1;
		}
		
		Console.WriteLine(res);
	}
}

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

int main() {
 int n,t;
  cin>> n>>t;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    int kaihi;
      int time;
    cin>>kaihi >> time;
    if(time<=t){
      vec.at(i)=kaihi;}
    else{
    vec.at(i)=9999;}
  }
  sort(vec.begin(),vec.end());
    if(vec.at(0)==9999){
      cout<<"TLE"<<endl;}
  else{
    cout << vec.at(0) <<endl;}
  
  
}


Measured memory_bytes: 256
from typing import List
import math


def calc_std():
    while True:
        num_students = int(input())
        if num_students == 0:
            break

        score_list: List[int] = list(map(int, input().split()))
        mean_score = sum(score_list) / len(score_list)
        squared_error = 0

        for i in range(len(score_list)):
            squared_error += (score_list[i] - mean_score) ** 2

        mean_squared_error = squared_error / len(score_list)
        std = math.sqrt(mean_squared_error)

        print(f"{std:.5f}")


if __name__ == "__main__":
    calc_std()



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


int main() {
    int n,a,b,c,d;
    cin >> n;
    a = n/1000;
    b = n%1000/100;
    c = n%100/10;
    d = n%10;
    if((a == b && b == c)||(b == c && c == d)){
        cout << "Yes" <<endl;

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

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    wv = [None] * N
    for i in range(N):
        wv[i] = tuple(map(int, input().split()))

    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i, (w, v) in enumerate(wv, start=1):
        dp_i = dp[i]
        dp_im = dp[i - 1]
        for j in range(1, W + 1):
            if j < w:
                dp_i[j] = dp_im[j]
            else:
                a = dp_im[j - w] + v
                b = dp_im[j]
                if a > b:
                    dp_i[j] = a
                else:
                    dp_i[j] = b

    ans = dp[-1][-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 493056
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <ctime>
#include <set>
#include <sstream>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
char s[105];int n,i,j;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	gets(s+1);
	n=strlen(s+1);
	for(i=1;i<n;i++)
	{
		if(s[i]=='C')
		{
			for(j=i+1;j<=n;j++)
			{
				if(s[j]=='F')
				{
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");
	return 0;
}



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

int main()
{
	int x,y;
	cin>>x>>y;

	for (int i = 0; i <= x; ++i)
	{
		int a = i*4 + (x-i)*2;
		if(a==y)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");

	
	return 0;
}

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

using namespace std;
typedef long long ll;

ll big = 1000000007ll;
ll n,m,k,x,y;

vector<ll> A;
vector<ll> D;
vector<ll> P;
vector<ll> CS;

ll DP[100001][2] = {0};

ll dp(ll i, ll p){
    if(i == n)return 1;
    if(DP[i][p] != -1){return DP[i][p];}
    ll ans = 0;
    if(p == 1 || D[i] >= x || i == 0)ans += dp(i+1,0);
    bool bort = 0;
    ll pek = P[i];
    if(i >= 1 && p == 0 && i < n-1 && P[i] != i+1){
        if(A[i+1] - A[i-1] < x)bort = 1;
    }
    //if(pek == n)bort = 1;
   if(i < n-1){ if(CS[pek] - CS[i+2] > 0)bort = 1;}
    if(bort == 0){
        if(pek == i+1){
            ans += dp(pek,1);
        }
        else{
            ans += dp(pek,0);
        }
    }
    ans %= big;
    DP[i][p] = ans;
    //cout << i << " " << p << "  -  " << ans << " , " << bort <<"  " << dp(i+1,0) << " " << dp(pek,(pek == i+1)) << "\n";
    return ans;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll c1,c2,c3,c4,c5;
    ll a,b,c;

    cin >> n >> x >> y;
    if(x > y){
        a = x;
        x = y;
        y = a;
    }
    ll prev = 0;
    for(c1 = 0; c1 < n; c1++){
        cin >> a;
        A.push_back(a);
        D.push_back(a-prev);
        prev = a;
    }

    CS.push_back(0);
    for(c1 = 0; c1 < n; c1++){
        if(c1 == 0){
            CS.push_back(0);
        }
        else{
            CS.push_back(CS[c1] + (D[c1] < x));
        }
        DP[c1][0] = -1;
        DP[c1][1] = -1;
    }

    for(c1 = 0; c1 < n; c1++){
        ll l = c1+1;
        ll r = n;
        if(c1 == n-1 || D[l] >= y){
            P.push_back(l);
        }
        else{
            while(l < r-1){
                ll mid = (l+r)/2;
                if(A[mid] - A[c1] < y){
                    l = mid;
                }
                else{
                    r = mid;
                }
            }
            P.push_back(r);
        }

        //cout << P[c1] << " ";

    }

    cout << dp(0,1) << "\n";

    return 0;
}


Measured memory_bytes: 9708
#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() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int			n;
	int			max;
	int			second_max;
	cin >> n;
	vector<int>	A(n);
	vector<int>	B;

	/* rep(i, n) */
	/* 	cin >> A.at(i); */
	for (int &a : A)
		cin >> a;
	B = A;
	sort(B.rbegin(), B.rend());
	/* max = B.at(0); */
	/* second_max = B.at(1); */
	for (int a : A)
	{
		if (a != B.at(0))
			cout << B.at(0) << endl;
		else
			cout << B.at(1) << endl;
	}
}


Measured memory_bytes: 3200
#include<stdio.h>
int solve(int,int);
int n,q,i;
int a[2000],m[2000];
int main(){
  int h;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
    h=solve(0,m[i]);
    if(h==1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
}
int solve(int c,int b){
  int res;
  if(b==0){
    return 1;
  }
  if(c>=n){
    return 0;
  }
  res=solve(c+1,b) || solve(c+1,b-a[c]);
  return res;
}



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

inline void work(int H, int W) {
    char str[110];
    int b[110][110];
    for (int i = 0; i < H; ++ i) {
        scanf("%s", str);
        for (int j = 0; j < W; ++ j) {
            b[i][j] = (str[j] == '#' ? 1 : 0);
        }
    }
    bool h[110], w[110];
    memset(h, 0, sizeof(h));
    memset(w, 0, sizeof(w));
    for (int i = 0; i < H; ++ i) {
        for (int j = 0; j < W; ++ j) {
            if (b[i][j] == 1) {
                h[i] = 1;
                break;
            }
        }
    }

    for (int i = 0; i < W; ++ i) {
        for (int j = 0; j < H; ++ j) {
            if (b[j][i] == 1) {
                w[i] = 1;
                break;
            }
        }
    }

    for (int i = 0; i < H; ++ i) {
        if (h[i] == false) continue;
        for (int j = 0; j < W; ++ j) {
            if (w[j] == false) continue;
            cout << (b[i][j] == 1 ? '#' : '.');
        }
        cout << endl;
    }
}

int main() {
    int H, W;
    while (cin >> H >> W) {
        work(H, W);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N;
MII cnt;


bool judge(){
	for(int i = N-1;i >= 0;i-=2){
		if(cnt.find(i) == cnt.end()) return false;
		if(cnt.find(i+1) != cnt.end()) return false;
		if(i == 0 && cnt[i] != 1) return false;
		if(i != 0 && cnt[i] != 2) return false; 
	}
	return true;
}


int solve(){
	if(!judge()) return 0;
	llint ans = 1;
	for(PII p : cnt) ans = MUL(ans, p.se);
	return (int)ans;
}


signed main(){
	cin >> N;
	rep(i, 0, N){
		int A;
		cin >> A;
		cnt[A]++;
	}

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 3200
/// sultanov

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type,
less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int N = 2e5;
const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int c[N], d[N];

set<int> s;

vector<int> adj[N];

void dfs(int x = 0, int p = -1) {
    int cur = 1;
    for (int to : adj[x])
        if (to != p) {
            if (c[x] == cur)
                cur++;
            d[to] = d[x] + 1;
            c[to] = cur++;
            s.insert(c[to]);
            dfs(to, x);
        }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pii> es;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].pb(v);
        adj[v].pb(u);
        es.emplace_back(u, v);
    }
    dfs();
    cout << sz(s) << "\n";
    for (pii x : es) {
        if (d[x.x] < d[x.y])
            swap(x.x, x.y);
        cout << c[x.x] << "\n";
    }
    return 0;
}

Measured memory_bytes: 14204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef complex<double> point;

#define X real()
#define Y imag()
#define angle(a) (atan2((a).imag(), (a).real()))
#define vec(a, b) ((b) - (a))
#define same(p1, p2) (dp(vec(p1, p2), vec(p1, p2)) < EPS)
#define dp(a, b) ((conj(a) * (b)).real())
#define cp(a, b) ((conj(a) * (b)).imag())
#define length(a) (hypot((a).imag(), (a).real()))
#define normalize(a) (a) / length(a)
#define rotateO(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotateO(vec(about, p), ang) + about)
#define reflectO(v, m) (conj((v) / (m)) * (m))
#define clr(a, b) memset(a, b, sizeof(a));

const ll N = 100005;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

ll n, a[N], b[N], c[N];
ll memo[N][4];

ll solve(ll i, ll j)
{
	if(i == n)
		return 0;

	ll& ret = memo[i][j];

	if(~ret)
		return ret;

	ret = 0;

	if(j != 0)
		ret = max(ret, solve(i + 1, 0) + a[i]);
	if(j != 1)
		ret = max(ret, solve(i + 1, 1) + b[i]);
	if(j != 2)
		ret = max(ret, solve(i + 1, 2) + c[i]);
	return ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    clr(memo, -1);
    cin >> n;
    for(int i = 0; i < n; i++)
    	cin >> a[i] >> b[i] >> c[i];
    cout << solve(0, 3) << endl;
}

Measured memory_bytes: 10368
num = 1

while True:
    n = int(input())
    if not n:
        break
    x0, y0 = map(float, input().split())
    prx, pry = x0, y0
    area = 0
    for _ in range(n - 1):
        x, y = map(float, input().split())
        area += (prx * y - x * pry)
        prx, pry = x, y
    area += (prx * y0 - x0 * pry)
    area /= 2
    print(num, abs(area))
    num += 1
    input()

Measured memory_bytes: 7640
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
class Main{

    static int[] a;
    static int[] b;
    static int N;
    static int getMaxk(){
        int res = -1;
        for(int i=0;i<N;++i){
            for(int j=1;j<a[i];++j){
                if(a[i]==b[i])continue;
                if(a[i]%j==b[i] || a[i]%j > b[i]*2){
                    res = Math.max(res,j);
                    break;
                }
            }
        }
        return res;
    }

    static boolean chk(){
        for(int i=0;i<N;++i)if(a[i]!=b[i])return false;
        return true;
    }

    static class Edge{
        int to,cost;
        Edge(int to,int cost){
            this.to=to;
            this.cost=cost;
        }
    }

    static List<Edge> edgeList[];
    static int getMaxCost(int s,int t,int res){
        if(s==t)return res;
        int c = 100;
        if(s<=2*t)return 100;
        for(Edge e : edgeList[s]){
            c=Math.min(c,getMaxCost(e.to, t, Math.max(e.cost,res)));
        }
        return c;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        N = scan.nextInt();
        a = new int[N];
        b = new int[N];
        for(int i=0;i<N;++i)a[i]=scan.nextInt();
        for(int i=0;i<N;++i)b[i]=scan.nextInt();
        long ans = 0;

        edgeList = new ArrayList[51];
        for(int i=1;i<=50;++i)edgeList[i]=new ArrayList<>();
        for(int i=1;i<=50;++i){
            for(int j=1;j<=i;++j){
                edgeList[i].add(new Edge(i%j,j));
            }
        }



        while(true){
            int k = 0;
            for(int i=0;i<N;++i)k = Math.max(k,getMaxCost(a[i], b[i], 0));
            if(k==0)break;
            if(k==100){
                ans=-1;
                break;
            }
            for(int i=k;i<=50;++i){
                edgeList[i].get(k-1).cost=0;
            }
            ans += ((long)1<<k);
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 22740
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i32,
        y: i32,
    }
    // annotate for rust-analyzer
    let x: i32 = x;
    let y: i32 = y;

    println!(
        "{}",
        if y % 2 == 0 && x * 2 <= y && y <= x * 4 {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long double p[n+1], dp[n+1][n+1], s=0.0;
    for(int i=1;i<=n;i++) cin>>p[i];
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++) dp[i][0]=dp[i-1][0]*(1.0-p[i]);
    for(int i=1;i<=n;i++) dp[i][i]=dp[i-1][i-1]*p[i];
    for(int i=1;i<=n;i++) for(int j=1;j<=i-1;j++) dp[i][j]=(dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i]);
    for(int i=(n+1)/2;i<=n;i++) s+=dp[n][i];
    cout<<setprecision(10)<<s;
}

Measured memory_bytes: 85604
#include<stdio.h>
int A[1000000], n;

int binarySearch(int key){
	int left = 0;
	int right = n;
	int mid;

	while(left < right){
		mid = (left + right) / 2;
		if (key ==A[mid] ) return 1;
		if (key > A[mid]) left = mid + 1;
		else if(key < A[mid]) right = mid;
	}
	return 0;
}

int main(){
	int i, q, k, sum = 0;
	
	scanf("%d" , &n);
	for (i = 0; i < n; i++){
		scanf("%d", &A[i]);
	}
	
	scanf("%d", &q);
	for(i = 0; i < q; i++){
		scanf("%d", &k);
		if (binarySearch(k)) sum++;
	}
	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 3000
#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() {
    int a, b, c; cin >> a >> b >> c;
    if (a + b + c <= 21)
        cout << "win" << endl;
    else
        cout << "bust" << endl;
}


Measured memory_bytes: 256
import sys

in1 = sys.stdin.readlines()
N = int(in1[0])
#N = 10 ** 18
#N = 2
"""
0 + 0 = 0
0 x 0 = 0

1 + 0 = 1
1 x 0 = 1

2 + 0 = 2
2 x 0 = 2
1 + 1 = 2
1 x 1 = 0

3 + 0 = 3
3 x 0 = 3
2 + 1 = 3
2 x 1 = 3
"""
p = 10 ** 9 + 7

def f(n):
    if n in d:
        return d[n]
    d[n] = f(n // 2) + f((n - 1) // 2) + f((n - 2) // 2)
    return d[n]

d = {0: 1, 1: 2}
print(f(N) % p)


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b;
    cin>>a>>b;
    cout<<(a/__gcd(a,b)*b)<<endl;
}

Measured memory_bytes: 256