akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def f(n):
    r = 2
    ret = 1
    for i in range(n, n-r, -1):
        ret *= i
    for i in range(1, r+1):
        ret //= i
    return ret * 2 + n


class Bisect:
    def __init__(self, func):
        self.__func = func

    def bisect_left(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if self.__func(mid) < x:
                lo = mid+1
            else:
                hi = mid
        return lo

    def bisect_right(self, x, lo, hi):
        while lo < hi:
            mid = (lo+hi)//2
            if x < self.__func(mid):
                hi = mid
            else:
                lo = mid+1
        return lo

@mt
def slv(N, M, A):
    A.sort(reverse=True)
    print(A)
    b = Bisect(f)

    i = b.bisect_left(M, 1, N)
    if f(i) != M:
        i -= 1
    l = f(i)

    ans = 0
    for j in range(i):
        ans += A[j] * 2
        ans += A[j] * (i-1)

    rem = M - l
    print(i, l, rem)
    j = 0
    while rem != 0:
        ans += A[j] + A[i]
        rem -= 1
        if rem == 0:
            break
        ans += A[j] + A[i]
        rem -= 1
        if rem == 0:
            break
        j += 1


    return ans

import numpy as np
@mt
def slv2(N, M, A):
    C = Counter(A)
    L = 1 << ((max(A)).bit_length() + 1)
    B = [C[i] for i in range(L)]
    D = np.fft.rfft(B)
    D *= D
    E = list(np.fft.irfft(D).real)
    ans = 0
    c = 0
    i = L - 1
    while c != M:
        n = int(round(E[i]))
        if c + n > M:
            n = M-c
        c += n
        ans += i * n
        i -= 1
        assert i != -1

    return ans

def main():
    N, M = read_int_n()
    A = read_int_n()
    print(slv2(N, M,A))

    # N = 10**5
    # M = random.randint(1, N**2)
    # A = [random.randint(1, 10**5) for _ in range(N)]
    # print(slv(N, M, A))


if __name__ == '__main__':
    main()


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

int n,k;
int a[1005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<k;i++)ans+=a[i];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3648
import sys
from collections import deque
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	H, W = MAP()
	TABLE = [MAP() for _ in range(10)]
	A = [MAP() for _ in range(H)]

	to_one = [t[1] for t in TABLE]
	queue = deque([i for i in range(10)])
	
	while queue:
		# print(queue)
		mi = queue.popleft()
		for i, t in enumerate(TABLE):
			if i == mi: continue
			if t[mi]+to_one[mi] < to_one[i]:
				to_one[i] = t[mi]+to_one[mi]
				queue.append(i)
	
	# print(to_one)
	
	ans = 0
	for row in A:
		for a in row:
			if a != -1: ans += to_one[a]
	
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3700
N = gets.chomp.to_i
values = gets.chomp.split.map(&:to_i)
costs = gets.chomp.split.map(&:to_i)

diffs = [0]
N.times do |i|
  diffs.push (values[i] - costs[i])
end
puts diffs
      .select{|d| d >= 0 }
      .inject(&:+)


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

namespace AtCoder.Abc
{
    class QuestionO
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            string result = "";

            if (inputLongArray[0] % n == 0) result = "OK";
            else
            {
                var numA = inputLongArray[0] / n;
                var numB = numA * n + n;

                if (numB <= inputLongArray[1]) result = "OK";
                else result = "NG";

            }
            
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}

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

int main() {
	string s;
	cin >> s;
	if(s[0]=='o'&&s[1]=='o'&&s[2]=='o')cout << 1000 << endl;
	else if(s[0]=='o'&&s[1]=='o'||s[2]=='o'&&s[1]=='o'||s[0]=='o'&&s[2]=='o')cout << 900 << endl;
	else if(s[0]=='o'||s[1]=='o'||s[2]=='o')cout << 800 << endl;
	else cout << 700 << endl;
	return 0;
}

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

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

  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }

  map<ll, ll> m;
  vector<ll> b(n + 1);
  b[0] = 0;
  m[0]++;
  for (ll i = 0; i < n; i++) {
    b[i + 1] = b[i] + a[i];
    m[b[i + 1]]++;
  }
  ll cnt = 0;
  for (auto it : m) {
    ll c = it.second;
    cnt += (c * (c - 1) / 2);
  }

  cout << cnt << endl;
}

Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
#define MOD 1000000007
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }

const LL INF = 1LL << 60;

bool is_ascending_order(vector<LL> vec) {
	bool is_ascending = true;

	for (LL i = 0; i < LL(vec.size()) - 1LL; i++) {
		if (vec[i] > vec[i + 1]) {
			is_ascending = false;
			break;
		}
	}

	return is_ascending;
}

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

	vector<LL> A(N+1);
	rep(i, N + 1) cin >> A[i];

	vector<LL> A_copy = A;

	vector<LL> B(N);
	rep(i, N) cin >> B[i];

	for (LL i = 0; i < N; i++) {
		LL tmp = min(A[i] - B[i], 0LL);
		A[i + 1] = max(A[i + 1] + tmp, 0LL);
		A[i] = max(A[i] - B[i], 0LL);
	}

	LL ans = 0;
	for (LL i = 0; i < N + 1; i++) {
		ans += abs(A_copy[i] - A[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2560
i , max = gets.split.map(&:to_i)
array = gets.split.map(&:to_i).sort

cnt = 0

(0..i-1).each do |n|
    if max < array[n] 
       break
    end
    if n == array.length-1 && max > array[n]
        break
    end
     max -= array[n]
     cnt += 1
end
puts cnt



Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main(void){
  int h,w,i,j,k,l,ans=0;
  int di[4]={1,0,-1,0},dj[4]={0,1,0,-1};
  string g[23];
  
  cin >> h >> w;
  for (i=0;i<h;i++) cin >> g[i];
  
  for (i=0;i<h;i++) for (j=0;j<w;j++){
    if (g[i][j]=='#') continue;
    int d[23][23]={},ni,nj;
    P p;
    queue<P> q;
    q.push(P(i,j));
    d[i][j]=1;
    while (q.size()>0){
      p=q.front();
      q.pop();
      for (k=0;k<4;k++){
        ni=p.first+di[k];
        nj=p.second+dj[k];
        if (ni>=0 && ni<h && nj>=0 && nj<w && g[ni][nj]=='.' && d[ni][nj]==0){
          q.push(P(ni,nj));
          d[ni][nj]=d[p.first][p.second]+1;
        }
      }
    }
    
    int dmax=0;
    for (k=0;k<h;k++) for (l=0;l<w;l++){
      if (g[k][l]=='.' && dmax<d[k][l]){
        dmax=d[k][l];
      }
    }
    
    ans=max(ans,dmax-1);
    
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] input = new int[n];
		
		for(int i = 0; i < n; i++){
			input[i] = sc.nextInt();
		}
		
		Arrays.sort(input);
		
//		long lcmAll = input[0];
//		
//		for(int i = 1; i < n; i++){
//			lcmAll = lcm(input[i], lcmAll);
//		}
		
		long lcm2 = lcm(input[n - 1], input[n - 2]);
		//debug
//		System.out.println(lcmAll);
		
		System.out.println(solve2(input));
//		long result = 0;
//		for(int i = 1; i < 1000; i++){
//			long number = lcm2 * i - 1;
//			result = Math.max(result, calcWorst(number, input));
//			System.out.println("i = "+i+" number = " + number+ " " +calcWorst(number, input)+" max = "+result);
//			
//		}
//		long result = 0;
//		for(int i = 0; i < n; i++){
//			result += (lcmAll - 1)%input[i];
//		}
//		System.out.println(result);
	}

	static long calcWorst(long x, int[] mods){
		long result = 0;
		
		for(int i = 0; i < mods.length ; i++){
			result += x%mods[i];
		}
		
		return result;
	}
	
	static long solve2(int[] mods){
		long lcm[] = new long[mods.length - 1];
		
		for(int i = 0; i < mods.length - 1; i++){
			lcm[i] = lcm(mods[i], mods[i + 1]);
		}
		
		long x[] = new long[mods.length];
		Arrays.fill(x, 1);
		
		for(int i = 0; i < mods.length ; i++){
			
			for(int j = 0; j < lcm.length ; j++){
				x[i] *= lcm[j];
				x[i] %= mods[i];
			}
			
			x[i]--;
			if(x[i] < 0){
				x[i] += mods[i];
			}
		}
		
		long result = 0;
		
		for(int i = 0; i < x.length ; i++){
			result += x[i];
		}
		
		return result;
	}
	
	static long gcd(long a, long b){
        long tmp;
 
        while (a % b != 0)
        {
            tmp = b;
            b = a % b;
            a = tmp;
        }
        return b;
    }
 
    static long lcm(long a, long b, long gcd){
        return a*(b/gcd);
    }
 
    static long lcm(long a, long b){
        long g = gcd(a, b);
 
        return lcm(a,b,g);
    }
}



Measured memory_bytes: 26892
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
A = LIST()

# MOD毎でまとめておく
modA = [a%M for a in A]
modC = Counter(modA)

# li[i] := mod Mでi毎に、(数値, 個数)のペアを個数の降順で格納したリスト
# ただし、奇数個ある数値は1つだけ優先して使うように後ろに移動させる
li = [Counter() for i in range(M)]
for a in A:
    li[a%M][a] += 1
for i in range(M):
    li[i] = li[i].most_common()
for i in range(M):
    tmp = []
    for j in range(len(li[i])):
        x, cnt = li[i][j]
        if cnt % 2 == 1:
            tmp.append((x, 1))
            li[i][j] = (x, cnt-1)
    li[i] += tmp

# mod Mでxの要素をcnt個消費する
def sub(x, cnt):
    while li[x] and cnt - li[x][-1][1] >= 0:
        cnt -= li[x][-1][1]
        li[x].pop()
    if li[x]:
        li[x][-1] = (li[x][-1][0], li[x][-1][1] - cnt)

# 0とM/2の場合は同じものでペアを作るので別処理
ans = 0
pcnt = modC[0] // 2
sub(0, pcnt*2)
ans += pcnt
if M % 2 == 0:
    pcnt = modC[M//2] // 2
    sub(M//2, pcnt*2)
    ans += pcnt

# それ以外は足してMになる同士でペアを作る
for i in range(1, ceil(M, 2)):
    j = M - i
    pcnt = min(modC[i], modC[j])
    sub(i, pcnt)
    sub(j, pcnt)
    ans += pcnt

# 倍数ペアを全て作ったら、残ったものから同値ペアを作る
for i in range(M):
    for _, cnt in li[i]:
        ans += cnt // 2
print(ans)


Measured memory_bytes: 57528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;



int main()
{
    int n;cin >> n;
    vector<int> a(n),b(n),c(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(),a.end());
    //sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll up = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
        ll down = c.end() - upper_bound(c.begin(),c.end(),b[i]);
        ans += up * down;
    }
    cout << ans << endl;
} 

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 998244353
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 3e5;
ll dp[N];
ll dpsum[N];

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n, k; cin>>n>>k;
    vii v(k);
    for(int i = 0; i < k; i++){
        cin>>v[i].ff>>v[i].ss;
    }
    dp[1] = dpsum[1] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 0; j < k; j++){
            if(v[j].ff >= i) continue;
            int l = max(1, i - v[j].ss), r = i - v[j].ff;
            dp[i] += (dpsum[r] - dpsum[l-1]);
            dp[i] = (dp[i] + MOD) % MOD;
        }
        dpsum[i] = dpsum[i-1] + dp[i], dpsum[i] %= MOD;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 6692
#include<stdio.h>
#include<vector>
int main()
{
	int N,K,M,i,c;
	while(scanf("%d%d%d",&N,&K,&M),N)
	{
		std::vector<int>v(N);
		for(i=0;i<N;++i)v[i]=i+1;
		for(c=1,i=M-1;c<N;++c)
		{
			v.erase(v.begin()+i);
			i = (i+K-1)%v.size();
		}
		printf("%d\n",v[0]);
	}
	return 0;
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  ll N, A, B;
  cin >> N >> A >> B;

  ll ret = 0;
  ret += N/(A+B)*A;
  N = N%(A+B);
  ret += min({N, A});

  cout << ret << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

void MAIN() {
  string s;
  cin >> s;
  int k; cin >> k;
  int n = s.size();
  vector<string> a;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= min(5ll, n - i); j++) {
      a.push_back(s.substr(i, j));
    }
  }
  sort(all(a));
  a.resize(unique(all(a)) - a.begin());
  cout << a[k - 1] << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 4308
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	Int ans = 0;
	map<char, Int> m;
	m['r'] = p;
	m['s'] = r;
	m['p'] = s;
	vector<bool> v(n, 0);
	for(Int i=0; i<n; ++i){
		if(i < k){
			ans += m[t[i]];
			v[i] = true;
		}else{
			if(t[i] != t[i-k] || v[i-k] == false){
				ans += m[t[i]];
				v[i] = true;
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 512
log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin.split("\n");
var N = lines[0].split(" ").map(Number)[0];
var A = lines
  .slice(1)
  .filter(v => v !== "");

A.sort((a,b)=> a-b)

var count = 0;
var tmp = false;
A.forEach((v,i,a)=>{
    if(i===0) return
    if(a[i] === a[i-1]){
      tmp = !tmp
    }else {
      if(!tmp) count += 1
      tmp = false
    }
})
if(!tmp) count += 1

log(count)

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

int main(void){
  char A,T;
  cin>>A>>T;
  
  if(A=='H'){
   cout<<T<<endl; 
  }else{
   if(T=='H')cout<<'D'<<endl;
   else cout<<'H'<<endl;
  }
  return 0;
}

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

int main(){
    int N,D,X,a;
    long long r=0;

    cin >> N >> D >> X;


    for(int i=0;i<N;++i){
        cin >> a;
        r += (D+a-1)/a;
    }
    cout << r+X << endl;}
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

Measured memory_bytes: 256
n, m = map(int, input().split())
la = [int(input()) for i in range(m)]

p = [1] * (n+1)
ans = 1

for a in la:
	p[a] = 0

for i in range(n+1):
	if i == 0 and p[i] == 0:
		ans = 0
		break
	elif i > 1:
		if p[i] == 0 and p[i-1] == 0:
			ans = 0
			break
		elif p[i] > 0:
			ans = p[i-1] + p[i-2]
			p[i] = ans

print(ans % (10**9+7))

Measured memory_bytes: 460020
n = int(input())
ta = [tuple(map(int, input().split())) for _ in range(n)]
x, y = 1, 1
for t, a in ta:
    z = max((x + t - 1) // t, (y + a - 1) // a)
    x = t * z
    y = a * z
print(x + y)

Measured memory_bytes: 3060
while True:
	a, b = map(int, input().split())
	if a == 0 and b == 0:
		exit()
	for i in range(0,a):
		for j in range(0,b):
			if i == 0 or j == 0 or i == a-1 or j == b-1:
				print('#', end='')
			else:
				print('.',end='')
		print()
	print()


Measured memory_bytes: 7000
import collections
w = input()
s = list(w)
c = collections.Counter(s)
ls = list(c.most_common())
flag = 0
for i in range(len(ls)):
    if ls[i][1] %2 == 0:
        continue
    else:
        flag += 1
        print("No")
        break
if flag == 0:
    print("Yes")

Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
 
	k := sc.ReadInt()
	n := sc.ReadInt()
 
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.ReadInt()
	}
	aPlus := append(a, k+a[0])
 
	distances := make([]int, n)
	for i := 0; i < n; i++ {
		distances[i] = aPlus[i+1] - aPlus[i]
	}
 
	maxDistance := distances[0]
	for _, d := range distances {
		if d > maxDistance {
			maxDistance = d
		}
	}
 
	answer := k - maxDistance
	fmt.Printf("%d\n", answer)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Abs64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func Min64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 7424
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn myalloc(n: usize) -> Box<[f64]> {
    vec![0.0; n].into_boxed_slice()
}
fn main(){
    input!{n: i64,
    m: i64}
    let allcolum:i64 =n+1-m+1;
    let mut ans:i64=0;
    for i in 0 ..allcolum{
        ans+=(n-(m+i)+1)*(m+i)+1
    }
    println!("{}", ans%1000000007)
}


Measured memory_bytes: 2156
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;

const int maxn = 1e5 + 5;
int n, a[maxn], dp[maxn];

void solve() {
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]),
                    dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    // write your code here
    solve();
    return 0;
}

Measured memory_bytes: 1024
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

#pragma region 素因数分解
vector<pair<ll, int>> prime_factorize(ll n)
{
	vector<pair<ll, int>> res;
	for (ll i = 2; i*i <= n; ++i)
	{
		if (n%i != 0)continue;
		int cnt = 0;
		while (n%i == 0)
		{
			n /= i;
			++cnt;
		}
		res.push_back(make_pair(i, cnt));
	}
	if (n != 1)res.push_back(make_pair(n, 1));
	return res;
}
#pragma endregion

int main()
{
	ll n; cin >> n;
	vector<pair<ll, int>> v = prime_factorize(n);
	int res = 0;
	for (auto p : v)
	{
		int cnt = p.second;
		int i = 1;
		while (cnt >= i)
		{
			++res;
			cnt -= i;
			++i;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#define MN 10010

char s[MN];
int l = -1, r = -1;

bool cmp(int a, int b, int c, int d)
{
	int len = b - a + 1;
	for(int i = 0; i < len; i++)
	{
		if(s[b - i] < s[d - i]) return 1;
		if(s[b - i] > s[d - i]) return 0;
	}
	return 0;
}

int main()
{
	int n, k; scanf("%d%d%s", &n, &k, s);
	for(int i = n; i < 2 * n; i++) s[i] = s[2 * n - i - 1];
	char Min = 'z'; int len = 0, Max = 0;
	for(int i = 0; i < 2 * n; i++)
	{
		if(s[i] < Min) Min = s[i], len = 1;
		else if(s[i] == Min) len++;
		else len = 0;
		Max = std::max(Max, len);
	}
	
	k--;
	
	if(k > 30 || ((1ll * Max) << k) >= n)
	{
		for(int i = 0; i < n; i++) printf("%c", Min);
		return 0;
	}
	
	len = 0; 
	
	for(int i = 0; i < 2 * n; i++)
	{
		if(s[i] == Min) len++;
		else len = 0;
		if(i >= n && len == Max)
		{
			int L = i - Max - (n - (Max << k)) + 1, R = i - Max;
			if(l == -1 || cmp(L, R, l, r)) l = L, r = R;
		}
	}
	
	for(int i = 1; i <= (Max << k); i++) printf("%c", Min);
	for(int i = r; i >= l; i--) printf("%c", s[i]);
}

Measured memory_bytes: 256
import sys,math,collections,itertools
input = sys.stdin.readline

H,W=list(map(int,input().split()))
a = [ input().rstrip() for _ in range(H)]
dp = [[0]*(W) for _ in range(H)]
dp[0][0]=1
m=10**9+7
for ih in range(H):
    for iw in range(W):
        if a[ih][iw] == '#':
            dp[ih][iw] = 0
        else:
            if ih>0 and dp[ih-1][iw] >0:
                dp[ih][iw] += dp[ih-1][iw]
                dp[ih][iw] %=m
            if iw>0 and dp[ih][iw-1] >0:
                dp[ih][iw] += dp[ih][iw-1]
                dp[ih][iw] %=m
print(dp[-1][-1])
                
            


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

int main() {
    int i=0;
    int n;
    cin>>n;
    vector<long long> data(90);
    data.at(0)=2;
    data.at(1)=1;
    for(i=0;i<n-1;i++){
        data.at(i+2)=data.at(i)+data.at(i+1);
    }
    cout<<data.at(i+1)<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t,d,cnt=0;
    cin>>t>>d;
    while(t--){
        int x,y;
        cin>>x>>y;
        double dist=sqrt(pow(abs(x),2)+pow(abs(y),2));
        if(dist<=d){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int y[110];

int main() {
	int n,a,b,c,x;
	while(cin>>n>>a>>b>>c>>x,n){
		int i;
		for(i=0;i<n;i++)cin>>y[i];
		int f;
		int s=0;
		for(f=0;f<=10000;f++){
			if(y[s]==x){
				s++;
				if(s==n)break;
			}
			x=(a*x+b)%c;
		}
		if(f>10000){
			cout<<-1<<endl;
		}else{
			cout<<f<<endl;
		}
	}
	return 0;
}

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

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



Measured memory_bytes: 3096
#include<stdio.h>
#include<string.h>
#define anD &&
#define oR ||
#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)<(b))?(a):(b)
#define rep(i,n) for((i)=0;(i)<(n);(i)++)

int main(void) {
	int i, n, h, m, st, j;
	char a[201];
	while (1) {

		scanf("%s", a);
		if (a[0] == '-') break;
		st = strlen(a);

		scanf("%d", &m);

		for (i = 0; i < m; i++) {
			char temp[201] = {};

			scanf("%d", &h);
			for (j = 0; j < h; j++) {
				temp[j] = a[j];
			}
			for (j = 0; j < st - h; j++) {
				a[j] = a[j + h];
			}
			for (j = 0; j < h; j++) {
				a[st - h + j] = temp[j];

			}
		}
		a[st] = '\0';
		printf("%s\n", a);

	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};



int main(){
 int N,K;
  int ans=0;
  cin >> N >>K;
  vec<int> d(K);
  vec<bool> whohave(N,0);
  vec<vec<int>> A(K,vec<int>(N,0));
  Rep(i,K){
    cin >> d.at(i);
    Rep(j,d.at(i)){
      cin >> A.at(i).at(j);
      whohave.at(A.at(i).at(j)-1) = 1;
    }
  }
  
 Rep(i,N){
   if (!whohave.at(i) ){ ans++;}
 }
 cout << ans;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input;

        int square = 0;
        int diamond = 0;

        while ((input = br.readLine()) != null) {
            String[] line = input.split(",");
            int a = Integer.parseInt(line[0]);
            int b = Integer.parseInt(line[1]);
            int c = Integer.parseInt(line[2]);

            if (c * c + a * a == b * b || c * c + b * b == a * a || a + b <= c || b + c <= a || c + a <= b) {
                continue;
            }

            if (a * a + b * b == c * c) {
                square++;
            }
            if(a == b){
                diamond++;
            }
        }

        System.out.println(square);
        System.out.println(diamond);
    }
}


Measured memory_bytes: 24224
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $m);
$refri = explode(' ', fgets(STDIN));
$micro = explode(' ', fgets(STDIN));

$min_p = min($refri) + min($micro);

$coupon;
for($i = 0; $i < $m; $i++) {
    $coupon[] = explode(' ', fgets(STDIN));
    $price_list[] = $refri[$coupon[$i][0] - 1] + $micro[$coupon[$i][1] - 1] - $coupon[$i][2];
}
//var_dump($min_p);
//var_dump($price_list);
$min_pl = min($price_list);
//var_dump($min_pl);
echo min($min_p, $min_pl), PHP_EOL;
//var_dump($refri, $micro);
//var_dump($coupon);

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

int main(){
  long long int a, b, k;
  cin >> a >> b >> k;
  map<long long int, int> mp;
  for(long long int i = a; i < a + k; i++){
    if(i > b) break;
    cout << i << endl;
    mp[i] = 1;
  }
  for(long long int i = b - k + 1; i <= b; i++){
    if(i <= 0 || i < a) continue;
    if(mp[i] > 0) continue;
    cout << i << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string s;
cin>>s;
ll ca=0;
for(ll i=0; i<4; i++){
if(s.at(i)=='2'){
ca++;}}
cout << ca << endl;}

Measured memory_bytes: 3560
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	void doIt() {
		int N = sc.nextInt();
		long K = sc.nextLong();
		int A[] = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}
		Set<Integer> used = new HashSet<>();
		int idx[] = new int[N];
		int pos[] = new int[N];
		int next = 0, cur = 0;
		while(!used.contains(next)) {
			used.add(next);
			idx[next] = cur;
			pos[cur] = next;
			next = A[next];
			cur++;
		}
		//System.out.println(next + " " + cur);
		long a = (long)cur - idx[next];
		long b = (long)idx[next];
		//System.out.println(a + " " + b);
		//System.out.println(((K - b) % a + b));
		int ans = (int) ((10000 * a + K - b) % a + b);
		if(b > K) ans = (int)K;
		System.out.println(pos[ans] + 1);
		//System.out.println(Arrays.toString(idx));
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


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

int main(){
    string s;
    cin >> s;
    int cnt = 0, cnt_max = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='R'){ cnt++; }
        else{
            if(cnt>cnt_max){ cnt_max = cnt; }
            cnt = 0;
        }
        if(cnt>cnt_max){ cnt_max = cnt; }
    }
    cout << cnt_max << endl;
    return 0;
}

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

int main(void){
    int k, a, b;
    cin >> k >> a >> b;
    bool ok = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) ok = true;
    }
    cout << ((ok) ? "OK" : "NG") << endl;
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005;
int n,m,vis[N],tong[N][2];
vector<int> v[N];
char ch[N];
bool check(int x){
	return tong[x][0]&&tong[x][1];
}
void dfs(int p){
	if(vis[p])return;
	vis[p]=1;
	for(auto i:v[p])if(--tong[i][ch[p]]==0)dfs(i);
}
signed main(){
	n=read(); m=read();
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)ch[i]-='A';
	for(int i=1;i<=m;i++){
		int s=read(),t=read();
		v[s].push_back(t); v[t].push_back(s);
	}
	for(int i=1;i<=n;i++)for(auto j:v[i])tong[i][ch[j]]++;
	for(int i=1;i<=n;i++)if(!check(i))dfs(i);
	for(int i=1;i<=n;i++)if(check(i)){
		puts("Yes"); return 0;
	}
	puts("No");
}

Measured memory_bytes: 14464
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int count=0;
    cin >> N;

    for(int i=1;i<=N;i++){
    double ore;
    ore=sqrt(i);
    int A=ore;
        for(int a=1;a<=A;a++){
            for(int b=a;b<=A;b++){
                for(int c=b;c<=A;c++){
                    if(a*a+b*b+c*c+a*b+b*c+c*a==i){
                        if(a!=b && b!=c && c!=a){count+=6;}else if(a==b && b!=c || b==c && c!=a || c==a && a!=b){count+=3;}else{count++;}
                    }
                }
            }
        }
            cout << count << endl;
            count=0;
    }
}


Measured memory_bytes: 3652
#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;
LL A[100001];
LL dp[100011];
LL dp2[100011];

int binary_search(int x){
	int lb=-1;
	int ub=N+10;
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		if(dp[mid]<=x){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	return ub;
}

int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	REP(i,N+10){
		dp[i]=-1;
		dp2[i]=0;
	}
	int l=0;
	//LL ans=0;
	for(int i=N-1;i>=0;i--){
		int now=binary_search(A[i]);
		if(now==0){
			dp[now]=A[i];
			dp2[now]=A[i];
		}else{
			dp[now]=A[i];
			dp2[now]=A[i]+dp2[now-1];
		}
	}
	LL ans=0;
	REP(i,N+5){
		/*if(dp[i]!=-1){
			//cout<<dp[i]<<endl;
			ans+=dp[i];
		}*/
		if(dp[i]==-1){
			if(i!=0)ans=dp2[i-1];
			break;
		}
		//ans=max(ans,dp2[i]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5444
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){

    int n;
    I(n);
    cout<<(n + n*n + n*n*n)<<endl;
    
    return 0;
}


Measured memory_bytes: 3652
import math
ABHM=input().split(' ')
A=int(ABHM[0])
B=int(ABHM[1])
H=int(ABHM[2])
M=int(ABHM[3])

radian=(11.0/360*M-H/6.0)*math.pi
C=abs(A**2 + B**2 -2*A*B*math.cos(radian) )**0.5
print(C)

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

int main() {
  int N, num, dig, sum = 0;
  cin >> N;
  num = N;
  while (num) {
  	dig = num % 10;
    sum += dig;
    num /= 10;
  }
  if (N % sum == 0) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
v=gets.split.map(&:to_i)
m=-1/0.0
0.upto([n,k].min) do |i|
  0.upto([n-i,k-i].min) do |j|
    a=v[0,i]+v[n-j,j]
    a.sort!
    c=a.sum
    [k-i-j,i+j].min.times do |i|
      if a[i]<0
        c-=a[i]
      else
        break
      end
    end
    m=c if m<c
  end
end
puts m


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

# n = int(input())
# a, b = map(int, input().split())
# s = input()

P, Q, R = map(int, input().split())
ans = P + Q
ans = min(ans, Q+R)
ans = min(ans, R+P)
print(ans)





Measured memory_bytes: 38384
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const K = Number(input[0].split(' ')[1])

  let S = input[1].split('')

  S[K - 1] = S[K - 1].toLowerCase()
  console.log(S.join(''))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 22080
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;
 
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
 
int n,m,s[2001],t[2001],sumarray[2001]={0};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if(j){
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1) % MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            } else {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3708
sx,sy,tx,ty=map(int,input().split())
print('R'*(tx-sx)+'U'*(ty-sy)+'L'*(tx-sx)+'D'*(ty-sy+1)+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'+'U'+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'R')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int n3 = n / 100;
		int n1 = n % 10;
		String message = "No";
		if(n1 == n3) {
			message = "Yes";
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 21844