akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <queue>
using namespace std;

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

template<class T>           //自定义读入函数
inline void read(T &a) {
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    a = x * flag;
}

template <class T>        //自定义写入函数
inline void write(T x) {
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }   //自定义比较函数
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }   //自定义比较函数

#define For(i, a, b) for (int i = (a); i <= (b); ++i)   //从小到大重复
#define Rep(i, a, b) for (int i = (a); i >= (b); --i)   //从大到小重复
#define For_edge(x) for (int i = head[x]; i; i = net[i])
#define mem0(a) memset(a, 0, sizeof a)                  //内存复制


#if 0
int main()
{
	priority_queue<ll> minMin, minMax;
	priority_queue<ll, vector<ll>, greater<ll> > maxMin, maxMax;
	int N;
	scanf("%d", &N);
	
	for(int i = 0; i < N; i++)
	{
		ll min, max;
		scanf("%lld %lld", &min, &max);
		if(minMin.size() > maxMin.size())
			maxMin.push(min);
		else
			minMin.push(min);
		if(minMax.size() > maxMax.size())
			maxMax.push(max);
		else
			minMax.push(max);
	}
	ll result = 0;
	if(N == 1)
		result = minMax.top() - minMin.top() + 1;
	else if(N == 0)
		result = 0;
	else if(N & 1)
	{
		ll myMin = min(minMin.top(),maxMin.top()), myMax = min(minMax.top(),maxMax.top());
		result = (myMax - myMin + 1);
	}
	else
		result = (minMax.top() + maxMax.top()) - (minMin.top() + maxMin.top()) + 1;
	cout << result << endl;
	return 0;
}

#endif

#if 1

int main()
{
	int n ;
	cin >> n ;
	vector<long long> small ;
	vector<long long>large  ;
	for (int i = 0 ; i < n ; ++i) {
		long long a , b ;
		cin >> a >> b  ;
		small.push_back(a) ;
		large.push_back(b) ;
	}
 
	sort(small.begin() , small.end()) ;
	sort(large.begin() , large.end()) ;
	if (n % 2 == 1) {
		long long d = large[(n) / 2] - small[(n) / 2] + 1 ;
		cout << d << endl ;
	}
	else {
		long long a, b ;
		a = small[n / 2 - 1] +  small[n / 2 ]   ;
 
		b = large[n / 2 - 1]  + large[n / 2] ;
		cout << b - a + 1 << endl ;
	}
	return 0;
}

#endif

Measured memory_bytes: 6644
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int n;
    cin >> n;
    int a[n];
    int count = 0;
    for(int i = 0; i < n; i++) cin >> a[i];
    while(1){
        for(int i = 0; i < n; i++){ 
            if(a[i] % 2 == 0) a[i] /= 2;
            else{
                cout << count << endl;
                return 0;
            }
        }
        count++;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
s = [int(sys.stdin.readline()) for _ in range(3)]

if s[0] < s[1]:
  ans = s[2]//s[1]
  if s[2]%s[1] != 0:
    ans += 1
else:
  ans = s[2]//s[0]
  if s[2]%s[0] != 0:
    ans += 1

print(ans)


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

using namespace std;

bool check(int v)
{
    for (int i = 1; i <= 317; ++i)
    {
        if (i * i == v)
            return true;
    }
    return false;
}

int main()
{

    string a, b;
    cin >> a >> b;

    string ab = a + b;

    int v = stoi(ab);

    if (check(v))
        cout
            << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,m,output = 0;
    cin >> n >> m;
    bool opt[m],food[m] = {false};
    for(int mctr = 0;mctr < m;mctr++)
        opt[mctr] = true;
    for(int ctr = 0;ctr<n;ctr++)
    {
        int k,ipt;
        cin >> k;

        for(int kctr = 0;kctr < k ; kctr++)
        {
            cin >> ipt;
            food[ipt-1] = true;
        }
        for(int mctr = 0;mctr < m;mctr++)
        {

            if(opt[mctr]&&food[mctr]){}
            else
            {
                opt[mctr] = false;
            }
            food[mctr] = false;
        }
    }
    for(int ctr = 0;ctr < m;ctr++)
    {
        if(opt[ctr])
        {
            output++;
        }
    }
    cout << output << endl;
    return 0;
}


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


// ABC124B - Great Ocean View
// https://atcoder.jp/contests/abc124/tasks/abc124_b
void ABC124B() {
	int N;
	cin >> N;

	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	int ans = 0;
	for  (int i = 0; i < N; i++)
	{
		bool can_see = true;
		for  (int j = 0; j < i; j++) //jはiよりも西側の山
		{
			//自分より西側の山の方が高いときは海が見えない
			if (H[i] < H[j]) {
				can_see = false;
				break;
			}
		}

		if (can_see) {
			ans++;
		}

	}

	cout << ans << endl;
}


int main() {
	ABC124B();

	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $n);
if ($n % 2 === 1) {
    echo (0) . PHP_EOL;
    exit;
}
$ans = 0;
$num = 10;
while ($num <= $n) {
    $ans += intdiv($n, $num);
    $num *= 5;
}
echo $ans . PHP_EOL;

Measured memory_bytes: 4728
import java.util.*;

public class Main {
    
    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        HashSet<String> K = new HashSet<>();
        for(int i=0; i<N ; i++){
            K.add(scanner.next());
        }
        System.out.println(K.size());
    }
}

Measured memory_bytes: 76692
import math

N,D=map(int,input().split())
S = [[0 for j in range(D)] for i in range(N)]

for i in range(N):
    Z=list(map(int,input().split()))
    for j in range(D):
        S[i][j]=Z[j]
DC=0
goukei=0
root=0
count=0
for i in range(N):
    for j in range(i+1,N):
        goukei=0
        DC=0
        while DC<D:
            goukei+=abs(S[i][DC]-S[j][DC])**2
            DC+=1
            
        root=math.sqrt(goukei)
        if root.is_integer() ==True:
            count+=1
print(count)    

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

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      int[] dp = new int[n+1];
      dp[0] = 0;
      for(int i=1; i<=n; i++) {
        dp[i] = Integer.MAX_VALUE;
        
        for(int pow = 1; pow <= i; pow *= 6) {
          dp[i] = Math.min(dp[i], dp[i-pow]+1);
        }

        for(int pow = 9; pow <= i; pow *= 9) {
          dp[i] = Math.min(dp[i], dp[i-pow]+1);
        }
      }

      System.out.println(dp[n]);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#define ls id<<1
#define rs id<<1|1
using namespace std;
typedef long long ll;
int n,a,b;

int main(){
	cin >>n>>a>>b;
	cout<<min(n*a,b);
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <deque>
#include <algorithm>
#include <math.h>
#include <random>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define int long long
#define double long double
#define Matrix vector<vector<int> >
#define kektor vector
#define pii pair<int, int>
#define pp pair
#define all(x) x.begin(), x.end()
  
using namespace std;
  
typedef long long ll;                                                             
  
int RandInt(int min, int max) {
    if (max < min) {
        swap(min, max);
    }
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<int> dist(min, max);
    return dist(mt);
}

const int maxn = 3e5 + 1, mod = 1e9 + 7, inf = 1e18;
int n;

void solve() {                          
	cin >> n;
	if (n <= 2) {
		cout << 0;
		return;
	}
	cout << 1 + (n - 3) / 3; 		
}         
  
signed main() {
    cout.precision	(10);
    cout << fixed;
    ios_base::sync_with_stdio(false);
   	cin.tie(0);
    cout.tie(0);
    #ifdef offline
   		freopen("TASK.in", "r", stdin);
    	freopen("TASK.out", "w", stdout);
    #endif
    solve();
    return  0;
}


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

int unko(long a,long b){
    int a1=0,b1=0;
    while(true){
        if(a==0)break;
        a /=10;
        a1++;
        
    }
    while(true){
        if(b==0)break;
        b /=10;
        b1++;
    }
    if(a1>b1)return a1;
    else return b1;
    a1=0;b1=0;
}

int main(){
    long N=0,A=0,B=0,C=1000000000;
    cin >> N;
    for(long i=1;i<=sqrt(N);i++){
        if(N%i==0){
            A=i,B=N/i;
            //cout << A << " " << B << endl;
            if(C>unko(A,B))C=unko(A,B);
            //cout << unko(A,B) << endl;
        }

    }
    cout << C << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define int long long

using namespace std;

typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int oo = 1e17 + 7;
const int maxN = 1e5 + 7;
const int MOD = 1e9 + 7;

int N;
ii P[2 * maxN];

main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> P[i].fi;
		P[i].se = 0;
	}
	for (int i = N + 1; i <= 2 * N; i++)
	{
		cin >> P[i].fi;
		P[i].se = 1;
	}
	sort(P + 1, P + 2 * N + 1);
	int cnt = 0, ans = 1;
	for (int i = 1; i <= 2 * N; i++)
	{
		if (P[i].se == 0)
		{
			if (cnt < 0)	ans = (ans * (-cnt)) % MOD;
			cnt++;
		}
		else
		{
			if (cnt > 0)	ans = (ans * cnt) % MOD;
			cnt--;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3328
import heapq
def dijkstra_heap(s):
  d=[float("inf")]*n
  used=[True]*n 
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while len(edgelist):
    minedge=heapq.heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v=minedge[1]
    d[v]=minedge[0]
    used[v]=False
    for e in edge[v]:
      if used[e[1]]:
        heapq.heappush(edgelist,[e[0]+d[v],e[1]])
  return d

n=int(input())
edge=[[] for i in range(n)]
for i in range(n-1):
  x,y,z=map(int,input().split())
  edge[x-1].append([z,y-1])
  edge[y-1].append([z,x-1])

ans=dijkstra_heap(0)
for i in range(n):
  print(ans[i]%2)

Measured memory_bytes: 92576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int N, u, v;
    cin >> N >> u >> v;
    int A[N-1], B[N-1];
    vector<int> edge[N+1];
    rep(i, N-1){
        cin >> A[i] >> B[i];
        edge[A[i]].push_back(B[i]);
        edge[B[i]].push_back(A[i]);
    }
    queue<int> que1, que2;
    int dist1[N+1], dist2[N+1];
    dist1[u] = 0, dist2[v] = 0;
    bool used1[N+1], used2[N+1];
    fill_n(used1, N+1, false);
    fill_n(used2, N+1, false);
    que1.push(u);
    used1[u] = true;
    que2.push(v);
    used2[v] = true;
    while(!que1.empty()){
        int i = que1.front();
        que1.pop();
        rep(j, edge[i].size()){
            int k = edge[i][j];
            if(!used1[k]){
                used1[k] = true;
                dist1[k] = dist1[i]+1;
                que1.push(k);
            }
        }
    }
    while(!que2.empty()){
        int i = que2.front();
        que2.pop();
        rep(j, edge[i].size()){
            int k = edge[i][j];
            if(!used2[k]){
                used2[k] = true;
                dist2[k] = dist2[i]+1;
                que2.push(k);
            }
        }
    }
    int ans = 0;
    rep2(i, 1, N){
        int a = dist1[i], b = dist2[i];
        if(a > b) continue;
        else{
            if(edge[i].size() >= 2) ans = max(ans, b);
            else ans = max(ans, b-1);
        }
    }
    cout << ans << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	map<ll, int> mp;
	rep(i, n){
		int a; cin >>a; mp[-a]++;
	}
	rep(i, m){
		int b,c;
		cin >>b >>c;
		mp[-c] += b;
	}
	ll ans = 0;
	for(auto& x: mp){
		int mn = min(x.second, n);
		n -=mn; ans -= x.first * mn;
		if(mn <=0) break;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 12800
n = int(input())
s = input()
t = input()
max_ans = 0
if n==1:
    if s != t:
        print(2)
    else:
        print(1)
else:
    for i in range(n):
        if s[i:n] == t[0:n-i]:
            max_ans = max(n-i,max_ans)
    print(max_ans+(n-max_ans)*2)


Measured memory_bytes: 2940
import sys
from collections import defaultdict
from copy import deepcopy

N = int(input())
S = input()

alpha_dict = {}
beta_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
    alpha_dict[chr(c)] = i + 1
    beta_dict[(i + 1)%26] = chr(c)

ans = []
for i in range(len(S)):
    x = S[i]
    num = alpha_dict[x]
    num += N
    num %= 26
    ans.append(beta_dict[num])

print(''.join(ans))

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

vector<string> pro;

map<char,long long int> size;
map<char,map<long long int,long long int>> ary;

void range(char name,int index){
  if(!size.count(name) || size[name]<=index) throw "RANGE";
  return;
}

void assigned(char name,int index){
  range(name,index);
  if(!ary.count(name) || !ary[name].count(index)) throw "ASSIGN";
  return;
}

long long int num(string &s,int& p){
  long long int res=0;
  while(isdigit(s[p])){
    res*=10;
    res+=s[p]-'0';
    p++;
  }
  return res;
}

long long int get_val(string& s,int& p){
  if(isdigit(s[p])){
    return num(s,p);
  }
  assert(isalpha(s[p]));
  char name=s[p];
  p++;
  assert(s[p]=='[');
  p++;
  long long int index=get_val(s,p);
  assert(s[p]==']');
  p++;
  assigned(name,index);
  return ary[name][index];
}

void dec_ass(string &s,int &p){
  assert(isalpha(s[p]));
  char name=s[p];
  p++;
  assert(s[p]=='[');
  p++;
  long long int index=get_val(s,p);
  assert(s[p]==']');
  p++;
  if(p==s.size()){
    //dec
    size[name]=index;
  }else{
    //assign
    assert(s[p]=='=');
    p++;
    long long int val=get_val(s,p);
    range(name,index);
    ary[name][index]=val;
  }
}

int program(){
  for(int i=0;i<pro.size();i++){
    int p=0;
    try{
      dec_ass(pro[i],p);
    }catch(const char* msg){
      return i+1;
    }
  }
  return 0;
}

int main(){
  while(true){
    pro.clear();
    size.clear();
    ary.clear();

    while(true){
      string buf;
      getline(cin,buf);
      if(buf==".") break;
      pro.push_back(buf);
    }
    
    if(pro.size()==0) break;
    cout<<program()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define dfor(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long
#define ull unsigned long long

int main() {
	ll x,y;
	cin>>x>>y;
	ll n1 = x*y , n2 = x+y , n3 = x-y;
	if( n1>=n2 && n1>=n3 )
        printf("%d", n1);
    else if( n2>=n1 && n2>=n3 )
        printf("%d", n2);
    else if( n3>=n1 && n3>=n2 )
        printf("%d", n3);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <map>
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++)
#define reg(i, a, b) for (int i = ((int)(a)); i <= ((int)(b)); i++)
#define irep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (int i = ((int)(b)); i >= ((int)(a)); i--)
typedef long long ll;
typedef pair<ll, ll> mp;
// LLONG_MIN

int main(void) {
  int N, M, P, x, y, z;
  vector<int> v[3010];
  vector<int> c[3010];
  scanf("%d%d%d", &N, &M, &P);
  rep(i, M) {
    scanf("%d%d%d", &x, &y, &z);
    v[x].push_back(y);
    c[x].push_back(z - P);
  }
  ll s1[3010], s2[3010], t;
  reg(i, 1, N) s2[i] = -(1e14 + 10);
  s2[1] = 0;
  reg(cnt, 1, 2 * N) {
    reg(i, 1, N) s1[i] = s2[i];
    reg(i, 1, N) {
      rep(j, v[i].size()) {
        if (s2[v[i][j]] < s1[i] + c[i][j])
          s2[v[i][j]] = s1[i] + c[i][j];
      }
    }
    if (cnt == N - 1)
      t = s2[N];
  }
  if (s2[N] > t) {
    printf("-1\n");
  } else {
    printf("%lld\n", max(0LL, s2[N]));
  }
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cerr << #x << " = " << x << endl;
typedef long long ll;
int main()
{
  string N;
  cin >> N;
  int K = N.size() - 1;
  dump(K);
  bool is_all_nine = true;
  for (int i = 1; i < N.size(); i++)
    if (N[i] != '9')
      is_all_nine = false;
  int h = (N.front() - '0') - 1;
  if (is_all_nine)
    h++;
  int ans = h;
  for (int i = 0; i < K; i++)
    ans += 9;
  cout << ans << endl;
  return 0;
}


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

int main(){
    int i,N,count=0;
    cin >> N;
    int a[N],b[N];
    for(i=0;i<N;i++){
        a[i]=i+1;
    }
    for(i=0;i<N;i++){
        cin >> b[i];
        if(a[i]==b[i]){}else{count++;}
    }
    if(count==2||count==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
  }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
typedef long long lint;
const int N=2e5+5;
int n,m1,m2,ans[N];
std::vector <int> buk[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

class _ufs{
	protected:
		int fa[N];
	public:
		int find_rt(const int x){
			return fa[x]?fa[x]=find_rt(fa[x]):x;
		}
		void link(int x,int y){
			x=find_rt(x),y=find_rt(y);
			if(x!=y) fa[x]=y;
		}
}u1,u2;

void solve(const int r){
	static int cnt[N];
	for(std::vector <int> ::iterator it=buk[r].begin(); it!=buk[r].end(); ++it){
		++cnt[u2.find_rt(*it)];
	}
	for(std::vector <int> ::iterator it=buk[r].begin(); it!=buk[r].end(); ++it){
		ans[*it]=cnt[u2.find_rt(*it)];
	}
	for(std::vector <int> ::iterator it=buk[r].begin(); it!=buk[r].end(); ++it){
		cnt[u2.find_rt(*it)]=0;
	}
}

int main(){
	n=nxi(),m1=nxi(),m2=nxi();
	while(m1--) u1.link(nxi(),nxi());
	while(m2--) u2.link(nxi(),nxi());
	for(int i=1; i<=n; ++i){
		buk[u1.find_rt(i)].push_back(i);
	}
	for(int i=1; i<=n; ++i){
		if(!buk[i].empty()) solve(i);
	}
	for(int i=1; i<=n; ++i){
		printf("%d ",ans[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)


const ll N   =  1000001;
const ll mod = 1e9 + 7;

using namespace std;

ll f[1000001];
  ll power(ll a, ll b)  //a is base, b is exponent
  {
    if(b==0)
      return 1;
    if(b==1)
      return a;
    if(b%2 == 1)
      return (power(a,b-1)*a)%mod;
    ll q = power(a,b/2);
    return (q*q)%mod;
  }
void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n;
  ll a[n];
  for (ll i = 0; i < n; ++i)
  {
  cin>>a[i];
  }
  ans =1;
    for (ll i = 0; i < n; i++) 
    {
       x = a[i];
       for(ll j=2;j*j<=x;j++)
       {
        c=0;
        while(x%j==0)
          {c++;x/=j;}
       f[j] = max(f[j],c);
       }
    if(x>1)f[x] = max(f[x],1LL);
    }
    c=0;
    for (int i = 0; i < N; ++i)
    {
      if(f[i]>0)
        ans = ans*power(i,f[i])%mod; 
    }
    for (int i = 0; i < n; ++i)
    {
       c += ans*power(a[i],mod-2);

       c%=mod;
    }
    c%=mod;
    c(c);

  
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  ll T=1;
  //cin>>T;
  while(T--){
  solve();
  }
  return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
#define ll long long
int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> L(N + 2);
	vector<pair<int, int>> v(N + 2, { 1,1 });
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		cin >> L[i];
		if (i == 1) L[i - 1] = L[i];
		if (i == N) L[N + 1] = L[N];
	}
	for (int i = 2; i <= N;i++) {
		if (L[i] != L[i - 1]) { 
			v[i].first = v[i - 1].first + 1; 
			ans = max(ans, v[i].first);
		}
	}
	for (int i = N - 1; i >= 1; i--) {
		if (L[i] != L[i + 1]) {
			v[i].second = v[i + 1].second + 1;
			ans = max(ans, v[i].second);
		}
	}
	v[0].first = 0; v[N + 1].second = 0;

	int l = 1, r = 1;
	while (true) {
		if (L[r] == L[r + 1]) {
			if ((r - l + 1) % 2 == 1) {
				if (L[l] == L[r]) {
					ans = max(ans, v[l - 1].first + (r - l + 1) + v[r + 1].second);
				}
			}
			else {
				if (L[l] != L[r]) {
					ans = max(ans, v[l - 1].first + (r - l + 1) + v[r + 1].second);
				}
			}
			l = r + 1;
		}
		r++;
		if (r == N) {
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4140
#include <iostream>

using namespace std;

long long n, m, i, a, s;

int main()
{
    cin >> n >> m;
    for(i = 1; i <= m; i++)
    {
        cin >> a;
        s += a;
    }
    if(s > n)
        cout << "-1";
    else
        cout << n - s;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

	    int n=gi();
	    long k=gl();
	    int[] A=new int[n];

        for (int i=0; i<n; i++) {
        	A[i]=gi();
        }

        long ans =0;
        long ans2=0;
        for (int i=0; i<n; i++) {
        	for (int j=i+1; j<n; j++) {
            	if(A[i]>A[j]) {
            		ans++;
            	} else if(A[i]<A[j]) {
            		ans2++;
            	}
            }
        }
        

        long k1 =(k*(k+1)/2)% 1000000007;
        long k2 =(k*(k-1)/2)% 1000000007;
        ans=(ans*k1)% 1000000007;
        ans2=(ans2*k2)% 1000000007;
        ans=(ans+ans2) % 1000000007;


	    System.out.println(ans);
//        if(ans==0) {
//
//		    System.out.println("Yes");
//        } else {
//        	System.out.println("No");
//
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 38928
def to_sorted(s)
  s.split('').sort.join
end
h = {}
n = gets.chomp.to_i
sum = 0
n.times do
  s = to_sorted(gets.chomp)
  h[s] = h.key?(s) ? h[s] + 1 : 1
end
sum = 0
sum = h.values.reduce(0) do |result, item|
  result + ((item > 1) ? (item * (item -1) / 2) : 0)
end
puts sum

Measured memory_bytes: 18940
#include <iostream>
#include <climits>
using namespace std;
typedef long long int ll;
const ll inf = 1000000000000;
ll dp[110][100010];
ll w[110];
ll v[110];

int main(){
    ll n,k;

    scanf("%lld %lld",&n,&k);
    ll sum = 0;
    for(ll i = 1; i <= n; i++){
        scanf("%lld %lld",w+i,v+i);
        sum += v[i];
    }

    for(ll i = 1; i <= sum; i++){
        dp[0][i] = inf;
    }

    for(ll i = 1; i <= n; i++){
        for(ll j = 1; j <= sum; j++){
            dp[i][j] = inf;
            dp[i][j] = dp[i-1][j];
            if(j >= v[i]){
                dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]] + w[i]);
            }
        }
    }

    ll ans = 0;
    for(ll i = 0; i <= sum; i++){
        if(dp[n][i] <= k){
            ans = i;
        }
    }

    printf("%lld\n",ans);


    //printf("%lld\n",dp[n]);
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

ll dp[305][305][305];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];
    reverse(ALL(s));

    ll ret = 0;
    REP(i, w-1) {
        // s[y][i] と s[y][i+1] の間について考える
        vector<vector<ll>> cost(h+1, vector<ll>(h+1));
        REP(j, h+1) {
            ll a = 0, b = j;
            // cost[a][b] を求める
            REP(k, h-j) cost[a][b] += s[a+k][i] == s[b+k][i+1];
            while(a+1<=h && b+1<=h) {
                ++a, ++b;
                cost[a][b] = cost[a-1][b-1] - (s[a-1][i]==s[b-1][i+1]);
            }
        }
        FOR(j, 1, h+1) {
            ll a = j, b = 0;
            REP(k, h-j) cost[a][b] += s[a+k][i] == s[b+k][i+1];
            while(a+1<=h && b+1<=h) {
                ++a, ++b;
                cost[a][b] = cost[a-1][b-1] - (s[a-1][i]==s[b-1][i+1]);
            }
        }
        // dp[a][b] = (左をa段,右をb段沈めたときの最小コスト)
        vector<vector<ll>> dp(h+1, vector<ll>(h+1, LLINF));
        dp[0][0] = 0;
        REP(a, h+1) REP(b, h+1) {
            if(a>=1) chmin(dp[a][b], dp[a-1][b] + cost[a-1][b]);
            if(b>=1) chmin(dp[a][b], dp[a][b-1] + cost[a][b-1]);
        }
        ret += dp[h][h];
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1864
// Problem : 
// 			E - This Message Will Self-Destruct in 5s
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
	int n,num; cin >> n;		
	unordered_map<ll,ll>cnt;
	ll ans = 0;
	
	rep(i,0,n){
		cin >> num;
		ans += cnt[i-num];
		cnt[i+num]++;
	}
	
	cout << ans;
}

int main(){
    IOS;
    solve();
}

Measured memory_bytes: 18556
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <algorithm>
#define N 300005
using namespace std;
typedef long long ll;
int n;
int a[N];
ll ls[N], rs[N];
int main() {
	cin>>n;
	for (int i = 1; i <= 3*n; ++i) {
		cin>>a[i];
	}
	ll ans = 0LL-1000000000000000000LL;
	set<pair<ll, int>> ss;
	ll sum=0LL;
	for (int i = 1; i <= 3*n; ++i) {
		ls[i] = ans;
		rs[i] = -ans;
	}
	for (int i = 1; i <= 3*n; ++i) {
		ss.insert(make_pair(a[i], i));
		sum += (ll)a[i];
		while(ss.size() > n) {
			sum -= (*ss.begin()).first;
			ss.erase(*ss.begin());
		}
		if (ss.size() == n)ls[i] = sum;
	}
	for (int i = 2; i <= 3*n; ++i) {
		ls[i] = max(ls[i], ls[i-1]);
		//cout<<i<<" "<<ls[i]<<endl;
	}
	ss.clear();
	sum = 0LL;
	for (int i = 3*n; i >= 1; --i) {
		ss.insert(make_pair(a[i], i));
		sum += a[i];
		while(ss.size() > n) {
			sum -= (*ss.rbegin()).first;
			ss.erase(*ss.rbegin());
		}
		if (ss.size() == n)rs[i] = sum;
	}
	for (int i = 3*n-1; i >= 1; --i) {
		rs[i] = min(rs[i+1], rs[i]);
		//cout<<i<<" "<<rs[i]<<endl;
	}
	for (int i = 1; i < 3*n; ++i) {
		if (ls[i] > 0LL-1000000000000000000LL && rs[i+1] < 1000000000000000000LL) {
			ans = max(ans, ls[i]-rs[i+1]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int s[n];
    rep(i, n) cin >> s[i];
    sort(s, s + n);

    int ans = 0;
    rep(i, n) ans += s[i];

    if (ans % 10 == 0) {
        rep(i, n) {
            if (s[i] % 10 != 0) {
                ans -= s[i];
                break;
            }
        }
    }

    if (ans % 10 == 0)
        cout << 0 << endl;
    else
        cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int A[] = new int[100];
        int N = sc.nextInt();
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        int flag = 1, t, change = 0;
        while(flag == 1){
            flag = 0;
            for(int j=N-1; j>=1; j--){
                if(A[j] < A[j-1]){
                    t = A[j];
                    A[j] = A[j-1];
                    A[j-1] = t;
                    flag = 1;
                    change++;
                }
            }
        }
        for(int j=0; j<N; j++)  {
            System.out.print(A[j]);
            if(j != N-1) System.out.print(" ");
        }
        System.out.println("\n" + change);
    }
}


Measured memory_bytes: 26404
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

h,w = m()

c = l()

d = l()

s = [list(input()[:-1]) for i in range(h)]

data = [[-1 for j in range(w)]for i in range(h)]

po = [cl.deque([]) for i in range(h*w // 2 + 1)]

now = 0
po[0] = cl.deque([[c[0]-1,c[1]-1]])
d[0] -= 1
d[1] -= 1
dire = [[1,0],[0,1],[-1,0],[0,-1]]

#data[c[0]-1][c[1]-1] = 0

while True:
    if now >= h*w // 2 + 1:
        break
    if len(po[now]) == 0:
        now += 1
        continue
    else:
        popo = po[now].popleft()
        if data[popo[0]][popo[1]] != -1 and data[popo[0]][popo[1]] < now:
            continue
        else:
            data[popo[0]][popo[1]] = now
            for kkk in dire:
                if (popo[0] + kkk[0] >= 0 and popo[0] + kkk[0] < h) and (popo[1] + kkk[1] >= 0 and popo[1] + kkk[1] < w):
                    if s[popo[0] + kkk[0]][popo[1] + kkk[1]] == "#":
                        continue
                    if data[popo[0] + kkk[0]][popo[1] + kkk[1]] == -1 or data[popo[0] + kkk[0]][popo[1] + kkk[1]] > now:
                        data[popo[0] + kkk[0]][popo[1] + kkk[1]] = now
                        po[now].append([popo[0]+ kkk[0],popo[1] + kkk[1]])

            for i in range(5):
                i -= 2
                if i + popo[0] < 0 or i + popo[0] >= h:
                    continue
                for j in range(5):
                    j -= 2
                    if j + popo[1] < 0 or j + popo[1] >= w:
                        continue
                    elif s[popo[0]+ i][popo[1] + j] == ".":
                        if data[popo[0]+ i][popo[1] + j] > now+1 or data[popo[0]+ i][popo[1] + j] == -1:
                            if now + 1 <= h*w // 2:
                                data[popo[0]+ i][popo[1] + j] = now+1
                                po[now+1].append([popo[0]+ i,popo[1] + j])


print(data[d[0]][d[1]])

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

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

    int Q;
    cin >> Q;

    deque<char> deq;
    for (char c : S) deq.push_back(c);

    bool flag = false;
    for (int q=0; q<Q; ++q) {
        int T;
        cin >> T;
        if (T == 1) flag = !flag;
        else {
            int F;
            char C;
            cin >> F >> C;

            --F;
            if (flag) F = 1 - F;

            if (F == 0) deq.push_front(C);
            else deq.push_back(C);
        }
    }

    if (flag) {
        while (!deq.empty()) {
            cout << deq.back();
            deq.pop_back();
        }
    }
    else {
        while (!deq.empty()) {
            cout << deq.front();
            deq.pop_front();
        }
    }
    cout << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+10;
char str[N];
int main() {
    cin >> str;
    for(int i = 0; str[i];  i++) {
        if(i %2 == 0) printf("%c",str[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
const double EPS = 1e-10;
typedef complex<double> P;
typedef pair<P,P> L;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
  }
}
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l.S-l.F, m.S-m.F)) > EPS ||
         abs(cross(l.S-l.F, m.F-l.F)) < EPS;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l.S - l.F, m.S - m.F);
  double B = cross(l.S - l.F, l.S - m.F);
  if (fabs(A) < EPS && fabs(B) < EPS) return m.F;
  return m.F + B / A * (m.S - m.F);
}

int main() {
  int n;
  while(cin >> n && n) {
    vector<L> v(n);
    int ans=1;
    for(int i=0; i<n; i++) {
      double x1,y1,x2,y2;
      cin >> x1 >> y1 >> x2 >> y2;
      v[i]=L(P(x1,y1),P(x2,y2));
      vector<P> p;
      for(int j=0; j<i; j++) {
        if(!intersectLL(v[i],v[j])) continue;
        P q=crosspoint(v[i],v[j]);
        if(q.real()>-100+EPS&&q.real()<100-EPS&&q.imag()>-100+EPS&&q.imag()<100-EPS) p.push_back(q);
      }
      sort(p.begin(),p.end());
      int c=p.size()?1:0;
      for(int j=1; j<p.size(); j++) {
        if(fabs(p[j-1].real()-p[j].real())<EPS&&fabs(p[j-1].imag()-p[j].imag())<EPS) continue;
        c++;
      }
      ans+=c+1;
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;

struct BIT{
private:
  vector<LL> node;
  int n;

public:
  BIT(int sz) : node(sz+1, 0), n(sz){}

  LL sum(int x){
    x++;
    LL ans = 0;
    while(x > 0){
      ans += node[x];
      x -= x & -x;
    }
    return ans;
  }

  void add(int x, LL a){
    x++;
    while(x <= n){
      node[x] += a;
      x += x & -x;
    }
  }
};

struct line{
  double a;
  double b;
  double c;
};

int main(){
  LL n;
  cin >> n;
  vector<line> v(n);
  rep(i, n){
    cin >> v[i].a >> v[i].b >> v[i].c;
  }

  double ansx, ansy;

  sort(all(v),[](const line &l, const line &r){
    return l.a/l.b > r.a/r.b;
  });
  vector<pair<double,int>> p(n);
  double l = -1e10, r = 1e10, mid;
  rep(t, 100){
    mid = (l+r)/2;
    rep(i, n) p[i]={(-v[i].a*mid+v[i].c)/v[i].b,i};
    sort(all(p));
    BIT bt(n);
    LL count = 0;
    rep(i, n){
      int idx = p[i].second;
      count+=bt.sum(idx);
      bt.add(idx, 1);
    }
    if(count < (n*(n-1)/2+1)/2){
      l = mid;
    }else{
      r = mid;
    }
  }
  ansx = l;


  sort(all(v),[](const line &l, const line &r){
    return l.b/l.a > r.b/r.a;
  });
  l = -1e10, r = 1e10, mid;
  rep(t, 100){
    mid = (l+r)/2;
    rep(i, n) p[i]={(-v[i].b*mid+v[i].c)/v[i].a,i};
    sort(all(p));
    BIT bt(n);
    LL count = 0;
    rep(i, n){
      int idx = p[i].second;
      count+=bt.sum(idx);
      bt.add(idx, 1);
    }
    if(count < (n*(n-1)/2+1)/2){
      l = mid;
    }else{
      r = mid;
    }
  }
  ansy = l;



  cout << fixed << setprecision(10) << ansx SP ansy << endl;
  return 0;
}


Measured memory_bytes: 2176
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
# define ll long long
# define int long long  //comment it out when MLE
//# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//# define m 163577857
//# define MOD 163577857
# define pi acos(-1)
# define fi first
# define se second
#define REP(i,n) for (int i = 1; i <= n; i++)
const ll mod = 998244353;
const int K = 2;
//typedef vector<vector<int> > matrix;

int add(int a, int b,int mod) {
    a%=mod;
    b%=mod;
	a += b;
	if (a >= mod) a -= mod;
	if(a<0)
    {
        a += mod;
        a %= mod;
    }
	return a;
}

int mul(ll a, int b,int mod) {
    a%=mod;
    b%=mod;
	a *= b;
	a += mod;
	return a % mod;
}
int po(int a,int b,int mod)
{
    if(b==0)
        return 1;
    if(b%2==0)
        return po(mul(a,a,mod),b/2,mod);
    return mul(a,po(mul(a,a,mod),(b-1)/2,mod),mod);
}


ll fact[1000003];
ll inv[1000003];

void fact0()
{
	int i,j;
	fact[0]=1;
	for(i=1;i<=200000;i++)
	{
		fact[i]=i*fact[i-1]%mod;
	}
	inv[0]=1;
	inv[1]=1;
	ll p=mod;
	for (i=2; i<=200000; i++)
		inv[i] = (p - (p/i) * inv[p%i] % p) % p;

	for(i=2;i<=200000;i++)
	{
		inv[i]*=inv[i-1];
		inv[i]%=mod;
	}
}
int n,s;
int a[3005];
int dp[3004][3003];
int help(int id,int su)
{
    if(id==n || su<=0)
    {
        if(su==0)
        {
            return po(2,n-id,mod);
        }
        return 0;
    }
    if(dp[id][su]!=-1)
        return dp[id][su];
    int an = 2*help(id+1,su) + help(id+1,su-a[id]);
    an %= mod;
    dp[id][su]=an;
    return an;
}
signed main(){
   gok


 memset(dp,-1,sizeof(dp));
 cin>>n>>s;

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

 int an = help(0,s);


cout<<an;














	return 0;
}


Measured memory_bytes: 74328
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))


def binarysearch(key, a, length):
    left = 0
    right = length
    while left < right:
        mid = int((left + right)/2)
        if a[mid] == key:
            return True
        elif key < a[mid]:
            right = mid
        else:
            left = mid+1
    return False


cnt = 0
for i in T:
    if binarysearch(i, S, n):
        cnt += 1
print(cnt)

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

int main() {
  string word;
  stack<int> S;
  while (cin >> word) { // 入力がある限り読み込む
  if (word == "+") {
    int a = S.top();
    S.pop();
    int b = S.top();
    S.pop();
    int n = a + b;
    S.push(n);
  // 数を2つpopして、和をpushする
  }
  else if (word == "-") {
    int a = S.top();
    S.pop();
    int b = S.top();
    int n = b - a;
    S.pop();
    S.push(n);
  // 数を2つpopして、差をpushする
  }
  else if (word == "*") {
    int a = S.top();
    S.pop();
    int b = S.top();
    int n = a * b;
    S.pop();
    S.push(n);
  // 数を2つpopして、積をpushする
  }
  else {
    int n = atoi(word.c_str());
    S.push(n);
  // wordを数値にしてpushする
  }

// Sの先頭要素を表示する。
}
  int ans = S.top();
  cout << ans << endl;
}



Measured memory_bytes: 3212
A,B,K =map(int,input().split())

T =[]

for i in range(A,min(A+K,B+1)):
    T.append(i)
for j in range(max(A+K,B-K+1),B+1):
    T.append(j)
S = map(str,sorted(set(T)))
print('\n'.join(S))

Measured memory_bytes: 3060
N = input()
C5 = 2
C7 = 1
for i in N.split():
  if i == '5':
    C5 -= 1
  elif i == '7':
    C7 -= 1
  else:
    print( 'NO' )
    break
else:
  if C5 == 0 and C7 == 0:
    print( 'YES' )
  else:
    print( 'NO' )

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

int N;

void DFS(int P, int Q, string S) {
	if (P == N) {
		cout << S << endl;
		return;
	}
	for (int i = 0; i <= Q + 1; i++) {
		DFS(P + 1, max(Q, i), S + (char)('a' + i));
	}
}

int main() {
	cin >> N;
	DFS(0, -1, "");
}


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

int main(){
    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = S % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3092
if __name__ == "__main__":
    n, m = map(int, input().split())

    if n > 3 and m > 3:
        ans = (n-2) * (m-2)
    elif n == 1 and m == 1:
        ans = 1
    elif n == 1 and m > 3:
        ans = m - 2
    elif m == 1 and n > 3:
        ans = n - 2
    else:
        ans = 0

    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, k;
int32_t main(){_

   cin>>n>>k;

   cout<<n-k+1;

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 256