akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)

int main()
{
  ll n;
  cin >> n;
  // rep(i, n)
  // {
  //   if (i == 0)
  //   {
  //     continue;
  //   }
  //   ll x = i;
  //   for (ll a = -100; a < 100; a++)
  //   {
  //     for (ll b = -100; b < 100; b++)
  //     {
  //       if (a * a * a * a * a - b * b * b * b * b == x)
  //       {
  //         cout << 111111 << endl;
  //         cout << "x: " << x << "  a:" << a << "  b:" << b << endl;
  //         cout << 11111111 << endl;
  //       }
  //     }
  //   }
  // }
  rep(a, 1000)
  {
    for (ll b = -a; b <= a; b++)
    {
      if (a * a * a * a * a - b * b * b * b * b == n)
      {
        cout << a << " " << b << endl;
      }
    }
  }
  return 0;
}


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

int main(){
    int ans1=-1, ans2=-1, ans3=-1;
    int N, Y; cin>>N>>Y;
    for(int i=0; i<=N; i++){
        for(int j=0; j+i<=N; j++){
            if(10000*i + 5000*j + 1000*(N-i-j) == Y){
                ans1=i;
                ans2=j;
                ans3=N-i-j;
            }
        }
    }
    cout<<ans1<<" "<<ans2<<" "<<ans3<<endl;
}


Measured memory_bytes: 3636
# ??????????????\???
length = gets.to_i

# ?????????????´??????\???(split????????\????????????????????????0????????????????´??????????)
A = gets.split(" ").map(&:to_i)

# ?????????????´?????????????
for i in 1..length-1
    # ???????????¶????????¨?????????
    for k in 0..length-2
        print A[k], " "
    end
    print A[k+1], "\n"

    key = A[i]
    # insert A[i] into the sorted sequence A[0..j-1]
    j = i - 1
    while j >= 0 && A[j] > key
        A[j+1] = A[j]
        j = j - 1
    end
    A[j+1] = key
end

k = -1
# ???????????????????????????????????????????????¶????????¨????????????
for k in 0..length-2
    print A[k], " "
end
print A[k+1], "\n"

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

long long N,K,arr[101];

int main(){
	cin>>N>>K;
	for(int i=0; i<N; i++){
		cin>>arr[i];
	}
	sort(arr,arr+N);
	int i=0;
	while(i<N&&K>=0){
		K-=arr[i];
		i++;
	}
	if(K==0){
		cout<<N<<'\n';
	}else if(K>0){
		cout<<N-1<<'\n';
	}else{
		cout<<i-1<<'\n';
	}
}

Measured memory_bytes: 3540
n,m = map(int, input().split())
s = [list(map(str, input().split())) for i in range(m)]
k = {}
for i in range(m):
    k[s[i][0]]=[]

for i in range(m):
    k[s[i][0]].append(s[i][1])

pena =0
ac =0

for i in k.keys():
    if "AC" not in k[str(i)]:
       continue
    else:
        for j in k[str(i)]:
            if j== "AC":
                ac+= 1
                break
            else: 
                pena+=1

print(ac,pena)
    
    
    

Measured memory_bytes: 46976
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


n, m = map(int, sys.stdin.buffer.readline().split())
uf = UnionFind(n)
for x in sys.stdin.buffer.readlines():
    a, b = map(int, x.split())
    uf.union(a-1, b-1)

grp = {}
for i in range(n):
    grp.setdefault(uf._root(i), []).append(i)

ans = 0
for x in grp.values():
    l = len(x)
    if ans < l:
        ans = l
print(ans)


Measured memory_bytes: 48868
//abc072_a.cpp
//Sat Sep  8 18:23:05 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (x-t<=0){
		cout << "0" << endl;
	}else{
		cout << x-t << endl;
	}
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

void min_self(int &a, int b) {
    a = min(a, b);
}

int main() {
    int n = nxt();
    VI stone(n);
    generate(all(stone), nxt);
    VI memo(n, INF);
    memo[0] = 0;
    for (int i = 0; i < n; i++) {
        if (i + 1 < n) min_self(memo[i + 1], memo[i] + abs(stone[i] - stone[i + 1]));
        if (i + 2 < n) min_self(memo[i + 2], memo[i] + abs(stone[i + 2] - stone[i]));
    }
    printf("%d\n", memo[n-1]);
    return 0;
}


Measured memory_bytes: 3964
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            int N= int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            int min2Exponent = int.MaxValue;

            for(int i=0;i<N;i++)
            {
                int x = int.Parse(str[i]); 
                int e=0;
                while(x%2==0){e++;x=x/2;};
                if(e<min2Exponent){min2Exponent=e;}
            }

            Console.WriteLine(min2Exponent);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N, M, p, x;
	int aux1, aux2, aux3;
	cin >> N;
	int T[100000];
	int suma[1001];
	int tiaux[100000];
		for (int i = 0; i < N;i++) {
			cin >> aux1;
			T[i] = aux1;
			tiaux[i] = aux1;
			suma[i] = 0;
		}
		cin >> M;
		for (int j= 0; j < M; j++) {
			cin >> aux2;
			cin >> aux3;
			tiaux[(aux2)-1] = aux3;
			for (int x = 0; x < N; x++) {
				suma[j] += tiaux[x];
			}
			for (int o = 0; o < N; o++)
				tiaux[o] = T[o];
		}
		for (int e = 0; e < M; e++)
			cout << suma[e] << endl;
	return(0);
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> date(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> date.at(i).at(j);
    }
  }

double ans = 0.0;

for (int i = 0; i < N; i++) {
  for (int j = 0; j < N; j++) {
    if (i == j) continue;
    ans += sqrt((date.at(i).at(0) - date.at(j).at(0)) * (date.at(i).at(0) - date.at(j).at(0)) + (date.at(i).at(1) - date.at(j).at(1)) * (date.at(i).at(1) - date.at(j).at(1)));
  }
}

cout << setprecision(20) << ans / N << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
int main(void){
    int N;
    long long int C[502],S[502],F[502];
    long long int Sum[502][502]={};
    cin >> N;
    REP(i,N-1){cin >> C[i] >> S[i] >> F[i];}
    for(int i=0;i<N-1;i++){
        for(int j=i;j<N-1;j++){
            Sum[i][j+1]=max(((((Sum[i][j]-1)/F[j])+1)*F[j]),S[j])+C[j];
        }
    }/*
    REP(i,N){
        REP(j,N){
            cout << Sum[i][j] << " ";
        }
        cout << endl;
    }*/
    
    REP(i,N){
        cout << Sum[i][N-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
n=N()
c=input()
ans=0
w=[]
r=[]
for i,j in enumerate(c):
    if j=="W":
        w.append(i)
    else:
        r.append(i)
x=min(len(w),len(r))
for i in range(x):
    if w[i]<r[-1-i]:
        ans+=1
    else:
        break
print(ans)

Measured memory_bytes: 81196
h, n = map(int, input().split())
a = []
b = []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)

dp = [float("inf")] * (h + 1)
dp[0] = 0
for i in range(h):
    for j in range(n):
        index = min(i + a[j], h)
        dp[index] = min(dp[index], dp[i] + b[j])

print(dp[h])

Measured memory_bytes: 42972
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int x; cin >> x;
	if(x >= 30) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in();
	vector<int>a(n);
	REPC(&i, a)i = in();
	int q = in();
	REP(i, q)
	{
		int b = in(), e = in(), t = in();
		REP(k, e - b)iter_swap(a.begin() + b + k, a.begin() + t + k);
	}
	REP(i, a.size())
	{
		if (i != 0)cout << ' ';
		cout << a[i];
	}
	cout << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  int K; cin>>K;
  int N=S.size();
  vii dp(N,vi(K));
  vi cp(N);
  rep(i,0,S[0]-'0') dp[0][i%K]++;
  cp[0]=(S[0]-'0')%K;
  rep(i,1,N){
    int X=S[i]-'0';
    rep(j,0,K){
      rep(l,0,10){
        dp[i][(j+l)%K]+=dp[i-1][j];
        dp[i][(j+l)%K]%=MOD;
      }
    }
    rep(j,0,X){
      dp[i][(cp[i-1]+j)%K]++;
      dp[i][(cp[i-1]+j)%K]%=MOD;
    }
    cp[i]=(cp[i-1]+X)%K;
  }
  int ans=(dp[N-1][0]+MOD-1)%MOD;
  if(cp[N-1]==0) ans=(ans+1)%MOD;
  cout<<ans<<endl;
  }



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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int cnt = 0;
    while (0 < a && 0 < c) {
        if (cnt % 2 == 0) {
            c -= b;
        } else {
            a -= d;
        }
        cnt++;
    }

    cout << (c < 1 ? "Yes" : "No") << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 3636
n,m = map(int,input().split())
drink = dict()
cost = list()
ans = 0
for i in range(n):
    ab = [int(i) for i in input().split()]
    if ab[0] in drink:
        drink[ab[0]] += ab[1]
    else:
        cost.append(ab[0])
        drink[ab[0]] = ab[1]
#ここまで入力
cost.sort()
for i in cost:
    if m <= drink[i]:
        ans += m*i
        break
    else:
        m -= drink[i]
        ans += i * drink[i] 
    
print(ans)

Measured memory_bytes: 63064
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main(void)
{
  char s[200];
  int l,i;
  fgets(s,200,stdin);
  l=strlen(s);
  for(i=0;i<l;i++)
    s[i]=toupper(s[i]);
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <cassert>
#include <iostream>
#include <memory>
#include <numeric>

#include <array>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cstring>
#include <ostream>
#include <type_traits>
#include <utility>
#include <chrono>
#include <random>

#ifdef ONLINE_JUDGE
#pragma GCC optimize ("O3")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

using namespace std;

using uint64 = uint64_t;
using int64 = int64_t;
using uint32 = uint32_t;
using vi = vector<int>;

#define seq(i,a,b) for (int i = (a); i < (b); ++i)
#define rev(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define dbg(x) {cerr << #x << ": " << x << endl;}

struct mergefind {
    vi parent;
    vi size;

    mergefind(int n) : parent(n), size(n,1) {
        iota(parent.begin(), parent.begin()+n, 0);
    }

    int find(int a) noexcept {
        int repr = a;
        while (repr != parent[repr]) {
            repr = parent[repr];
        }
        while (a != parent[a]) {
            int olda = a;
            a = parent[olda];
            parent[olda] = repr;
        }
        return parent[repr];
    }

    void merge(int a, int b) noexcept {
        a = find(a);
        b = find(b);

        if (a == b) return;

        if (size[a] < size[b]) swap(a,b);

        parent[b] = a;
        size[a] += size[b];
    }
};

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

  int n, m; cin >> n >> m;
  mergefind mf(n);
  
  seq(_,0,m) {
    int a,b; cin >> a >> b;
    --a; --b;
    mf.merge(a,b);
  }

  cout << *max_element(all(mf.size)) << endl;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
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; }
const ll inf = 1ll << 60;

int n, k;
vector<int> a;
vector<int> dp(100100, -1);
int m;

int rc(int k) {
    if(dp.at(k) > 0) return dp.at(k);
    rp(i, 0, n) {
        if(a.at(i) <= k) {
            if(rc(k - a.at(i)) == 2) {
                dp.at(k) = 1;
                return 1;
            }
        }
    }
    dp.at(k) = 2;
    return 2;
}

int main() {
    scanf("%d%d", &n, &k);
    a.assign(n, 0);
    rp(i, 0, n) scanf("%d", &a.at(i));
    m = *min_element(a.begin(), a.end());
    if(rc(k) == 1) {
        printf("First");
        return 0;
    } else {
        printf("Second");
        return 0;
    }
} 

Measured memory_bytes: 5376
using System;
using System.Linq;

namespace _2019024AtCoderA
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(EvalEra(Console.ReadLine()));
        }

        public static string EvalEra(string input)
        {
            var yyyymmdd = input.Split('/').Select(int.Parse);
            var year = yyyymmdd.ElementAt(0);
            if (2019 > year)
            {
                return "Heisei";
            }
            var month = yyyymmdd.ElementAt(1);
            if (year == 2019 && 4 >= month)
            {
                return "Heisei";
            }
            return "TBD";
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

ll check(string a,string b) {
  ll na=a.size();
  ll nb=b.size();
  if(na>nb) return 1;
  if(na<nb) return 0;
  for(ll i=0;i<na;i++) {
    if(a[i]>b[i]) return 1;
    if(a[i]<b[i]) return 0;
  }
  return 0;
}

int main() {
  string a,b;
  cin >> a >> b;
  if(check(a,b)) {
    cout << "GREATER" << endl;
  }
  else if(check(b,a)) {
    cout << "LESS" << endl;
  }
  else {
    cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int n;
    string s;
    while(cin>>n>>s)
    {
        int ans=0;
        for(int i=0;i<=n-3;)
        {
            if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            {
                ans++;
                i+=3;
            }
            else
            {
                i++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
def inpl(): return list(map(int, input().split()))

N, M = inpl()
X = sorted(inpl())
C = Counter(X)
D = defaultdict(int)
E = defaultdict(int)
for k, v in C.items():
    D[k%M] += v
    E[k%M] += v//2

ans = D[0] // 2

for i in range(1, M):
    j = M - i
    if i < j:
        x = min(D[i], D[j])
        y = min((D[i] - x)//2, E[i]) + min((D[j] - x)//2, E[j])
        ans += x + y
    elif i == j:
        ans += D[i] //2
    else:
        break

print(ans)

Measured memory_bytes: 82920
main = interact $ unlines . map (itp1_9_b) . read' . lines
 where
  read' ("-":_) = []
  read' (str:n:xs) = (str, (map read . take (read n)) xs) : read' (drop (read n) xs)

itp1_9_b (str,hs) = foldr ($) str (map shuffle hs)
 where shuffle n str = let (bot,top) = splitAt n str in top ++ bot

Measured memory_bytes: 4100
n = int(input())
arr = [int(i) for i in input().split()]
g_count = 0

def sub(arr, count):
    while 1:
        if arr == []:
            return count
        elif 0 in arr:
            index = arr.index(0)
            arr1 = arr[0:index]
            arr2 = arr[index + 1:len(arr)]
            count = count + sub(arr1, 0) + sub(arr2, 0)
            return count
        else:
            arr = [i - 1 for i in arr]
            count += 1 

print(sub(arr, 0))

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s, t;
    cin >> s >> t;
    vector<int> cnt1(26), cnt2(26);
    rep (i, s.size()) {
        cnt1[s[i] - 'a']++;
        cnt2[t[i] - 'a']++;
    }
    map<int, int> mp;
    rep (i, 26) mp[cnt1[i]]++;
    rep (i, 26) {
        mp[cnt2[i]]--;
    }
    for (auto m: mp) {
        if (m.second != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}



Measured memory_bytes: 916
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define Max 110
#define LL long long

double l[Max], a[Max], b[Max];
double dis[Max][Max], num[Max];
LL temp[Max];

//void init ()
//{
//	LL ans = 0, x;
//	for (LL i = 0;i <= 30;i ++)
//	{
//		x = i;
//		ans = 0;
//		while(x)
//		{
//			if(x % 2 == 1) 
//				ans ++;
//			x /= 2;
//		}
//		num[i] = ans;
//	}
//}


LL judge (LL x)
{
	LL ans = 0;

	while(x)
	{
		if(x % 2 == 1) 
			ans ++;
		x /= 2;
	}
	return ans;
}


double cal(LL x)
{
	double ans = 0.0;
	LL cnt = 0;
	for(LL i = 1; x; i++)
	{
		if(x % 2 == 1)
		{
			temp[++ cnt] = i;
			for(LL j = 1;j < cnt; j++)
			{
				ans += dis[i][temp[j]];
			}
		}
		x /= 2;
	}
	return ans;
}

double MAX(double a, double b)
{return a > b ? a : b;}

int main()
{
	//init ();
	LL n, m, i, j, k;
	while (scanf("%lld%lld", &n, &m) == 2)
	{
		for(i = 1;i <= n;i ++)
		{
			scanf("%lf%lf%lf", &l[i], &a[i], &b[i]);
			for(j = 1;j < i;j ++)
			{
				dis[i][j] = dis[j][i] = (l[i] - l[j]) * (l[i] - l[j]) + (a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]);
			}
		}

		if (m <= 1 || n == 0)
		{
			printf ("0.00000000000000000000\n");
			continue;
		}
		double ans = 0.0;
		for(i = 1;i < (1 << n);i ++)
		{
			//if (num[i] == m)
			if (judge (i) == m)
			{
				double temp = cal (i);
				ans = MAX (ans, temp);
			}
		}
		printf("%.20lf\n", ans);
	}
}

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

int main()
{
    long long N;
    cin >> N;
    long long X[100], Y[100], H[100];
    for (long long i = 0; i < N; ++i) {
        cin >> X[i] >> Y[i] >> H[i];
    }

    for (int x = 0; x < 101; ++x) {
        for (int y = 0; y < 101; ++y) {
            bool found = true;
            long long h = -1;
            for (long long n = 0; n < N; ++n) {
                if (H[n] == 0) {
                    continue;
                }
                h = H[n] + abs(X[n] - x) + abs(Y[n] -y);
            }
            for (long long n = 0; n < N; ++n) {
                long long h_candidate = max(h - abs(X[n] - x) - abs(Y[n] - y), 0ll);
                if (H[n] != h_candidate) {
                    found = false;
                    break;
                }
            }
            if (found) {
                printf("%d %d %lld\n", x, y, h);
                return 0;
            }
        }
    }

    return 0;
}



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

int main(){
    int r;
    cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

T = [(A[i], i) for i in range(N)]+[(B[i], N+i) for i in range(N)]
T.sort()

P = [-1]*(2*N)
for i in range(N):
  if T[i][0]==T[i+N][0]:
    print("No")
    exit(0)
  P[T[i][1]] = T[i+N][1]
  P[T[i+N][1]] = T[i][1]

bp1 = N
for ap1 in range(N):
  if P[ap1]//N==1:
    continue
  while P[bp1]//N==0:
    bp1 += 1
  ap2 = P[ap1]
  bp2 = P[bp1]
  if A[ap1]!=B[bp1-N] and A[ap2]!=B[bp2-N]:
    P[ap1] = bp1
    P[bp1] = ap1
    P[ap2] = bp2
    P[bp2] = ap2
  else:
    P[ap1] = bp2
    P[bp1] = ap2
    P[ap2] = bp1
    P[bp2] = ap1

print("Yes")
print(" ".join(str(B[P[i]-N]) for i in range(N)))


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

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

    n %= k;
    ll var= n ;
    ll foo = -n+k ;
    cout << min(var, foo) << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main()
{
	char a[10];
	int n,m,i,j,k;
	while(~scanf("%s",a))
	{
		k=0;
		for(i=1;i<4;i++)
		if(a[i]==a[i-1]) k=1;
		if(!k) printf("Good\n");
		else  printf("Bad\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const long INF=LONG_MAX;

int main(){
    LL N,W;
    cin>>N>>W;
    LL w0,v0;
    vector<LL>wv[4],wv2[4];
    cin>>w0>>v0;
    wv[0].PB(v0);
    REP(i,N-1LL){
        long w,v;
        cin>>w>>v;
        wv[w-w0].PB(v);
    }

    REP(i,4){
        sort(wv[i].begin(),wv[i].end(),greater<long>());
        wv2[i].PB(0);
        REP(j,SZ(wv[i]))wv2[i].PB(wv2[i].back()+wv[i][j]);
    }
    LL res=0;
    REP(i,N+1LL)REP(j,N+1LL)REP(k,N+1LL)REP(l,N+1LL){
        if(i+j+k+l<=N&&i*w0+j*(w0+1LL)+k*(w0+2LL)+l*(w0+3LL)<=W){
            if(SZ(wv[0])>=i&&SZ(wv[1])>=j&&SZ(wv[2])>=k&&SZ(wv[3])>=l){
                res=max(res,wv2[0][i]+wv2[1][j]+wv2[2][k]+wv2[3][l]);
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

struct CumulativeSum2D {
    int h, w;
    vvll data;

    CumulativeSum2D(int H, int W) {
        h = H;
        w = W;
        data.resize(h+1, vll(w+1, 0));
    } 

    void add(int x, int y, ll z) {
        if(x >= h || y >= w) return;
        ++x, ++y;
        data[x][y] += z;
    }

    void build() {
        for(int i = 1; i <= h; i++) {
            for(int j = 1; j <= w; j++) {
                data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
            }
        }
    }

    ll query(int sx, int sy, int gx, int gy) {
        return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
    }
};

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    CumulativeSum2D sum(n, n);
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        --l;
        --r;
        sum.add(l, r, 1);
    }
    sum.build();

    rep(i, q) {
        int p, q;
        cin >> p >> q;
        --p;
        --q;
        int ans = sum.query(p, p, q+1, q+1);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2944
from itertools import islice

# 入力
N, K = map(int, input().split())

# スターグラフに適当に辺を追加する
S = (N - 1) * (N - 2) // 2
D = S - K

ans = (
    -1 if K > S else
    '{}\n{}'.format(
        (N - 1) + D,
        '\n'.join(
            '{} {}'.format(u, v)
            for u, v in [
                (1, i)
                for i in range(2, N + 1)
            ] + [
                (u, v)
                for u, v in islice(
                    (
                        (x, y)
                        for x in range(2, N + 1)
                        for y in range(x + 1, N + 1)
                    ),
                    D
                )
            ]
        )
    )
)

# 出力
print(ans)


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

int main() {
  long long a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  long long a_dist = v * t;
  long long b_dist = w * t;
  if (a > 0) {
    if (b > 0) {
      if (a < b) {
        if (a + a_dist >= b + b_dist) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
      } else {
        if (a - a_dist <= b - b_dist) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
      }
    } else if (b == 0) {
      if (a - a_dist <= b - b_dist) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    } else {
      if (a - a_dist <= b - b_dist) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  } else if (a == 0) {
    if (b > 0) {
      if (a + a_dist >= b + b_dist) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    } else {
      if (a - a_dist <= b - b_dist) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  } else {
    if (b > 0) {
      if (a + a_dist >= b + b_dist) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    } else if (b == 0) {
      if (a + a_dist >= b + b_dist) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    } else {
      if (a > b) {
        if (a - a_dist <= b - b_dist) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
      } else {
        if (a + a_dist >= b + b_dist) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
      }
    }
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X; cin >> X;
  int ans=0;
  if(X<=3){
    cout << 1 << endl;
    return 0;
  }
  for(int i=2;i<34;i++){
    int k=i;
    while(true){
      if(k>X) break;
      k*=i;
      if(k<=X){
        ans=max(ans,k);
      }
    }
  }
  cout << ans << endl;
}



      
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m;
	int ans=0;
	cin >>n>>m;
	Vi x(m),dis(m-1,0);
	rep(i,m){
		cin>>x[i];
	}
	sort(all(x));
	rep(i,m){
		if(i!=0){
			dis[i-1]=x[i]-x[i-1];
		}
	}
	sort(all(dis));
	for(int i=0;i<m-n;i++){
		ans+=dis[i];
	}

	cout<<ans<<endl;
}
/*
1 2 10 12 14
(2)
1 8 2 2
*/

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

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: 3608
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
#define pie 3.141592653589793238
const int inf=0x3f3f3f3f3f3f3f3f;
 
void zz(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
 
int32_t main(){
zz();
int n;cin>>n;
double x=2*pie*n*(1.0);
cout<<fixed<<setprecision(20)<<x<<endl;
 
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp(a, b) make_pair(a, b)
#define pb push_back

const long long MOD = 1000000007;


int main(){
    ll n, l;
    cin >> n >> l;
    vector<string> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(all(v));
    rep(i, n){
        cout << v[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll gcd(ll x, ll y) { return (y ? gcd(y, x % y) : x); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	init();

	int N, K; cin >> N >> K;
	vector<int>vec(N);
	rep(i, 0, N)cin >> vec[i];
	int ans = 0;
	rep(i, 0, N) {
		ans += min(abs(K - vec[i]), vec[i]) * 2;
	}
	cout << ans << "\n";

	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

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

    ll N, D;
    cin >> N >> D;
    int result = 0;
    REP(_, N) {
        ll X, Y;
        cin >> X >> Y;
        if (X * X + Y * Y <= D * D) {
            ++result;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3644
def solve(l,k):
    if len(l[k])==0:print('ABC'[k])
    else:temp=l[k][0];del l[k][0];solve(l,temp)
l=[]
for _ in range(3):l.append(list(map(int,input().replace('a','0').replace('b','1').replace('c','2'))))
solve(l,0)

Measured memory_bytes: 3188
a = list(map(int, input().split()))

A = a[0]
B = a[1]
T = a[2]

cout = 0
loopCount = 1
timeOut = T + 0.5
time = A
while True:
    if time >= timeOut:
        break
    cout += B
    loopCount += 1
    time = A * loopCount

print(cout)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

constexpr int mod = 1000000007;
struct mint {
  long long x;
  constexpr mint(long long x = 0) : x((x % mod + mod) % mod) {}
  constexpr mint operator-() const { return mint(-x); }
  constexpr mint &operator+=(const mint &a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator-=(const mint &a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  constexpr mint &operator*=(const mint &a) {
    (x *= a.x) %= mod;
    return *this;
  }
  constexpr mint operator+(const mint &a) const {
    mint res(*this);
    return res += a;
  }
  constexpr mint operator-(const mint &a) const {
    mint res(*this);
    return res -= a;
  }
  constexpr mint operator*(const mint &a) const {
    mint res(*this);
    return res *= a;
  }
  constexpr mint pow(long long t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  constexpr mint inv() const { return pow(mod - 2); }
  constexpr mint &operator/=(const mint &a) { return (*this) *= a.inv(); }
  constexpr mint operator/(const mint &a) const {
    mint res(*this);
    return res /= a;
  }
};
ostream &operator<<(ostream &os, const mint &m) {
  os << m.x;
  return os;
}

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

mint factorial(int k) {
  mint sum = 1;
  for (int i = 1; i <= k; ++i) {
    sum *= i;
  }
  return sum;
}

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

  ll n, a, b;
  cin >> n >> a >> b;

  mint mint_two = 2;
  mint all = mint_two.pow(n) - 1;
  mint ans = all - comb(n, a) - comb(n, b);
  cout << ans.x << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
long long n;
long long ans=0;
int main(){
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0) ans+=i;
	}
	cout<<ans;
	return 0;
}

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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int x;
  cin >> x;
  
  if(x>=30) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string A,B,C;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C;
	if(A.back()==B[0] && B.back()==C[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    string s;
    cin >> s;
    if(s[2]==s[3] and s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, M, T; cin >> N >> M >> T;
    int A[N]; rep(i, N) cin >> A[i];
    int ans = max(A[0]-M, 0) + max(T-M-A[N-1], 0);
    for(int i = 0; i < N-1; i++){
        ans += max(0, (A[i+1]-A[i]-2*M));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>

int linear_search(int A[], int n, int key);

int main()
{
	using namespace std;
	int n, A[10000 + 1], q, key, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> key;
		if (linear_search(A, n, key))
		{
			sum++;
		}
	}
	cout << sum << endl;
}

int linear_search(int A[], int n, int key)
{
	int i = 0;
	A[n] = key;
	while (A[i] != key)
	{
		i++;
	}
	return i != n;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int k,t;
    cin>>k>>t;
    int ma=0;
    REP(i,t){
        int a;
        cin>>a;
        chmax(ma,a);
    }
    cout<<max(2*ma-1-k,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	bool even = true;
	for (int i = 0; i < n; i++) even &= a[i] % 2 == 0;
	cout << (!even ? "first" : "second") << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath> 
using ll = long long;
using namespace std;
ll ans=0;
#define rep(i,n) for(int i=0;i<n;i++)
int ctoi(char c){
	return c-'0';
}
int main(){
  int ans;
  int N;cin>>N;
  int K;cin>>K;
  if(K==1){
    ans=0;
  }else{

  ans=N-K;

  }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a,b;
  scanf("%d%d",&a,&b);
  
  if( (a*b)% 2== 1){
    printf("Odd");
    return 0;
  }
  if((a*b)%2 == 0){
    printf("Even");
      return 0;
    }
  }

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair

double dp[3002];

int main(){
	int n;
	scanf("%d",&n);
	double p[3002];
	for(int i=1;i<=n;i++){
		scanf("%lf",&p[i]);
	}

	dp[0]=1;
	for(int i=1;i<=n;i++){
		for(int j=n;j>=1;j--){
			dp[j] = dp[j-1]*p[i] + dp[j]*(1-p[i]);
			// printf("dp[%d] %lf\n",j,dp[j] );
		}
	}
	// for(int i=1;i<=n;i++)
	// 	printf("%d %lf\n",i,dp[i] );
	double ans=dp[n/2+1];
	printf("%.12lf\n",ans );




	return 0;
}


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

typedef struct {int from, to, w;} Edge;

int parent[100], rank[100];
Edge edge[10000];

int compare(const void *a, const void *b) {
	return ((Edge *)a)->w - ((Edge *)b)->w;
}

void init(int n) {
	int i;
	for (i = 0; i < n; i++) {
		parent[i] = i;
		rank[i] = 0;
	}
}

int find(int x) {
	return parent[x] != x ? parent[x] = find(parent[x]) : x;
}

void unite(int x, int y) {
	const int xr = find(x), yr = find(y);
	if (rank[xr] < rank[yr])
		parent[xr] = yr;
	else if (xr != yr) {
		parent[yr] = xr;
		rank[xr] += rank[xr] == rank[yr];
	}
}

int kruskal(int v, int e) {
	int i;
	int sum;

	qsort(edge, e, sizeof(Edge), &compare);

	init(v);

	sum = 0;
	for (i = 0; i < e; i++)
		if (find(edge[i].from) != find(edge[i].to)) {
			unite(edge[i].from, edge[i].to);
			sum += edge[i].w;
		}

	return sum;
}

int main(void) {
	int i, j;
	int n;
	int e;

	scanf("%d", &n);

	e = 0;
	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++) {
			int a;
			scanf("%d", &a);
			if (a != -1)
				edge[e++] = (Edge){i, j, a};
		}

	printf("%d\n", kruskal(n, e));

	return 0;
}

Measured memory_bytes: 816
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i;
	int yama[10];
	for(i=0;i<10;i++){
		scanf("%d",&yama[i]);
	}
	sort(yama,yama+10,greater<int>());
	for(i=0;i<3;i++){
		printf("%d\n",yama[i]);
	}
	return 0;
} 

Measured memory_bytes: 1044
#(x, a, b) = [int(i) for i in input().split()]

line = input()
nums = line.split()
x = int(nums[0])
a = int(nums[1])
b = int(nums[2])

ans = 'A'
if abs(x - b) < abs(x - a):
    ans = 'B'

print(ans)

Measured memory_bytes: 3060