akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            IO.WriteLineYes_or_No(n >= 30);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int main(){

  int n;

  cin>>n;

  if(n<=(n/100)*100+(n/100)*10+n/100){
    cout<<(n/100)<<(n/100)<<(n/100)<<endl;
  }else {
    cout<<(n/100)+1<<(n/100)+1<<(n/100)+1<<endl;
  }
  return 0;

}


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

int main(){
  int n; cin>>n;
  vector<double> arr(n);
  for(int i=0; i<n; i++) cin>>arr[i];

  vector<vector<double> > tab(n+1);
  vector<double> temp(n+1);
  for(int i=0; i<=n; i++) tab[i]=temp;
  tab[0][0]=1;

  int i,j;
  for(int c=0; c<n; c++){
    i=c; j=0;
    while(i>=0){
      tab[i+1][j]+=tab[i][j]*arr[c];
      tab[i][j+1]+=tab[i][j]*(1-arr[c]);
      i--; j++;
    }
  }

  double ans=0;
  i=n; j=0;
  while(j<=n/2){
    ans+=tab[i][j];
    i--; j++;
  }

  cout<<setprecision(12)<<ans<<endl;
}

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

int main(){
  long n, ret=0;
  cin >> n;
  for(long q=1; q*q<=n; q++){
    if(n%q==0){
      long m=n/q-1;
      if(q<m)ret+=m;
    }
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Map.Entry;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		while (true) {
			String line = reader.readLine();
			if (line.equals("0 0")) {
				break;
			}
			StringTokenizer tokenizer = new StringTokenizer(line);
			int n = Integer.parseInt(tokenizer.nextToken());
			int s = Integer.parseInt(tokenizer.nextToken());

			Map<int[], Integer> memo = new HashMap<int[], Integer>();
			memo.put(new int[0], 0);
			int count = 0;
			for (int i = 0; i < 10; i++) {
				Map<int[], Integer> memotmp = new HashMap<int[],Integer>();
				memotmp.putAll(memo);

				for (Entry<int[], Integer> entry : memo.entrySet()) {
					if (entry.getKey().length == n) {
						continue;
					}
					int[] nearray = Arrays.copyOf(entry.getKey(),
							entry.getKey().length + 1);
					nearray[nearray.length - 1] = i;
					int sum = 0;
					for (int j = 0; j < nearray.length; j++) {
						sum += nearray[j];
					}
					if (sum > s) {
						continue;
					}

					memotmp.put(nearray, sum);
					if (nearray.length == n && sum == s) {
						count++;
					}

				}
				memo = memotmp;
			}
			/*memo.entrySet().forEach(
					l -> System.out.println(Arrays.toString(l.getKey())
							+ " -> " + l.getValue()));*/
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 23692
# -*- coding: utf-8 -*-
"""
C - 755
TLE
"""
def gen_357():
    def conv(n):
        res = []
        while n:
            n, r = divmod(n, 4)
            if r == 0 and n:
                return '0'
            res.append(str(str(r)))
        if not res:
            res = ['0']
        return ''.join(res[::-1]).translate(str.maketrans('0123', '0357'))

    n = 0
    while True:
        t = conv(n)
        while '0' in t or len(set(list(t))) != 3:
            n += 1
            t = conv(n)
        yield t
        n += 1


def solve(n):
    ans = 0
    g = gen_357()
    while True:
        t = next(g)
        if int(t) > n:
            break
        ans += 1
    return ans


n = int(input())
ans = solve(n)
print(ans)


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

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

int main() {
    int x; cin >> x;
    cout << 10 - x / 200 << endl;
}

Measured memory_bytes: 3592
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	monster := make([]int, n)

	for i := range monster {
		fmt.Scan(&monster[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(monster)))

	MinSum := 0
	for i , value := range monster {
		if i >= k {
			MinSum += value
		}
	}
	fmt.Println(MinSum)
}


Measured memory_bytes: 6656
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')
 
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()

ans = 0
for i in range(1, N+1):
    if i % 3 == 0 or i % 5 == 0: continue
    ans += i
print(ans)

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

using namespace std;

typedef long long ll;

int main() {
    ll N, x; cin >> N >> x;
    vector<ll> A(N, 0);
    for (int i = 0; i < N; i++) { cin >> A[i]; }
    

    ll count = 0;
    if (A[0] > x) {
        count += A[0] - x;
        A[0] = x;
    }
    for (int i = 1; i < N; i++) {
        ll oldi = A[i];
        if (A[i - 1] + A[i] > x) {
            // count += ;
            A[i] = (x - A[i - 1]);
            count += oldi - A[i] ;
        }
    }

    // for (auto v : A) { cout << v << " "; } cout << endl;

    cout << count << endl;
}

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

#define llint long long int
#define pb push_back

using namespace std;

int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int num = 0;
  for(int i = min(a, b); i >= 1; i--){
    if(!(b%i) && !(a%i))
      num++;
    if(num == k){
      cout << i;
      return 0;
    }
  }
  return 0;
}

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


int main() {
  long N;
  cin >>N;
  vector<long> c(N+1,0);
  vector<long> A(N+1,0);
  for (int i=1; i<N+1; i++){
    cin >>A.at(i);
    c.at(A.at(i)) ++;
  }
  
  long cnt1=0;
  long cnt2=0;
  for (int i=1; i<N+1; i++){
    int tmp;
    tmp = c.at(i);
    cnt1 += c.at(i)*(c.at(i)-1)/2;
  }
  
  for (int k=1; k<N+1; k++){
    cnt2 = c.at(A.at(k))-1;
    cout << cnt1-cnt2 <<endl;
  }
  
}

Measured memory_bytes: 5760
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
ll N;
vector<ll>beki;
int main(){
	cin>>N;
	vi ind;
	int mark[50]={0};
	N++;
	int inc=0;
	int ma=0;
	int num=0;
	while(N){
		if(N%2){
			mark[inc]=1;
			ma=max(ma,inc);
			num++;
		}
		N=N>>1;
		inc++;
	}
	
	int temp=ma+num-1;
	
	cout<<2*temp<<endl;
	for(int i=0;i<=ma;i++){
		if(i>0)cout<<i<<" ";
		if(mark[i]&&i<ma)cout<<temp<<" ",temp--;
	}
	
	for(int i=1;i<=ma+num-1;i++){
		cout<<i<<" ";
	}
	cout<<endl;
}


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

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  
  int ans;
  if (A < B) ans = A;
  else ans = B;
  
  if (C < D) ans += C;
  else ans += D;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(k,i,n) for(int i=k;i<n;++i)
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    int A[N],B[N],C[N-1],ans=0;
    rep(0,i,N)cin>>A[i];
    rep(0,i,N)cin>>B[i];
    rep(0,i,N-1)cin>>C[i];
    ans+=B[A[0]-1];
    rep(1,i,N){
        if(A[i]==A[i-1]+1){
            ans+=C[A[i-1]-1];
        }
        ans+=B[A[i]-1];
    }
    cout<<ans<<endl;
}


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

int r, g, b, n, cnt;
int main() {
	cin >> r >> g >> b >> n;
	for (int i = 0; i * r <= n; i++)
		for (int j = 0; i * r + j * g <= n; j++)
			if ((n - i * r - j * g) % b == 0)
				cnt++;
	cout << cnt;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstdint>

using namespace std;

int N, W;
vector<int> v{};
vector<int> w{};
array<array<uint64_t, 10001>, 101> dp{};

int main(int argc, char** argv)
{
    cin >> N >> W;
    v.emplace_back(0);
    w.emplace_back(0);
    for (int i=1; i<=N; ++i) {
        int v_i, w_i;
        cin >> v_i >> w_i;
        v.emplace_back(v_i);
        w.emplace_back(w_i);
    }


    for (int i=1; i<=N; ++i) {
        for (int j=1; j<=W; ++j) {
            if (j >= w[i]) dp[i][j] = max(dp[i-1][j], dp[i][j-w[i]]+v[i]);
            else dp[i][j] = dp[i-1][j];
        }
    }

    cout << dp[N][W] << endl;
    return EXIT_SUCCESS;
}




Measured memory_bytes: 10948
#include<iostream>
#include<stdio.h>
#include<cmath> 
#include<stack> 
#include<algorithm> 
#include <string.h>
using namespace std;
int main() {
	int l,r,d,s=0,n,m;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>m;
		if(m%2==1&&i%2==1) s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3620
n = int(input())
al = list(map(int, input().split())) 


ans1 = 0
curr_sum = 0
next_sign = 1
for a in al:
    next_sum = curr_sum + a
    if next_sum >= 0 and next_sign == -1: 
        ans1 += next_sum+1
        next_sum = -1
    elif next_sum <= 0 and next_sign == 1:
        ans1 += (1-next_sum)
        next_sum = 1
    curr_sum = next_sum
    next_sign *= -1


ans2 = 0
curr_sum = 0
next_sign = -1
for a in al:
    next_sum = curr_sum + a
    if next_sum >= 0 and next_sign == -1: 
        ans2 += next_sum+1
        next_sum = -1
    elif next_sum <= 0 and next_sign == 1:
        ans2 += (1-next_sum)
        next_sum = 1
    curr_sum = next_sum
    next_sign *= -1

print(min(ans1,ans2))

Measured memory_bytes: 14468
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


int main(){

  int a, b;
  cin >> a >> b;
  double f = a*1.0 / b*1.0;
  printf("%d %d %.8lf\n", a/b, a%b, f);

  return 0;
}








// EOF

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

int main(){
    /*
    int N;
    cin >> N;
    if (N%2 == 0){
        cout << N << endl;
    }else{
        cout << 2 * N << endl;
    }
    */
   int n; cin >> n;
   if(n%2 == 0){
       cout << n << endl;
   }else{
       cout << 2*n << endl;
   }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N + 1);
	vector<long long> B(N);

	for (auto &x : A) cin >> x;
	for (auto &x : B) cin >> x;

	long long ans = 0;
	for (int i = 0; i < N; ++i) {
		auto x = min(A[i], B[i]);
		A[i] -= x;
		B[i] -= x;
		auto y = min(A[i + 1], B[i]);
		A[i + 1] -= y;
		B[i] -= y;

		ans += x + y;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;

void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

}

void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;

	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 

	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}


	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}

	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}


	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;

	if (right > left)
	{
		mid = (right + left) / 2;
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);

		merge(a, tmp, left, mid + 1, right);
	}
}


long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

bool c;
int point,N;
int H,X,Y ,Z,T, R, G, M, K, W, t[101], v[101], ans, now;
char S,s;

int main() {
	cin >> X >> Y >> Z;
	if ((X - Z) % (Z + Y) != 0) {
		X -= (X - Z) % (Z + Y);
	}
	ans = (X - Z) / (Z + Y);
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<set<int>> edge(N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) { continue; }
            edge[i].insert(j);
        }
    }
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        edge[A].erase(B), edge[B].erase(A);
    }
    using P = pair<int, int>;
    vector<int> col(N, -1);
    auto dfs = fix([&](auto&& self, const int s, const int c) -> P {
        P ans = c == 1 ? P{1, 0} : P{0, 1};
        col[s] = c;
        for (const int to : edge[s]) {
            if (col[to] == c) { return {0, 0}; }
            if (col[to] != -1) { continue; }
            const P sub = self(self, to, 1 - c);
            if (sub == P{0, 0}) { return {0, 0}; }
            ans.first += sub.first, ans.second += sub.second;
        }
        return ans;
    });
    bitset<2000> ok;
    ok[0] = 1;
    for (int i = 0; i < N; i++) {
        if (col[i] == -1) {
            const P sub = dfs(i, 0);
            if (sub == P{0, 0}) {
                cout << -1 << endl;
                return 0;
            }
            bitset<2000> tmp;
            tmp |= ok << sub.first;
            tmp |= ok << sub.second;
            ok = tmp;
        }
    }
    int ans = M;
    for (int i = 0; i <= N; i++) {
        if (ok[i]) { ans = min(ans, i * (i - 1) / 2 + (N - i) * (N - i - 1) / 2); }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n;
    cin>>n;
    vector <double> vec;
    for(int i=0; i<n; ++i)
    {
    	int x;cin>>x;vec.pb(x);
    }
    sort(all(vec));
    for(int i=0; i<vec.size()-1; ++i)
    {
    	//cout<<vec[i]<<" "<<vec[i+1]<<"\n";
    	vec[i+1]=(vec[i]+vec[i+1])/2;
    }
   // for(auto x : vec)
    	//cout<<x<<" ";
    cout<<vec[n-1]<<"\n";
}

Measured memory_bytes: 2944
N = int(input())
W = [int(i) for i in input().split()]
sum1 = 0
sum2 = sum(W)
ans = 10 ** 9
for i in range(N - 1):
  sum1 += W[i]
  sum2 -= W[i]
  ans = min(ans, abs(sum1 - sum2))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int N, A;
  cin >> N >> A;
  cout << ((N * N) - A) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;

string longestRepeatedSubstring(string str)
{
    int n = str.length();
    int LCSRe[n+1][n+1];


    memset(LCSRe, 0, sizeof(LCSRe));

    string res;
    int res_length  = 0;

    int i, index = 0;
    for (i=1; i<=n; i++)
    {
        for (int j=i+1; j<=n; j++)
        {
            if (str[i-1] == str[j-1] &&
                LCSRe[i-1][j-1] < (j - i))
            {
                LCSRe[i][j] = LCSRe[i-1][j-1] + 1;


                if (LCSRe[i][j] > res_length)
                {
                    res_length = LCSRe[i][j];
                    index = max(i, index);
                }
            }
            else
                LCSRe[i][j] = 0;
        }
    }

    if (res_length > 0)
        for (i = index - res_length + 1; i <= index; i++)
            res.push_back(str[i-1]);

    return res;
}

ll binarySearch(vector<ll> v, ll n, ll k, ll start)
{
    ll p = start;
    for (ll a = n; a >= 1; a /= 2)
    {
        while (a + p < n && v[a+p] <= k)
        {
            p += a;
        }
    }
    if (k > v[p])
    {
        return p + 1;
    }
    else
    {
     return p;
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
        sum += x;
    }
    int okp = 1;
    for (int i = 0; i < n; i++)
    {
        if (v[i] >= sum - v[i])
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";



    return 0;
}



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

using namespace std; 

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	long double arr[n] ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	sort(arr , arr + n) ;
	long double prv = (arr[0] + arr[1]) / 2.00 ;
	for(int i = 2 ; i < n ; ++i)
		prv = (arr[i] + prv) / 2.00 ;
	return cout<<fixed<<setprecision(12)<<prv<<"\n" , 0 ;
}

Measured memory_bytes: 256
import sys,math
range = xrange
input = raw_input

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0

n = inp[ii]; ii += 1
k = inp[ii]; ii += 1

X = inp[ii + 0: ii + 3 * n: 3]
Y = inp[ii + 1: ii + 3 * n: 3]
C = inp[ii + 2: ii + 3 * n: 3]
ii += 3 * n

def dist(i,j):
    return math.sqrt((X[i] - X[j])**2 + (Y[i] - Y[j])**2)

l = 0.0
r = 100.0 * 1e18
while r - l >= 1e-9:
    t = (l + r) / 2

    R = [t/C[i] for i in range(n)]

    cand = [(X[i], Y[i]) for i in range(n)]

    for i in range(n):
        r0 = R[i]
        x0 = X[i]
        y0 = Y[i]
        for j in range(i):
            r1 = R[j]
            x1 = X[j]
            y1 = Y[j]

            d = dist(i,j)
            if d == 0.0:
                continue
            a = (r0**2 - r1**2 + d**2)/(2*d)
            if 0.0 < d <= r0 + r1 and r0**2 - a**2 >= 0.0:
                h = math.sqrt(r0**2 - a**2)

                x2 = x0 + a * (x1 - x0)/d
                y2 = y0 + a * (y1 - y0)/d
                #cand.append((x2,y2))

                x3 = x2 + h * (y1 - y0)/d
                y3 = y2 - h * (x1 - x0)/d
                cand.append((x3,y3))
                
                x3 = x2 + h * (y1 - y0)/d
                y3 = y2 - h * (x1 - x0)/d
                cand.append((x3,y3))

    for x,y in cand:
        count = 0
        for i in range(n):
            if math.sqrt((X[i] - x)**2 + (Y[i] - y)**2) <= R[i] + 1e-9:
                count += 1

        if count >= k:
            r = t
            break
    else:
        l = t
print (l + r)/2


Measured memory_bytes: 34408
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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 main() {
  int n;
  cin >> n;
  vector<int> S(n);
  for (int i = 0; i < (int)(n); ++i) cin >> S[i];

  int q;
  cin >> q;
  vector<int> T(q);
  for (int i = 0; i < (int)(q); ++i) cin >> T[i];

  sort((S).begin(), (S).end());
  ll ans = 0;
  for (int i = 0; i < (int)(q); ++i) {
    auto p = equal_range((S).begin(), (S).end(), T[i]);
    ans += (p.second != p.first);
  }

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



Measured memory_bytes: 3424
# -*- coding: utf-8 -*-
"""
C - 2D Plane 2N Points
https://beta.atcoder.jp/contests/abc091/tasks/arc092_a

"""
import sys
from sys import stdin
from collections import namedtuple
input = stdin.readline
edge = namedtuple('edge', ['to', 'cap', 'rev'])


def add_edge(G, f, t, c):
    G[f].append(edge(t, c, len(G[t])))
    G[t].append(edge(f, 0, len(G[f]) - 1))


def dfs(G, used, v, t, f):
    if v == t:
        return f
    used[v] = True
    for i in range(len(G[v])):
        e = G[v][i]
        if (not used[e.to]) and (e.cap > 0):
            d = dfs(G, used, e.to, t, min(f, e.cap))
            if d > 0:
                G[v][i] = edge(e.to, e.cap - d, e.rev)
                G[e.to][e.rev] = edge(G[e.to][e.rev].to, G[e.to][e.rev].cap + d, G[e.to][e.rev].rev)
                return d
    return 0


def max_flow(G, V, s, t):
    used = [False] * V
    flow = 0
    while True:
        for i in range(len(used)):
            used[i] = False
        f = dfs(G, used, s, t, float('inf'))
        if f == 0:
            return flow
        flow += f


def main(args):
    N = int(input())
    G = [[] for _ in range(N*2 + 2)]
    red_points = []
    for ri in range(1, N+1):
        rx, ry = map(int, input().split())
        red_points.append([rx, ry])
        add_edge(G, 0, ri, 1)

    for bi in range(1, N+1):
        bx, by = map(int, input().split())
        add_edge(G, bi+N, N*2+1, 1)
        for i, r in enumerate(red_points, start=1):
            rx = r[0]
            ry = r[1]
            if rx < bx and ry < by:
                add_edge(G, i, bi+N, 1)

    ans = max_flow(G, 2*N+2, 0, 2*N+1)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
	reus;
	string s1,s2;
	cin>>s1>>s2;
	int c=s1.length(),d=0,i;
	for(i=0;i<c;i++)
	{
		if(s1[i]==s2[i])
		d++;
	}
	if(c==d)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
def c_biscuit(K, A, B):
    if A >= B:
        return K + 1
    if B == A + 1:
        return K + 1
    if K <= A - 1:
        return K + 1

    count = A - 1
    now_biscuit = A

    remain_count = (K - count) // 2
    now_biscuit = now_biscuit + remain_count * (B - A)

    if ((K - count) % 2) == 1:
        now_biscuit += 1

    return now_biscuit

K, A, B = [int(i) for i in input().split()]
print(c_biscuit(K, A, B))

Measured memory_bytes: 3064
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

cnt a b = (a + b - 1) `div` b

main :: IO ()
main = do
	[a,b,c,d] <- readIntToList <$> BS.getLine
	let tt = cnt a d
	let at = cnt c b
	if tt >= at
		then putStrLn "Yes"
		else putStrLn "No"


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

int main(){
  int m,d;
  int ans = 0;
  cin >> m >> d;
  rep(i,m+1){
    rep(j,d+1){
      int dumy = j;
      int temp1 = dumy % 10;
      dumy = dumy / 10;
      int temp2 = dumy;
      if((temp1 >= 2) && (temp2 >= 2) && (temp1 * temp2 == i)){
        // cout << i << temp2 << temp1 << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;

int const maxn = 404;
ll const inf = 0x3f3f3f3f3f3f3f3f;

ll a[maxn], p[maxn];
ll dp[maxn][maxn];

ll solve(int l, int r) {
    if (l == r) {
        return 0.0;
    }
    ll& d= dp[l][r];

    if (d != -1) {
        return d;
    }

    ll cost = p[r] - (l==0? 0 : p[l-1]);

    d = inf;
    for (int i = l+1; i <= r; i++) {
        d = min(d, solve(l, i-1) + solve(i, r) + cost);
    }

    return d;
}

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

    int n;
    cin >> n;

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

    p[0] = a[0];
    for (int i = 1; i < n; i++) {
        p[i] = p[i-1] + a[i];
    }

    memset(dp, -1, sizeof(dp));

    cout << solve(0, n-1) << "\n";
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ');
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

int main () {
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  rep(i,n) cin >> a[i];
  vector<string> b(m);
  rep(i,m) cin >> b[i];

  // n = 5, m = 2

  // 0 1 2 3 4
  // 1 2 3 4 5
  // 2 3 4 5 6
  // 3 4 5 6 7
  // 4 5 6 7 8

  // 0 1
  // 1 2

  for (int i = 0; i+m <= n; ++i) {
    for (int j = 0; j+m <= n; ++j) {
      bool ok = true;
      for (int k = i; k < i+m; ++k) {
        if (a[k].substr(j,m) != b[k-i]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
print(" ".join(list(map(str, [p for p in [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381]
 if p % 5 == 1][0:int(input())]))))


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int a, b;
	cin >> a >> b;
    cout << (a <= b ? a : a - 1) << endl;   
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
#define int long long int
constexpr int A_max = 1000005;
void solve(long long N, long long K, std::vector<long long> A)
{
  set<int> Fac;
  Fac.insert(1);
  lli all = accumulate(A.begin(), A.end(), 0ll);
  for (lli i = 2; i * i <= all; i++)
  {
    if (all % i == 0)
    {
      Fac.insert(i);
      Fac.insert(all / i);
    }
  }
  Fac.insert(all);
  lli ans = 0;
  for (auto s : Fac)
  {
    lli ret = 0;
    vector<lli> B;
    rep(i, N) if (A[i] % s) B.push_back(A[i] % s);
    sort(B.begin(), B.end());
    lli minus = accumulate(B.begin(), B.end(), 0ll);
    lli plus = 0;
    //   cerr << s << " " << minus << endl;

    rrep(i, B.size())
    {
      if (minus == plus && minus <= K)
      {
        chmax(ans, s);
      }
      minus -= B[i];
      plus += s - B[i];
      //      cerr << minus << " " << plus << " " << B[i] << " " << K << endl;
    }
    if (minus == plus && minus <= K)
    {
      chmax(ans, s);
    }
  }
  cout << ans << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


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

int main()
{
	//??????
	int num1=0,num2=0,num3=0,num4=0,num5=0,num6=0,num7=0,num8=0,num9=0,num10=0;
	cin>>num1>>num2>>num3>>num4>>num5>>num6>>num7>>num8;
	num9=num1+num2+num3+num4;
	num10=num5+num6+num7+num8;
	if(num9>num10){
		cout<<num9;
		cout<<"\n";
		return 0;
	}
	if(num9<num10){
		cout<<num10;
		cout<<"\n";
		return 0;
	}
	if(num9==num10){
		cout<<num9;
		cout<<"\n";
		return 0;
	}
}

Measured memory_bytes: 1164
import sys
input = sys.stdin.readline
n = int(input())
num = list(map(int, input().split()))
mod = 10**9+7

import fractions
lc = num[0]
for i in range(1, n):
    lc = lc * num[i] // fractions.gcd(lc, num[i])

lc %= mod    
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

ans =0
for i in range(n):
  ans += lc*modinv(num[i],mod)
  ans %= mod
print(ans)

Measured memory_bytes: 5612
//
// Created by TakahiroYamaji on 2020/08/13.
//
#include<iostream>
#include<queue>
typedef long long ll;
int D;
ll G;
int p[11];
ll c[11];

ll solve(int i){
    ll ans = 0;
    ll sum = 0;
    std::priority_queue<ll>P;
    for (int j=0;j<D;j++){
        //std::cout << j << std::endl;
        if (i & (1 << j)){
            sum += (j + 1) * 100 * p[j] + c[j];
            ans += p[j];
        }else{
            P.push(j);
        }
    }

    //微調整
    while (!P.empty()){
        int s = P.top();
        P.pop();
        for (int i=1;i<=p[s];i++){
            if (sum >= G){
                return ans;
            }
            ans++;
            sum += (s + 1) * 100;
        }
    }
    //std::cout << sum << std::endl;
    if (sum >= G){
        return ans;
    }else{
        return 1e12;
    }
}

int main(){
    std::cin >> D >> G;
    for (int i=0;i<D;i++){
        std::cin >> p[i] >> c[i];
    }

    ll min_v = 1e15;
    //bit 全探索
    for (int i=0;i<(1 << D);i++){
        ll ans1 = solve(i);
        //std::cout << ans1 << std::endl;
        if (min_v > ans1){
            min_v = ans1;
        }
    }
    std::cout << min_v << std::endl;
    return 0;
}



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

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + ( key % (M-1)); }

int find(char str[]){
  long long key,i,h;

  key = getKey(str);
  i=0;
  
  while(1){
    h = (h1(key) + i*h2(key))% M;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0)return 0;
    else {
      i++;
  }
  }
    return 0;
  }   
    

int insert(char str[]){
  long long key,i,h;

  key = getKey(str);
  i=0;

    while(1){
      h = (h1(key) + i*h2(key))% M;
      if(strcmp(H[h],str) == 0)return 1;
      else if(strlen(H[h]) == 0){
        strcpy(H[h],str);
        return 0;
      } 
        else{
          i++;
        }
      }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s %s", com, str);
        
        if ( com[0] == 'i' ){
            insert(str);
        } else {
            if (find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}



Measured memory_bytes: 15412
#include<stdio.h>
#define ll long long
ll flag[200005];
ll town[200005];
int main()
{
    ll N,K;ll i;
    scanf("%lld %lld",&N,&K);
    
    for(i=1;i<=N;i++)
        scanf("%lld",&town[i]);
    
    for(i=1;i<=N;i++)
        flag[i]=0;

    /***********************************************寻找第一个重复出现的镇************************************************/
    flag[1]=1;ll now=1;
    for(i=1;i<=K;i++)
    {
        if(flag[town[now]]==1)    //到达第一个重复的镇，走了i步；
            break;
        flag[town[now]]=1;         //将经历i步首次到达的镇标1 ；
        now=town[now];
    }
    ll SpTown=town[now];           //记录此镇编号，注意now指代其上一个镇；
    ll pre_sum=i;    // 记录已完成第一次循环加开头的步数；
    /***********************************************计算第一次走到该特殊镇的步数及环步数************************************************/
    i=0;now=1;
    while(now!=SpTown)
    {
        now=town[now];
        i++;
    }
    ll pre=i;ll y;//y指代一次循环的步数；
    y=pre_sum-pre;
/***********************************************分情况计算结果************************************************/
    now=1;
    if(K<=pre)       //所走K步未达到第一次环；
         while(K--)
            now=town[now];
    else             //至少进入第一个环；
    {
        K-=pre;
        K%=y;
        now=SpTown;
        while(K--)
            now=town[now];
    }
/***********************************************输出结果************************************************/

    printf("%lld",now);
    return 0;
}





Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;cin>>a>>b>>c>>k;
    for (int i=0;i<k;i++){
    if (b<=a){
        b=2*b;
    }
    else if (c<=b){
        c=2*c;
    }
    else c=2*c;
    }
    if (c>b && b>a){
        cout << "Yes";
    }
    else cout << "No";
}

Measured memory_bytes: 3624
import Control.Applicative
import Numeric

lmax [x] = x
lmax (x:xs) = 
    if x>m then x else m
    where m = lmax xs

lmin [x] = x
lmin (x:xs) = 
    if x<m then x else m
    where m = lmin xs

main = do
    _ <- getLine 
    ss <- words <$>getLine
    let a = [read x| x<- ss] ::[Int]
    putStrLn $ show(lmin a) ++ " " ++ show(lmax a) ++ " " ++ show(sum a)

Measured memory_bytes: 9264
fun main(args: Array<String>) = IO().exec {
    val x = long()
    val y = long()
    if (x % y == 0L) println(-1)
    else println(x)
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31260