akhauriyash/Code-Regression huggingface dataset:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        '''
        注意：0-idx
        '''
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())
uf = UnionFind(n)
for _ in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)
ans = 0
for i in range(n):
    ans = max(ans,uf.size(i))
print(ans)


Measured memory_bytes: 76300
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n;
    cin >> n;
    cout << n / 2 + (n % 2 != 0) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int[] heights = new int[10];
		int temp;
		
		for(int i = 0; i < 10; i++)
		{
			heights[i] = Integer.parseInt(scan.nextLine());
		}
		
		for(int i = 0; i < heights.length; i++)
		{
			for(int k = 1; k < heights.length - i; k++)
			{
				if( heights[k-1] > heights[k])
				{
					temp = heights[k];
					heights[k] = heights[k-1];
					heights[k-1] = temp;
				}
			}
		}
		for(int i = heights.length - 1; i > heights.length - 4; i--)
		{
			System.out.println(heights[i]);
		}
		scan.close();
	}
}

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

class AtCoder
{
    static void Main(string[] args)
    {
        string[] a = Input().Split(' ');
        int R = Int(a[0]);
        int G = Int(a[1]);
        int B = Int(a[2]);
        int N = Int(a[3]);
        int ans = 0;

        for(int r_i = 0;r_i * R <= N;r_i++)
        {
            for (int g_i = 0; r_i * R + g_i * G <= N; g_i++)
            {

                if((N - (r_i * R + g_i * G) )% B == 0)
                {
                    ans += 1;
                }
            }
        }

        Print(ans.ToString());
    }


    static long Gcd(long a, long b)
    {
        return (a < b) ? Gcd(b, a)
             : (b > 0) ? Gcd(b, a % b)
                       : a;
    }

    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }

    static int Int(string s)
    {
        return int.Parse(s);
    }

    static string String(int i)
    {
        return i.ToString();
    }

    static void Print(string text)
    {
        Console.WriteLine(text);
    }

    static string Input()
    {
        return (Console.ReadLine());
    }
}

public class Modulo
{
    private const int M = 1000000007;
    private readonly int[] m_facs;
    public int Mul(int a, int b)
    {
        return (int)(Math.BigMul(a, b) % M);
    }
    public Modulo(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
        {
            m_facs[i] = Mul(m_facs[i - 1], i);
        }
    }
    public int Fac(int n)
    {
        return m_facs[n];
    }
    public int Pow(int a, int m)
    {
        switch (m)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                int p2 = Mul(p1, p1);
                return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }
    public int Div(int a, int b)
    {
        return Mul(a, Pow(b, M - 2));
    }
    public int Ncr(int n, int r)
    {
        if (n < r) { return 0; }
        if (n == r) { return 1; }
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}


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

using namespace std;
using ll = long long;

const int limit = 50;
int N,M;
vector<int> a(limit);
vector<int> b(limit);
vector<vector<bool>> graph(limit,vector<bool>(limit)); //辺
vector<bool> vis(limit); //頂点

void dfs (int v) {
  //vは頂点の場所
  //vを訪れていたらやめる
  if (vis[v]) return;
  vis[v] = true;
  for (int i = 0; i < N; i++) {
    if (graph[v][i]) dfs(i);
  }
}

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

  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  int ans = 0;

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

    graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

    for (int j = 0; j < N; j++) vis[j] = false;

    dfs(0);

    bool connected = true;
    for (int i = 0; i < N; i++) {
      if (!vis[i]) {
        connected = false;
      }
    }
    if (!connected) ans++;

    graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }

  cout << ans << endl;

}


Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int MOD = 1e9 + 7;

int64 inv(int64 a, int64 mod) {
  a %= mod;
  int64 v[] = { 0, 1, mod };
  int64 u[] = { 1, 0, a };
  while (v[2] != 1) {
    if (v[2] < u[2]) {
      int64 tmp[] = { v[0], v[1], v[2] };
      v[0] = u[0]; v[1] = u[1]; v[2] = u[2];
      u[0] = tmp[0]; u[1] = tmp[1]; u[2] = tmp[2];
      continue;
    }
    int64 coe = v[2] / u[2];
    for (int i = 0; i < 3; ++i) v[i] = v[i] - u[i] * coe;
  }
  return v[0] < 0 ? v[0] + mod : v[0];
}

int64 pow(int64 a, int64 p, int64 mod) {
  a %= mod;
  int64 ret = a;
  while (p > 1) {
    if (p % 2) {
      ret = (ret * ret) % mod;
      ret = (ret * a) % mod;
    } else {
      ret = (ret * ret) % mod;
    }
    p /= 2;
  }
  return ret;
}

int main() {
  //cout << fixed << setprecision(15);
  int H, W, N;
  cin >> H >> W >> N;
  vector<int> vi;
  vi.reserve(H*W);
  int tmp;
  rep(i, N) {
    cin >> tmp;
    rep(j, tmp) vi.push_back(i+1);
  }

  rep(i, H) {
    rep(j, W) {
      cout << vi[i*W + j] << " ";
    }
    cout << "\n";
    ++i;
    if (i >= H) break;
    rep(j, W) {
      cout << vi[i*W + W - j - 1] << " ";
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 384
// https://atcoder.jp/contests/arc056/tasks/arc056_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    string s;
    cin >> s;
    int p = s.length() - 1, ans = 0;
    REP(b, (1 << p)) {
        int sum = 0, pos = 0;
        REP(i, p) {
            if (b & (1 << i)) {
                string t = s.substr(pos, i + 1 - pos);
                sum += stoll(t);
                pos = i + 1;
            }
        }
        string t = s.substr(pos, p + 1);
        sum += stoll(t);
        ans += sum;
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3620
import sys
str = input().split()

str[0] = int(str[0])
str[1] = int(str[1])
str[2] = int(str[2])

if str[0] < str[2]:
  if str[1] > str[2]:
    print('Yes')
    exit(0)

if str[0] > str[2]:
  if str[1] < str[2]:
    print('Yes')
    exit(0)
print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <limits.h>

#define N 500000

void merge(int*, int, int, int);
void mergesort(int*, int, int);

int count = 0;

int main(){
  int A[N];
  int right, mid, i;

  scanf("%d", &right);
  for(i = 0; i < right; i++){
    scanf("%d", &A[i]);
  }
  
  mergesort(A,0, right);
  
  for(i = 0; i < right-1; i++){
    printf("%d ", A[i]);
  }

  printf("%d\n", A[i]);
  printf("%d\n", count);
  
  return 0;
}

void merge(int*A, int left, int right, int mid){
  int L[N/2+5], R[N/2+5];
  int n1 = mid - left;
  int n2 = right - mid;
  int i, j , k;

  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;

  i = 0;
  j = 0;
  
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
    count++;
  }
}

void mergesort(int *A, int left, int right){
  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, right, mid);
  }
}



Measured memory_bytes: 5672
# a以上b以下の整数で小さい方からk番目以内であるか、大きい方からk番目以内である
a,b,k = map(int, input().split())
for i in range(a, min(a+k,b+1)):
    print(i)
for i in range(max(a+k,b-k+1), b+1):
    print(i)




Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: usize,
        k: i32,
        x: [i32; n],
    }
    let mut ret = 0;
    for i in 0..n {
        ret += 2 * x[i].min(k - x[i]);
    }
    println!("{}", ret);
}


Measured memory_bytes: 2120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define Rep(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int fact(int n){
    if(n == 1) return 1;
    return fact(n-1) * n;
}

int main(){
    int n; cin >> n;
    vector<pair<double, double>> T(n);
    rep(i, n) cin >> T[i].first >> T[i].second;

    double sum = 0.0;

    vi P(n); rep(i, n) P[i] = i;

    do{
        double length = 0.0;
        rep(i, n-1){
            double x_i = T[P[i]].first, y_i = T[P[i]].second;
            double x_j = T[P[i+1]].first, y_j = T[P[i+1]].second;

            double ll_i_j = pow(x_i - x_j, 2) + pow(y_i - y_j, 2) ;
            double l_i_j = sqrt(ll_i_j);

            length += l_i_j;
        }


        sum += length;
        //
    }while(next_permutation(all(P)));




    printf("%lf", sum/fact(n));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,T;
    cin >> N >> T;
    vector<int> t(N);
    for (int i = 0; i < N; i++) {
        cin >> t[i];
    }   
    ll now = 0;
    ll ans = 0;
    for(int i = 0 ; i < N; i++){
        if(now >= t[i]){
            ans += T - (now - t[i]);
        }else{
            ans += T;
        }
        now = t[i] + T;
    }
    pr(ans);
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            var ans = 0L;
            for (int i = 1; i < N; i++)
            {
                if (A[i] < A[i - 1])
                {
                    ans += A[i - 1] - A[i];
                    A[i] = A[i - 1];
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 47004
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> price(n);
  for (int i = 0; i < n; i++) {
    int p;
    cin >> price.at(i);
  }
  int sum_price = accumulate(price.begin(), price.end(), 0);
  int max_price = *max_element(price.begin(), price.end());
  cout << sum_price - max_price / 2 << endl;

}


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

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

  string a = "", b = "";
  for(int i = 0; i < m; i++){
    a += to_string(n);
  }
  for(int i = 0; i < n; i++){
    b += to_string(m);
  }

  if(a > b){
    cout << b << endl;
  }else{
    cout << a << endl;    
  }
}

Measured memory_bytes: 256
s=input('')
t=input('')
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
c=0
d=0
while c<26:
    if s+l[c]==t:
        print('Yes')
        d=1
        break
    c=c+1

if d==0:
    print('No')

Measured memory_bytes: 9076
S = gets.chomp
N = S.size

sections = []

back_track = 0
0.upto(N-1) do |i|
  if S[i, 2] == 'RL'
    left = i+1 - back_track
    right = (i+2).upto(N-1).reduce(1) { |r, si| break r if S[si] == 'R'; r+1 }
    back_track = i+1 + right
    sections.push [i, left, right]
  end
end

result = [0] * N
sections.each do |section|
  i = section[0]
  left = section[1]
  right = section[2]
  result[i] = left/2 + left%2 + right/2
  result[i+1] = left/2 + right/2 + right%2 
end

puts result.join(' ')


Measured memory_bytes: 7676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n,m,i;
  cin >> n >> m;

  vector<pair<int, int> > a;

  a.resize(m);

  for(i=0;i<m;i++){
    cin >> a[i].first >> a[i].second;
  }

  sort(a.begin(),a.end());

  int tmp = a[0].second;
  int ans = 1;
  
  i = 1;
  while(i<m){
    if(tmp<=a[i].first){
      ans++;
      tmp = a[i].second;
    }
    else if(tmp>a[i].second){
      tmp = a[i].second;
    }
    i++;
  }

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


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

public class Hello{
        static void Main(string[] args)
        {
            string[] str=Console.ReadLine().Split(' ');
            var num=new[]{int.Parse(str[0]),int.Parse(str[1]),int.Parse(str[2])};

            Array.Sort(num);

            Console.WriteLine(num[2]*10+num[1]+num[0]);        
        }
           
}

Measured memory_bytes: 11476
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 int main()
 {
   string s;
   int order;
   cin>>s>>order;
   while(order--)
   {
     string cmd;
     cin>>cmd;
     if(cmd=="replace")
     {
       int start,end;
       string change;
       cin>>start>>end>>change;
       string a=s.substr(0,start);
       string b=s.substr(start,end-start+1);
       string c=s.substr(end+1);
       s=a+change+c;     
       //cout<<s<<endl;             
     }              
     else if(cmd=="reverse")
     {
       int start,end;
       cin>>start>>end;
       string a=s.substr(0,start);
       string b=s.substr(start,end-start+1);
       //cout<<b<<endl;
       string c=s.substr(end+1);
       for(int i=0;i<b.length()/2;i++) swap(b[i],b[b.length()-i-1]);
       s=a+b+c;    
       //cout<<s<<endl;   
     }
     else
     {
       int start,end;
       cin>>start>>end;
       string b=s.substr(start,end-start+1);
       //cout<<s<<endl; 
       cout<<b<<endl;    
     }
   }
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3208
a,b,k=list(map(int,input().split()))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
num=gcd(a,b)
c=[]
for i in range(1,num+1):
    if num % i == 0:
        c.append(i)

print(c[len(c)-k])


Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int main(){
    long long int S;
    cin >> S;
    long long int x1,x2,x3,y1,y2,y3,I;
    I = 1000000000;
    x1=0;
    y1=0;
    x2=I;
    y2=1;
    x3 = (I-S%I)%I;
    y3 = (S+x3)/I;
    printf("%lld %lld %lld %lld %lld %lld\n",x1,y1,x2,y2,x3,y3);
}


Measured memory_bytes: 256
n, m  =map(int, input().split())

mod = 10**9+7
ans = 1


if abs(n-m) >= 2:
    ans = 0
elif abs(n-m) == 1:
    for i in range(1, max(n, m)+1):
        ans *= i
        ans %= mod
    for j in range(1, min(n, m)+1):
        ans *= j
        ans %= mod
elif abs(n-m) == 0:
    for i in range(1, n+1):
        ans *= i
        ans %= mod
    ans **= 2
    ans*= 2
    ans %= mod


print(ans)


Measured memory_bytes: 9160
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

vector<ll> a(20);

int main(){
	for(auto i=a.begin();i!=a.end();i++) cin>>*i;
	sort(a.begin(),a.begin()+10);
	sort(a.begin()+10,a.end());
	cout<<a[7]+a[8]+a[9]<<' '<<a[17]+a[18]+a[19]<<endl;
}

Measured memory_bytes: 3096
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!long;
  auto a = n * (n + 1) / 2 - n;
  a.writeln;
}


Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b
# s = input()


L, R = map(int, input().split())
ans = 2019

if R - L + 1 >= 2019:
    ans = 0
else:
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp = (i*j) % 2019
            ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 41564
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvcha;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);

  char　小文字のほうが32大　　  　大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

  int i = sqrt (n) で、ｎの平方根(9に対する3)をiに入れる

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除             */

int a = 0, b = 0, c = 0, d = 0, x = 0, y = 0
, z = 0, n = 0, sum = 0, i = 0, ans = 0, cnt = 0;
string s = "";

int main(void) {
	cin >> n;
	vllint a(n);
	int cnt = 0;
	vcin(a, n);
	sort(a);
	rep(i, n - 1) {
		if (a[i] == a[i + 1]) {
			cout << "NO" << rt; return 0;
		}
	}
	cout << "YES" << rt;
	please AC;
}

Measured memory_bytes: 1792
defmodule Main do       
def main do             
IO.gets("") |> String.trim() |> String.to_integer() |> solve()
end
 
def solve(maney) when maney > 1000, do: solve(maney-1000)
def solve(0, _), do: IO.puts(0)
def solve(maney) when maney <= 1000, do: IO.puts(1000 - maney)
end

Measured memory_bytes: 30768
using System;

class A12{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[,] mat = new int[n,n];
    int count = 0;
    bool[] memoryPos = new bool[n];
    int[] m = new int[n];

    for(int i = 0;i < n;i++){
      m[i] = int.MaxValue;
    }
    m[0] = 0;

    for(int i = 0;i < n;i++){
      string str = Console.ReadLine();
      char c = ' ';
      string str2 = str.Trim(c);
      string[] str3 = str2.Split();

      for(int j = 0;j < n;j++){
        mat[i,j] = int.Parse(str3[j]);
      }
    }

    for(int i = 0;i < n;i++){
      int min = int.MaxValue;
      int pos = -1;

      for(int j = 0;j < n;j++){
        if(!memoryPos[j] && m[j] < min){
          min = m[j];
          pos = j;
        }
      }

      memoryPos[pos] = true;
      count += m[pos];

      for(int j = 0;j < n;j++){
        m[j] = Math.Min(m[j],mat[pos,j] < 0 ? int.MaxValue : mat[pos,j]);
      }
    }
    Console.WriteLine(count);
  }
}


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

int main()
{
   int n,count=0,max=INT_MIN;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    if(a==b){
      count++;
      if(max<count)max=count;
    }
    else count=0;
  }
  if(max>=3)printf("Yes");
  else printf("No");
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n; cin >> n;
  vector<int> hoge(n);
  int tmp;
  bool f = false;
  rep_i(i, n){
    cin >> tmp;
    if(tmp == 2){
      f = true;
    }
    hoge[i] = tmp;
  }

  if(!f){
    say(-1)
    return 0;
  }

  int ind = 0;
  int cnt = 0;
  vector<bool> rireki(int(1e5), false);
  rireki[0] = true;
  while(true){
    ind = hoge[ind] - 1;
    cnt++;
    if(ind == 1){
      say(cnt)
      return 0;
    }else{
      if(rireki[ind]){
        say(-1)
        return 0;
      }else{
        rireki[ind] = true;
      }
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ( (A + B) > (C + D) ) {
    cout << "Left"  << endl;
  }
  else if( (A + B) == (C + D) ){
    cout <<"Balanced"  << endl;
  }
   else {
    cout <<"Right"  << endl;
  }
  
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
string s;
int x, a, b;

int main() {
	cin >> a >> b;
	if (a > b)cout << "a > b" << endl;
	else if (a < b)cout << "a < b" << endl;
	else cout << "a == b" << endl;
	return 0;
}


Measured memory_bytes: 3004
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [i64; n],
    }
    let add = n*(n+1)/2;
    let sum = aa.iter().sum::<i64>();
    if sum%add as i64 != 0 {
        return puts!("{}\n", "NO");
    }
    let k = sum/add as i64;

    let mut cnt = 0;
    for i in 0..n {
        let a = aa[i];
        let b = aa[ (i+1)%n ];
        let temp = k-b+a;
        if temp%n as i64 != 0 {
            return puts!("{}\n", "NO");
        }
        if temp < 0 {
            return puts!("{}\n", "NO");
        }
        cnt += temp/n as i64;
    }
    if cnt == k {
        puts!("{}\n", "YES");
    } else {
        puts!("{}\n", "NO");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define time efsfdsf
using namespace std;
typedef long long ll;
struct dats{ll x,y,p[10];};
struct datp{ll v,p;}; 
int n,m,W,T;
map<string,int>M;
dats shop[10];
datp prod[10];
vector<ll> time(1<<10,1e9);
void Min(ll &a,ll b){a=min(a,b);}
void Max(ll &a,ll b){a=max(a,b);}
int dis(int a,int b){return abs(shop[a].x-shop[b].x)+abs(shop[a].y-shop[b].y);}

void calc_time(int bit,ll cost,int pre){
  for(int i=0;i<n;i++){
    if(bit&(1<<i))continue;
    int nbit = bit|(1<<i);
    ll ncost = cost+dis(i,pre);
    Min(time[nbit],ncost+dis(i,n));
    calc_time(nbit,ncost,i);
  }
}

ll dp[1<<7][10010];
void calc_w(){
  for(int i=0;i<(1<<n);i++){
    vector<ll> p(10,1e9);
    for(int j=0;j<n;j++)
      if(i&(1<<j))for(int k=0;k<m;k++)Min(p[k],shop[j].p[k]);

    for(int j=0;j<m;j++)
      for(int k=0,w=prod[j].v;k<=W-w;k++)Max(dp[i][k+w],dp[i][k]+prod[j].p-p[j]);

    for(int j=1;j<=W;j++) Max(dp[i][j],dp[i][j-1]);
  }
}


ll DP[100010];
ll calc_p(){
  for(int i=0;i<(1<<n);i++)
    for(int k=0;k<=T-time[i];k++)Max(DP[k+time[i]],DP[k]+dp[i][W]);
  ll res=0;
  for(int i=0;i<=T;i++) Max(res,DP[i]);
  return res;
}

int main(){
  cin>>n>>m>>W>>T;
  for(int i=0,v,p;i<m;i++){
    string s;
    cin>>s>>v>>p;
    M[s]=i;
    prod[i] = (datp){v,p};
  }

  shop[n] = (dats){0,0,0};
  for(int i=0,l;i<n;i++){
    cin>>l>>shop[i].x>>shop[i].y;
    string s;
    for(int j=0;j<m;j++) shop[i].p[j] = 1e9;
    for(int j=0,p;j<l;j++)cin>>s>>p,shop[i].p[M[s]] = p;
  }
  calc_time(0,0,n);
  calc_w();  
  cout<<calc_p()<<endl;
  return 0;
}

Measured memory_bytes: 13288
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>

using namespace std;
typedef pair<int, int> P;
int main(void){

	int n;
	while (true){
		cin >> n;
		if (!n)return 0;

		P data[25];
		for (int i = 0; i < n; i++)
		{
			cin >> data[i].second >> data[i].first;
		}
		sort(data, data + n);
		int b = 0;
		for (int i = 0; i < n; i++)
		{
			if (data[i].first - data[i].second >= b)
				b += data[i].second;
			else b = -1;
			if (b < 0)break;
		}
		if (b == -1)cout << "No" << endl;
		else cout << "Yes" << endl;


	}

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#define INF (1<<30)
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, W; cin >> N >> W;
	vector<int> v(N), w(N);
	for (int i = 0; i < N;i++) {
		cin >> v[i] >> w[i];
	}
	int ans = 0;
	vector<int> dp(W + 1, 0);
	for (int i = 0; i <= W; i++) {
		for (int j = 0; j < N;j++) {
			if (i - w[j] < 0) continue;
			dp[i] = max(dp[i], dp[i - w[j]] + v[j]);
			ans = max(dp[i], ans);
		}
	}
	cout << ans << endl;
}

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

bool isPrime(int n)
{
  bool res = true;
  if (n == 2)
  {
    return res;
  }
  for (int i = 2; i <= (int)sqrt(n); i++)
  {
    if (n % i == 0)
    {
      res = false;
      break;
    }
  }
  return res;
}

bool isLikeNumber(int n)
{
  return isPrime(n) && isPrime((n + 1) / 2);
}

int main()
{
  int q;
  cin >> q;
  vector<pair<int, int>> P(q);
  int maximum = 0;
  rep(i, q)
  {
    int l, r;
    cin >> l >> r;
    maximum = max(maximum, r);
    P.at(i) = make_pair(l, r);
  }
  vector<int> dp(maximum + 1);
  dp.at(0) = 0;
  dp.at(1) = 0;
  for (int i = 2; i <= maximum; i++)
  {
    if (i % 2 == 0 || !isLikeNumber(i))
    {
      dp.at(i) = dp.at(i - 1);
      continue;
    }
    dp.at(i) = dp.at(i - 1) + 1;
  }
  rep(i, q)
  {
    int l, r;
    tie(l, r) = P.at(i);
    cout << dp.at(r) - dp.at(l - 1) << endl;
  }
}

Measured memory_bytes: 2300
H, W = map(int, input().split())
A = [list(input())for _ in range(H)]

cnt_j = 0
for i in range(H):
    for j in range(W):
        if(A[i][j] == "#"):
            if(cnt_j <= j):
                cnt_j = j
            else:
                print("Impossible")
                quit()
else:
    print("Possible")

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c=10;
  string s,t;
  cin >>a>>b;
  if(a<b)c=0;
  cout <<c;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;

const int MOD=1000000007;

int main()
{
	int n,k;
	int ans=0;
	cin>>n>>k;
	
	while(n>0)
	{
		n=n/k;
		ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

// elt.at(x) x の親 (Elternteil)
vector<int> elt;
// 木の深さ
vector<int> tiefe;

// ツリーの初期化
void init( int n ){
	elt.clear();
	tiefe.clear();
	for( int i = 0; i < n; ++i ){
		elt.push_back(i);
		tiefe.push_back(0);
	}
}

// wurz(x) x の根 (Wurzel)
int wurz( int x ){
	if( elt.at(x) == x ){
		return x;
	} else {
		// wurz(elt.at(x)) で親の根を順番に再帰的にたどっていく
		// return wurz(elt.at(x)) でも動作はするが，高速化のために経路の圧縮を行う
		// 再帰的にたどって一番上の根にたどり着いたら，elt.at(x) に根を代入することでノードをその根に付け替える
		// こうすることによって深さが 1 になり，木が大きくなることを防ぐことができる
		return elt.at(x) = wurz(elt.at(x));
	}
}

// kopp(x, y) x と y の木をつなげる (koppeln)
void kopp( int x, int y ){
	// 根に根をつなげるので，まず根を探しに行く
	x = wurz(x);
	y = wurz(y);
	if( x == y ) return;
	// 深さの小さい木に深さの大きい木をくっつければ，深さが大きくなる
	// 深さの大きい木に深さの小さい木をくっつければ，深さが変わらない　←このほうが有利
	if( tiefe.at(x) < tiefe.at(y) ){
		elt.at(x) = y;
	} else {
		elt.at(y) = x;
		// 深さ N と 深さ N ならくっつけてできる木の深さは N+1 になる
		// 深さ 0 と 0 のときは 1 になる
		if( tiefe.at(x) == tiefe.at(y) ){
			++tiefe.at(x);
		}
	}
}

// x と y が同じ木に属しているか
bool gleich( int x, int y ){
	return wurz(x) == wurz(y);
}

struct point{
	int x;
	int y;
	int index;
};

struct edge{
	int u;
	int v;
	int cost;
};

int main(){
	int n; cin >> n;
	vector<point> vp;
	for( int i = 0; i < n; ++i ){
		int tmpa, tmpb; cin >> tmpa >> tmpb;
		vp.push_back( (point){tmpa, tmpb, i} );
	}
	vector<edge> graph;
	sort(
		vp.begin(), vp.end(),
		[]( const point& a, const point& b ){
			return ( a.x == b.x ) ? ( a.y < b.y ) : ( a.x < b.x );
		}
	);
	for( int i = 0; i < n-1; ++i ){
		graph.push_back( (edge){ vp[i].index, vp[i+1].index, vp[i+1].x-vp[i].x } );
	}
	sort(
		vp.begin(), vp.end(),
		[]( const point& a, const point& b ){
			return ( a.y == b.y ) ? ( a.x < b.x ) : ( a.y < b.y );
		}
	);
	for( int i = 0; i < n-1; ++i ){
		graph.push_back( (edge){ vp[i].index, vp[i+1].index, vp[i+1].y-vp[i].y } );
	}
	sort( graph.begin(), graph.end(), 
		[]( const edge& a, const edge& b ){
			return ( a.cost == b.cost ) ? ( a.u < b.u ) : ( a.cost < b.cost );
		}
	);
	init(n);
	int ans = 0;
	for( auto e : graph ){
		if( !gleich( e.u, e.v ) ){
			kopp( e.u, e.v );
			ans += e.cost;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6004
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    h, w = MI()
    t = [["."] * (w + 2)] + [["."] + list(input()) + ["."] for _ in range(h)] + [["."] * (w + 2)]
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if t[i][j] == "#": continue
            cnt=0
            for ii in range(i-1,i+2):
                for jj in range(j-1,j+2):
                    if t[ii][jj]=="#":cnt+=1
            t[i][j]=cnt

    for tk in t[1:1+h]:
        print(*tk[1:1+w],sep="")

main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#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--)
typedef long long LL;
int N;

int main(){
	cin>>N;
	string S,T;
	cin>>S>>T;
	string ans;
	REP(i,N){
		ans.push_back(S[i]);
		ans.push_back(T[i]);
	}
	cout<<ans<<endl;
}

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

long int min(long int a, long int b){
    if(a < b){
        return a;
    }else{
        return b;
    }
}

int main(void){
   long int n,tmp,i;
   long int a[5];
   
   scanf("%ld%ld%ld%ld%ld%ld",&n,&a[0],&a[1],&a[2],&a[3],&a[4]);

   tmp = a[0];
   for(i=0; i<5; i++){
       tmp = min(a[i],tmp);
   }

   printf("%ld\n",(long) ceil( (double) n / tmp ) + 4);

   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,n,i,j,b=0,ans;
  cin >> k;
  cin >> n;
  vector<int> a(n);
  vector<int> sa(n);
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  for(i=0;i<n-1;i++){
    sa.at(i)=a.at(i+1)-a.at(i);
    //cout << sa.at(i) << endl;
  }
  sa.at(n-1)=k+a.at(0)-a.at(n-1);
  for(i=1;i<n;i++){
    if(sa.at(b)<sa.at(i))
      b=i;
  }
  ans=k-sa.at(b);
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

int main(void) {
	ll s, x2, x3, y3, buf;
	cin >> s;
	x2 = (ll)sqrt(s);
	y3 = x2;
	while (x2 * y3 < s)
		y3++;
	if (y3 > 1000000000) {
		x2++;
		y3 = x2;
		while (x2 * y3 < s)
			y3++;
	}
	x3 = x2 * y3 - s;
	printf("0 0 %lld 1 %lld %lld\n", x2, x3, y3);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        while (sc.hasNext()) {
            int N = sc.nextInt();
            int L = sc.nextInt();

            int[] flavors = new int[N];
            int sum = 0;

            for (int i = 0; i < N; i++) {
                flavors[i] = L + i;
            }

            if ((flavors[0] < 0 && flavors[N-1] == 0) || (flavors[0] < 0 && flavors[N-1] < 0) ){
                for (int i = 0; i < N - 1; i++)
                    sum += flavors[i];
            }else if ((flavors[0] == 0 && flavors[N-1] > 0) || (flavors[0] > 0 && flavors[N-1] > 0) ){
                for (int i = 1; i < N; i++) {
                    sum += flavors[i];
                }
            }else if (flavors[0] < 0 && flavors[N-1] > 0){
                for (int i = 0; i < N; i++) {
                    if (flavors[i] == 0)
                        continue;
                    sum+= flavors[i];
                }
            }

            System.out.println(sum);


        }


    }
}

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

using namespace std;

int main(int argc, char* argv[])
{
  int N; cin >> N;

  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }
  
  int diff = 0;
  for (int i = 0; i < N; i++) {
    if (V[i] > C[i]) {
      diff += V[i] - C[i];
    }
  }

  cout << diff << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
map<char,int> mcxi;
int main(){
	int n;
	mcxi['m']=1000;
	mcxi['c']=100;
	mcxi['x']=10;
	mcxi['i']=1;
	string num[11]={"0","1","2","3","4","5","6","7","8","9"};
	cin>>n;
	while(n--){
		int ans=0,a=1;
		string s,s1,s2;
		cin>>s1>>s2;
		s=s1;
		for(int i=s.size()-1;i>=0;i--){
			if(s[i]=='i' || s[i]=='x' || s[i]=='c' || s[i]=='m'){
				a=1;
				if(s[i-1]<=57 && s[i-1]>=50)
				a+=s[i-1]-'1';
				ans+=mcxi[s[i]]*a;
			}
		}
		s=s2;
		for(int i=s.size()-1;i>=0;i--){
			if(s[i]=='i' || s[i]=='x' || s[i]=='c' || s[i]=='m'){
				a=1;
				if(s[i-1]<=57 && s[i-1]>=50)
				a+=s[i-1]-'1';
				ans+=mcxi[s[i]]*a;
			}
		}
		if(ans>=1000){
			if(ans/1000>1)
			cout<<ans/1000;
			cout<<'m';
			ans-=ans/1000*1000;
		}
		if(ans>=100){
			if(ans/100>1)
			cout<<ans/100;
			cout<<'c';
			ans-=ans/100*100;
		}
		if(ans>=10){
			if(ans/10>1)
			cout<<ans/10;
			cout<<'x';
			ans-=ans/10*10;
		}
		if(ans>=1){
			if(ans>1)
			cout<<ans;
			cout<<'i';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)

int main(){
    int n;
    scanf("%d", &n);
    rep(i, 1, n + 1){
        int x = i;
        if(!(i % 3)){
            printf(" %d", i);
        }else if(i % 10 == 3){
            printf(" %d", i);
        }else{
            while(x > 0){
                x /= 10;
                if(x % 10 == 3){
                    printf(" %d", i);
                    break;
                }
            }
        }
    }

    printf("\n");

    return 0;
}



Measured memory_bytes: 2096
N,M = map(int,input().split())

l_lst = []
r_lst = []
for i in range(M):
	l,r = map(int,input().split())
	l_lst.append(l)
	r_lst.append(r)

l = max(l_lst)
r = min(r_lst+[N])

print(max(0,r-l+1))

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

// バブルソートを行う関数
int bubbleSort(int A[], int N) {
    // 交換回数
    int sw = 0;
    // 交換したかどうかのフラグ
    bool flag = true;

    while (flag) {
        flag = false;

        for (int j = N - 1; j >= 1; --j) {
            if (A[j] < A[j - 1]) {
                int tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = true;

                ++sw;
            }
        }
    }

    return sw;
}

int main() {
    int A[100], N, sw;
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    sw = bubbleSort(A, N);

    for (int i = 0; i < N; ++i) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;

    return 0;
}


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


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

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

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

    cout << min({a+b,a+c,c+b}) << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  for(int i=0; i<num; i++){ cout << v[i].first << v[i].second; if(i!=num-1) cout << " ";}
  cout << endl;
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
  int n;
  cin >> n; 
  vector<int> s(n);
  for(int i=0; i<n; i++) cin >> s[i];
  int q;
  cin >> q;
  vector<int> t(q);
  for(int i=0; i<q; i++) cin >> t[i];

  int ans = 0;
  sort(s.begin(), s.end());
  for(int i=0; i<q; i++){
    auto iter = lower_bound(s.begin(), s.end(), t[i]);
    auto index = iter - s.begin();
    if(index == (int)s.size()) continue;
    if(s[index] == t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}




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

using namespace std;

int main() {

   int N, D;
   cin >> N >> D;

   vector<vector<int>> X(N, vector<int>(D, 0));
   for (int i = 0; i < N; ++i)
      for (int j = 0; j < D; ++j)
         cin >> X[i][j];

   int count = 0;
   for (int i = 0; i < N; ++i) {
      for (int j = i + 1; j < N; ++j) {
         double L_ij = inner_product(X[i].begin(), X[i].end(), X[j].begin(), 0.0, [](double x1, double x2) { return x1 + x2; }, [](int x1, int x2) { return pow(x1 - x2, 2); });
         double L = sqrt(L_ij);
         if (ceil(L) == floor(L))
            ++count;
      }
   }

   cout << count << endl;

   return 0;
}

Measured memory_bytes: 256