akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 505;
const ll mod = 10;
const ll INF = 0x3f3f3f3f;
const double eps = 1e-9;

int n,K;

struct node
{
    int x,y;
}a[maxn],b[maxn];

bool cmp1(node a,node b)
{
    return a.x<b.x;
}

bool cmp2(node a,node b)
{
    return a.y<b.y;
}

int solve(int i,int j,int k,int l)
{
    int ans=0;
    for(int kk=0;kk<n;kk++)
    {
        if(a[kk].x>=a[i].x&&a[kk].x<=a[j].x&&a[kk].y>=b[k].y&&a[kk].y<=b[l].y)
        {
            ans++;
        }
    }
    return ans;
}

ll area(int i,int j,int k,int l)
{
    return (ll)(a[j].x-a[i].x)*(ll)(b[l].y-b[k].y);
}

int main()
{
    scanf("%d%d",&n,&K);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i].x,&a[i].y);
        b[i].x=a[i].x,b[i].y=a[i].y;
    }
    sort(a,a+n,cmp1);
    sort(b,b+n,cmp2);
    ll ans=4e18;
    for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
    for(int k=0;k<n;k++)
    for(int l=k+1;l<n;l++)
    {
        if(solve(i,j,k,l)>=K)
        {
            ans=min(ans,area(i,j,k,l));
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    sort(all(s));
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int x,y; cin>>x>>y;
	if(x%y==0) return puts("-1"),0;
	for(int i=2;;i++)
		if(y%i) return printf("%lld\n",1LL*i*x),0;
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
def chk_ent(r, c, arr):   
    chk_up = (arr[r-1][c] == '#') if ((r - 1) >= 0) else False
    chk_left = (arr[r][c-1] == '#') if ((c - 1) >= 0) else False
    
    return (chk_up, chk_left)

def chk_exit(r, c, arr):
    my_h = len(arr)
    my_w = len(arr[0])
    
    chk_down = (arr[r+1][c] == '#') if ((r + 1) < my_h) else False
    chk_right = (arr[r][c+1] == '#') if ((c + 1) < my_w) else False
    
    return (chk_down, chk_right)


h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

r = 0
c = 0
while True:
    up, left = chk_ent(r, c, a)
    if (not(up or left) and not((r == 0) and (c == 0))) or (up and left):
        flg = False
        break
    down, right = chk_exit(r, c, a)
    if not(down or right):
        if((r == (h - 1)) and (c == (w - 1))):
            flg = True
            break
        else:
            flg = False
            break
    elif (down and right):
        flg = False
        break
    elif right:
        c += 1
    elif down:
        r += 1
print('Possible' if flg else 'Impossible')

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

typedef long long ll;
const ll INF = 1e9;
const ll INFF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAXN = 1e3;
const double EPS = 1e-9;

bool cek(string a,string b) {
    int cur = 0;
    for (int i = 0 ; i < b.length() ; i++) {
        if (cur == 3) return true;
        if (a[cur] == b[i])
            ++cur;
    }
    return (cur == 3);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    vector< string > tab;
    for (int i = 0 ; i < 10 ; i++) {
        for (int j = 0 ; j < 10 ; j++) {
            for (int k = 0 ; k < 10 ; k++) {
                string tmp;
                tmp += (char)(i + '0');
                tmp += (char)(j + '0');
                tmp += (char)(k + '0');
                tab.push_back(tmp);
            }
        }
    }
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0 ; i < tab.size() ; i++) {
        if (cek(tab[i],s))
            ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
int ans = INT_MAX;
//------------------------------------------------------------------------------
void DFS(int N, const vector<pair<int, int>>& a, int index, int product)
{
    if (product >= N)
    {
        chmin(ans, product);
        return;
    }

    if (index >= a.size())
    {
        return;
    }

    int n = 1;
    for (int i = 0; i <= a[index].second; ++i)
    {
        DFS(N, a, index + 1, product * n);
        n *= a[index].first;
    }
}

void _main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> a;
    int m = M;
    for (int i = 2; i * 2 <= M; ++i)
    {
        int exponent = 0;
        while (m % i == 0)
        {
            ++exponent;
            m /= i;
        }
        if (exponent > 0)
        {
            a.push_back(make_pair(i, exponent));
        }
        if (m == 1) break;
    }
    if (m != 1) a.push_back(make_pair(m, 1));
    DFS(N, a, 0, 1);
    cout << M / ans << endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
using namespace std;
int a[100005];
int n;
int p[5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%4==0)a[i]=4,p[4]++;
		else if(a[i]%2==0)a[i]=2,p[2]++;
		else a[i]=1,p[1]++;
	}
	if(p[1]<=p[4])
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(p[1]==p[4]+1&&p[2]==0)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	else 
	{
		cout<<"No"<<endl;
		return 0;
	}
	
}

Measured memory_bytes: 640
# = int(input())
# = str(input())
L, R, d = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
count = 0

for i in range(L, R+1):
    if i % d == 0:
        count += 1

print(count)


Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,ans=0,i;
    ll a[100000];
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        ans+=a[i]-1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll n,ans,a,a2,ans2,r;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ans=1;
    REP(i,n){
        //cout <<" " << ans << endl;
        cin >> a;
        //cout << ans << ":" << a << endl;
        a2 = a;
        ans2 = ans;
        if(i==0){ ans = a; continue; }
        if(a<ans)swap(a,ans);
        r = a % ans;
        while(r!=0){
            a = ans;
            ans = r;
            r = a % ans;
        }
        ans = (a2/ans)*ans2;
        //cout << "> " << ans << endl;
    }
    cout << ans << endl;
}

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

int main(){
    int a,b;
    char op;
    while(op != '?'){
        scanf("%d %c %d", &a,&op,&b);
        if(op == '+') printf("%d\n",a+b);
        if(op == '-') printf("%d\n",a-b);
        if(op == '*') printf("%d\n",a*b);
        if(op == '/') printf("%d\n",a/b);
        if(op == '?') break;
    }
    
   
return 0;
}


Measured memory_bytes: 3216
N=int(input())
a=0
b=0
c=0
d=0
for i in range(N):
    A=input()
    if A=="AC":
        a+=1
    elif A=="WA":
        b+=1
    elif A=="TLE":
        c+=1
    else:
        d+=1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Measured memory_bytes: 9060
Imports System

Module practiceA
    Sub Main()
        Call test3()


    End Sub

    Sub test1()
        Dim S, W As Integer
        Dim arr(2) As String
        arr = Split(Console.ReadLine())
        S = arr(0)
        W = arr(1)

        If S > W Then
            Console.Write("safe")

        Else
            Console.Write("unsafe")
        End If

    End Sub

    Sub test2()
        Dim A, B, C, D, HP_A, HP_B As Integer
        Dim arr(4) As String
        arr = Split(Console.ReadLine())
        A = arr(0)
        B = arr(1)
        C = arr(2)
        D = arr(3)

        HP_B = C - B


        If HP_B <= 0 Then
            Console.Write("Yes")
            Exit Sub
        End If

        HP_A = A - D

        If HP_A <= 0 Then
            Console.Write("No")
            Exit Sub
        End If

        While True

            HP_B = HP_B - B

            If HP_B <= 0 Then
                Console.Write("Yes")
                Exit While
            End If

            HP_A = HP_A - D

            If HP_A <= 0 Then
                Console.Write("No")
                Exit While
            End If

        End While

    End Sub

    Sub test3()
        Dim N, i, count As Integer

        count = 1

        N = Console.ReadLine()

        Dim stringlist(N - 1) As String

        For i = 0 To N - 1
            stringlist(i) = Console.ReadLine()
        Next i

        Dim uniqueFoods() As String = stringlist.Distinct.ToArray

        count = uniqueFoods.Length

        Console.WriteLine(count)

    End Sub


End Module

Measured memory_bytes: 50820
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,p,a=0,w=0;string J;cin>>N>>M;
  vector<bool>x(N,false);
  vector<int>WA(N,0);
  for(int i=0;i<M;i++){
    cin>>p>>J;
    if(J=="AC"){
      if(!x.at(p-1)){a++;x.at(p-1)=true;w+=WA.at(p-1);}
    }
    else if(!x.at(p-1))WA.at(p-1)++;
  }
  cout<<a<<" "<<w<<endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
int read(){
	register int x = 0;
	register char f = 1, ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
	return f ? x : -x;
}
char s[10];
int main(){
	scanf("%s", s);
	if (s[0] == 'S') puts("Cloudy");
	else if (s[0] == 'C') puts("Rainy");
	else puts("Sunny");
}

Measured memory_bytes: 128
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int A = cin(), B = cin(), C = cin();
    if ((A <= C && C <= B) || (B <= C && C <= A)) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }
  }

  private static List<int> _var;
  public static int cin() { if (_var == null || _var.Count() == 0) { _var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>(); } int ans = _var[0]; _var.RemoveAt(0); return ans; }
  public static void Swap<T>(ref T a, ref T b) {T temp = a;a = b;b = temp;}
  public static string ReadStr() { return Console.ReadLine(); }
  public static int ReadInt() { return int.Parse(Console.ReadLine()); }
  public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  public static long ReadLong() { return long.Parse(Console.ReadLine()); }
  public static char ReadChar() { return Console.ReadLine()[0]; }
  public static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  public static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  public static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13396
a, b = map(int, input().split())

ans = 0
for i in range(a, b + 1):
    s = str(i)
    s = list(s)
    for j in range(len(s) // 2):
        if s[j] != s[len(s) - 1 - j]:
            break
        if j == (len(s) // 2) - 1:
            ans += 1

print(ans)    

Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

N = str(int(input()))
idx = int(N[-1])

if idx == 3:
    print('bon')
elif idx <= 1 or idx == 6 or idx == 8:
    print('pon')
else:
    print('hon')




Measured memory_bytes: 9044
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	int n;
	char s[50+2];
	while(scanf("%d\n%50[A-Z]\n", &n, s)==2)
	{
		int ans=0;
		for(int i=2;s[i];i++)
		{
			if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C')
			{
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll x;
  cin >> x;  
  ll keta=log10(x);

  rep(i,1e4+3){
    ll rest=x-100*i;
    if(rest>=0 && rest<=5*i){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  
  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);


		int n =sc.nextInt();
		int k = sc.nextInt();
		int x[] = new int[n];
		int negnum=0;
		int posnum=0;
		long time1;
		long time2=300000000;

		for (int i=0;i<n;++i){
			x[i]=sc.nextInt();
		}

		for(int i=0;i<=n-k;++i){
			if ((x[i]>0&&x[i+k-1]<0) ||(x[i]<0 && x[i+k-1]>0)){
				time1 = Math.min(2*Math.abs(x[i])+Math.abs(x[i+k-1]), Math.abs(x[i])+2*Math.abs(x[i+k-1]));
			}
			else time1 =Math.max(Math.abs(x[i]),Math.abs(x[i+k-1]));

			time2 = Math.min(time2, time1);
		}

		System.out.println(time2);

	}
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int A[222222];

int N;
int cnt[222222];
int cover[422222];
int uncovered;

void do_cover(int k) {
  if (k < N && cover[k] == 0) --uncovered;
  ++cover[k];
  // printf("COVERING %d\n", k);
}

void do_uncover(int k) {
  --cover[k];
  if (k < N && cover[k] == 0) ++uncovered;
  // printf("UNCOVERING %d\n", k);
}

int main() {
  int M;
  scanf("%d%d", &N, &M);
  REP(i,N) {
    scanf("%d", &A[i]);
    ++cnt[A[i]];
  }

  uncovered = N;
  FOR(i,1,N+1) {
    FOR(j,N-i,N-i+cnt[i]) {
      do_cover(j);
    }
  }

  // FOR(j,1,N+1) printf("CNT %d %d\n", j, cnt[j]);
  // REP(j,N) printf("COVER %d %d\n", j, cover[j]);

  REP(i,M) {
    int X, Y;
    scanf("%d%d", &X, &Y);
    --X;
    do_uncover(N-A[X]+cnt[A[X]]-1);
    --cnt[A[X]];

    A[X] = Y;
    ++cnt[A[X]];
    do_cover(N-A[X]+cnt[A[X]]-1);

    // FOR(j,1,N+1) printf("CNT %d %d\n", j, cnt[j]);
    // REP(j,N) printf("COVER %d %d\n", j, cover[j]);

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


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
long n,m,k;
vector <long> a,b;
vector <long long> sumA,sumB;
long getB(long inA){
    long long passedTime = 0;
    if(inA!=0)passedTime=sumA[inA-1];
    long long remainTime = k - passedTime;
    long ret = 0;
    // for(long i = 0; i < m; i++){
    //     if(sumB[i]<=remainTime){
    //         ret++;
    //     }else{
    //         break;
    //     }
    // }
    decltype(sumB)::iterator it = upper_bound(sumB.begin(),sumB.end(),remainTime);
    long index = it - sumB.begin();
    ret = index;
    return ret;
}
bool isValidA(long inA){
    if(inA==0)return true;
    if(inA>n)return false;
    if(sumA[inA-1]>k)return false;//thisPath"inA">0
    return true;
}
int main(){
    cin >> n >> m >> k;

    a = vector<long>(n);
    sumA = vector<long long>(n,0);
    b = vector<long>(m);
    sumB = vector<long long>(m,0);

    for(long i = 0; i < n; i++){
        cin >> a[i];
        if(i==0){
            sumA[i]=a[i];
        }else{
            sumA[i]=sumA[i-1]+a[i];
        }
    }
    for(long i = 0; i < m; i++){
        cin >> b[i];
        if(i==0){
            sumB[i]=b[i];
        }else{
            sumB[i]=sumB[i-1]+b[i];
        }
    }
    long ans = 0;
    for(long i = 0; i <= n; i++){
        if(isValidA(i)){
            long bnum = getB(i);
            ans = max(ans,bnum+i);
        }else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
/// Start using lower bound !!

void solve ( int test_case )
{
    int n , k ;
    cin >> n >> k ;

    vi v ( n ) ;
    for ( int i=0 ; i < n ; i ++ )
        cin >> v[i] ;

    int maxx = *max_element ( all ( v ) ) ;
    int ans = maxx ;

    for ( int lo = 1 , hi = maxx ; lo <= hi ; )
    {
        int mid = lo + hi >> 1 ;
        int operations = 0 ;

        for ( auto &val : v )
        {
            operations += (val - 1)/mid ;
        }

        if ( operations <= k )
            ans = mid , hi = mid - 1 ;

        else lo = mid + 1 ;
    }

    cout << ans ; line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a[n];
    int i,count=0;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        count+=a[i]-1;
    }
    cout<<count;

    return 0;
}


Measured memory_bytes: 256
var lines = [];
//前後の文字がつながっているかを確認するためハッシュ化
var checkSpell = {};
//標準出力
var stdout = "Yes";
//一つ前の最後の文字を初期化
var lastWord = null;

var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function(line) {
  lines.push(line);
});
reader.on('close', function() {
  var checkSpell = {};
  for(var i = 1; i <= lines[0]; i++) {
    //既出か検索
    var str = lines[i];

    if(checkSpell[str] != undefined || ( lastWord != null && str.slice(0,1) != lastWord)){
      stdout = "No";
      break;
    }

    checkSpell[str] = 'exists';
    lastWord = str.slice(-1);
  }
  console.log(stdout);
});


Measured memory_bytes: 11596
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n , k;
int arr[N];
long long sum[N];
long long sup[N];
long long ans;
int main(){
    scanf("%d %d" , &n , &k);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , arr + i);
        sum[i] = sum[i - 1] + arr[i];
        sup[i] = sup[i - 1] + max(0 , arr[i]);
    }
    for(int i = 1 ; i + k - 1 <= n ; ++i){
        ans = max(ans , sup[i - 1] + max(0LL , sum[i + k - 1] - sum[i - 1]) + sup[n] - sup[i + k - 1]);
    }
    printf("%lld\n" , ans);
}

Measured memory_bytes: 2176
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][][] x = new int[N][N][2];
        int[] A=new int[N];
        int max=0;
        
        for(int i=0;i<N;i++) {
        	A[i] = sc.nextInt();
        	for(int j=0;j<A[i];j++) {
        		x[i][j][0]= sc.nextInt()-1;
        		x[i][j][1]= sc.nextInt();
        	}
        }
        int[] p = new int[N];
        
        for(int i=0;i<Math.pow(2, N);i++) {
        	for(int j=0;j<N;j++) {
        		p[j]=(i>>j)&1;
        	}
        	
    		boolean flg=true;
        	for(int j=0;j<N;j++) {
        		if(p[j]==1) {
        			for(int k=0;k<A[j];k++) {
        				if(p[x[j][k][0]]!=x[j][k][1]) {
        					flg=false;break;
        				}
        				
        			}
        			
        		}
        	}
    		if(flg==true) {
    			int cnt=0;
    			for(int k=0;k<N;k++) {
    				if(p[k]==1) {
    					cnt++;
    				}
    			}
    			max=Math.max(max, cnt);
    		}
        	
        }
        
        
        System.out.println(max);
        		
    }
}

Measured memory_bytes: 24532
#include<iostream>

#define MAX 10000001

bool isPrime[MAX];

int main(){

	for (int i = 2; i < MAX; i++){
		isPrime[i] = true;
	}

	for (int i = 2; i*i < MAX; i++){
		if (isPrime[i]){
			for (int j = i * 2; j < MAX; j += i)isPrime[j] = false;
		}
	}

	int n;
	while (std::cin >> n, n){
		for (int i = n; i >= 8; i--){
			if (isPrime[i] && isPrime[i - 2] && isPrime[i - 6] && isPrime[i - 8]){
				std::cout << i << std::endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 10924
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,k; cin >> n >> k;
  string t; cin >> t;
  vector<int> a(0);
  int cnt=0;
  rep(i,n){
    if(t[i]==t[i+1]) cnt++;
    else{
      a.push_back(cnt+1);
      cnt=0;
    }
  }
  int l=a.size();
  vector<ll> s(l+1);
  s[0]=0;
  rep(i,l) s[i+1]=s[i]+a[i];
  if(t[0]=='1'){
    ll ans=0;
    rep(i,l){
      if(i%2==0){
        if(i+2*k+1<=l) chmax(ans,s[i+2*k+1]-s[i]);
        else chmax(ans,s[l]-s[i]);
      }
    }
    cout << ans << endl;
  }
  else{
    ll ans=2*k<=l?s[2*k]-s[0]:s[l]-s[0];
    rep(i,l){
      if(i%2==1){
        if(i+2*k+1<=l) chmax(ans,s[i+2*k+1]-s[i]);
        else chmax(ans,s[l]-s[i]);
      }
    }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 1656
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
	ll X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}

ll dp[105][100005];
ll v[105];
ll w[105];
int main()
{
	ll n,c;
	cin>>n>>c;
	for(ll i=1;i<=n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=c;j++)
		{
			if(j>=w[i])
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=c;j++)
		{
			ans=max(dp[i][j],ans);
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 79360
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	int n,number;
	double t, a, h[1010], ans = 99999999;
	cin >> n >> t >> a;
	for (int i = 0; i < n; i++) { cin >> h[i]; }
	for (int i = 0; i < n; i++)
	{
		if (fabs(a - (t - h[i] * 0.006)) < ans)
		{
			ans = fabs(a - (t - h[i] * 0.006));
			number = i;
		}
	}
	cout << number + 1 << endl;
	return 0;
}

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

int main() {
	int N;
	cin>>N;
	vector<pair<int, int> > pairs(N);
	for(int i=0;i<N;++i){
		int a,b;
		cin>>a>>b;
		pairs[i]=make_pair(b,a);
	}
	sort(pairs.begin(), pairs.end());

	int time = 0;
	bool ans = true;
	for(int i=0;i<N;++i){
		time += pairs[i].second;
		if (time > pairs[i].first)
		{
			ans = false;
			break;
		}
	}	
	if (ans) 	cout << "Yes" << endl;
	else 		cout << "No" << endl;
	
	return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	string a, b;

	cin >> a >> b;

	string s = a + b;

	ll x = stoll(s);

	REP(i, sqrt(x)) {
		if ((i + 1) * (i + 1) == x) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long func(long long a,long long b){
    return a/b;
}

int main(){
    priority_queue<int> pq;
    vector<pair<int,int> > vp;
    int N,M; cin >> N >> M;
    for (int i = 0; i < N; i++){
        int a,b; cin >> a >> b;
        vp.push_back({a,b});
    }
    sort(vp.begin(),vp.end());
    long long ans = 0;
    int index = 0;

    for (int i = 1; i <= M; i++){
        while (index <= N && vp[index].first <= i){
            pq.push(vp[index].second);
            index++;
        }
        if (pq.size()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 1908
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int N;
        Input(out N);
        string[] nameList = new string[N];
        int[] timeList = new int[N];
        for(int i = 0; i < N; i++) {
            string name;
            int time;
            Input(out name, out time);
            nameList[i] = name;
            timeList[i] = time;
        }
        string X;
        Input(out X);
        int x = Array.IndexOf(nameList, X);
        int sum = 0;
        for(int i = x + 1; i < N; i++) {
            sum += timeList[i];
        }
        Console.WriteLine(sum);
    }
    static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
    static void Input<A>(out A a) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
    }
    static void Input<A, B>(out A a, out B b) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
    }
    static void Input<A, B, C>(out A a, out B b, out C c) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
    }
    static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
    }
    static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d, out E e) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
    }
    static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d, out E e, out F f) {
        var words = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
        a = ChangeT<A>(words[0]);
        b = ChangeT<B>(words[1]);
        c = ChangeT<C>(words[2]);
        d = ChangeT<D>(words[3]);
        e = ChangeT<E>(words[4]);
        f = ChangeT<F>(words[5]);
    }
    static void InputArray<T>(out T[] array) {
        array = Console.ReadLine().Split(new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries).Select(s => ChangeT<T>(s)).ToArray();
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
 
int main()
{
    long long int n;
    while(~scanf("%lld",&n))
    {
        int sum=0;long long int x=n;
        while(x)
        {
            sum+=x%10;
            x=x/10;
        }
       /// printf("%d %d",n,sum)
        if(n%sum==0)
            printf("Yes\n");
        else
            printf("No\n");
    }
 
    return 0;
}

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

#define MIN(a, b) ((a) > (b) ? (b) : (a))

int main() {
  int n;
  scanf("%d\n", &n);
  int b[n-1];
  for (int i=0; i<n-1; i++) {
    scanf("%d", b+i);
  }
  int sum = b[0];
  for (int i=0; i<n-2; i++) {
    sum += MIN(b[i+1], b[i]);
  }
  printf("%d\n", sum+b[n-2]);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int maxN = 3000 + 5;

int n, m;
int64_t cell[maxN][maxN];
int64_t memo[maxN][maxN][4];

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

    int k;
    cin >> n >> m >> k;

    for(int i = 0; i < k; i++) {
        int r, c, v;    cin >> r >> c >> v;
        cell[r][c] = v;
    }

    for(int row = n; row >= 1; row--) {
        for(int col = m; col >= 1; col--) {
            for(int rem = 0; rem <= 3; rem++) {
                if(row == n && col == m) {
                    int64_t best = 0;

                    if(rem > 0) {
                        best = cell[row][col];
                    }

                    memo[row][col][rem] = best;
                    continue;
                }

                int64_t ans = 0;

                if(col + 1 <= m) {
                    ans = max(ans, memo[row][col + 1][rem]);
                    if(rem - 1 >= 0) {
                        ans = max(ans, memo[row][col + 1][rem - 1] + cell[row][col]);
                    }
                }

                if(row + 1 <= n) {
                    ans = max(ans, memo[row + 1][col][3]);
                    if(rem - 1 >= 0) {
                        ans = max(ans, memo[row + 1][col][3] + cell[row][col]);
                    }
                }

                memo[row][col][rem] = ans;
            }
        }
    }

    cout << memo[1][1][3] << '\n';

    return 0;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b;
    cin >> a >> b;
    set<int> vis;
    while(vis.find(a) == vis.end())
    {
        vis.insert(a);
        if(a > b) a = a%b;
        else a = abs(a - b);
    }
    cout << *vis.begin() << "\n";
    
    
    return 0;
}



Measured memory_bytes: 256
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    minus = 0
    for a in A:
        if a < 0:
            minus += 1

    abs_A = [abs(a) for a in A]
    if minus % 2:
        return sum(abs_A) - min(abs_A) * 2
    else:
        return sum(abs_A)


print(main())


Measured memory_bytes: 15180
// C - Lining Up
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

	map<int,int> A;
	for(int i=1; i<=N; i++){
		int a; cin>>a;
		A[a]++;
	}

	int ans = 1;
	int i,s = (N-1)%2;
	bool f = true;
	for(i=s; i<N; i+=2){
		if(A.count(i)!=1){
			f = false;
			break;
		}

		if(A[i]!=2){
			if(s==0 && i==0 && A[i]==1) continue;
			f = false;
			break;
		}
		ans = ans * 2 % MOD;
	}
	cout<< (f?ans:0) <<endl;
}

Measured memory_bytes: 3200
H, W, sh, sw = map(int, input().split())

if H%sh == 0 and W%sw == 0:
    print("No")
else:
    print("Yes")
    state = [[1]*W for _ in range(H)]
    INF = 10**9
    for h in range(H):
        for w in range(W):
            if w%sw == sw-1 and h%sh == sh-1:
                state[h][w] = -INF
            elif w%sw == 0 and h%sh == 0:
                state[h][w] = INF - (sh*sw-1)
    for h in range(H):
        print(" ".join([str(a) for a in state[h]]))


Measured memory_bytes: 15664
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll ary[110],dp[110][30];
int main() {
	int N,ans;
	cin >> N;
	for (int i = 1; i <= N-1; i++) {
		cin >> ary[i];
	}
	cin >> ans;
	dp[0][0] = 1;
	for (int i = 1; i <= N - 1; i++) {
		if (i == 1 && ary[i] == 0) {
			dp[1][0] = 1;
			continue;
		}
		for (int j = ary[i]; j <= 20; j++) {
			dp[i][j] += dp[i-1][j - ary[i]];
		}
		for (int j = 0; j + ary[i] <= 20; j++) {
			dp[i][j] += dp[i-1][j + ary[i]];
		}
	}
	cout << dp[N - 1][ans] << endl;
	return 0;
}

Measured memory_bytes: 3104
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    a=*max_element(all(v));
    b=accumulate(all(v),0);
    if(b-a-a>0) Yes;
    else No;

    

    return 0;
}


Measured memory_bytes: 3640
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    D, X = map(int, input().split())
    A = [None] * N
    for i in range(N):
        A[i] = int(input())

    ans = X
    for a in A:
        q, r, = divmod(D - 1, a)
        ans += q + 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    float x[N];
    string u[N];
    for(int i = 0; i < N; i++)
    {
        cin >> x[i] >> u[i];
    }
    float ans = 0.0;
    for(int i = 0; i < N; i++)
    {
        if (u[i] == "BTC") {
            x[i] *= 380000.0;
        }
        ans += (float) x[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1<<17|5,P=1e9+7;
int n,m,ans,a[20],fac[N],ifac[N],f[20][N];
inline int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%P)if(b&1)r=1ll*r*a%P;return r;}
inline int C(int a,int b){return a<b||a<0||b<0?0:1ll*fac[a]*ifac[b]%P*ifac[a-b]%P;}
inline int sz(int x){int r=0;while(x)r+=x&1,x>>=1;return r;}
int main()
{
	for(int i=fac[0]=1;i<N;i++)fac[i]=1ll*fac[i-1]*i%P;
	ifac[N-1]=pw(fac[N-1],P-2);
	for(int i=N-1;i;i--)ifac[i-1]=1ll*ifac[i]*i%P;
	scanf("%d%d",&n,&m);ans=0;
	for(int i=1;i<=m;i++)scanf("%d",&a[m-i+1]);
	f[0][0]=1;
	for(int i=0;i<m;i++)for(int s=0;s<(1<<n);s++)if(f[i][s])
	{
		f[i+1][s]=(f[i+1][s]+f[i][s])%P;
		for(int j=0;j<n;j++)if(~s>>j&1)f[i+1][s|(1<<j)]=(f[i+1][s|(1<<j)]+1ll*f[i][s]*fac[1<<j]%P*C((1<<n)-s-a[i+1],(1<<j)-1))%P;
	}
	for(int s=0;s<(1<<n);s++)ans=(ans+1ll*(sz(s)&1?P-1:1)*f[m][s]%P*fac[(1<<n)-s-1])%P;
	printf("%d\n",1ll*ans*(1<<n)%P);
	return 0;
}

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

using namespace std;
int A,B,C,n,len[10000];
int dfs(int x,int a,int b,int c)
{
    if(x == n){
        if(min(a,min(b,c)) > 0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
        else return 100000000;
    }
    int num1 = dfs(x+1,a,b,c) ;
    int num2 = dfs(x+1,a+len[x],b,c) + 10;
    int num3 = dfs(x+1,a,b+len[x],c) + 10;
    int num4 = dfs(x+1,a,b,c+len[x]) + 10;
    return min(min(num1,min(num2,num3)),num4);
}
int main()
{
    cin>>n>>A>>B>>C;
    for(int i = 0;i < n; ++i) cin>>len[i];
    cout<<dfs(0,0,0,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(n);
  pair<int,int> c[n+1];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    c[i]=make_pair(a[i],b[i]);
  }
  sort(c,c+n);
  priority_queue<int> pq;
  int t=0;
  int ans=0;
  for(int i=1;i<=m;i++){
    while(c[t].first<=i){
      pq.push(c[t].second);
      t++;
    }
    if(!pq.empty()){
      ans+=pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 2428
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<string>
#include<iostream>
using namespace std;
#define LL long long
#define db(x) cout<<#x<<"="<<x<<endl
LL n;
int main() {
	cin>>n;
	cout<<1LL*n*(n-1)/2;
}

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

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

typedef long long ll;

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

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<int> vec[2];
    rep(i, 2) vec[i].resize(100001, 0);
    rep(i, N){
        int v; cin >> v;
        vec[i&1][v]++;
    }
    priority_queue<pair<int, int>> pq0;
    priority_queue<pair<int, int>> pq1;
    int sz0, sz1;
    sz1 = N/2; sz0 = N-sz1;
    rep(i, 100001){
        pq0.push(make_pair(vec[0][i], i));
        pq1.push(make_pair(vec[1][i], i));
    }
    pair<int, int> p0[2], p1[2];
    p0[0] = pq0.top(); pq0.pop(); p0[1] = pq0.top();
    p1[0] = pq1.top(); pq1.pop(); p1[1] = pq1.top();
    if(p0[0].second != p1[0].second){
        cout << sz0-p0[0].first + sz1-p1[0].first << endl;
    }
    else{
        int eval0 = sz0-p0[0].first + sz1-p1[1].first;
        int eval1 = sz0-p0[1].first + sz1-p1[0].first;
        cout << min(eval0, eval1) << endl;
    }
    return 0;
}

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



int num_lane,num_info;

int main(){

	scanf("%d %d",&num_lane,&num_info);

	queue<int> Q[num_lane];

	int command,value;
	int min_car,min_lane;

	for(int loop = 0; loop < num_info; loop++){

		scanf("%d %d",&command,&value);

		if(command == 0){

			value--;
			printf("%d\n",Q[value].front());
			Q[value].pop();

		}else{ //command == 1

			min_car = BIG_NUM;
			for(int i = 0; i < num_lane; i++){
				if((int)Q[i].size() < min_car){
					min_car = (int)Q[i].size();
					min_lane = i;
				}
			}
			Q[min_lane].push(value);
		}
	}

	return 0;
}



Measured memory_bytes: 3260
#include <iostream>
#include <math.h>
#include <string>    // useful for reading and writing
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream

using namespace std;

int main()
{
    while(1)
    {
    int h, w;
    std::cin >> h >> w;
    if(h==0&&w==0){break;}
    
        for(int i = 0; i < h; i++)
        {
            if( i%2 == 0)
            {
                for(int j = 0; j < w; j++)
                {
                    if(j%2==0)
                    {
                        std::cout<<"#";
                    }
                    else
                    {
                        std::cout<<".";
                    }
                }
            }
            else
            {
                for(int j = 0; j < w; j++)
                {
                    if(j%2==0)
                    {
                        std::cout<<".";
                    }
                    else
                    {
                        std::cout<<"#";
                    }
                }
            }

            std::cout<<"\n";
        }
        std::cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3032