akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
as = gets.chomp
arr = as.split(' ').map(&:to_i)

mul = 1

if arr.any? { |e| e == 0 }
  puts 0
  return
end

arr.each do |i|
  if mul > 1_000_000_000_000_000_000
    puts -1
    return
  end

  mul *= i
end

if mul > 1_000_000_000_000_000_000
  puts -1
else
  puts mul
end


Measured memory_bytes: 23340
S=input()
N=len(S)
Y=[1]
for i in range(1,N):
    if S[i-1]==S[i]:
        Y[-1]+=1
    else:
        Y.append(1)
X=[]
M=len(Y)//2
tmp=-1
for i in range(M):
    tmp+=Y[2*i]
    X.append((tmp,Y[2*i],Y[2*i+1]))
    tmp+=Y[2*i+1]
#(a,b,c) in X
#a:一番右にあるR
#b:Rの数
#c:Lの数
ans=[0 for i in range(N)]
for seq in X:
    a,b,c=seq
    ans[a]+=c//2+(b-b//2)
    ans[a+1]+=b//2+(c-c//2)
print(" ".join([str(i) for i in ans]))

Measured memory_bytes: 16828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;


signed main(){
  const int m = 2019;
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(),s.end());
  int x = 1;
  int tot = 0;
  int ans = 0;
  vint cnt(m);
  rep(i,n){
    cnt[tot]++;
    tot += (s[i] - '0')*x;
    tot %= m;
    ans += cnt[tot];
    x = x*10%m;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int h, w;
    std::cin >> h >> w;
    std::vector<std::string> s(h);
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
    }

    std::vector<std::vector<int>> used(h, std::vector<int>(w));
    std::vector<std::pair<int, int>> pp {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
    i64 ret = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.' || used[i][j]) continue;

            std::deque<std::pair<int, int>> q { { i, j } };
            used[i][j] = 1;
            i64 white = 0, black = 0;
            while (!q.empty()) {
                auto curr = q.front();
                q.pop_front();

                bool ww = s[curr.first][curr.second] == '.';
                if (ww) white++;
                else black++;

                for (auto &el : pp) {
                    auto x = el.first, y = el.second;
                    if (curr.first + x < 0 || curr.first + x >= h || curr.second + y < 0 || curr.second + y >= w) continue;
                    if (used[curr.first + x][curr.second + y]) continue;
                    if (!(ww ^ (s[curr.first + x][curr.second + y] == '.'))) continue;
                    used[curr.first + x][curr.second + y] = 1;
                    q.emplace_back(curr.first + x, curr.second + y);
                }
            }
            ret += white * black;
        }
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 1152
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/



void solve() {
	int h, w, m; cin >> h >> w >> m;
	unordered_map<int, int> row, col;
	vector<pair<int, int>> a(m);
	set<pair<int, int>> vis;
	for (int i = 0; i < m; i++) {
		cin >> a[i].first >> a[i].second;
		vis.insert(a[i]);
		row[a[i].first]++; col[a[i].second]++;
	}
	int mr = row[1], r = 1, mc = col[1], c = 1, ans = 0;
	unordered_set<int> rvis, cvis;
	for (auto x : row) {
		if (mr <= x.second) {
			if (mr == x.second) {
				rvis.insert(x.first);
				continue;
			}
			rvis.clear();
			mr = x.second;
			rvis.insert(x.first);
		}
	}
	for (auto x : col) {
		if (mc <= x.second) {
			if (mc == x.second) {
				cvis.insert(x.first);
				continue;
			}
			mc = x.second;
			cvis.clear();
			cvis.insert(x.first);
		}
	}
	for (int i : rvis) {
		for (int j : cvis) {
			if (vis.find({i, j}) == vis.end()){
				ans = max(ans, row[i] + col[j]);
				break;
			}
			else ans = max(ans, row[i] + col[j] - 1);
			// cout << i << " " << j << " " << ans << endl;
		}
	}
	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 80852
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt();
        if(a<=9&&b<=9) System.out.println(a*b);
        else System.out.println(-1);

    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25368
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  int n,left=0,right=0,l=0,r=0;
  string s;
  cin>>n>>s;
  char c=s[0];
  rep(i,n){
     if(c!=s[i]){
        if(s[i]=='('){
           left+=max(0,l-r);
           r=max(0,r-l);
           l=0;
        }
        c=s[i];
     }
     c==')'?l++:r++;
  }
  left+=max(0,l-r);
  right=max(0,r-l);
  rep(i,left) cout<<"(";
  cout<<s;
  rep(i,right) cout<<")";
    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    string s,t;cin>>s>>t;
    int n=sz(s),len=n;
    while (len--){
        char c=s[n-1];
        if (s==t){
            cout << "Yes" << endl;
            return;
        }
        s.erase(s.begin()+n-1);
        s.insert(s.begin(),c);
    } 
    cout << "No" << endl;
    return;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;

  if (K <= A) {
    cout << K << endl;
  } else if (K <= A + B) {
    cout << A << endl;
  } else {
    int x = K - (A+B);
    cout << A - x << endl;
  }
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){

  int i ;
  int length ;
  scanf("%d" , &length);

  int A[length];

  for ( i = 0 ; i < length ; i++){
    scanf("%d" , &A[i]) ;
  }

  int minj;
  int j;
  int tmp;
  int counter = 0;

  for( i = 0 ; i < length ; i++){
    minj = i;

    for ( j = i ; j < length ; j++){
      if (A [j] < A[minj]){
	minj = j;
      }
    }

    if(A[i] != A[minj]){
      tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
      counter++;
    }
    
  }



  

  for(i = 0 ; i < length ; i++){
    printf("%d",A[i]);
    if(i < length - 1)printf(" ");
  }
  
  printf("\n");

  printf("%d\n",counter);

  return 0;
  
  
}



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

using namespace std;

struct point{
  double x, y;
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x>q.x;
  return p.y < q.y;
}

int main(void){
  int n;
  point a;
  vector<point>v;

  cin >> n;
  while(n--){
    cin >> a.y >> a.x;
    v.push_back(a);
  }

  sort(v.begin(),v.end(),cmp_x);

  cout << v[0].y << " "<< v[0].x <<endl;

  return 0;
}

Measured memory_bytes: 1320
from sys import stdin

N, X, Y = [int(x) for x in stdin.readline().rstrip().split()]
d = {}
# print(d)
for k in range(1, N):
    for i in range(1, N+1-k):
        temp = min(k, (abs(i-X)+1+abs(Y-(i+k))))
        d[temp] = d.get(temp, 0)+1
        # print("k=", k, "a=", min(k, (abs(i-X)+1+abs(Y-(i+k)))))
        # if k != min(k, (abs(i-X)+1+abs(Y-(i+k)))):
        #     pass
for l in range(1, N):
    print(d.get(l, 0))
# print(d.get(5, 0))


Measured memory_bytes: 3572
#include<stdio.h>
int main(void)
{
  long a,b,k,tmp;
  
  scanf("%ld %ld %ld",&a,&b,&k);
  
  if(a + b <= k){
    a = 0;
    b = 0;
  }else if((a - k) == 0){
    a = 0;
  }else if((a - k) > 0){
    a = a - k;
  }else if((a - k) < 0){
    tmp = k - a;
    b = b - tmp;
    a = 0;
  }
  printf("%ld %ld",a,b);  

  return 0;  
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextLong();
        }

        Arrays.sort(A);

        TreeMap<Long, Long> counter = new TreeMap<>();
        long R = 0;

        counter.put(A[N-1], 1L);
        for (int i = N-2; i >= 0 ; i--) {
            long key = counter.floorKey(Long.MAX_VALUE);
            R += key;
            if(counter.get(key) == 1L){
                counter.remove(key);
            } else {
                counter.put(key, counter.get(key)-1L);
            }
            counter.put(A[i], counter.getOrDefault(A[i],0L) + 2L);
        }

        System.out.println(R);
    }

    public static void main(String[] args){
        new Main();
    }
}


Measured memory_bytes: 68512
main = do
  s <- getContents
  let ss = init . filter (not . null) . lines $ s
  mapM_ (print . calc . words) ss

calc :: [String] -> Int
calc [x,"+",y] = (read x + read y)
calc [x,"-",y] = (read x - read y)
calc [x,"*",y] = (read x * read y)
calc [x,"/",y] = (read x `div` read y)

Measured memory_bytes: 3988
def sum1(N):
    S1 = int((((N // 3)) * (2 * 3 + (N //3 - 1) * 3) //2) )
    S2 = int((((N // 5)) * (2 * 5 + (N // 5 - 1) * 5) // 2) )
    S3 = int((((N // 15)) * (2 * 15+ (N // 15 - 1) * 15) // 2))
    a =  int(S1 + S2 - S3) 
    return a
N = int(input())
ans = (N*(N+1)/2)-sum1(N)
print(int(ans))

Measured memory_bytes: 9196
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>   
#include <functional>

#define lnd '\n'
#define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mkp make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

void solution();

template <class T>
T GCD (T a, T b) {
  if(b == 0) return a;
  return GCD(b, a%b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    int h, w, n;
    cin >> h >> w >> n;
    int d = max(h,w);
    if(n%d){
        cout << n/d+1 << endl;
    }else{
        cout << n/d << endl;
    }
}

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

/*
ある頂点からの距離が偶数であるものは白、奇数であるものは黒とすれば、
同色の任意の頂点について距離が偶数になる。
根からの距離を計算する関数が必要。
*/

/*
グラフ：
Edge 結んでいる頂点とその重みのペア
Graph Edgeの配列の配列
*/
vector<vector<pair<int,int>>> g;

/*
頂点u、uの親頂点v, uの頂点からの距離を表すdが与えられる
uと繋がっている頂点がvと等しい時、スキップ
*/
vector<ll> dist;
void dfs(int u, int v, ll d){
    dist[u] = d;
    
    for(auto e : g[u]){
        if(e.first != v) dfs(e.first, u, d+e.second);
    }
    
    /*
    int siz = g[u].size();
    rep(i,siz){
        pair<int,int> e;
        e = g[u][i];
        if(e.first != v) dfs(e.first, u, d+e.second);
    }
    */
}

void solve(){
    int n;
    cin >> n;
    //assign:同じ値で要素を埋める
    g.assign(n,vector<pair<int,int>>());
    dist.assign(n,0);
    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        //頂点番号を0始まりにする
        u--;
        v--;
        g[u].emplace_back(make_pair(v,w));
        g[v].emplace_back(make_pair(u,w));
    }
    dfs(0,-1,0);
    rep(i,n){
        cout << dist[i]%2 << endl;
    }
}

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

Measured memory_bytes: 8576
import java.io.*;
import java.util.*;


class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int count = 0;
	int R = sc.nextInt();
	int[] A = new int[R];
	for(int i = 0;i < R;i++){
	    A[i] = sc.nextInt();
	}
	int N = sc.nextInt();
	int[] B = new int[N];
	for(int j = 0;j < N;j++){
	    B[j] = sc.nextInt();
	}
	for(int j = 0;j < N;j++){
	    if(linearSearch(A,B[j])){
		count++;
	    }
	}
	System.out.println(count);
    }
    public static boolean linearSearch(int[] A,int key){
    	int i = 0;
    	for(i = 0;i < A.length;i++){
    	    if(A[i] == key){
    		return true;
    	    }
    	}
    	return false;
    }
}
    // public static boolean binarySearch(int[] A,int key){
    // 	int left = 0;
    // 	int right = A.length;
    // 	int mid = 0;
    // 	while(left < right){
    // 	    mid = (left + right) / 2;
	 
    // 	    if(A[mid] == key){
    // 		return true;
    // 	    }else if(key < A[mid]){
    // 		right = mid;
    // 	    }else{
    // 		left = mid + 1;
    // 	    }
    // 	}
    // 	return false;
    // }



Measured memory_bytes: 39808
#include <iostream>
using namespace std;
int main(void){
  int a;
  cin >> a;
  bool ans = false;
  
  for(int i=1;i<10;i++){
    if(a % i == 0 && a / i < 10){
      cout << "Yes" << endl;
      ans = true;
      break;
    }
  }
    if(!ans) cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n;
	int judge[100];
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> judge[i];
		}
		for (int i = n; i > 1; i--) {
			for (int j = 0; j < i-1; j++) {
				if (judge[j] > judge[j+1]) {
					swap(judge[j], judge[j+1]);
				}
			}
		}
		for (int i = 1; i < n-1; i++) {
			sum += judge[i];
		}
		cout << sum/(n-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

vector<long> enumDiviser(long n) {
  vector<long> res(1,1);

  for (long i=2; i*i<=n; i++) {
    if (n%i==0) {
      res.push_back(i);
      if (i*i != n) res.push_back(n/i);
    }
  }

  res.push_back(n);
  return res;
}

int main() {
  long n,m;
  long ans = -1;
  cin >> n >> m;
  vector<long> divisers = enumDiviser(m);
  sort(divisers.rbegin(), divisers.rend());

  for (auto diviser : divisers) {
    if (n <= m/diviser) ans = diviser;
    if (ans > 0) break;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

// 二分累乗法
Int modpow(Int a, Int n, Int mod) {
    Int ret = 1;
    while (n > 0) {
        if (n & 1) {
            ret = ret * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }

    return ret;
}

vector<Int> factorials(0), invs(0);
bool is_ncr_table = false;
void calc_ncr_table(Int n, Int mod) {
    is_ncr_table = true;

    // 1! ~ n! の計算
    Int f = 1;
    factorials.push_back(f);
    for (Int i = 1; i < n + 1; i++) {
        f *= i;
        f %= mod;
        factorials.push_back(f);
    }
    // n!^-1 の計算
    Int inv = modpow(factorials[n], mod - 2, mod);
    // (n-1)!^-1 ~ 1!^-1 の計算
    invs.assign(n, 1);
    invs[n] = inv;
    for (Int i = n; i >= 1; i--) {
        inv *= i;
        inv %= mod;
        invs[i - 1] = inv;
    }
}

Int factorial(Int n, Int mod = 1) {
    Int ret = 1;
    if (mod == 1) {
        for (Int i = 1; i < n + 1; i++) {
            ret *= i;
        }

        return ret;
    } else {
        for (Int i = 1; i < n + 1; i++) {
            ret *= i;
            ret %= mod;
        }

        return ret;
    }
}

Int ncr(Int n, Int r, Int mod, bool use_table = false) {
    if (use_table) {
        // modが素数の場合のみ
        if (!is_ncr_table) {
            calc_ncr_table(n, mod);
        }
        return factorials[n] * invs[r] * invs[n - r] % mod;
    } else {
        Int x = 1;
        for (Int i = n - r + 1; i < n + 1; i++) {
            x *= i;
            x %= MOD;
        }
        return x * modpow(factorial(r, mod), mod - 2, mod) % mod;
    }
}

int main() {
    int k, x;
    cin >> k >> x;
    if (500 * k >= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		m: usize,
	}

	println!("{}", (n-1)*(m-1));
}



Measured memory_bytes: 2064
s = input()
n = len(s)
S=[0 for i in range(n)]
for i in range(n):
    if s[i]=="R":
        S[i]=1


ANS =[0 for i in range(n)]
tame =[0,0]
k=0
for i in range(n):
    if S[i] == 1:
        tame[k]+=1
        k = (k+1)%2
    elif tame[0]>0:
        ANS[i-1] += tame[0]
        ANS[i] += tame[1]
        tame=[0,0]
        k=0
tame =[0,0]
k=0
for i in range(n-1,-1,-1):
    if S[i] == 0:
        tame[k]+=1
        k = (k+1)%2
    elif tame[0]>0:
        ANS[i+1] += tame[0]
        ANS[i] += tame[1]
        tame=[0,0]
        k=0
#print(ANS)
ans=""
for i in range(n):
    ans += str(ANS[i])
    ans += " "
print(ans)
#print(n)

Measured memory_bytes: 5500
#include<bits/stdc++.h>
#define ll long long
#define pb(a) push_back(a)
#define pi pair<int,int>
using namespace std;
void solveD()
{
    int n;
    cin>>n;
    vector<int>input(n);
    int m=n;
    for(int i=0;i<n;i++)
    {
        cin>>input[i];
        m=max(m,input[i]);
    }
    vector<bool>vis(m+1,true);
    map<int,int>mp;
    for(int a:input)
    ++mp[a];
    input.clear();
    for(auto x:mp)
    input.push_back(x.first);
    sort(input.begin(),input.end());
    for(int a:input)
    {
        if(vis[a]==true)
        {
            for(int j=a;j<=m;j+=a)
            vis[j]=false;
            vis[a]=true;
        }
    }
    int ans=0;
    for(int i:input)
    if(vis[i] and mp[i]==1) ans+=1;
    cout<<ans;
    // if(vis[input[i]]) cout<<i+1<<" ";
}
int  main()
{
    solveD();
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 N,K;
  cin >> N >> K;
  vector<f80> p(N);
  rep(i,N) cin >> p[i];

  vector<f80> ps(N+1);
  ps[0] = 0;
  rep(i,N)
    ps[i+1] = ps[i] + (1+p[i])/2;

  f80 ans = 0;
  rep(i,N-K+1)
    maxs(ans,ps[i+K]-ps[i]);
  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 6528
#include <iostream>

using namespace std;

int main(){
  int n;
  while(cin >> n){
    int m = 100000;
    while(n--){
      m = m*1.05;
      m = (int)(m / 1000 + ((m % 1000)?1:0)) * 1000 ;
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int a, b, c, d;

int main(){
  cin >> a >> b >> c >> d;
  int l = a+b;
  int r = c+d;
  if(l>r)
    cout << "Left" << endl;
  else if(l==r)
    cout << "Balanced" << endl;
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let mut count = vec![0; 10];
    count[v[0]] += 1;
    count[v[1]] += 1;
    count[v[2]] += 1;

    if count[5] == 2 && count[7] == 1 {
        println!("YES");
    } else {
        println!("NO");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  ull a,b,c,sum=0,ans=0;
  bool flag=false;
  cin>>a>>b>>c;
  rep(i,1,101){
    sum=a*i;
    ans=sum%b;
    if(ans==c)flag=true;
  }
  if(flag){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
s_bin = input()
n = len(s_bin)

def make_target(n):
    target1_bin = '01' * (n//2)
    target2_bin = '10' * (n//2)
    if (n%2 == 1):
        target1_bin += '0'
        target2_bin += '1'
    return([target1_bin, target2_bin])

s = int(s_bin, 2)
target1, target2 = [int(i, 2) for i in make_target(n)]

diff1 = bin(s ^ target1)
diff2 = bin(s ^ target2)

cost1 = diff1.count('1')
cost2 = diff2.count('1')

print(min([cost1, cost2]))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
#define MOD 1000000007
#define yes "YES"
#define no "NO"
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;

int main() {
    fastcin;
    ll n, in, ans = 0;
    vll a, aa;
    cin >> n;
    rep(i, 1, n+1) {
        cin >> in;
        in -= i;
        a.push_back(in);
    }
    VSORT(a);
    if(n&1) {
        ll tmp = a[n/2];
        rep(i, 0, n) {
            ans += abs(a[i]-tmp);
        }
    } else {
        ll tmp1 = a[n/2-1], tmp2 = a[n/2], ans1 = 0, ans2 = 0;
        rep(i, 0, n) {
            ans1 += abs(a[i]-tmp1);
            ans2 += abs(a[i]-tmp2);
        }
        ans = min(ans1, ans2);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,E,F;
int water[3005],sugar[3005];
int main(){
	cin>>A>>B>>C>>D>>E>>F;
	water[0]=sugar[0]=1;
	for(int i=1;i<=F;i++){
		if(i>=100*A)water[i]=water[i-100*A];
		if(i>=100*B)water[i]=(water[i]|water[i-100*B]);
		if(i>=C)sugar[i]=sugar[i-C];
		if(i>= D)sugar[i]=(sugar[i]|sugar[i-D]);
	}
	int ansx=100*A;
	int ansy=0;
	for(int x=1;x<=F;x++){
		if(water[x]==1){
			for(int y=0;y<=F-x;y++)if(sugar[y]==1){
				double s=y*1.0/x;
				double t= E*1.0/100;
				double u=ansy*1.0/ansx;
				if(s<=t&&s>u){
					ansx=x;
					ansy=y;
				}	
			}
		}
	}
	cout<<ansx+ansy<<" "<<ansy<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
*    author:  y_takano
*    created: 22.06.2020 11:47:18
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  string x;
  int sum;
  
  for (;;)
  {
      cin >> x;
      sum = 0;

      if (x == "0")
      {
          break;
      }
      else
      {
          for (size_t i = 0; i < x.size(); i++)
          {
              sum += x[i] - '0';
          }
      }
      
      cout << sum << '\n';
      
  }
  
  return 0;
}


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

using namespace std;
typedef long long int ll;

const ll mod = 1e9 + 7;


void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cout << "ACL";
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <iostream>
using namespace std;

#define MOD 1000000007

int main()
{
	long long N, K, S;
	cin >> N >> K;
	int i;
	N++;
	K = N - K;
	S = 0;
	long long san = 0;
	for (i = 0; i <= K; i++)
	{
		san += i;
		//cout << "#" << i * (N+1) - san*2 + 1 << endl;
		S += i * (N + 1) - san * 2 + 1;
		S %= MOD;
	}
	cout << S;
	return 0;
}

Measured memory_bytes: 3640
import queue

H,W=map(int,input().split())
s=[[] for _ in range(H+2)]
s[0]="#"*(W+2)

for i in range(H):
    s[i+1]="#"+input()+"#"
    
s[-1]="#"*(W+2)

dx=[0,0,1,-1]
dy=[1,-1,0,0]

q=queue.Queue()
q.put((1,1))
d=[[-1]*(W+2) for _ in range(H+2)]
d[1][1]=0

while not q.empty():
    pos=q.get()
    l=d[pos[0]][pos[1]]
    for i in range(len(dx)):
        nxt=(pos[0]+dx[i],pos[1]+dy[i])
        if d[nxt[0]][nxt[1]]==-1 and s[nxt[0]][nxt[1]]==".":
            d[nxt[0]][nxt[1]]=l+1
            q.put(nxt)
            
use=d[H][W]+1

cnt=0
for i in range(H+2):
    cnt+=s[i].count(".")



if use!=0:
    print(cnt-use)
else:
    print(-1)





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

# define C continue;
# define R return

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

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >

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

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

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(1,1);
const D tpie = 2*pie;

string vow = "aeiou";
ull n;
int d;
vi v;

bool check ( ull n )
{
    //cout << n ; line getline(cin,vow);
    while ( n )
    {
        int dig = n%10;
        int indx = 0;
        for ( ; indx<d && v[indx]!=dig ; indx++ );

        if ( indx < d ) { R false; }
        n/=10;
    }
    R true;
}

void solve( int test_case )
{
    cin >> n >> d;
    v.resize(d);

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

    for ( ; ; n++ )
    {
        if ( check(n) )
        {
            cout << n;
            line
            R;
        }
        //cout << "Value of n : " << n; line getline(cin,vow);
    }
}

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

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>

using namespace std;

int main() {

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

  int a, b;
  cin >> a >> b;
  if (a == 1) {
    a += 13;
  }
  if (b == 1) {
    b += 13;
  }
  if (a == b) {
    cout << "Draw" << endl;
  } else if (a > b) {
    cout << "Alice" << endl;
  } else {
    cout << "Bob" << endl;
  }

}


Measured memory_bytes: 256
H,W,D = map(int, input().split())

pos = [0] * (H*W)
Z = [0] * (H*W+1)
for j in range(H):
    A = list(map(int, input().split()))
    for i in range(W):
        pos[A[i]-1] = (i, j)
for k in range(D):
    for x in range(k, H*W-D, D):
        pos1 = pos[x]
        pos2 = pos[x+D]
        Z[x+D+1] = abs(pos2[0]-pos1[0]) + abs(pos2[1]-pos1[1]) + Z[x+1]

for _ in range(int(input())):
    x, y = map(int, input().split())
    print(Z[y]-Z[x])


Measured memory_bytes: 14292
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
void solve()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = 0, count = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> ma;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  vlli d;
  repe(i, 1, n)
  {
    repe(j, 1, n / i)
    {
      if (n - (i * j) > 0)
      {
        ans++;
      }
      // out(i << " " << j);
    }
  }
  out(ans);
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  solve();
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main(){
  string s;
  cin>>s;
  int x=753;
  int min=99999;
  for (int i=0;i<s.length()-2;i++){
    int t=abs(x-stoi(s.substr(i,3)));
    if (t<min) min=t;
  }
  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

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

#define READ freopen("in.txt", "r", stdin)
#define ROUT freopen("out.txt", "w", stdout)
#define pb push_back
#define endl '\n'

#define REP(i,a,b) for(int i=a; i<=b; i++)
#define arrL(i,a,b) for(int i=a; i<b; i++)

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    ROUT;
}

void solve()
{
    int n, k, j, flag=0;

    cin>>n;

    int a[n];

    arrL(i, 0, n)
        cin>>a[i];

    if(is_sorted(a, a+n))
        flag=1;
    else{
        for(k=0; k<n-1; k++){
            if(flag==1)
                break;
            for(j=k+1; j<n; j++){
                swap(a[k], a[j]);
                if(is_sorted(a, a+n)){
                    flag=1;
                    break;
                }
                else
                    swap(a[k], a[j]);
            }
        }
    }

    if(flag)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}

int main()

{
    ///fileIO();
    fasterIO();

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
long long n,a[205],f,k; 
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    	if(a[i]%2==1)
    		f=1;
	}
	if(f==1)
	{
		cout<<0<<endl;
		return 0;
	}
	while(1)
	{
		for(int i=1;i<=n;i++)
		{
			if(a[i]%2==0)
				a[i]/=2,f=0;
			else
			{
				f=1;
				break;
			}
		}
		if(f==0)
			k++;
		else
			break;
	}
	cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define X 3
#define Y 3
#define THRESHOLD 2
int manhattan(int x1,int y1,int x2,int y2){
	return abs(x1-x2)+abs(y1-y2);
}
int calc(vector<int>&v){
	int s=0;
	for(int coor=0;coor<X*Y;coor++){
		if(v[coor]!=0){
			s+=manhattan(coor%X,coor/X,(v[coor]-1)%X,(v[coor]-1)/X);
		}else{
			s+=manhattan(coor%X,coor/X,X-1,Y-1);
		}
	}
	return s;
}
int main(){
	int i=1,start_point;
	vector<int>start(X*Y),goal;
	for(;i<X*Y;i++)goal.push_back(i);goal.push_back(0);
	for(i=0;i<X*Y;i++){
		scanf("%d",&start[i]);
		if(start[i]==0)start_point=i;
	}
	if(start==goal){puts("0");return 0;}

	map<vector<int>,pair<int,int> >mstart,mgoal;
	queue<pair<vector<int>,bool> >q;
	mstart[start]=make_pair(start_point,0);
	mgoal[goal]=make_pair(X*Y-1,0);
	q.push(make_pair(start,false));
	q.push(make_pair(goal,true));
	for(;!q.empty();){
		vector<int> v=q.front().first;
		bool f=q.front().second;
		q.pop();
		int val=calc(v);
		map<vector<int>,pair<int,int> >&m=f?mgoal:mstart;
		map<vector<int>,pair<int,int> >&m2=f?mstart:mgoal;
		int coor=m[v].first,x=coor%X,y=coor/X;
		int depth=m[v].second;
		if(0<x){
			swap(v[coor],v[coor-1]);
			if(m.find(v)==m.end() && calc(v)<=val+THRESHOLD)m[v]=make_pair(coor-1,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor-1]);
		}
		if(x<X-1){
			swap(v[coor],v[coor+1]);
			if(m.find(v)==m.end() && calc(v)<=val+THRESHOLD)m[v]=make_pair(coor+1,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor+1]);
		}
		if(0<y){
			swap(v[coor],v[coor-X]);
			if(m.find(v)==m.end() && calc(v)<=val+THRESHOLD)m[v]=make_pair(coor-X,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor-X]);
		}
		if(y<Y-1){
			swap(v[coor],v[coor+X]);
			if(m.find(v)==m.end() && calc(v)<=val+THRESHOLD)m[v]=make_pair(coor+X,depth+1),q.push(make_pair(v,f));
			if(m2.find(v)!=m2.end()){printf("%d\n",m2[v].second+depth+1);return 0;}
			swap(v[coor],v[coor+X]);
		}
	}
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

    ll N;
    cin >> N;
    ll ans = 0;

    REP(i, N+1){
        if(i % 3 == 0 || i % 5 == 0){

        }else{
            ans += i;
        }
    }

    cout << ans << endl;




}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 24) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int A[100005], B[100005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b, m; gi(a); gi(b); gi(m);
	int oa = 100005, ob = 100005;
	rep1(i, a) {
		gi(A[i]);
		oa = min(oa, A[i]);
	}
	rep1(i, b) {
		gi(B[i]);
		ob = min(ob, B[i]);
	}
	int opt = oa + ob;
	rep(i, m) {
		int x, y, c; 
		gi(x); gi(y); gi(c);
		opt = min(opt, A[x] + B[y] - c);
	}
	cout << opt << endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int W, H, N, area = 0;
	cin >> W >> H >> N;
	int b[W][H] = {};
	int x, y, a;
	for (int k = 0 ; k < N ; k++ ) {
		cin >> x >> y >> a;
		if (a==1) {
			for ( int i = 0 ; i < x ; i++ ) {
                for ( int j = 0 ; j < H ; j++ ) {
                    b[i][j] = 1;
                }
            }
		} else if (a == 2) {
			for (int i = x ; i < W ; i++ ) {
				for (int j = 0 ; j < H ; j++ ) {
					b[i][j] = 1;
				}
			}
		} else if (a==3) {
			for ( int i = 0 ; i < W ; i++ ) {
                for ( int j = 0 ; j < y ; j++ ) {
                    b[i][j] = 1;
                }
            }
		} else {
			for ( int i = 0 ; i < W ; i++ ) {
                for ( int j = y ; j < H ; j++ ) {
                    b[i][j] = 1;
                }
            }
		}
	}
	for ( int i = 0 ; i < W ; i++ ) {
        for ( int j = 0 ; j < H ; j++ ) {
            if ( b[i][j] == 0) area++;
        }
    }
	cout << area;
}

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

int main() {
    int k;
    cin >> k;
    vector<ll> a;
    for (int i = 1; i < 10; i++) {
        a.push_back(i);
    }
    while (1) {
        if (a.size() >= k) {
            cout << a.at(k-1) << endl;
            return 0;
        }
        k = k - a.size();
        vector<ll> old;
        swap(a, old);
        for (ll x : old) {
            for (int i = -1; i < 2; i++) {
                int y = x % 10 + i;
                if (y < 0 || y > 9) {
                    continue;
                }
                ll newx = x * 10 + y;
                a.push_back(newx);
            }
        }
    }

    return 0;
}

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

long long C(int n, int k) {
    if(k == 0 || k == n) {
        return 1;
    }
    long long res = 1;
    if(k > n-k) k = n-k;
    for(int i = 0; i < k; i++) {
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}

int main() {
    int n; 
    cin >> n;
    int a[n+1], k, inp[n];
    long long ch[n+1];
    for(int i = 0; i < n+1; i++) {
        a[i] = 0;
        ch[i] = 0;
    }
    for(int i = 0; i < n; i++) {
        cin >> inp[i];
        a[inp[i]]++;
    }

    long long sum = 0;
    for(int i = 1; i <= n; i++) {
        if(a[i] > 1) {
            // cout << "a[inp][i] " << a[i] << endl;
            ch[i] = C(a[i], 2);
            
            sum += ch[i];
        }
        // cout << "ch[i] " << ch[i] << endl;
    }
    // cout << "sum " << sum << endl;
    for(int i = 1; i <= n; i++) {
        // cout << "inp[i] " << inp[i-1] << endl;
        if(a[inp[i-1]] <= 2) {
            cout << sum - ch[inp[i-1]] << "\n";
        } else if(a[inp[i-1]] > 2)
            cout << sum - ch[inp[i-1]] + C(a[inp[i-1]]-1, 2) << "\n";
       
    }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const double PI=3.14159265358979323846;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    double r;
    cin >> r;

    cout << fixed << setprecision(24) << r * 2 * PI << endl;

    return 0;
}

Measured memory_bytes: 3804
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] a = new int[s.length()];
        Arrays.fill(a, -1);
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'R' && s.charAt(i + 1) == 'L') {
                a[i] = 1;
                a[i + 1] = 1;
            }
        }
        int cnt = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'R' && a[i] == -1) {
                a[i] = 0;
                cnt++;
            } else if (a[i] != -1 && cnt > 0) {
                if (cnt % 2 == 0) {
                    a[i] += cnt / 2;
                    a[i + 1] += cnt / 2;
                } else {
                    a[i] += cnt / 2;
                    a[i + 1] += cnt / 2 + 1;
                }
                cnt = 0;
            }
        }
        cnt = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == 'L' && a[i] == -1) {
                a[i] = 0;
                cnt++;
            } else if (a[i] != -1 && cnt > 0) {
                if (cnt % 2 == 0) {
                    a[i] += cnt / 2;
                    a[i - 1] += cnt / 2;
                } else {
                    a[i] += cnt / 2;
                    a[i - 1] += cnt / 2 + 1;
                }
                cnt = 0;
            }
        }
        System.out.println(Arrays.stream(a).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
    }
}

Measured memory_bytes: 33808