akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, M;
vector<int> AB[101010];
int dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        AB[a].push_back(b);
    }

    rep(i, 1, N + 1) {
        chmax(dp[i], dp[i - 1]);
        fore(j, AB[i]) chmax(dp[j], dp[i] + 1);
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll commax(ll x, ll y, ll z) {
	ll tmp = x;
	tmp = max(tmp, y);
	tmp = max(tmp, z);
	return tmp;
}
ll commin(ll x, ll y, ll z) {
	ll tmp = x;
	tmp = min(tmp, y);
	tmp = min(tmp, z);
	return tmp;
}
int main() {
	ll x, y;
	cin >> x >> y;
	ll ans = 0;
	if (x % 3 == 0) { // 縦に分割
		cout << 0;
		return 0;
	}
	else ans = y;
	if (y % 3 == 0) { // 横に分割
		cout << 0;
		return 0;
	}
	else ans = min(ans, x);
	int i;
	for (i = 1; i <= (x + 1) / 2; i++) { // 入出力例2のような切り分け方
		ll y1 = y / 2;
		ll y2 = y - y1;
		ll s1 = i * y;
		ll s2 = (x - i) * y1;
		ll s3 = (x - i) * y2;
		ll diff = commax(s1, s2, s3) - commin(s1, s2, s3);
		ans = min(ans, diff);
	}
	for (i = 1; i <= (y + 1) / 2; i++) { // 入出力例3のような切り分け方
		ll x1 = x / 2;
		ll x2 = x - x1;
		ll s1 = i * x;
		ll s2 = (y - i) * x1;
		ll s3 = (y - i) * x2;
		ll diff = commax(s1, s2, s3) - commin(s1, s2, s3);
		ans = min(ans, diff);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;		
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b) 
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	int n;
	cin >> n;
	unordered_map<ll, int> a;
	for (int i = 0; i < n; i++)
	{
		ll in;
		cin >> in;
		if (a.find(in) == a.end())
			a[in] = 0;
		a[in]++;
	}

	ll r = 0;

	for (auto i = a.begin(); i != a.end(); i++)
		if (i->first == i->second)
			continue;
		else if (i->first > i->second)
			r += i->second;
		else
			r += i->second - i->first;
	printf("%lld", r);
	return 0;
}


Measured memory_bytes: 5536
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N,T;
    cin>>N>>T;
    vector<pair<ll,ll>> A(N);
    rep(0,i,N){
        cin>>A[i].first;
        cin>>A[i].second;
    }
    //解法２
    sort(A.begin(),A.end());
    ll dp[N+1][T+1];
    rep(0,i,N)rep(0,j,T)dp[i][j]=0;
    ll ans=0;
    rep(0,i,N){
        ll x=A[i].first,y=A[i].second;
        rep(0,j,T+1){
            dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
            ll nj=x+j;
            if(nj<T)dp[i+1][nj]=max(dp[i+1][nj],dp[i][j]+y);
            //if(i==N-2)cout<<dp[i+1][j]<<endl;
        }
        ans=max(ans,dp[i][T-1]+y);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,N;
  int S=0;
  cin>>K>>N;
  vector<int>vec(N);
  vector<int>ve(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
    if(0<X){
      ve.at(X-1)=abs(vec.at(X)-vec.at(X-1));
    }
  }
  ve.at(N-1)=K-vec.at(N-1)+vec.at(0);
  sort(ve.begin(), ve.end());
  for(int X=0;X<N-1;X++){
    S+=ve.at(X);
  }
  cout<<S<<endl;
}

Measured memory_bytes: 4792
#include <stdio.h>

int main(void) {
    int a, b, i;

    scanf("%d %d", &a, &b);

    if(a > b) {
        for(i = 0; i < a; i++) {
            printf("%d", b);
        }
    } else {
        for(i = 0; i < b; i++) {
            printf("%d", a);
        }
    }

    return 0;
}

Measured memory_bytes: 128
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
p = [int(x) for x in input().split()]
p.sort()
q = len(p)
index = 0
ans = -1
count = 101
for i in range(0, 102):
  if index < q and p[index] == i:
    index += 1
    continue
  if count > abs(i-x):
    count = abs(i-x)
    ans = i
print(ans)

Measured memory_bytes: 9200
#include <stdio.h>
int main(int argc, const char * argv[]) {
    int H, W, i, x, y;
    for(;scanf("%d%d", &H, &W);){
        if(H == 0 && W == 0){break;}
        for(i=1; i<=H;i++){
            for(x=1;x<=W;x++){
                printf("#");}
            printf("\n");}
        printf("\n");}
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, s;
  cin >> n >> s;
  vl a(n);
  rep(i, n) cin >> a[i];
  mint dp[s + 1] = {}, ans = 0;
  rep(i, n) {
    dp[0] += 1;
    for(int j = s; j >= 0; j--) {
      int nj = j + a[i];
      if(nj <= s) dp[nj] += dp[j];
    }
    ans += dp[s];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def oddline(l: int):
    "print # and . taking turns for l-length"
    print("".join(["." if n % 2 == 0 else "#" for n in range(l)]))


def evenline(l: int):
    "print . and # taking turns for l-length"
    print("".join(["#" if n % 2 == 0 else "." for n in range(l)]))


def buildboard(s: int):
    "print a checked board with given size"
    for r in range(s[0]):
        if r % 2 == 0:
            evenline(d[1])
        else:
            oddline(d[1])
    print()  # for a blank line


while 1:
    d = tuple(map(int, input().split()))
    if d[0] == d[1] == 0:
        break
    buildboard(d)




Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <algorithm>
// #include <cmath>
// #include <math.h>
using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int a, b;
    vector<int> d(N+10, 0);
    for (int i = 0; i<M; ++i){
        cin >> a >> b;
        d[a] += 1;
        d[b] += 1;
    }
    for (int i=1; i<=N; ++i) cout << d[i] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;
int a[100010];
int l[100010];
int r[100010];
signed main(){
  int n;cin>>n;
  int ans=0;
  rep(i,n)cin>>a[i];
  rep(i,n){
    if(i==0)l[0]=a[0];
    else l[i]=__gcd(l[i-1],a[i]);
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1)r[n-1]=a[n-1];
    else r[i]=__gcd(r[i+1],a[i]);
  }
  rep(i,n){
    if(i==0)ans=max(ans,r[1]);
    if(i==n-1)ans=max(ans,l[n-2]);
    else ans=max(ans,__gcd(l[i-1],r[i+1]));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5912
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	//freopen("test.txt", "r", stdin);
	int a, b;
	while (~scanf("%d%d", &a, &b) && (a || b)) {
		if (a > b) swap(a, b);
		printf("%d %d\n", a, b);
	}
	return 0;
}

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

int main(void) {

    while (1) {
        int N; cin >> N;
        if (N == 0) break;

        int num, cnt = 0;
        for (int i = 1; i <= N-1; i++) {     // ??????
            for (int j = i+1; j <= N; j++) { // ??????
                num = j*(j+1)/2 - (i-1)*i/2;
                if (N == num) cnt++;
            }
        }

        cout << cnt << endl;
    }

    return 0;
}

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

int main()
{
    int N, T, A, ans;
    double a, min = 1000000000;
    cin >> N >> T >> A;
    vector<int> H(N);
    vector<pair<int, int> > S(N);
    rep(i, N)
    {
        cin >> H[i];
    }
    rep(i, N)
    {
        S[i] = make_pair(i + 1, H[i]);
    }
    rep(i, N)
    {

        a = T - H[i] * 0.006;
        if (fabs(A - a) < min)
        {
            min = fabs(A - a);
            ans = H[i];
        }
    }
    rep(i, N)
    {
        if (S[i].second == ans)
        {
            cout << S[i].first << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left

import math
n = 10**5
e = [True]*(n+1)
e[0] = False
e[1] = False
for i in range(2, int(n**0.5)+1):
    if not e[i]:
        continue
    for j in range(i*2, n+1, i):
        e[j] = False

c = [0]*(n+2)
for i in range(3, n+1, 2):
    if e[i] and e[(i+1)//2]:
        c[i] += 1

for i in range(3, n+1):
    c[i] += c[i-1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(c[r]-c[l-1])




Measured memory_bytes: 7156
#include <stdio.h>
#include <string.h>

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

int t[101][101];
int size[101];
int notEnd[101];
int used[101];

int solve(int idx,int s){
	int i,tmp,res=0;

	notEnd[idx] = 0;
	used[idx] = 1;

	rep(i,size[idx]){
		if(!used[t[idx][i]]){
			tmp = solve(t[idx][i],s);
			if(res < tmp) res = tmp;
		}
	}
	used[idx] = 0;

	return res+1;
}

int main(void){
	int i,j;
	int n,from,to;
	int max,breakFlg,tmp;

	while(scanf("%d",&n) && n){
		memset(t,0,sizeof(t));
		memset(size,0,sizeof(size));
		memset(notEnd,0,sizeof(notEnd));

		rep(i,n){
			scanf("%d%d",&from,&to);
			t[from][size[from]++] = to;
			t[to][size[to]++] = from;
			notEnd[from] = notEnd[to] = 1;
		}

		max = 0;
		memset(used,0,sizeof(used));

		for(j=1;;j++){
			REP(i,1,101){
				if(size[i] == j){
					tmp = solve(i,j);
					if(max < tmp) max = tmp;
				}
			}

			breakFlg = 1;
			REP(i,1,101){
				if(notEnd[i]){
					breakFlg = 0;
					break;
				}
			}
			if(breakFlg) break;
		}

		printf("%d\n",max);
	}

	return 0;
}

Measured memory_bytes: 452
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	long long int X[210] = {}; 
	long long int Y[210] = {}; 
	for(int i = 0; i < N; i++){
		cin >> X[i] >> Y[i]; 
	}
	long long int P = 998244353; 
	long long int A[210] = {}; // 一般項2^n-n-1
	bool B[210][210] = {}; 
	for(int i = 1; i <= 200; i++){
		A[i] = (2 * A[i-1] + i - 1) % P; 
	}
	long long int ans = A[N]; 
	for(int i = 0; i < N; i++){ //2点以下の集合も含めて和をとると，各部分集合が1回ずつ数えられる(ように重みが設定されている)ので総和は2^N．2点以下の分を引く．0点は1，1点はN，2点はちょうどm点が一直線上とすると2^m-m-1で，これをすべての直線について加える．
		for(int j = i+1; j < N; j++){
			if(B[i][j] == true) continue;
			vector<int> tansaku; 
			tansaku.push_back(i); 
			tansaku.push_back(j); 
			for(int k = j+1; k < N; k++){
				long long int s = (Y[i]-Y[j])*X[k] + (X[j]-X[i])*Y[k] - (Y[i]*X[j]-X[i]*Y[j]);
				if(s == 0){
					tansaku.push_back(k); 
				}
			}
		int c = tansaku.size(); 
		for(int p = 0; p < c; p++){
			for(int q = p+1; q < c; q++){
				B[tansaku.at(p)][tansaku.at(q)] = true; 
			}
		}
          	ans = (ans + P - A[c]) % P; 
		}
	}
	cout << ans << endl; 
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int mod = 1_000_000_007;
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		ArrayList<ArrayList<Integer>> edge = new ArrayList<ArrayList<Integer>>();
		for (int i=0;i<N;i++) {
			ArrayList<Integer> list = new ArrayList<Integer>();
			edge.add(list);
		}
		for (int i=0;i<N-1;i++) {
			int a = Integer.parseInt(sc.next())-1;
			int b = Integer.parseInt(sc.next())-1;
			edge.get(a).add(b);
			edge.get(b).add(a);
		}
		int flag[] = new int[N];
		long ans = 1L;
		ArrayList<Integer> dfs = new ArrayList<Integer>();
		dfs.add(0);
		dfs.add(0);
		flag[0] = 1;
		ans *= K;

		while (dfs.size()>0) {
			Integer i = dfs.remove(0);
			Integer depth = dfs.remove(0);
			int j;
			if (depth==0) {
				j = -1;
			} else {
				j = 0;
			}
			for (Integer element : edge.get(i)) {
				if (flag[element] == 1) {
					continue;
				} else {
					flag[element] = 1;
					ans = ans * (K-2-j) % mod;
					j++;
					for (Integer element_2 : edge.get(element)) {
						if (flag[element_2] == 0) {
							dfs.add(element);
							dfs.add(depth+1);
							break;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}

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

using namespace std;

typedef long long ll;

int max(int a, int b)
{ return (a > b) ? a : b; }

const int MAXN = 200031;
int a[MAXN];

vector<ll> p(31);
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    for (int i = 0; i < 31; i++)
    {
        p[i] = (1 << i);
    }
//    cerr << p[30];
    int n;
    cin >> n;
    unordered_map<int, int> s;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        s[a[i]]++;
    }
    sort(a, a + n);
    int ans = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = 30; j >= 0; j--)
        {
            if (p[j] < a[i] || s[p[j] - a[i]] == 0 || s[a[i]] == 0) continue;
            if (p[j] - a[i] == a[i] && s[a[i]] == 1) continue;

            ans++;
            s[p[j] - a[i]]--;
            s[a[i]]--;
            break;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 30992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp93 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Array.Sort(a);

            //aに含まれる数字の種類
            int num_kind = a.Distinct().ToArray().Count();

            //Console.WriteLine(num_kind);

            int ans = 0;

            foreach(var element in a.Distinct().ToList().OrderBy(x => x).ToList()) {
                if (element >= 100001) {
                    ans += a.Where(x => x >= 100001).ToArray().Count();

                    break;
                }
                int cnt = a.Where(x => x == element).ToList().Count();

                if (cnt < element) {
                    ans += cnt;
                } else {
                    ans += (cnt - element);
                }

            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 32096
#include <bits/stdc++.h>
#define ll long long 
#define vi vector<int>
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define vii vector<pair<int,int> >
#define pb push_back
#define inf -1000000007
#define f(i,a,b) for(i=a;i<b;i++)

using namespace std;
bool cmp(string &a,string &b)
{
	if(a.size()==b.size())return a<b;
	return a.size()<b.size();
}
ll d[200001];
int main()
{
	
int n,k=0,i,j,l=0;
cin>>n;
int a[n];
f(i,0,n)cin>>a[i];

f(i,0,n)
{
    f(j,i+1,n)
    {
        f(k,j+1,n)
        {
           
                if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]))l++;
            
        }
    }
}
cout<<l;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
bool cmp(pint a, pint b) {return a.second < b.second;}

int main() {
    int h, n;
    cin >> h >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int sum = 0;
    rep(i, n) sum += a[i];

    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
int main(){
  int n,a,b;
  vector<int> test[3];
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    int p;
    cin>>p;
    if(p<=a) test[0].push_back(p);
    else if(p<=b) test[1].push_back(p);
    else test[2].push_back(p);
  }
  int ans=min(test[0].size(),min(test[1].size(),test[2].size()));
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<ii , int> iii;
ll n , x[300000] , memo[300000] , memor[300000] , t;
ll sum;
stack<int>st , str;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> x[i];
	}
	for(int i = 1 ; i <= n ; i++){
		if(!st.empty()){
			while(st.top() > x[i]){
				t = st.top();
				memo[x[i]] += memo[t];
				st.pop();
				if(st.size() == 0)break;
			}
		}
		memo[x[i]]++;
		st.push(x[i]);
	}
	for(int i = n ; i >= 1 ; i--){
		if(!str.empty()){	
			while(str.top() > x[i]){
				t = str.top();
				memor[x[i]] += memor[t];
				str.pop();
				if(str.size() == 0)break;
			}
		}
		memor[x[i]]++;
		str.push(x[i]);
	}
	sum = 0;
	for(int i = 1 ; i <= n ; i++){
		sum += (memo[i]*memor[i])*i;
	}
	cout << sum;
}

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

#define NIL 2000000001
#define N 251
int A[N];

int main(void){
  int i,j,n;
  
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    A[i]=NIL;
    
  }
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    
  }

  for(i=1 ; i<=n ; i++){
    printf("node %d: key = %d, ",i,A[i]);
    
    if(A[i/2] != NIL){
      if(A[i/2] != 0){ 
	printf("parent key = %d, ",A[i/2]);
      }
    }

    if(2*i <= n){
      
      if(A[2*i] != NIL){
	
	if(A[2*i] != 0){ 
	  printf("left key = %d, ",A[2*i]);
	}
      }
      
      if(A[2*i+1] != NIL){
	if(A[2*i+1] != 0){ 
	  printf("right key = %d, ",A[2*i+1]);
	}
      }
      
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {    
    /////////////////////
    // Write code below /
    /////////////////////
    string N;
    cin >> N;
    
    if (N[0] == N[1] && N[1] == N[2]) {
        cout << "Yes" << endl;
    } else if (N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

int main() {
  int N, K, x, a=0;
  cin >> N >> K;
  
  for (int i=0; i<N; i++){
    cin >> x;
    if (2*x <= K) {
      a += 2*x;
    } else {
      a += 2*(K-x);
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())

lis = list(map(int, input().split()))

a = Counter(lis)

slis = sorted(set(lis))

t1 = 0
t2 = 0

for k, v in a.items():
    if v >=2 and k > t1:
        t2 = t1
        t1 = k

if a[t1] >= 4:
    print(t1*t1)
    exit()

print(t1*t2)



Measured memory_bytes: 25260
#include <stdio.h>
#include <iostream>

using namespace std;

static const int MAX=200000;

int main()
{
    int R[MAX],n;
    cin>>n;
    for (int i=0;i<n;i++)cin>>R[i];
    
    int maxv=-2000000000;
    int minv=R[0];
    
    for(int i=1;i<n;i++)
    {
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }
    cout<<maxv<<endl;
}


Measured memory_bytes: 3860
import itertools

n = int(input())
l =[]

for _ in range(n):
  a = int(input())
  m = []
  for _ in range(a):
    xn, yn = map(int, input().split())
    m.append([xn-1, yn])
  l.append(m)

for i in itertools.product([1, 0], repeat=n):
  i = list(i)
  flg = 0
  for j in range(n):
    for k in l[j]:
      if i[j] == 1:
        if i[k[0]] != k[1]:
          flg += 1
          break
      if flg != 0:
        break
  if flg == 0:
    break
    
print(sum(i))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#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 pb push_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 INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int T,X;
    cin >> T >> X;
    cout << (double)T / X << endl;

    return 0;
}

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

int main(void)
{
    int m, d;
    char c;
    double x = 0; 
    double y = 0;
    double cur_d = M_PI / 2.0;
    while (cin >> m >> c >> d) {
        if (m == 0 && d == 0) break;
        x += cos(cur_d) * m;
        y += sin(cur_d) * m;
        cur_d -= d * M_PI / 180.0;
    }
    cout << (int)x << endl;
    cout << (int)y << endl;
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<string> s(n),ans;
  rep(i,n) cin >> s[i];
  map<string,int> cnt;
  rep(i,n){
    cnt[s[i]]++;
  }
  int tmp=-1;
  rep(i,n){
    int rec=cnt[s[i]];
    chmax(tmp,rec);
  }

  rep(i,n){
    if(cnt[s[i]]==tmp){
      ans.pb(s[i]);
    }
  }


  sort(all(ans));
  ans.erase(std::unique(ans.begin(), ans.end()), ans.end());
  rep(i,sz(ans)) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 28916
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
import itertools
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n = I()

P = LI()
Q = LI()

tp = tuple(P)
tq = tuple(Q)

combination = sorted(list(itertools.permutations(P, n)))
a = 0
b = 0
for i, v in enumerate(combination):
    if v == tp:
      if a == 0:
        a = i+1

    if v == tq:
      if b == 0:
        b = i+1
    
print(np.absolute(a-b))

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

  int N;
  cin >> N;
  vector<int> X(N), Y(N), T(N);
  repr(i, N, 0) {
    cin >> T[i] >> X[i] >> Y[i];
  }

  int x,y,time;
  x = 0, y = 0, time = 0;
  for (int i = 0; i < N; ++i) {
    int nx,ny,dist,rtime;
    nx = X[i], ny = Y[i], rtime = T[i] - time;
    dist = abs(x - X[i]) + abs(Y[i] - y);
    if (dist > rtime || rtime % dist == 1) {
      cout << "No" << endl;
      return 0;
    }

    x = nx, y = ny, time = T[i];
  }

  cout << "Yes" << endl;
}

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

#define all_of(x) std::begin(x), std::end(x)
#ifdef _GLIBCXX_DEBUG
    #define debug(x) cerr << #x << ": " << x << endl
#else
    #define debug(x) 
#endif

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}
template<typename T>
istream& operator >> (istream& in, vector<T>& v) {
    for(auto& x : v) {
        in >> x;
    }
    return in;
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int x;
    cin >> x;
    cout << (1 - x) << "\n";
    
    
    
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
using namespace std;
long a, b, c;
int main()
{
  cin >> a >> b >> c;
  if (4 * a * b < (c - a - b) * (c - a - b) && c - a - b > 0)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

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

    int ma_size = s.size()-t.size()+1;
    int t_size = t.size();
    int ans = t.size();
    for(int i=0; i<ma_size; i++){
        int sans = t.size();
        int u = i;
        for(int j=0; j<t_size; j++){
            if(s[u]==t[j]) sans--;
            u++;
        }
        if(sans < ans) ans = sans;
    }
    cout << ans;

}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int r = 0, b = 0;
  int i;
  for (i = 0; i < n; i++) {
    if (s.at(i) == 'R') {
      r++;
    } else {
      b++;
    }
  }
  cout << (r > b ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <sstream>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    getline(cin, s);
    string tmp;
    string A = "apple", B = "peach";
    for (auto &&i : s) {
        tmp += i;
        if(tmp.size() >= 5) {
            int okA = 1, okB = 1;
            for (int j = 0; j < 5; ++j) {
                if(tmp.end()[j-5] != A[j]) okA = 0;
                if(tmp.end()[j-5] != B[j]) okB = 0;
            }
            for (int j = 0; j < 5; ++j) {
                if(okA) tmp.end()[j-5] = B[j];
                if(okB) tmp.end()[j-5] = A[j];
            }
        }
    }
    cout << tmp << "\n";
    return 0;
}


Measured memory_bytes: 3112
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	long long n,m,cnt,x;
	scanf("%lld %lld",&n,&m);
	if(n*2<=m)	{
		cnt=n;
		m=m-n*2;
		x=m/4;
		cnt+=x;
	}
	else {
		cnt=m/2;
	}
	printf("%lld\n",cnt);
	return 0;
}

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

int main(){
  int X;
  cin >> X;
  
  int b;
  int p;
  int ans = 1;
  for(b = 2;b > -1;b++){
    int bekizyo = b;
    if(b > X){
      break;
    }
    for(p = 1;p > -1;p++){
      bekizyo *= b;
      if(bekizyo > X){
        bekizyo /= b;
        break;
      }
      if(bekizyo > ans){
        ans = bekizyo;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
101010
)");
#define cin input
#endif

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

	if (s.back() == '1' || s.front() == '0')
	{
		cout << -1 << endl;
		return 0;
	}

	s.pop_back();

	string r = s;
	reverse(r.begin(), r.end());
	if (s != r)
	{
		cout << -1 << endl;
		return 0;
	}

	vector<int> l;
	l.push_back(s.length());
	for (int i = (s.length() - 1) / 2; i >= 0; --i)
		if (s[i] == '1')
			l.push_back(i + 1);
	
	int v = 1;
	for (int i = 0; i < l.size() - 1; ++i)
	{
		cout << v << ' ' << (v + 1) << endl;
		++v;
	}

	l.push_back(0);
	for (int i = l.size() - 2; i >= 0; --i)
		for (int j = l[i + 1] + 1; j < l[i]; ++j)
			cout << (i + 1) << ' ' << ++v << endl;
	cout << 1 << ' ' << (v + 1) << endl;

	return 0;
}


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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

int n;

void init(){
	si(n);
	int a[n + 1], b[n + 2];
	for (int i = 0; i < n; ++i)
	{
		si2(a[i], b[i]);
	}
	//printf("3=%d\n", a[2]);

	
	LL s = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		int t = (a[i] + s) % b[i];
		if(t != 0){
			s += b[i] - t;
		}
	}
	printf("%lld\n", s);
}

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

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#define pii pair<int,int>
#define S second
#define F first

using namespace std;
const int MAX_N = 1e5+10;
const int INF = 1e9+10;
int from[MAX_N],to[MAX_N],DP[MAX_N],depth[MAX_N];
vector <int> vec[MAX_N];
vector <pii> ans;
bool mark[MAX_N];
void dfs(int v,int cnt,int l){
    mark[v]=true;
    depth[v]=cnt;
    for(int en:vec[v]){
        if(en==l)
            continue;
        int u=to[en]^from[en]^v;
        if(mark[u])
            DP[v]=min(DP[v],depth[u]);
        else{
            dfs(u,cnt+1,en);
            DP[v]=min(DP[v],DP[u]);
        }
    }
    if(DP[v]>=depth[v]&&l!=-1)
        ans.push_back({from[l],to[l]});
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    if(n==1)
        return 0;
    fill(DP,DP+max(n,m),INF);
    for(int i=0;i<m;i++){
        cin>>from[i]>>to[i];
        from[i]--;
        to[i]--;
        if(from[i]>to[i])
            swap(from[i],to[i]);
        vec[from[i]].push_back(i);
        vec[to[i]].push_back(i);
    }
    dfs(0,0,-1);
    sort(ans.begin(),ans.end());
    cout<<ans.size();
}

Measured memory_bytes: 2688
import math
import itertools

n = int(input())
xy = [ list(map(int, input().split())) for _ in range(n) ]
p = itertools.permutations(xy, n)
c = 0
for i in p:
  for j in range(n-1):
    c += ( (i[j][0]-i[j+1][0])**2 + (i[j][1]-i[j+1][1])**2 )**0.5
    
l = math.factorial(n)
print(c/l)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  cout << a[n - 1] - a[0] << endl;
  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll n,s=0;
  int a[]={1,3,5,7,8,10,12};
  int b[]={4,6,9,11};
  int c[]={2};
int x,y,d=0,e=0;
cin>>x>>y;
for(int i=0;i<7;i++)
{
  if(a[i]==x)
  {
       d=1;
  }
  if(a[i]==y)
  {
    e=1;
  }
}
if(d==1&&e==1)
{
Yes
}
else
{
  d=0,e=0;
  for(int i=0;i<4;i++)
{
  if(b[i]==x)
  {
       d=1;
  }
  if(b[i]==y)
  {
    e=1;
  }
}
if(d==1&&e==1)
{
  Yes
}
else
{
  if(x==2&&y==2)
  {
    Yes
  }
  else
  {
    No
  }
}
}
  

}
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    char str[1200];
	int i;
    
    scanf("%[^\n]", str);
	
	for(i=0; str[i]!='\0'; i++){
		if((str[i]>='A') && (str[i]<='Z')){
			str[i] += 32;}
			
		else if((str[i]>='a') && (str[i]<='z')){
			str[i] -= 32;}}
			
    
    printf("%s\n", str);
}


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

#define ll long long
#define PB push_back
#define PF push_front
#define L size
#define vi vector<int>
#define MOD 1000000007
#define mp make_pair
#define fi first
#define se second


using namespace std;
ll fib(int n);
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a[n];
    int count =0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        if((i+1)%2 && a[i]%2)
            count++;
    }
    cout << count ;
    
}
ll fib(int n)
{
    vector<ll> a;
    a.PB(0);a.PB(1);
    for(int i=2;i<=n+1;i++)
       a.PB(a[i-1]+a[i-2]);
    return a.back();
}

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

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll n, d, a, b, count = 0;
	cin >> n >> d;
	fo(i, n) {
		cin >> a >> b;
		a = pow(a, 2);
		b = pow(b, 2);
		if (sqrt(a + b) <= d) count++;
	}
	cout << count;

	return 0;
}

Measured memory_bytes: 3668
#include <math.h>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed
		<< setprecision(4)
		<< sqrt(
			pow(x2 - x1, 2.0) +
			pow(y2 - y1, 2.0)
			) << endl;
	return 0;
}

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

int main() {
    long long n, k;
    cin >> n >> k;
    if (k % 2 == 0) {
        long long a = n / k;
        long long b = (n + (k/2)) / k;
        cout << a*a*a + b*b*b << endl;
    }
    else {
        long long a = n / k;
        cout << a*a*a << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long i=0; i<n; ++i) { cout<<a[i]; if(i!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> vl;
typedef vector<vector<long long> > vll;
typedef vector<P> vp;
typedef vector<vector<P> > vpp;

// k=0:there is one solution.
// k=1:there is multiple solution.
// k=-1:there is no solution.
vector<int> topological(vector<vector<P> > &adj, int& k) {
	k=0;
	int n=(int)adj.size();
	vector<set<int> > s(n);
	for(int i=0; i<n; ++i) {
		for(int j=0; j<adj[i].size(); ++j) {
			s[adj[i][j].first].insert(i);
		}
	}
	queue<int> q;
	for(int i=0; i<n; ++i) {
		if(s[i].size()==0) q.push(i);
	}
	vector<int> res(n,-1);
	int roc=0;
	while(!q.empty()) {
		if(q.size()>1) k=1;
		int p=q.front();
		q.pop();
		res[roc]=p;
		for(int i=0; i<adj[p].size(); ++i) {
			s[adj[p][i].first].erase(p);
			if(s[adj[p][i].first].size()==0) q.push((int)adj[p][i].first);
		}
		++roc;
	}
	if(res[n-1]==-1) k=-1;
	return res;
}
int main() {
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<vector<P> > adj(n);
	REP(i,m) {
		int a,b;
		cin>>a>>b;
		--a;
		--b;
		adj[b].pb(P(a,1));
	}
	int k=0;
	vector<int> ret=topological(adj,k);
	REP(i,n) cout<<ret[n-1-i]+1<<endl;
	cout<<k<<endl;
}

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

int main()
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
    long long x, y, sol;
	((a*c) > (a*d)) ? x = (a*c) : x = (a*d);
	((b*c) > (b*d)) ? y = (b*c) : y = (b*d);
	(x>y) ? sol = x : sol = y;
	cout << sol << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int s, s1, s2, s3;
      
      cin >> s;
      
      s1 = s / 100;
      s2 = (s - s1*100) / 10;
      s3 = s - s1*100 - s2*10;
      
      cout << s1+s2+s3 << endl;

    }

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


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

  // able or unable
  vector <int> freq1(40,0); // s material
  vector <int> freq2(40,0);// t object

  //cout<<99<<endl;

  for(int i=0;i<s.size();i++){
      freq1[s[i] - 'a']++;
  }

   for(int i=0;i<t.size();i++){
      freq2[t[i] - 'a']++;
  }

 

 //cout<<888<<endl;

  for(int i=0;i<40;i++){
      if(freq1[i] == 0 and freq2[i] > 0) {
          cout<<-1<<endl;
          return 0;
      }
      if(freq1[i] == 0 and freq2[i] == 0) continue;


  }

  ll ans = 0;

  vector <vector <int> > moji(40);

  for(int i=0;i<s.size();i++){
    moji[s[i] - 'a'].push_back(i);
  }


  for(int i=0;i<s.size();i++){
    moji[s[i] - 'a'].push_back(i+ s.size());
  }

  int now = moji[t[0] - 'a'].at(0);
  int terget = 1;
  ans += now;

  while(true){
      if(terget == t.size()) break;

    auto next = upper_bound(moji[t[terget]-'a'].begin(),moji[t[terget]-'a'].end(),now);
    int dif = *next - now;
    ans += dif;
    now = *next;
    now = now % s.size();
    terget++;
    if(terget == t.size()) break;



  }

  

  cout<<ans+1<<endl;


    return 0 ;
}

Measured memory_bytes: 1724
# coding: utf-8
def getLnInputs():
    return input().split()


def getLnIntInputs():
    return list(map(int, getLnInputs()))


def main():
    N, M = getLnIntInputs()
    if M <= N * 2:
        print(M // 2)
        return

    print(N + (M - N * 2) // 4)

    return


main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    string X, Y;
    cin >> X >> Y;
    if (X < Y) cout << "<\n";
    else if (X == Y) cout << "=\n";
    else cout << ">\n";
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int H,W;
  cin >> H >> W;
  char a[H][W];
  int N[H],M[W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a[i][j];
      N[i]=0;
      M[j]=0;
    }
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a[i][j]=='#'){
	N[i]+=1;
	M[j]+=1;
      }
    }
  }
  for(int i=0;i<H;i++){
    if(N[i]!=0){
      for(int j=0;j<W;j++){
	if(M[j]!=0) cout << a[i][j];
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3052
/*よくばりセット2019/07/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

int main(){
    int n;
    int p[2000][3];
    int point[2000]={};
    int min=99999999;
    int max=-1;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&p[i][j]);
        }
        qsort(p[i],3,sizeof(int),asc);
    }
    int cnt=0;
    int list[1000]={};
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(list[j]==1)continue;
            if(p[i][0]==p[j][0]&&p[i][1]==p[j][1]&&p[i][2]==p[j][2]){
                cnt++;
                list[j]=1;
            }
        }
    }
    
    printf("%d\n",cnt);
    return 0;

}


Measured memory_bytes: 2112
import sys
input=sys.stdin.readline
import math
X = int(input())
if X == 2:
    print(2)
else:
  x = math.ceil(math.sqrt(X))
  for i in range(X,X+1000):
      c = 0
      for j in range(2,x+1):
          if i % j == 0:
              c = 1
              break
      if c == 0:
          print(i)
          break

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}

vi v[110];
vector<P> res[110];





signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  FOR(H,2,101){
    int bunshi=3600*H;
    int bunbo=120*H-(H+1);
    int g=__gcd(bunshi,bunbo);
    bunshi/=g;
    bunbo/=g;
    int ori_bunshi=bunshi;
    while(bunshi<3600*H*bunbo){
      v[H].PB(bunshi/bunbo);
      res[H].PB(P(bunshi,bunbo));
      bunshi+=ori_bunshi;
    }
  }

  int H,h,m,s;
  while(true){
    cin>>H>>h>>m>>s;
    if(H==0) break;
    int t=3600*h+60*m+s;
    int i=-1;
    auto it = lower_bound(all(v[H]),t);
    if(it==v[H].end()) i=0;
    else i=it-v[H].begin();

    P ans=res[H][i];
    int hour=(ans.F/ans.S)/3600;
    int minits=((ans.F/ans.S)/60)%60;
    int second=((ans.F/ans.S)%60)*ans.S+ans.F%ans.S;
    int bunbo=ans.S;
    cout<<hour<<' '<<minits<<' ';
    
    cout<<second/__gcd(second,bunbo)<<' '<<bunbo/__gcd(second,bunbo)<<endl;
  }


}


Measured memory_bytes: 17840