akhauriyash/Code-Regression huggingface dataset:
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define ll long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    string s;
    cin>>s;
    string t1=s.substr(0,s.size()/2);
    string t2=s.substr((s.size()+3)/2-1,s.size()/2);
    string rs=s,rt1=t1,rt2=t2;
    reverse(rs.begin(),rs.end());
    reverse(rt1.begin(),rt1.end());
    reverse(rt2.begin(),rt2.end());
    int f=1;
    rep(i,s.size())
    {
        if(s[i]!=rs[i])
        {
            f=0;
            break;
        }
    }
    rep(i,t1.size())
    {
        if(t1[i]!=rt1[i])
        {
            f=0;
            break;
        }
    }
    rep(i,t2.size())
    {
        if(t2[i]!=rt2[i])
        {
            f=0;
            break;
        }
    }
    //cout<<s<<'\n'<<t1<<'\n'<<t2<<endl;
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    vector<int> a(n);
    vector<int> b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    sort(ALL(a));
    sort(ALL(b));
    for(int i=a[n-1]+1;i<=b[0];i++){
        for(int j = x+1;j<=y;j++){
            if(i==j) {
                cout<<"No War"<<endl;
                return 0;
            }
        }
    }
    cout<<"War"<<endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(scanner.nextLine());
			if (n == 0) {
				break;
			}
			int[][] num = new int[n][2];
			for (int l = 0; l < n; l++) {
				StringTokenizer tokenizer = new StringTokenizer(
						scanner.nextLine());
				num[l][0] = Integer.parseInt(tokenizer.nextToken());
				int t = tokenizer.countTokens();
				int[] b = new int[t];
				int frame = 1;
				for (int i = 0; i < t; i++) {
					b[i] = Integer.parseInt(tokenizer.nextToken());
				}

				int j = 0;
				int sum = 0;
				while (j < b.length) {
					if (frame >= 10) {
						sum += b[j];
						j++;
					} else {
						sum += b[j] + b[j + 1];
						if (b[j] == 10) {
							sum += b[j + 2];
							j++;
						} else {
							if (b[j] + b[j + 1] == 10) {
								sum += b[j + 2];
							}
							j += 2;
						}
					}
					frame++;
				}
				num[l][1] = sum;
			}
			Arrays.sort(num, new Comparator<int[]>() {
				@Override
				public int compare(int[] a, int[] b) {
					if (a[1] == b[1]) {
						return a[0] - b[0];
					}
					return b[1] - a[1];
				}
			});
			for (int[] a : num) {
				System.out.println(a[0] + " " + a[1]);
			}
		}
	}
}

Measured memory_bytes: 21200
/*
ID: leezhen
TASK: practice
LANG: C++11
*/
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
#define bit(x, i) (x & (1 << i))
#define IN(i, l, r) (l < i && i < r)
#define LINR(i, l, r) (l <= i && i <= r)
#define LIN(i, l, r) (l <= i && i < r)
#define INR(i, l, r) (l < i && i <= r)
#define getI(a) scanf("%d", &a)
#define getII(a, b) scanf("%d%d", &a, &b)
#define getIII(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define getS(x) scanf("%s", x)
#define clr(a, x) memset(a, x, sizeof(a))
#define char2Int(c) (c - '0')
#define SZ(x) ((int)((x).size()))
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// for debug
inline void pisz(int n) { printf("%d\n", n); }
#define DBG(vari) cerr << #vari << " = " << (vari) << endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i == R ? '\n' : ' ')
#define printV(a) printA(a, 0, a.size() - 1)
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

// struct

// data

int main() {
  char s[200010];
  getS(s);
  int sum = 0;
  int len = strlen(s);
  REP(i, 0, len) { sum += char2Int(s[i]); }
  if (sum % 9)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}


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

using namespace std;
int main(void) {
    int N;
    cin >> N;
    int D[110];
    int max = -1;
    int min = 1000000001;
    for (int i = 0; i < N; i++) {
        cin >> D[i];
        if (D[i] < min) min = D[i];
        if (D[i] > max) max = D[i];
    }

    cout << max - min << endl;

    return 0;
}

Measured memory_bytes: 256
# 1時間位はかかった
# lcmはfloatで返され、floatのまま処理を続けると値が正確でなくなる点になかなか気づけなかった

import fractions

a,b,c,d = map(int, input().split())
total = b-a+1
lcm = int(c*d / fractions.gcd(c,d))
x = (b//c) + (b//d) - (b//lcm)
y = ((a-1)//c) + ((a-1)//d) - ((a-1)//lcm)
print(total - (x - y))


Measured memory_bytes: 5048
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	string s;
	cin >> s;

    int n = s.size();
	int ans = 999;

	for (int i = 0; i <= n - 3; i++) {
		int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');

		ans = min(ans, abs(num - 753));
	}
	
	cout << ans << endl;

	return 0;
}

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

{
    string S;
    cin >> S;
    set<char> t;
    rep(i, 3)
    {
        t.insert(S[i]);
    }
    if (t.size() == 3)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


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

public class Main {
	
	int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	void submit() {
		int n = nextInt();
		int k = nextInt();
		int g = 0;
		
		int max = -1;
		for (int i = 0; i < n; i++) {
			int x = nextInt();
			max = Math.max(max, x);
			g = gcd(g, x);
		}
		
		out.println(k <= max && k % g == 0 ? "POSSIBLE" : "IMPOSSIBLE");
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

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

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 33360
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n, r;
    cin >> n >> r;
    int k = 100 * (10 - n);
    if (n >= 10){
        cout << r << endl;
    }else if (n < 10){
        cout << k + r << endl;
    }
}

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    spot_count = int(input())
    spots = [0] + list(map(int, input().split())) + [0]

    # See:
    # https://www.youtube.com/watch?v=WFg2yJGZ2Cw
    # https://img.atcoder.jp/arc093/editorial.pdf
    total_distance = 0
    total_cost = 0

    for i in range(spot_count + 1):
        total_distance += abs(spots[i + 1] - spots[i])

    for j in range(1, spot_count + 1):
        shortcut_cost = (abs(spots[j - 1] - spots[j]) + abs(spots[j] - spots[j + 1]))
        total_cost = total_distance + abs(spots[j - 1] - spots[j + 1]) - shortcut_cost
        print(total_cost)


Measured memory_bytes: 13920
using System;

namespace AOJ.Volume0
{
    public class LeapYear
    {
        public static void Main()
        {
            bool first = true;
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);
                if (a <= 0 || b <= 0) { break; }

                if (!first) { Console.WriteLine(); }
                else { first = false; }

                // 最初のうるう年を見つける
                for (int i = 0; i < 4; i++)
                {
                    if (a % 4 == 0)
                    {
                        if (a % 100 == 0)
                        {
                            // うるう年
                            if (a % 400 == 0) { break; }
                            // うるう年ではない
                            a++;
                            continue;
                        }
                        // うるう年
                        break;
                    }
                    a++;
                }

                // 指定期間にうるう年無し
                if (a > b) { Console.WriteLine("NA"); }
                else
                {
                    Console.WriteLine(a);
                    for (int i = a + 4; i <= b; i = i + 4)
                    {
                        if (i % 100 == 0)
                        {
                            if (i % 400 == 0) { Console.WriteLine(i); }
                            else { continue; }
                        }
                        else { Console.WriteLine(i); }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 5640
/*
 Author: Alokit Kumar 
 */
 #include<bits/stdc++.h>
 using namespace std;
 #define int long long
 int32_t main()
 {
   int n,k,d,i,j,m,l,y,x,s=0;
   cin>>n>>m;
   int a[n+1];
   for(i=1;i<=n;i++) cin>>a[i];
   vector<int> v[n+1];
   for(i=1;i<=m;i++)
   {
     cin>>x>>y;
     v[x].push_back(y);
     v[y].push_back(x);
   }
   bool b[n+1];
   memset(b,1,sizeof(b));bool hi;
   for(i=1;i<=n;i++)
   {
     hi=true;
     if(v[i].empty()) s++;
     else
     {
       if(b[i])
       {
         for(j=0;j<v[i].size();j++)
         {
           if(a[v[i][j]]<a[i])
           {
             b[v[i][j]]=0;
           }
           else
            {hi=false;break;}
         }
         if(hi) s++;
       }
      
     }
   }
   cout<<s;
   return 0;
 }

Measured memory_bytes: 10352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i,a) repi(i,0,a)
#define pb push_back
const int inf = 1e9;
int N, Q;
vector<int> ch[100010];
int marked[100010];

void dfs(int v, int a){
    if(marked[v] == v or marked[v] == a) return;
    marked[v] = a;
    rep(i,ch[v].size()) dfs(ch[v][i], a);
}

int solve(){
    memset(marked, 0, sizeof(marked));
    int ans = 0;
    while(Q--){
        char c; int v;
        cin >> c >> v;
        v--;
        if(c == 'Q') ans += marked[v]+1;
        else dfs(v, v);
    }
    return ans;
}

bool input(){
    cin >> N >> Q;
    if(!N and !Q) return 0;
    rep(i,N) ch[i].clear();
    rep(i,N-1) {
        int a; cin >> a;
        ch[a-1].pb(i+1);
    }
    return 1;
}
signed main(){
    while(input()) cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 12816
from itertools import permutations
from math import factorial
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
x, y = zip(*XY)


def f(x, y): return (x ** 2 + y ** 2)**0.5


ans = 0
for p in permutations(range(N)):
    for s, t in zip(p[:-1], p[1:]):
        dx = x[t] - x[s]
        dy = y[t] - y[s]
        ans += f(dx, dy)

print(ans/factorial(N))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define int long long
ll msize;
int N,Max=0;
vector<int> bit(1e7);
int lowbit(int x){
	return x&(-x);
}
void add(int x){
	for(int i=x;i<=1e7;i+=lowbit(i))
	bit[i]+=1;
}
ll sum(int a){
	ll ret = 0;
	for(int x = a;x>0;x -=x&-x)ret += bit[x];
	return ret;
}
ll count(vector<int> &c){
	ll ret = 0;
	fill(ALL(bit),0);
	for(int j=0;j<c.size();j++){
		ret += sum(c[j] + N+1);
		add(c[j] + N+1);
	}
	//cout << ret << endl;
	return ret;
}
bool check(vector<int> &a,int k){
	vector<int> b = a,c(a.size()+1);
	for(int i=0;i<b.size();i++){
		if(a[i] >= k)b[i]=1;
		else b[i] = -1;
	}
	//cout << "(msize+1)/2) =" << (msize+1)/2 <<" ";
	//cout << "k = " << k <<" ";
	c[0] = 0;
	for(int i=0;i<b.size();i++){
		c[i+1] = c[i] + b[i];
	}
	//cのある区間について、k以上の数をカウントする
	if(count(c) >= (msize+1)/2)return 1;
	else return 0;
}
signed main(void){
	
	cin >> N;
	vector<int> a(N);
	msize = N*(N+1)/2;
	for(int i=0;i<N;i++){
		cin >> a[i];
		Max = max(Max,a[i]);
	}
	int ok = -1;
	int ng = 1e9+7;
	while(abs(ok-ng)>1){
		int mid = (ok+ng)/2;
		//check(vector<int> &a,mid)はmid以上の数がmに半分以上含まれていた場合1を返す
		if(check(a,mid)){
			ok = mid;
		}else{
			ng = mid;
		}
	}
	cout << ok << endl;
}


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

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

  vector<int> l(n);
  rep(i,n){
    cin >> l[i];
  }

  int cdn=0,count=1;
  rep(i,n){
    cdn += l[i];
    if(cdn <= x){
      count++;
    }
    else{
      break;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    int n; 
    cin >> n;
    vector <int> v(n);
    vector <int> c(n);
    vector <int> cospa(n);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    for(int i = 0; i < n; i++){
        if((v[i]-c[i]) <= 0) continue;
        ans += (v[i]-c[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
n = int(input())

xs = []
ys = []
hs = []
for i in range(n):
  x,y,h = map(int,input().split())
  xs.append(x)
  ys.append(y)
  hs.append(h)

for x in range(101):
  for y in range(101):
    for i in range(n):
      if hs[i] >0:
        H = hs[i] + abs(xs[i]-x)+abs(ys[i]-y)
    for i in range(n):
      if hs[i] != max(0, H-abs(xs[i]-x)-abs(ys[i]-y)):
        break
    else:
      print(x,y,H)
      exit()

Measured memory_bytes: 3064
/*
I just got lost in thought. It was unfamiliar territory.
- Steven Wright
*/

#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <vector>
//#include <boost/math/common_factor.hpp>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 1000000000;
const int MAX = 100005;
const int MAX1 = 105;
const int MAX2 = 4007;
const int LEN = 21;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1234567891;
//g++ -std=c++11 your_file.cpp -o your_program

int n, m, x, y, arrn[MAX1], arrm[MAX1];

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
    cin >> n >> m >> x >> y;
    REP(i, n) cin >> arrn[i];
    REP(i, m) cin >> arrm[i];
    sort(arrn, arrn + n);
    sort(arrm, arrm + m);
    if (x >= y or arrn[n - 1] >= arrm[0]) {
        cout << "War" << endl;
        return 0;
    }
    int lo = x + 1, hi = y, mid;
    while (lo <= hi){
        mid = lo + hi >> 1;
        if (mid > arrn[n - 1] && mid <= arrm[0]){
            cout << "No War" << endl;
            return 0;
        }
        else if (mid <= arrn[n - 1]) lo = mid + 1;
        else hi = mid - 1;
    }
    cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        List<Integer> values = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (((a % i) == 0) && ((b % i) == 0)) {
                values.add(i);
            }
        }
        Collections.sort(values);
        Collections.reverse(values);

        System.out.println(values.get(k - 1));
    }

}

Measured memory_bytes: 21460
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

main = do
	[ a, b, n ] <- readIntegers
	let
		x = min ( b - 1 ) n
	print $ ( a * x `div` b ) - a * ( x `div` b )

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

void Main()
{
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  /*int minidx = N+1;
  int amin = N+1;
  rep(i,N) {
    cin >> A[i];
    if(A[i] < amin) {
      minidx = i;
      amin = A[i];
    }
  }
  */
  if (N == K) {cout << 1 << endl; return;}
  int cnt = ceil((float)(N-1) / (K-1));
  cout << cnt << endl;
}

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


Measured memory_bytes: 640
from math import *

def gcd2(array):
    temp = array[0]
    for a in array[1:]:
        temp = gcd(temp, a)
    return temp

def prime_factors(n):       # 戻り値はiterable type
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i             # whileループを進めるごとにイテレータに値を貯め続ける
    if n > 1:
        yield n

N = int(input())
A = list(map(int, input().split()))
f1 = False
if gcd2(A) == 1:
    f1 = True
A.sort()
M = A[-1]
P = set()
f2 = True
for a in A:
    Q = set(prime_factors(a))
    if P & Q:
        f2 = False
        break
    P |= Q
if f2:
    print("pairwise coprime")
elif f1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 205352
#include "bits/stdc++.h"
using namespace std;

// fundamental
using ll = long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,s,n) for (ll i = (s); i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(x) ((ll)1e##x)
#define MAXC(c,x) (c = max(c, x))
#define MINC(c,x) (c = min(c, x))
const ll mod = TEN(9) + 7;

// vector
using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>;
template<class T, size_t N, class A = size_t> auto mdv(A size = 0) -> typename enable_if<N==1, vector<T>>::type { return vector<T>(size); }
template<class T, size_t N, class A = size_t> auto mdv(A size = 0) -> vector<decltype(mdv<T, N - 1>())> { return vector<decltype(mdv<T, N - 1>())>(size); }
template<class T, size_t N, class A, class... B> auto mdv(A size, B... rest) -> typename enable_if<N!=1, vector<decltype(mdv<T, N - 1>(rest...))>>::type { return vector<decltype(mdv<T, N - 1>(rest...))>(size, mdv<T, N - 1>(rest...)); }
template<class T, class... A> auto mdv(A... size) -> decltype(mdv<T, sizeof...(size), A...>(size...)) { return mdv<T, sizeof...(size), A...>(size...); }
// template<size_t N, class A, class... B> auto mdvl(A size, B... rest) -> decltype(mdv<N, ll, A, B...>(size, rest...)) { return mdv<N, ll, A, B...>(size, rest...); }

// template<class T, class A> auto mdv(A size) -> vector<T> { return vector<T>(size); }
// template<class T, class A, class... B> auto mdv(A size, B... rest) -> vector<decltype(mdv<T>(rest...))> { return vector<decltype(mdv<T>(rest...))>(size, mdv<T>(rest...)); }

// io
template<class T> istream& operator >>(istream& is, vector<T>& vec){ for(T& x: vec) is >> x; return is; }
template<class T, class U> istream& operator >>(istream& is, pair<T, U>& p){ is >> p.first >> p.second; return is; }
template<class T> void input(T& t) { cin >> t; assert(cin); } template<class T, class... Ts> void input(T& t, Ts&... ts) { cin >> t; input(ts...); }
template<class T> void print(T&& t) { cout << t; } template<class T, class... Ts> void print(T&& t, Ts&&... ts) { cout << t; print(ts...); }
template<class T> void println(T&& t) { cout << t << endl; } template<class T, class... Ts> void println(T&& t, Ts&&... ts) { cout << t; println(ts...); }
template<class T> string join(const vector<T>& v, const string & sep) { stringstream ss; REP(i, v.size()) ss << (i != 0 ? sep : "") << v[i]; return ss.str(); }

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(50);
    
    ll n; cin >> n;
    vl diff(n);
    vl a(n), b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) diff[i] = a[i] - b[i];
    sort(ALL(diff));
    reverse(ALL(diff));

    ll sum = 0;
    ll cnt = 0;
    REP(i, n) if (diff[i] < 0) {
        cnt++;
        sum += diff[i];
    }
    REP(i, n) {
        if (sum >= 0) break;
        cnt++;
        sum += diff[i];
    }
    if (sum < 0) {
        cout << -1 << endl;
    } else {
        cout << cnt << endl;
    }
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<int> g[2550];
vector<int> revg[2550];
int vis1[2550],vis2[2550];
void dfs1(int now){
	if(vis1[now])return;
	vis1[now] = 1;
	for(auto next:g[now])dfs1(next);
}
void dfs2(int now){
	if(vis2[now])return;
	vis2[now] = 1;
	for(auto next:revg[now])dfs2(next);
}
const int INF = 1e18;
signed main(){
	int n,m,p;cin >>  n >> m >> p;
	vector<tuple<int,int,int>>es;
	rep(i,m){
		int a,b,c;cin >> a >> b >> c;
		a--;b--;
		c -= p;
		c = -c;
		es.emplace_back(a,b,c);
		g[a].push_back(b);
		revg[b].push_back(a);
	}	
	dfs1(0);
	dfs2(n-1);
	vector<int> ok(n);
	rep(i,n)ok[i] = (vis1[i]&vis2[i]);
	vector<int> dist(n,INF);
	dist[0] = 0;
	{
		
		bool update = true;
		rep(cnt,n){
			update = false;
			rep(i,m){
				int a,b,c;
				tie(a,b,c) = es[i];
				if(!ok[a])continue;
				if(!ok[b])continue;
				if(dist[a] + c < dist[b]){
					update = true;
					dist[b] = dist[a]+c;
				}
			}
			if(!update)break;
			if(cnt == n-1){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << max(0ll,-dist[n-1]) << endl;


	return 0;
}

Measured memory_bytes: 4132
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long  ryuka[] = new long[95];
        ryuka[0] = 2;
        ryuka[1] = 1;
        for(int i = 2;i <= 90 ;i++){
          ryuka[i] = ryuka[i-1] + ryuka[i-2];
        }
        System.out.println(ryuka[n]);
  }
}


Measured memory_bytes: 23124
def calc(_input):
  amari = _input % 2
  if amari == 0:
    return _input/2
  else:
    return _input*3 + 1

a = int(input())
b = []
b.append(a)
i = 1
while True:
  i += 1
  c = calc(a)
  if c in b:
    print(i)
    break
  else:
    b.append(c)
    a = c

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define LL long long int

int main() {
	LL k,n;
	cin>>k>>n;
	LL a[n];
	for(LL i=0;i<n;i++){
	    cin>>a[i];
	}
	vector<LL> b;
	for(LL i=1;i<n;i++){
	    b.push_back(a[i]-a[i-1]);
	}
	b.push_back((k-a[n-1])+(a[0]-0));
	sort(b.begin(),b.end());
	LL sum=0;
	for(LL i=0;i<b.size()-1;i++){
	    sum+=b[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


int main() {
string n;
cin >> n;
int count = 0;
rep(i,n.size()){
    int x;
    x = ctoi(n[i]);
    count += x;
}

if(count%9 == 0){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}
}

Measured memory_bytes: 3716
#include<stdio.h>
int main()
{
	int N, i, a, b, c;
	scanf("%d", &N);
	for (i = 0; i < N; i ++) {
		scanf("%d%d%d", &a, &b, &c);
		if (a*a + b*b == c*c ||
			b*b + c*c == a*a ||
			c*c + a*a == b*b) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}

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

typedef long long ll;

int main(void){
    ll N;
    cin >> N;
    
    vector<vector<ll>> a(110000,vector<ll>(3));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j]; 
        }
    }
    
    vector<vector<ll>> dp(110000,vector<ll>(3,0));
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i][j]);
            }
            
        }
    }
    
    ll res = 0;
    for(int j = 0; j < 3; j++){
        res = max(res, dp[N][j]);
    }
    cout << res << endl;
}

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

int main(){
    string s;
    cin >> s;

    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == '1') ans++;
    }

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

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		String[] str = buf.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		int[][] A = new int[n][m];
		int[] B = new int[m];
		int[] C = new int[n];

		for(int i=0; i<n; i++){
			str = buf.readLine().split(" ");
			for(int j=0; j<m; j++){
				A[i][j] = Integer.parseInt(str[j]);
			}
		}
		for(int i=0; i<m; i++){
			B[i] = Integer.parseInt(buf.readLine());
		}
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				C[i] += A[i][j]*B[j];
				//System.out.print(A[i][j]);
			}
		}
		for(int i=0; i<n; i++){
			System.out.println(C[i]);
		}

	}
}

Measured memory_bytes: 27620
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, M, Q;
vector<vector<int>> to;

vector<int> st_max;
vector<int> st_now;
vector<int> color;

int v[100000], d[100000], c[100000];

int main()
{
    cin >> N >> M;
    to.resize(N);
    REP(i, M)
    {
        int a, b;
        cin >> a >> b;
        to[a - 1].push_back(b - 1);
        to[b - 1].push_back(a - 1);
    }

    st_max.assign(N, -1);
    color.assign(N, 0);

    cin >> Q;
    REP(i, Q)
    {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    IREP(i, Q)
    {

        if (d[i] <= st_max[v[i]]) continue;
        queue<int> q;
        q.push(v[i]);

        st_now.assign(N, -1);
        st_now[v[i]] = d[i];

        while (!q.empty())
        {
            int now = q.front();
            q.pop();

            if (color[now] == 0) color[now] = c[i];

            if (st_now[now] > st_max[now])
            {
                st_max[now] = st_now[now];
                for (auto nxt : to[now]) if (st_max[nxt] < st_now[now] - 1)
                {
                    q.push(nxt);
                    st_now[nxt] = max(st_now[nxt], st_now[now] - 1);
                }
            }
        }
    }
    for (auto v : color) cout << v << endl;
}


Measured memory_bytes: 9336
N, M = map(int, input().split())
Alst = []
cnt = 0
for _ in range(N):
    K, *A = map(int, input().split())
    Alst += A
for i in range(1, M + 1):
    if Alst.count(i) == N:
        cnt += 1
print(cnt)

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

void solve()
{
	int fake;
	cin >> fake;

	string str;
	cin >> str;

	int n = str.length();

	int i = 0, j = n - 1;

	int cnt = 0;
	while(i < j and j < n)
	{
		while(i < n and str[i] == 'R')
			i++;

		while(j >= 0 and str[j] == 'W')
			j--;

		if(i < j)
			cnt += 1;

		i++;
		j--;

	}

	int w_cnt = 0;
	for(auto ele : str)
		if(ele == 'W')
			w_cnt++;

	int r_cnt = n - w_cnt;

	cnt = min(cnt, n - w_cnt);
	cnt = min(cnt, n - r_cnt);

	cout << cnt << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();
	return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll x, p=0, t=0;
  cin >> x;
  x = abs(x);
  while(p < x){
	t++;
	p += t;
  }
  cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, n - 2) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
A,B,C,X,Y=list(map(int,input().strip().split()))
need=0
if A+B>2*C:
    need+=min(X,Y)*2*C
    dd=min(X,Y)
    X=X-dd
    Y=Y-dd
    
    if X>0:
        if A>2*C:
            need+=2*C*X
        else:
            need+=A*X
    else:
        if B>2*C:
            
            need+=2*C*Y
        else:
            need+=B*Y
else:
    need=A*X+B*Y
print(need)    
    

Measured memory_bytes: 3064
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N, X = map(int,input().split())

xx = list(map(int,input().split()))

xx_new = [abs(i-X) for i in xx]
xx_new.sort()

pair = 0

for i in xx_new:
  if pair ==0:
    pair = i
  else:
    pair = gcd(i,pair)
    
print(pair)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int dsum(int n) {
  int sm = 0;
  while (n>0) {
    sm += n%10;
    n /= 10;
  }
  return sm;
}
int main() {
  int n,a,b;cin>>n>>a>>b;
  int cnt=0,d;
  rep(i,n) {
    d = dsum(i+1);
    if (d >= a and d <= b) cnt+=i+1;
  }
  cout << cnt;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    map<ll, int> z;
    int i;
    ll curr = 0; z[0]++;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        curr += a[i];
        z[curr]++;
    }
    ll ans = 0;
    auto it = z.begin();
    for (; it != z.end(); ++it) {
        int num=it->second;
        ans += (ll)num * (num - 1) / 2;
    }
    printf("%lld\n", ans);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int look_site(int i, int j, int H, int W){
    
    if (i < 0) return 0;
    if (j <0) return 0;
    if (i>=H)return 0;
    if (j >= W) return 0;
    
    return 1;
    
}

int num2of(int temp){
    
    int out = 0;
    
    while(temp%2 == 0){
        out++;
        temp/=2;
    }
    
    return out;
}


int main() {
    
    int N = in();
    
    int K = in();

    
    if (N == K){
        cout << 1 << endl;
        return 0;
    }
    
    vector<int> A;

    for(auto i = 0; i<N; i++){
        
        A.push_back(in());
        
    }
    
    int ans = 1;
    
    ans += (N-K)/(K-1);
    
    if ((N-K)%(K-1) != 0){
        ans++;
    }
    
    
    cout << ans << endl;
    
    return 0;
}










Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

vll get_divs(ll n){
	set<ll> divs;
	if(n != 1)
		divs.I(n);
	for(ll i = 2; i * i <= n; i++){
		if(n % i == 0)
			divs.I(i), divs.I(n / i);
	}
	vll ans(all(divs));
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n;
	cin >> n;
	vll div1 = get_divs(n), div2 = get_divs(n - 1);
	ll ans = 0;
	for(auto i : div1){
		ll n1 = n;
		while(n1 % i == 0)
			n1 /= i;
		if(n1 > i)
			n1 %= i;
		if(n1 == 1)
			ans++;
	}
	ans += div2.size();
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <cstdio>
#include <complex>
#include <algorithm>

using namespace std;
bool cmp(complex<double> a,complex<double> b){
  if(a.real()!=b.real()) return a.real()<b.real();
  return a.imag()<b.imag();
}
int main(){
  int n;
  complex<double> R9(0.0,1.0);
  while(1){
    scanf("%d",&n);
    if(n==0) return 0;
    complex<double> p[n];
    for(int i=0;i<n;++i){
      scanf("%lf,%lf",&p[i].real(),&p[i].imag());
    }
    sort(p,p+n,cmp);
    int k=0;
    complex<double> q[n*2];
    for(int i=0;i<n;i++){
      while(k>1&&arg(q[k-1]-q[k-2])>arg(p[i]-q[k-1])) k--;
      q[k++]=p[i];
    }
    for(int i=n-2,t=k;i>=0;i--){
      while(k>t&&arg((q[k-1]-q[k-2])*R9)>arg((p[i]-q[k-1])*R9)) k--;
      q[k++]=p[i];
    }
    printf("%d\n",n-k+1);
  }
  return 0;
}

Measured memory_bytes: 1140
main :: IO ()
main = do
  n <- (read :: String -> Int) <$> getLine
  ai <- map (read :: String -> Int) . words <$> getLine
  print $ ans ai

ans :: [Int] -> Int
ans ai = (\(_,xs) -> maximum xs) $ foldl func (0,[]) ai where
  func (h,xs) k = (gcd h k,func2 $ h : foldl (\acc l -> if gcd k l == 1 then acc else gcd k l : acc) [] xs)
  func2 [] = []
  func2 (x:[]) = [x]
  func2 (x1:x2:xs)
    | mod x1 x2 == 0 = func2 (x1:xs)
    | mod x2 x1 == 0 = func2 (x2:xs)
    | otherwise = x1 : func2 (x2:xs)

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

int main()
{
    int A,B,ans = 0;
    scanf("%d%d",&A,&B);
    ans += min(A,B);
    scanf("%d%d",&A,&B);
    ans += min(A,B);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define pb push_back
#define all(v) (v).begin(),(v).end() 
#define endl "\n"
#define int long long int
#define ll long long
#define ld long double
const int mod = 1000000007;
const int N=200005;
const int inf=1e18;
int vis[N];
vector<vector<int>>adj(N);


bool isPrime(ll n){if(n<2)return false;for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res%mod;}
ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
ll max(ll a,ll b){ll ans=a>b?a:b;return ans;}
ll min(ll a,ll b){ll ans=a<b?a:b;return ans;}
void dfs(int x){
    vis[x]=1;
    for(auto i:adj[x]){
        if(!vis[i])
            dfs(i);
    }
}


void fun(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int time(int x,int y){
    int r=0;
    while(x<y){
        x*=2;
        r++;
    }
    return r;
}

double powe(int r){
    double c=1;
    for(int i=0;i<r;i++){
        c/=2;
    }
    return c;
}
signed main(){
    flash;
    fun();
    int t=1;
    //cin>>t;
    while(t--){        
        int n,k;
        cin>>n>>k;
        ld ans=0;
        for(int i=1;i<=n;i++){
            ans+=powe(time(i,k))/n;
        }
        cout<<fixed<<setprecision(10);
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 7800
#include<iostream>
using namespace std;
int main()
{
	
	int a[200];
	int n;
	cin >> n;
	
	for (int i = 0; i < n; i++){
		cin >> a[i];
		
	}
	for (int i = n-1; i >= 0; i--){
		cout << a[i];
		if (i == 0){
			cout << endl;
		}
		else cout << " ";
	}






	return 0;
}

Measured memory_bytes: 3088
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Reflection.PortableExecutable;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var A = t.ParseLongList(t.ReadInput());
            var ans = 0;
            for(var i = 0; i<A.Count; i++)
            {
                if(A[i] == 0)
                {
                    ans = i+1;
                }
            }
            Console.WriteLine(ans); 
        }



        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 27836
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [0] * n
for i in range(n):
    a[i] = list(map(int, input().split()))

ans = 0
for i in a:
    val = c
    for j in range(m):
        val += i[j] * b[j]
    if val > 0:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;


int main() {

	string s;
	cin >> s;
	string ss = "";

	rep(i, s.size() - 1) {
		if (s[i] == 'B' && s[i + 1] == 'C') {
			ss.push_back('D');
			i++;
		}
		else ss.push_back(s[i]);
	}
	

	int a = 0;
	ll ans = 0;

	rep(i, ss.size()) {
		if (ss[i] != 'A' && ss[i] != 'D')a = 0;
		if (ss[i] == 'A')a++;
		if (ss[i] == 'D')ans += a;
	}

	cout << ans << endl;
}

Measured memory_bytes: 776