akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll a[N],b[N],pre[N];
int main()	{
	int n,m;
	ll k;
	scanf("%d%d%lld",&n,&m,&k);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]),a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++) scanf("%lld",&b[i]),b[i]+=b[i-1];
	ll ans=0,mx=0;
	for(int i=0;i<=m;i++){
		int p=upper_bound(a,a+n+1,k-b[i])-a;
		p--;
		if(a[p]+b[i]>k) break;
		if(p+i>ans) {
			ans=p+i;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int getScore(int num, char suit, char H, char R){
	int res = 0;
	if(suit == H) res += 100;
	else if(suit == R) res += 50;
	return res + num;
} 

int main(){
	char c;
	while(cin >> c){
		if(c=='#') break;
		int num[4][13];
		char suit[4][13];
		int read = 0;
		string buf;
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				cin >> buf;
				suit[i][j] = buf[1];
				if(isdigit(buf[0])) num[i][j] = (buf[0]-'0');
				if(buf[0]=='T') num[i][j] = 10;
				if(buf[0]=='J') num[i][j] = 11;
				if(buf[0]=='Q') num[i][j] = 12;
				if(buf[0]=='K') num[i][j] = 13;
				if(buf[0]=='A') num[i][j] = 14;
			}
		}
		int score = 0;
		for(int i=0;i<13;i++){
			int pos = read;
			char st = suit[read][i];
			int maxScore = getScore(num[read][i], suit[read][i], c, st);
			for(int j=read+1;j<read+4;j++){
				int score = getScore(num[j%4][i], suit[j%4][i], c, st);
				if(maxScore < score){
					pos = j%4;
					maxScore = score;
				}
			}
			read = pos;
			if(read%2==0) score++;
		}
		if(score > 6) cout << "NS " << score-6 << endl;
		else          cout << "EW " << 13-score-6 << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;
	int N = S.size();

	bool F = true;

	int i = 0, j = N - 1;
	while (i < j) {
		if (S[i] != S[j]) {
			cout << "No" << endl;
			return 0;
		}
		i++;
		j--;
	}
	i = 0, j = (N - 1) / 2 - 1;
	while (i < j) {
		if (S[i] != S[j]) {
			cout << "No" << endl;
			return 0;
		}
		i++;
		j--;
	}
	i = (N + 3) / 2 - 1, j = N - 1;
	while (i < j) {
		if (S[i] != S[j]) {
			cout << "No" << endl;
			return 0;
		}
		i++;
		j--;
	}


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



Measured memory_bytes: 384
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



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

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}




	return 0;
}


Measured memory_bytes: 256
#s = input()
#n = int(input())
#a, b, c = map(int, input().split())
#p = list(map(int, input().split()))

s = input()
t = input()
cnt = 0
for i in range(len(s)):
    a = s[i:i+1]
    b = t[i:i+1]
    if(a != b):
        cnt += 1
print(cnt)

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

#define KMAX 26

void oriSort(int *phead);

int main(void){
	int N,K,phead[KMAX],res,tmp;
	for(int i=0;i<KMAX;i++){phead[i]=0;}
	vector<string> p;
	string str;

	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>str;
		p.push_back(str);
		phead[str[0]-'A']++;
	}

	for(res=1;res<=N/K;res++){
	tmp=0;
		for(int i=0;i<KMAX;i++){
			if(res<phead[i]){tmp=tmp+res;}
			else{tmp=tmp+phead[i];}
		}
		if(tmp<res*K)break;
	}
	res--;
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
int main() {
	long N = 0;
	cin >> N;
	vector<long>A(N);
	for (long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	long long ans = 0;
	for (long i = 0; i < N; i++) {
		ans += A.at(i) - i - 1;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3588
N,M = map(int,input().split())
INF = float("inf")
d = [INF]*N
edges = [None]*M
for i in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    edges[i] = (a,b,-c)
d[0] = 0
for cnt in range(N):
    update = False
    for i in range(M):
        a,b,c = edges[i]
        if d[b] > d[a]+c:
            d[b] = d[a]+c
            update = True
            if cnt == N-1 and b == N-1:
                print("inf")
                exit(0)
    if not update:
        break
print(-d[N-1])

Measured memory_bytes: 3316
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
A = LI()

# 買った株は翌日全て売ってよい
# 貪欲に

money = 1000
for i in range(N-1):
    if A[i] < A[i+1]:
        money += (A[i+1]-A[i])*(money//A[i])
print(money)


Measured memory_bytes: 61812
import scala.io.StdIn._

object Main extends App {
  val n = readInt()
  val lengths = readLine().split(' ').map(_.toInt).toSeq
  
  val maxLength = lengths.max
  val sum = lengths.sum
  val result = if (maxLength < sum - maxLength) "Yes" else "No"
  println(result)
}

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

int main()
{
  int X;
  string Y;
  while(cin >> X >> Y, X || Y != "0") {

    int ret = -1, cnt = 0;
    vector< int > ans;

    for(int i = 0; i < 1 << (Y.size() - 1); i++) {
      int now = 0, sum = 0;
      vector< int > nums;
      for(int j = 0; j < Y.size(); j++) {
        now = now * 10 + Y[j] - '0';
        if(j == Y.size() - 1 || (i >> j) & 1) {
          sum += now;
          nums.push_back(now);
          now = 0;
        }
      }
      if(sum <= X && ret <= sum) {
        if(ret == sum) ++cnt;
        else ret = sum, cnt = 1, swap(ans, nums);
      }
    }
    if(cnt == 0) cout << "error" << endl;
    else if(cnt > 1) cout << "rejected" << endl;
    else {
      cout << ret;
      for(int v : ans) cout << " " << v;
      cout << endl;
    }
  }
}

Measured memory_bytes: 3160
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

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

const int N = 1e5 + 5;

/***************************************************************************/

vector<int> adj[N];
set<int> ds[N];

int vis[N];
int deg[N];

void dfs(int v, int p, int nt) {
	if(deg[v] >= 4) {
		ds[v].insert(p);
		ds[p].insert(v);
		return;
	}
	vis[v] = 1;
	for(auto it : adj[v]) {
		if(it == nt) continue;
		if(vis[it]); else {
			dfs(it, p, v);
		}
	}
}

int main() {

	boost;
	int n, m; cin>>n>>m;
	for(int i=1; i<=m; i++) {
		int a, b; cin>>a>>b;
		deg[a]++, deg[b]++;
		adj[a].pb(b), adj[b].pb(a);
	}
	int is6 = 0, isOk = 1, is4 = 0;
	for(int i=1; i<=n; i++) {
		if(deg[i] & 1) isOk = 0;
		if(deg[i] >= 6) is6 = 1;
		if(deg[i] >= 4) is4++;
	}
	if(isOk); else {
		cout<<"No\n";
		exit(0);
	}
	if(is6) {
		cout<<"Yes\n";
		exit(0);
	}
	isOk = 0;
	for(int i=1; i<=n; i++) {
		if(deg[i] >= 4) {
			for(auto it : adj[i]) {
				if(vis[it]); else {
					dfs(it, i, i);
				}
			}
			vis[i] = 1;
			if((int) ds[i].size() >= 2) {
				isOk = 1;
				break;
			}
		}
	}
	if(isOk) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 13440
def solve():
    answers = [[] for i in range(31)]
    ans = []
    def square(n, rest, limit):
        if rest == 0:
            answers[n].append(ans[:])
        else:
            for i in range(rest, 0, -1):
                if i > limit:
                    continue
                ans.append(i)
                square(n, rest - i, i)
                ans.pop()
    
    import sys
    for n in map(int, sys.stdin.readlines()):
        if n == 0:
            break
        a = answers[n]
        if not a:
            square(n, n, n)
        for l in a:
            print(*l)

solve()


Measured memory_bytes: 8180
/******************************
＜解法＞
最初に、簡単のため D=1 の場合を考えると、
入力されたN個の点を、それぞれ任意の場所に移動できることがわかる
（ただし異なる点を同じ座標に置いてはいけない）
なので、答（正方形の一辺の長さの最小値）は
sqrt(N)の小数点以下を切りあげた値-1 となる。

一般のDに対しては、
入力された点を、x,y それぞれ modD することにより、D*D個のグループに分類する。
それぞれのグループについて上記と同じ考察をすれば、
小さい正方形や、長方形で2辺の長さの差が1というものに変形することによって
全体の収まる正方形領域を小さくする、という問題になる。

各グループの点の個数を数えて、その最大値を

****************************/


#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


const int max_comb=120000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<ll> a(n),s(n+1);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        s[i+1]=s[i]+a[i];
    }
    pre_comb();

    vector<ll> p(n-1),sp(n);
    for(i=0; i<n-1; i++) {
        p[i]=perm(i,i)*minv(perm(i+2,i+2))%MOD;
        p[i]=p[i]*perm(n-1,n-1)%MOD;
        sp[i+1]=(sp[i]+p[i])%MOD;
    }

    ll ans=0;
    int j;
    for(i=0; i<n-1; i++) {
        {
            ll tmp=(MOD+perm(n-1,n-1)-sp[n-i-2])%MOD;
            ll ans0=tmp*((a[n-1]-a[i])%MOD)%MOD;
            ans=(ans+ans0)%MOD;
        }
#if 1
        if(i<n-1) {
            ll tmp=p[i];
            ll aaa=(s[n-1]-s[i+1]-s[n-i-2]+MOD+MOD)%MOD;
            ll ans0=tmp*aaa%MOD;
            //ll ans0=tmp*((a[n-2]-a[i])%MOD)%MOD;
            ans=(ans+ans0)%MOD;
        }
#else
        for(j=i+1; j<n; j++) {
            if(j==n-1) {
                ;
            }
            else {
                ll tmp=p[j-i-1];
                printf("%d,%d  %lld %lld\n", i,j,tmp, a[j]-a[i]);
                ll ans0=tmp*((a[j]-a[i])%MOD)%MOD;
                ans=(ans+ans0)%MOD;
            }
        }
#endif
    }
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int N,Z,W; cin >> N >> Z >> W;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	if(N == 1){
		cout << abs(a[0]-W) << endl;
		return 0;
	}
	int ans = max(abs(a[N-1]-W),abs(a[N-1]-a[N-2]));
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;


int gcd(int p, int q) {
	int upper, lower, r;

	if (p >= q) upper = p, lower = q;
	else upper = q, lower = p;
	r = upper % lower;
	if (r)return gcd(lower, r);
	else return lower;
}

int main() {
	ll N, M; cin >> N >> M;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	ll ans = 0;
	ll sd = 0, p = 1, temp = a[0];
	while (temp % 2 == 0) { temp /= 2, sd++; }
	for (int i = 0; i < N ; i++) {
		ll cnt = 0, temp = a[i];
		while (temp % 2 == 0) {
			temp /= 2;
			cnt++;
		}

		if (sd != cnt) {
			p = M + 1;
			break;
		}
		p = p * (a[i] / 2) / gcd(p, a[i] / 2);
		//cout << "gcd=" << gcd(p, a[i] / 2) << endl;
		//cout << "p=" << p << endl;
		
		
	}

	ans = (M / p + 1) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M;
  cin >> N >> M;
  vi a(N+1);
  for(int x = 0; x<M; x++){
    int t;
    cin >> t;
    a[t]=1;
  }
  vi memo(N+1);
  memo[0] = 1;
  for(int x = 1; x<=N; x++){
    if(a[x]==1){
      memo[x]=0;
      continue;
    }
    if(x-1>-1 && memo[x-1])
      memo[x]+=memo[x-1]%1000000007;
    if(x-2>-1 && memo[x-2])
      memo[x]+=memo[x-2]%1000000007;
    memo[x]%1000000007;
  }
  cout << memo[N]%1000000007 << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
import java.lang.Math;

public class Main {
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double n = sc.nextDouble();
		sc.close();
		long intn = (long)n;
		long t = (long)Math.sqrt(n);
		long ans = Long.MAX_VALUE;
		for(int i = 1;i <= t;i++){
				if(intn%i == 0){
					long tmp = intn/i;
					long ans_ = i + tmp - 2;
					if(ans_ < ans){
					ans = ans_;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25296
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define Mod 998244353
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
int main()
{
    ll N;
    cin>>N;
    ll ans=0;
    vector<ll> vec;
    if(N==1)
    {

        cout<<0;
    }
    else
    {
        ll i;
        for(i=2;i*i<=N;i++)
        {
            ll cnt=0;
            while(N%i==0)
            {
                N/=i;
                cnt++;
            }
            if(cnt>0)
            {
                vec.push_back(cnt);
            }
        }
        if(N>1)
            vec.push_back(1);

        for(i=0;i<vec.size();i++)
        {
            ll g=vec[i];
            ll lo=1,hi=1000;
            ll res,mid;
            while(lo<=hi)
            {
                mid=(lo+hi)/2;
                ll f=mid*(mid+1);
                f/=2;
                if(f>g)
                {
                    hi=mid-1;
                }
                else if(f<=g)
                {
                    res=mid;
                    lo=mid+1;
                }

            }
            ans+=res;
        }
        cout<<ans;
    }


}


Measured memory_bytes: 3632
k = gets.to_i
s = gets.chomp.size

M = 10 ** 9 + 7

pow_25 = Array.new(k+1, 1)
pow_26 = Array.new(k+1, 1)
k.times do |i|
    pow_25[i+1] = pow_25[i] * 25 % M
    pow_26[i+1] = pow_26[i] * 26 % M
end

pow =->(x,n){n == 0 ? 1 : (n.odd? ? x : 1) * pow.(x ** 2 % M, n/2) % M}

fac = Array.new(k+s, 1)
(k+s-1).times {|i| fac[i+1] = fac[i] * (i+1) % M}

inv_fac = Array.new(k+s)
inv_fac[-1] = pow.(fac[-1], M-2)
(k+s-2).downto(0) {|i| inv_fac[i] = inv_fac[i+1] * (i+1) % M}

com =->(a,b){fac[a] * inv_fac[b] * inv_fac[a-b] % M}

ans = 0
(k+1).times do |i|
    ans = (ans + com.(s+i-1, i) * pow_25[i] * pow_26[k-i]) % M
end

p ans


Measured memory_bytes: 63440
#include <iostream>
#include <math.h>
#include <cmath>
#include <iomanip>
using namespace std;

long double x[3], y[3], l[3], a[3], r[3];
	
bool check() {
	for (int i = 0; i < 3; i++) {
		if (x[i] != 0) {
			return true;
		}
		if (y[i] != 0) {
			return true;
		}
	}
	return false;
}


int main() {
	cout << fixed;
	cout << setprecision(6);

	int tmp;
	bool first = true;
	long double value;
	long double opp, hyp, adj;
	long double dist;
	long double diffx[2], diffy[2];
	long double dirx, diry;

	for (int i = 0; i < 3; i++) {
		cin >> x[i];
		cin >> y[i];
	}

	int itr = 0;
	while (check()) {
		//cout << itr++ << endl;
		for (int i = 0; i < 3; i++) {
			tmp = (i+1) % 3;

			//cout << pow(x[i] - x[tmp], 2) << " " << pow(y[i] - y[tmp], 2) << endl;
			l[i] = sqrtl(pow(x[i] - x[tmp], 2) + pow(y[i] - y[tmp], 2));
		}

		for (int i = 0; i < 3; i++) {
			/*
			hyp = 2*l[i]*l[(i+2)%3];
			adj = pow(l[i], 2) + pow(l[(i+2)%3], 2) - pow(l[(i+1)%3], 2);
			opp = sqrtl(pow(hyp,2)-pow(adj,2));

			a[i] = (hyp - adj) / opp;
			*/

			a[i] = pow(l[i],2) + pow(l[(i+2)%3],2) - pow(l[(i+1)%3],2);
			a[i] /= 2*l[i]*l[(i+2)%3];
			a[i] = acos(a[i]);
			a[i] = tan(a[i]/2);
			//cout << a[i] << endl;
		}


		long double diff = max(l[0],l[2]);
		long double diff2;
		r[0] = 0.1;

		while (diff > 1e-10) {
			r[0] += diff;
			//cout << "START: " << r[0] << endl;

			r[1] = 0.1;
			diff2 = l[0];
			while (diff2 > 1e-10) {
				r[1] += diff2;

				if (r[0]/a[0] + 2*sqrtl(r[0]*r[1]) + r[1]/a[1] > l[0]) {
					r[1] -= diff2;
					diff2 /= 2;
				}
			} 

			r[2] = 0.1;
			diff2 = l[2];
			while (diff2 > 1e-10) {
				r[2] += diff2;

				if (r[0]/a[0] + 2*sqrtl(r[0]*r[2]) + r[2]/a[2] > l[2]) {
					r[2] -= diff2;
					diff2 /= 2;
				}
			} 
			
			value = r[1]/a[1] + 2*sqrtl(r[1]*r[2]) + r[2]/a[2];

			if (value < l[1]) {
				r[0] -= diff;
				diff /= 2;
			} 
		}

		if (first) {
			first = false;
		} else {
			cout << endl;
		}

		cout << r[0];
		for (int i = 1; i < 3; i++) {
			cout << " " << r[i];
		}

		for (int i = 0; i < 3; i++) {
			cin >> x[i];
			cin >> y[i];
		}
	}

	return 0;
}


Measured memory_bytes: 3412
#include <iostream>
#include <stack>
using namespace std;
static const int N =100;
static const int white=0;
static const int gray=1;
static const int black=2;

int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u){
    for (int v=nt[u];v<n;v++){
        nt[u] = v+1;
        if(M[u][v])return v;    }
        return -1;
}

void dfs_visit(int r){
    for(int i=0;i<n;i++)nt[i]=0;
    
    stack<int>s;
    
    s.push(r);
    color[r]=gray;
    d[r]=++tt;
    
    while(!s.empty()){
        int u=s.top();
        int v=next(u);
        if(v!=-1){
            if(color[v]==white){
                color[v]=gray;
                d[v]=++tt;
                s.push(v);
            }
        }else{
            s.pop();
            color[u]=black;
            f[u]=++tt;
        }
    }
}
void dfs(){
    for(int i=0;i<n;i++){
        color[i]=white;
        nt[i]=0;
    }
    tt=0;
    for(int u=0;u<n;u++){
        if(color[u]==white)dfs_visit(u);
    }
    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
        
    }
    }
    int main(){
        int u,k,v;
        cin>>n;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++)M[i][j]=0;
        }
        for(int i=0;i<n;i++){
            cin>>u>>k;
            u--;
            for(int j=0;j<k;j++){
                cin>>v;
                v--;
                M[u][v]=1;
            }
        }
        dfs();
        return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int n=18;
    char a[n];
    for (int i=0; i<=n; i++)
        scanf("%c",&a[i]);
    for(int i=0; i<=n; i++)
    {
        if (a[i]==',')
            printf(" ");
        else
            printf("%c",a[i]);
    }
}


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

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

	int n,k;
	cin>>n>>k;

	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n);
	int dp[k+1]={0};
	for(int i=0;i<arr[0];i++)
		dp[i]=0;
	for(int i=0;i<n;i++)
		dp[arr[i]]=1;

	for(int i=1;i<=k;i++)
	{
		if(dp[i]==0)
		{
			for(int j=0;j<n;j++)
			{
				if(i+arr[j]<=k)
					dp[i+arr[j]]=1;
			}
		}
	}

	if(dp[k]==1)
		cout<<"First";
	else
		cout<<"Second";


}

Measured memory_bytes: 640
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 200005;


void task(){
    int n; cin >> n;
    cout<<(n%1000==0?0:1000-(n%1000))<<endl;
}

int main(){
        _
        int T = 1; //cin >> T;
        while(T--){
            task();
        }
return 0;
}



Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main(void){
    char op;
    int a,b;
    while(1){
        cin >> a >> op >> b;
        if (op=='?') break;
        else if(op=='+') cout << a+b << endl;
        else if(op=='-') cout << a-b << endl;
        else if(op=='*') cout << a*b << endl;
        else if(op=='/') cout << a/b << endl;
    }
}



Measured memory_bytes: 3076
#include<stdio.h>
main(){
    char op;
    int ans,in;
    scanf("%d ",&ans);
    while(1){
        scanf("%c",&op);
        if(op=='='){
            printf("%d\n",ans);
            return 0;
        }
        scanf("%d ",&in);
        switch(op){
            case'+':
                ans+=in;
                break;
            case'-':
                ans-=in;
                break;
            case'*':
                ans*=in;
                break;
            case'/':
                ans/=in;
                break;
        }
    }
}

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

int main(){
  int N , K ;
 string S; 
 cin >> N >> K ;
  cin >> S;
  char d = S.at(K-1);
  if (d == 'A') d = 'a';
  if (d == 'B') d = 'b';
  if (d == 'C') d = 'c';
  
  S.at(K-1) = d;
  
  cout << S << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {

  double d1,d2,d3,d4;
  int i,j,k,l,n;
  double x[1020] = {0};
  double y[1020] = {0};
  double z[1020] = {0};
  double o,p,q,max;
  max = -1;
  o=0;
  p=0;
  q=0;
  d1 = 0;
  d2 = 0;
  d3 = 0;
  d4 = 0;

  scanf("%d",&n);

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

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

  for(i=0; i<n;i++) {

    o = (x[i] - y[i]) * (x[i] - y[i]);
    p = (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
    p = p*p;
    p = sqrt(p);
  
    d3 = d3 + p;
    d2 = d2+o;
    d1 = d1 + sqrt(o); 

    if(max < sqrt(o)) {
      max = sqrt(o);
    }

   
  }

  d2 = pow(d2,1.0/2);
  d3 = pow(d3,1.0/3);
  d4 = max;

  printf("%.11lf\n%.11lf\n%.11lf\n%.11lf\n" ,d1,d2,d3,d4);

  return 0;

}



Measured memory_bytes: 2148
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
namespace MY{
	const int maxn = 200005;
	const int oo = 300005;
	int n;
	char s[maxn];
	int next[maxn][30];
	int last[30];
	void pre_work(){
		for(int i = 0; i < 26; i++) last[i] = n;
		for(int i = n - 1; i >= 0; i--){
			last[s[i]-'a'] = i;
			for(int j = 0; j < 26; j++) next[i][j] = last[j];
		}
	}
	int f[maxn];
	int c[maxn];
	void work(){
		f[n] = 1; f[n+1] = 0; // 
		for(int i = n - 1; i >= 0; i--){
			f[i] = oo;
			for(int j = 0; j < 26; j++){
				if(f[next[i][j] + 1] + 1 < f[i]){
					f[i] = f[next[i][j]+1] + 1;
					c[i] = j;
				}
			}
		}
		int tmp = 0;
		while(tmp < n){
			printf("%c",c[tmp]+'a');
			tmp = next[tmp][c[tmp]] + 1;
		}
		puts("");
	}
}
int main(){
#ifdef __APPLE__
	freopen("main.in","r",stdin);
#endif
	scanf(" %s", MY::s); MY::n = strlen(MY::s);
	MY::pre_work();
	MY::work();
	return 0;
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
int main () {
  int ans = 0;
  int N, X, T;
  cin >> N >> X >> T;
  while (N) {
    if (N >= X) N -= X;
    else N = 0;
    ans += T;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <cstdlib>
#define INF 998244353

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pi;

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}



int main() {
    int N;
    cin >> N;
    for(int i = 1 ;i <= 50000;i++){
        int result = 1.08*i;
        if(N==result){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;




}










Measured memory_bytes: 256
function Main(input){
	input=input.split(/\n|\s/);
	input.forEach(function(e,i,a){a[i]=Number(a[i]);});
	var arr=input.splice(2,input.length-1);
	for(var i=0;i<input[0];i=(i+1)|0){input[1]-=arr[i];}
	arr.sort(ArraySortNumeric);
	function ArraySortNumeric(prev,next){return (prev-next);}
	console.log(input[0]+(input[1]/arr[1]|0));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int INF = 1e9 + 7;
const int maxm = 305;
const int maxn = 305;

int n, m, ans;
int jmx[maxn], jmn[maxn], kmx[maxn], kmn[maxn];
int l[maxm], r[maxm], x[maxm];
int f[maxn][maxn];
int row[maxn], col[maxn];

inline bool in(int x, int lb, int rb){ return (x >= lb && x <= rb); }
inline void uadd(int &x, int y){ (x += y) %= INF; }
inline void umul(int &x, int y){ (x = 1ll * x * y % INF); }
inline void umin(int &x, int y){ x = min(x, y); }
inline void umax(int &x, int y){ x = max(x, y); }

int main(){
	scanf("%d%d", &n, &m);
	REP(i, 0, n)
		jmx[i] = kmx[i] = n;
	FOR(i, 0, m){
		scanf("%d%d%d", l + i, r + i, x + i);
		if(x[i] == 1)
			umin(jmx[r[i]], l[i] - 1), umin(kmx[r[i]], l[i] - 1);
		else if(x[i] == 2)
			umax(jmn[r[i]], l[i]), umin(kmx[r[i]], l[i] - 1);
		else
			umax(jmn[r[i]], l[i]), umax(kmn[r[i]], l[i]);
	}
	
	f[0][0] = 1;
	row[0] = col[0] = 1;
	REP(i, 1, n){
		REP(j, 0, max(0, i - 1)){
			uadd(f[i - 1][j], row[j]);
			row[j] = 0;
		}
		REP(k, 0, max(0, i - 2)){
			uadd(f[i - 1][k], col[k]);
			col[k] = 0;
		}
		REP(j, 0, max(0, i - 1)) REP(k, 0, max(0, j - 1)) if(!in(j, jmn[i], jmx[i]) || !in(k, kmn[i], kmx[i]))
			f[j][k] = 0;
		REP(j, 0, max(0, i - 1)) REP(k, 0, max(0, j - 1)){
			uadd(row[j], f[j][k]);
			uadd(col[k], f[j][k]);
		}
	}
	
	REP(j, jmn[n], jmx[n]) REP(k, kmn[n], kmx[n])
		uadd(ans, f[j][k]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            int D = in.nextInt();

            System.out.println(Math.min(A, B) + Math.min(C, D));
        }
    }
}


Measured memory_bytes: 27076
//
//  main.cpp
//  ProblemSolving
//
//  Created by Mac mini on 1/7/20.
//  Copyright © 2020 Mac mini. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
using namespace std;
long long int  dp[51][51][900];
int x[52], n, a;

long long int call(int idx, int cnt, int amount) {
	if(idx >= n) {
		if((double)amount / cnt == a)
			return 1;
		return 0;
	}

	if(dp[idx][cnt][amount] != -1) return dp[idx][cnt][amount];

	long long int  ret1 = 0, ret2 = 0;

	ret1 = call(idx + 1, cnt + 1, amount + x[idx]);
	ret2 = call(idx + 1, cnt, amount);

	dp[idx][cnt][amount] = ret1 + ret2;

	return dp[idx][cnt][amount];
}

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

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

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

	cout << call(0, 0, 0) << "\n";

}


Measured memory_bytes: 21968
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
int a, b;


int main(void) {
    scanf("%d %d", &a, &b);

    int s = min(a, b);
    int l = max(a, b);
    rep(i, 0, l) printf("%d", s);
    printf("\n");

	return 0;
}


Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

#ifdef SHIK
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) do { \
    fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
    _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif

template<typename T>
void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( long long &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }

void R() {}
template<typename T, typename... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<typename T>
void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
template<typename T>
void _W( const vector<T> &x ) {
    for ( auto i=x.cbegin(); i!=x.cend(); i++ ) {
        if ( i!=x.cbegin() ) putchar(' ');
        _W(*i);
    }
}

void W() {}
template<typename T, typename... U>
void W( const T& head, const U&... tail ) {
    _W(head);
    putchar(sizeof...(tail)?' ':'\n');
    W(tail...);
}

#ifdef SHIK
#define FILEIO(...)
#else
#define FILEIO(name) do {\
    freopen(name ".in","r",stdin); \
    freopen(name ".out","w",stdout); \
} while (0)
#endif

// }}}

const int N=1e5+10;
int n,t,a[N],dp[N];
int main() {
    R(n,t);
    REP1(i,1,n) R(a[i]);
    for ( int i=n; i>=1; i-- ) dp[i]=max(a[i],dp[i+1]);
    int mx=0;
    REP1(i,1,n) mx=max(mx,dp[i+1]-a[i]);
    dump(mx);
    int ans=0;
    REP1(i,1,n) if ( dp[i+1]-a[i]==mx ) ans++;
    W(ans);
    return 0;
}


Measured memory_bytes: 1024
/* Fairy dandy tickling the fancy of his lady friend */

#include <iostream>

#include <vector>

#include <algorithm>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

#define rep(i,a,b) for(int i=int(a); i<int(b); i++)

#define rip(i,a,b) for(int i=(int)a; i>=(int)b; i--)

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

#define sz(x) int(x.size())

#define all(v) (v).begin(), (v).end()

#define trace(x) cerr << #x << ": " << x <<endl;



using namespace std;



typedef long long int lli;

typedef pair<lli, lli> ii;

typedef vector<int> vi;

typedef vector<ii> vii;



int main(){

    fastio;

	int l, r; cin>>l>>r;
	int lo = l/2019;
	int hi = r/2019;
	if(hi-lo>=1) cout<<0<<endl;
	else{
		int left=l%2019;
		int right=r%2019;
		int ans=2020;
		rep(i,left,right)
			rep(j,i+1,right+1)
				ans=min(ans, (i*j)%2019);
		cout<<ans<<endl;
	}

    return 0;

}

Measured memory_bytes: 256
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include<iostream>
#include<queue>
using namespace std;
int a,b,x;
int main()
{
	cin>>x>>a>>b;
	if(abs(x-a)<abs(x-b))
		cout<<"A\n";
	else if(abs(x-a)>abs(x-b))
		cout<<"B\n";
		

	
	
	

	return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs ( llong n ) { return ( n < 0 ) ? -n : n; }
    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
}

namespace Rlyeh {

    int h[100100];
    int dp[100100];

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;
        for ( int i = 0; i < n; i++ ) {
            read h[i];
            dp[i+1] = INF;
        }
        for ( int i = 0; i < n; i++ ) {
            for ( int j = 1; j <= 2; j++ ) {
                dp[i+j] = std::min( dp[i+j], dp[i]+abs(h[i]-h[i+j]));
            }
        }
        echo dp[n-1] fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


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

double f(double K, double i, int n) {
    if(K <= i) {
        return n;
    }
    n++;
    f(K, i * 2, n);
}

int main() {
    double N, K;
    cin >> N >> K;
    double ans;
    for(double i = N; i >= 1; i--) {
        double cl = f(K, i, 0);
        ans += (1.0 / N) * pow(1.0 / 2.0, cl);
    }

    printf("%.12f\n", ans);
}


Measured memory_bytes: 384
#include <cstdint>
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main() {
  int64_t N;
  cin >> N;
  
  set<string> gacha;
  for (int64_t n = 0; n < N; ++n) {
    string str;
    cin >> str;
    gacha.insert(str);
  }
  cout << gacha.size() << endl;
  
  return 0;
}


Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}

#define mxn 100005

vector<int>g[mxn];
int lvl[mxn];
int vis[mxn];
int par[mxn];


void bfs(int x)
{
    queue<int>q;
    q.push(x);
    lvl[x]=0;
    vis[x]=1;

    while(!q.empty())
    {
        int u=q.front();
        q.pop();


        for(int v:g[u])
        {
            if(vis[v]) continue;
            vis[v]++;
            lvl[v]=lvl[u]+1;
            par[v]=u;
            q.push(v);
        }
    }

}


int main(){


      int n,m;
      cin>>n>>m;

      for(int i=0;i<m;i++)
      {
          int a,b;
          cin>>a>>b;
          g[a].pb(b);
          g[b].pb(a);
      }



     bfs(1);


     cout<<"Yes"<<endl;
        for(int i=2;i<=n;i++)
     {
         cout<<par[i]<<endl;
     }




return 0;
}



Measured memory_bytes: 11192
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a;
	int sum=0;
	int b;
	cin >> a ;
	for(int i=1; i<=a; i++){
		for(int j=1; j<=a; j++){
			for(int k=1; k<=a; k++){
				b=__gcd(i, j);
				sum+=__gcd(b, k);
				// cout<<__gcd(b, k)<< " ";
			}
		}
	}
	cout <<sum;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define y0    lol
#define y1    lool
#define yn    loool
#define prev  looool
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#ifdef LOCAL
#define rall(x,a) for(x : a)
#else
#define rall(x,a) for(auto x : a)
#endif
#define rng(a) a.begin(), a.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

bool solve(const string& s) {
    if(s[0] != 'A') return false;
    int occ = 0;
    rep(i, 2, s.size() - 2) {
        if(s[i] == 'C') {
            occ++;
        }
    }
    if(occ != 1) return false;
    rep(i, 1, s.size() - 1) {
        if(s[i] == toupper(s[i]) && s[i] != 'C') return false;
    }
    return true;
}

signed main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << (solve(s) ? "AC" : "WA") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long a[100][2];
vector <long long> v[4];

int main() {
    int n, w, ans = 0, i, j, k;
    
    scanf("%d %d", &n, &w);
    
    for (i = 0; i < n; i++) scanf("%lld %lld", &a[i][0], &a[i][1]);
    
    for (i = 0; i < n; i++) v[a[i][0] - a[0][0]].push_back(a[i][1]);
    
    for (i = 0; i < 4; i++) {
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin(), v[i].end());
        
        for (j = 1; j < v[i].size(); j++) v[i][j] += v[i][j - 1];
    }
    
    for (i = 0; i <= v[0].size(); i++) {
        for (j = 0; j <= v[1].size(); j++) {
            for (k = 0; k <= v[2].size(); k++) {
                long long sum = a[0][0] * (i + j + k) + 1 * j + 2 * k;
                int c, t = 0;
                
                if (sum > w) continue;
                
                c = min((w - sum) / (a[i][0] + 3), (long long)v[3].size());
                
                if (i > 0) t += v[0][i - 1];
                if (j > 0) t += v[1][j - 1];
                if (k > 0) t += v[2][k - 1];
                if (c > 0) t += v[3][c - 1];
                
                ans = max(ans, t);
            }
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    
    double A = sc.nextDouble();
    double B = sc.nextDouble();
    double H = sc.nextDouble();
    double M = sc.nextDouble();
    
    double angleH = (H/12 + M/60/12) * Math.PI*2;
    double angleM = M / 60 * Math.PI*2;
    
    double difference = angleH - angleM;
    
    double cosTheta = Math.cos(difference);
    
    double answer = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - (2*A*B*cosTheta));
    
    System.out.println(answer);
  }
}

Measured memory_bytes: 37484
#include <bits/stdc++.h>
using namespace std;
string func(string s, string t, int n, int m)
{
    int arr[n+1][m+1];
    for(int i=0; i<=n; i++)
    {
        for(int j=0; j<=m; j++)
        {
            if(i==0  ||  j==0)
            {
                arr[i][j] = 0;
            }
            else if(s[i-1]==t[j-1])
            {
                arr[i][j] = 1 + arr[i-1][j-1];
            }
            else
            {
                arr[i][j] = max(arr[i-1][j],  arr[i][j-1]);
            }
        }
    }
    string ans;
    int i=n, j=m;
    while(i>0 &&  j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans += s[i-1];
            i--; j--;
        }
        else if(arr[i-1][j]>arr[i][j-1])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    return ans;
}

int main()
{
    string s, t;
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    string ans = func(s, t, n, m);
    for(int i=ans.length()-1; i>=0; i--)
    {
        cout<<ans[i];
    }
    return 0;
}


Measured memory_bytes: 35456
#include <stdio.h>
#include <stdlib.h>
#include <string.h> 

int top,S[1000];

void push(int x) {
    S[++top]=x;
}

int pop() {
    top--;
    return S[top+1];
}

int main() {
    int a,b;
    top=0;
    char s[100];
    while (scanf("%s",s)!=EOF) {
        if (s[0]=='+') {
            a=pop(); b=pop();
            push(a+b);
        } else if (s[0]=='-') {
            b=pop(); a=pop();
            push(a-b);
        } else if (s[0]=='*') {
            a=pop(); b=pop();
            push(a*b);
        } else {
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
    return 0;
}


Measured memory_bytes: 2144