akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }


int main(){
    int X, N;
    cin >> X >> N;
    int mi = 101;
    int near;
    vector<bool> p(101, 0);
    rep(i, N){
        int pi;
        cin >> pi;
        p[pi] = 1;
    }
    rep(i, 102){
        if(p[i]==0){
            if(mi > abs(i-X)){
                mi = abs(i-X);
                near = i;
            }
        }
    }
    cout << near << endl;
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,ans=0;
  vector<int> b;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    b.push_back(a);
  }
  sort(b.begin(),b.end());
  for(int i=0;i<n;i++){
    int cnt=0;
    int tmp=b[i];
    if(i==n-1){
      ans++;
      break;
    }
    while(b[i]==b[i+1]){
      i++,cnt++;
      if(i==n-1)break;
    }
    if(cnt%2==0)ans++;
  }
  cout<<ans;
  return 0;
}


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

int main(){
    char ch;
    while (1)
    {
        scanf("%c", &ch);
        if ('a' <= ch && 'z' >= ch)
        {
            printf("%c", ch-32);
        }else if ('A' <= ch && ch <= 'Z')
        {
            printf("%c", ch+32);
        }else
        {
            printf("%c", ch);
        }
        
        if(ch =='\n')break;
    }
    return 0;
}


Measured memory_bytes: 3156
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e17;
const int mod=1e9+7;
const int M=100005;
int n,m;
vector<pi>adj[M];
int d[M];
bool vis[M];
 main()

{
    fast
    cin>>n>>m;
    f(i,1,m)
    {
        int lft,rgt,c;
        cin>>lft>>rgt>>c;
        adj[lft].pb(mp(rgt,c));
        adj[rgt].pb(mp(lft,c));
    }
    f(i,2,n)
    {
       adj[i].pb(mp(i-1,0));
    }
   

    priority_queue<pi,vector<pi>,greater<pi> >pq;
    f(i,1,n)d[i]=inf;
    d[1]=0;
    pq.push(mp(d[1],1));
    while(!pq.empty())
    {
        pi tmp=pq.top();
       // cout<<tmp.fi<<" "<<tmp.si<<endl;
        pq.pop();
        int u=tmp.si;
        int cost=tmp.fi;
        if(vis[u])continue;
        vis[u]=1;
        for(auto x:adj[u])
        {
            int v=x.fi;
            int c=x.si;

            if(d[v]<=c+cost)continue;
            d[v]=c+cost;


            pq.push(mp(d[v],v));
        }
    }
    if(d[n]>=inf)d[n]=-1;
    cout<<d[n]<<endl;
    return 0;
}


Measured memory_bytes: 15784
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] Lz = new int[N];
        for (int i = 0; i < N; i++){
            Lz[i] = sc.nextInt();
        }
        Arrays.sort(Lz);
        int cnt = 0;
        for (int i = 0; i < N; i++){
            for (int j = 0; j < i; j++){
                for (int k = 0; k < j; k++){
//                    System.out.println(i+" "+j+" "+k);
//                    System.out.println(Lz[i]+" "+Lz[j]+" "+Lz[k]);
//                    System.out.println((Lz[i] != Lz[j])+" "+(Lz[j] != Lz[k])+" "+(Lz[j] + Lz[k] > Lz[i]));
                    if ((Lz[i] != Lz[j]) && (Lz[j] != Lz[k]) && (Lz[j] + Lz[k] > Lz[i])){
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 36664
package main

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

func main() {
  var n int
  fmt.Scan(&n)
  
  s := bufio.NewScanner(os.Stdin)
  s.Scan()
  S := strings.Split(s.Text(), " ")
  
  A := 0
  for i := 0; i < n; i++ {
    for j := i + 1; j < n; j++ {
      d1, _ := strconv.Atoi(S[i])
      d2, _ := strconv.Atoi(S[j])
      A += d1 * d2
    }
  }
  fmt.Println(A)
}

Measured memory_bytes: 640
# ABC159_B
s=input()
n=len(s)
# if n==1:
#     print('No')
#     exit()

n=n//2
for i in range(int(n//2)+1):
    if s[i]==s[-1-i]:
        pass
    else:
        print('No')
        exit()
f=''
e=''
f=s[:n]
e=s[-n:]
# print(f,e)
for i in range(int(n//2)+1):
    if f[i]==f[-1-i]:
        pass
    else:
        print('No')
        exit()
    if e[i]==e[-i-1]:
        pass
    else:
        print('No')
        exit()
print('Yes')


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

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    rep(i,n){
        ll t;
        cin >> t;
        ans = lcm(ans,t);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

import random


def main():
    n = int(input().strip())
    S = input().strip()
    cnt=0
    for SS in range(1000):
        SSs=str(SS).zfill(3)
        #eprint("SSs ",end=": ")
        #eprint(SSs)
        a=str(SSs[0])
        b=str(SSs[1])
        c=str(SSs[2])
        success_flag=0
        ii=sys.maxsize
        jj=sys.maxsize
        kk=sys.maxsize
        for i in range(len(S)):
            if S[i]==a:
                ii=min(i,ii)
            if S[i]==b and i>ii:
                jj=min(i,jj)
            if S[i]==c and i>jj:
                kk=min(i,kk)
                success_flag=1
                #eprint("ii,jj,kk ",end=": ")
                #eprint(ii,jj,kk)
            # if SSs=="224":
                #eprint("ii,jj,kk ",end=": ")
                #eprint(ii,jj,kk)
                
            
        if success_flag==1:
            cnt+=1
    print(cnt)
    return

if __name__ == '__main__':
    main()


'''
#+TITLE: math formulation

given n \in N, S \in {S}
(4 <= n == len(S) <= 3*10^4)

defun SS such that
	+ SS \in {String} and
	+ there exist (i,j,k) such that
		(i \in N and j \in N and k \in N)
		and
		(i<j<k<n) and S[i] = SS[0] and S[j] = SS[1] and S[k] = SS[2]
defun x is |{SS}|
find x


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

'''


Measured memory_bytes: 73432
#include <stdio.h>
#include <algorithm>
using namespace std;
const int MAX_HW = 1401;
int dp[MAX_HW][MAX_HW];
int board[MAX_HW][MAX_HW];
int H, W;
int main() {
  scanf("%d %d", &H, &W);
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      scanf("%d", &board[i][j]);
    }
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      dp[i][j] = (board[i][j] + 1) % 2;
    }
  }
  int res = 0;
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (board[i][j] == 0) {
        dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
      }
      res = max(res, dp[i][j]);
    }
  }
  printf("%d\n", res * res);
  return 0;
}

Measured memory_bytes: 16344
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (chunk) {
	var a = chunk.split(' ');
	b = parseInt(a[0],10);
	c = parseInt(a[1],10);
	d = parseInt(a[2],10);
	e = parseInt(a[3],10);
	f = parseInt(a[4],10);
	if(b<d+f || c<e+f || d<0 || e<0)
		console.log("No");
	else
		console.log("Yes");
});

Measured memory_bytes: 15600
/*  
	If they say
    Who cares if one more light goes out?
    In a sky of a million stars
    It flickers, flickers
    Who cares when someone's time runs out?
    If a moment is all we are
    We're quicker, quicker
    Who cares if one more light goes out?
    Well I do
*/

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

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a) / gcd(a,b)) * (b)
#define all(x)  x.begin(),x.end()

#define ll long long
#define ull unsigned long long
#define VI vector<int>
#define VLL vector<ll>
#define VS vector<string>
#define MPII map<int, int>
#define SET set<int>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io   ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);

ll MOD = 1e9+7;

ll add(ll a, ll b){a+=b; a%=MOD;if(a<0) a+=MOD;return a;}
//doesn't work for neg numbers

ll mult(ll a, ll b){if(a>MOD) a%=MOD;if(b>MOD) b%=MOD;ll ans=(a*b)%MOD;if(ans<0) ans+=MOD;return ans;}
//doesn't work for neg numbers

ll pw(ull a, ull b){ll r=1;while(b){if(b&1) r=mult(r,a);a=mult(a,a);b>>=1;}return r;}
//doesn't work for neg numbers

void solve(){
	ll a,b;
	cin>>a>>b;
	ll x,y,cnt=0;
	for(ll i = 0 ; i < a ; i++){
		cin>>x>>y;
		long double ans = (sqrt((x*x) + (y*y)));
		//cout<<ans<<endl;
		if(ans <= (b))cnt++;
	}
	cout<<cnt<<endl;
}

int main(){
/*	#if ONLINE_JUDGE
	  freopen("inputf.in", "r", stdin);
	  freopen("outputf.in", "w", stdout);
	#endif
*/
    fast_io;
    ll t, k=0;
    t=1;
    while(t--){
        //k++;        
        //cout<<"Case "<<k<<": ";
        solve();
    }
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String n = scanner.next();
		
		scanner.close();
		
		String X = null;
		
		if (n.length() == 1) {
			X = n;
		} else if (n.length() == 2) {
			X = n.substring(1,2);
		} else {
			X = n.substring(2,3);
		}
		
		if (X.equals("3")) {
			System.out.println("bon");
		} else if (X.equals("0") || X.equals("1") || X.equals("6") || X.equals("8")) {
			System.out.println("pon");
		} else {
			System.out.println("hon");
		}
	}

}


Measured memory_bytes: 27004
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    // a_iが1のとき、start[b_i]はtrue
    boolean[] start = new boolean[N+1];

    // b_iがNのとき、goal[a_1]はtrue
    boolean[] goal = new boolean[N+1];

    for (int i = 0; i < M; i++) {
      int a_ = sc.nextInt();
      int b_ = sc.nextInt();
      if (a_ == 1) {
        start[b_] = true;
      }
      if (b_ == N) {
        goal[a_] = true;
      }
    }

    sc.close();
    
    String result = "IMPOSSIBLE";

    for (int i = 0; i < N; i++) {
      if (start[i] && goal[i]) {
        result = "POSSIBLE";
        break;
      }
    }

    System.out.println(result);

  }

}


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

xl = (map(int, input().split()) for _ in range(n))
w = [(x - l, x + l) for x, l in xl]
w = sorted(w, key=lambda x: x[1])
cur = w[0][1]
res = 1
for l, r in w[1:]:
    if l >= cur:
        res += 1
        cur = r
print(res)


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

string s, t;
int main() {
  cin >> s >> t;
  
  bool ok = false;
  for (int i = 0; i < s.size(); ++i) {
    string q = s.substr(i) + s.substr(0, i);
    if (q == t) {
      ok = true;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;
 
 
int main()
{
  string S;
  cin>>S;
  bool flag=true;
 
  for(int i=0;i<S.size();i++){
    if(abs(S[i]-S[S.size()-1-i])!=1&&abs(S[i]-S[S.size()-1-i])!=2)
      flag=false;
  }
 
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;  
 
  return 0;
}

Measured memory_bytes: 512
#133_E
import sys
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7
n, k = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
def dfs(frm, cur):
    if frm == -1:
        color_num = k - 1
    else:
        color_num = k - 2
        
    if k < len(edges[cur]):
        return 0
    
    mul = 1
    for to in edges[cur]:
        if to == frm:
            continue
        mul *= color_num
        mul %= mod
        color_num -= 1
        
    for to in edges[cur]:
        if to == frm:
            continue
        mul *= dfs(cur, to)
        mul %= mod
    
    return mul

print(k * dfs(-1, 0) % mod)

Measured memory_bytes: 87340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
    return 0;
}


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

using namespace std;

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
typedef long long ll;
//////////////////////

int const N = 1e5 + 41;
ll const INF = 1e9 * 1LL * 1e9 + 41;

ll a[N];
int n;


void solve(){
	cin >> n;
	fr(i, 0, n) cin >> a[i];
	ll ans = INF;
	ll sum = 0;
	ll pans = 0;
	fr(i, 0, n){
		sum += a[i];
		ll add = 0;
		ll s = (i&1 ? -1 : 1);
		if(i&1){
			add = max(0LL, sum - (-1LL) );
		}else{
			add = max(0LL, (1LL) - sum);
		}
		pans += add;
		sum += add * s;
	}
	ans = min(ans, pans);

	sum = 0;
	pans = 0;
	fr(i, 0, n){
		sum += a[i];
		ll add = 0;
		ll s = (i & 1 ? 1 : -1);
		if(!(i&1)){
			add = max(0LL, sum - (-1LL) );
		}else{
			add = max(0LL, (1LL) - sum);
		}
		pans += add;
		sum += add * s;
	}
	ans = min(ans, pans);

	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 1024
s;n;e;w;i;main(q){char t[1000];for(gets(t);i<strlen(t);i++){q=t[i];if(q==78)n=1;if(q==83)s=1;if(q==69)e=1;if(q==87)w=1;}puts(abs(n-s)+abs(w-e)?"No":"Yes");}

Measured memory_bytes: 1516
#include <iostream>

using namespace std;
int n;
int main()
{
    scanf("%d",&n);
    int x=n;
    int ans=0;
    while(x)
    {
        ans++;
        x/=10;
    }

    if(ans==1)
        printf("%d\n",n);
    else if(ans==2)
        printf("9\n");
    else if(ans==3)
        printf("%d\n",9+n-99);
    else if(ans==4)
        printf("909\n");
    else if(ans==5)
        printf("%d\n",909+n-9999);
    else
        printf("90909\n");
    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 W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
         
        if(x - r >= 0 && y - r >=0){
            if(x + r <= W && y + r <= H){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26392
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d",&n);
  if(n%2==0){
    cout << 0.5 << endl;
  }else{
    double ans = (double)(n/2+1)/(double)n;
    cout << ans << endl;
  }
}





Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{},m{},x{},res{},ans{};
	cin>>n>>m>>x;
	map<int,int>mm;
	For(i,0,m){int a{};cin>>a;mm[a]++;}
	int s=x+1;
	while(s<n)
	{
		if(!mm[s])s++;
		else res++,s++;
	}
	s=x-1;
	while(s>0){
			if(!mm[s])s--;
		else ans++,s--;
	}
	cout<<min(ans,res)<<'\n';
	//system("pause");
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(void){
  char a, b; 
  cin >> a >> b;
  if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
    cout << 'H' << endl;
  }else{
    cout << 'D' << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
 
 int main(){
	 double PI=3.141592653589;
	 double r;
	 cin>>r;
	 printf("%.6f %.6f\n",PI*r*r,2.0*r*PI);
	 
	 return 0;
}	 



Measured memory_bytes: 3188
///exchange arguments to find sorting condition
//order matters
//consider two elemenys
//suppose 1 is always above 2 
//then it means S2>=W1 && S1<W2
//adding bothbof them S2+W2>S1+W1
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
lli N=10000001;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
void solve()
{
	int n;
	cin>>n;
	//cout<<n;

	//vector<pair<lli,pair<lli,lli> > >v;
	vector<pair<int,pair<int,int> > >v;
	for(int i=0;i<n;i++)
	{
		int w,s,val;
		cin>>w>>s>>val;
		//cout<<w;
		v.push_back({s+w,{w,val}});
		//v.push_back(MP(s+w,MP(w,val)));
	}
	sort(all(v));
	//cout<<v[0].ff<<v[0].ss.ff<<v[0].ss.ss<<endl;
	//lli dp[N]={0};
	vector<lli>dp(N,0);
	for(int i=0;i<n;i++)
	{
		int st=v[i].ff;
		int w=v[i].ss.ff;
		int val=v[i].ss.ss;
		//cout<<st<<" "<<w<<" "<<val<<endl;
		for(int j=st-w;j>=0;j--)
		{
			if(j+w<=st)
				dp[j+w]=max(dp[j+w]*1LL,(dp[j]+val)*1LL);

		}
	}

	cout<<*max_element(all(dp))<<endl;
}
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	
	
	solve();
	
	
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int h,n; cin >>h >>n;
  vector<int>a(n),b(n),dp(h+1,INT_MAX); dp[0]=0;
  for(int i=0; i<n; i++) cin >>a[i] >>b[i];
  for(int i=1; i<=h; i++) for(int j=0; j<n; j++)
  dp[i]=min(dp[i],dp[max(i-a[j],0)]+b[j]);
  cout <<dp[h];
}

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

Measured memory_bytes: 3552
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n; cin >> n;
    string s; cin >> s;
    string t; cin >> t;
    
    vector<int> v;
    for(int i = 0; i < n; i++){
        if(s[i] == t[i]) v.push_back(0);
        else{
            v.push_back(1);
            i++;
        }
    }

    int ans = 1;
    if(v[0] == 0) ans = 3;
    else ans = 6;

    for(int i = 1; i < (int)v.size(); i++){
        if(v[i - 1] == 0 && v[i] == 0) ans *= 2;
        else if(v[i - 1] == 0 && v[i] == 1) ans *= 2;
        else if(v[i - 1] == 1 && v[i] == 0) ans *= 1;
        else ans *= 3;
        ans %= MOD;
    }
        
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>
#include<numeric>

using namespace std;

int main()
{
  long long R;
  cin >> R;

  cout << 2*3.141592*R << endl;

  return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  int N;
  int check=0;
  vector<string> w;

  cin >>N;
  for(int i=0;i<N;i++){
    string temp;
    cin>>temp;
    w.push_back(temp);
  }

  char fw,bw;
  bw=w[0].back();
  for(int i=1;i<N;i++){
    if(bw!=w[i].front()){check=1;break;}
    for(int j=0;j<i;j++){
      if(w[i]==w[j]){check=1;break;}
    }
    if(i<(N-1)) bw=w[i].back();
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<set>
#include<string>
#include<sstream>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll c){
    ll ans = 1;
    a %= c;
    while (b){
        if (b & 1) ans = (ans * a) % c;
        a = (a * a) % c;
        b >>= 1;
    }
    return (ans % c);
}

ll Pow(ll a, ll b){
    ll ans = 1;
    while (b){
        if (b & 1) ans *= a;
        a *= a;
        b >>= 1;
    }
    return ans;
}

int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b){
    return a * 1ll / gcd(a, b) * b;
}

int main(){
    int a, b;
    scanf("%d%d", &a, &b);
    if ((a + b) & 1) printf("IMPOSSIBLE\n");
    else printf("%d", (a + b) / 2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  double t,a;
  cin >> n >> t >> a;
 
  double h[n];
 
  for (int i = 0 ; i < n ; i ++)
    {
      cin >> h[i];
    }
 
  for (int i = 0 ; i < n ; i ++)
    {
      h[i] = t - h[i]*0.006;
    }
  
  int ans = 1;
  double delta = 1000000;
 
  for (int i = 0 ; i < n ; i ++)
    {
      if(abs(a-h[i]) <= delta){
	delta = abs(a-h[i]);
	ans = i+1;
      }
    }
 
  cout << ans <<  endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
    int n, c, k, result = 0;
    cin >> n >> c >> k;
    int t[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }
    sort(t, t + n);
    for (int i = 0, depart = -1, count = 0; i < n; i++) {
        if (t[i] > depart || count == c) {
            depart = t[i] + k;
            count = 1;
            result++;
        } else {
            count++;
        }
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 640
m = int(input())
dc=[list(map(int, input().split())) for i in range(m)]
b = [[(1,0)]]
f = []
ans = 0
now = 0
for i in range(1,10):
  mini_b = []
  c = i
  d = 0
  c += i
  d += 1
  while (c // 10):
    c = c % 10 + 1
    d += 1
  mini_b.append((d,c))
  while c != i:  
    c += i
    d += 1
    while (c // 10):
      c = c % 10 + 1
      d += 1
    mini_b.append((d,c))
  b.append(mini_b)
for d,c in dc:
  if d:
    if c > 1:
      x,y = divmod(c-1,len(b[d]))
      if y == 0:
        ans +=  b[d][-1][0] * x
        f.append(d)
      else:
        ans +=  b[d][-1][0] * x + b[d][y-1][0]
        f.append(b[d][y-1][1])
    else:
      f.append(d)
  else:
    ans += c-1
    f.append(0)
for i in f:
  now += i
  ans += 1
  while (now//10):
    now = now % 10 + 1
    ans += 1
  
print(ans-1)

Measured memory_bytes: 87512
##templete

require "prime"


def gcd(a,b)
  if b>a
     gcd(b,a)
  end

  if a%b == 0
    return b
  end
r = a%b

 return gcd(b,r)
end

a, b = gets.chomp.split(" ").map{|e| e.to_i}

g = gcd(a, b)

pr = Prime.prime_division(g)


ans = pr.length + 1

puts ans


Measured memory_bytes: 2172
while True:
    W, H = map(int, input().split())
    if W == 0 and H == 0:
        break
    else:
        for j in range(W):
            for i in range(H):
                if (i + j) % 2 == 0 :
                    print('#', end='')
                else:
                    print('.', end='')
            print()
        print()



Measured memory_bytes: 7008
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();

        TreeSet<Integer>[] idx = new TreeSet[26];
        for (int i = 0; i < 26; i++) {
            idx[i] = new TreeSet<>();
        }

        boolean exist[] = new boolean[26];
        for (int i = 0; i < S.length(); i++) {
            int pos = S.charAt(i) - 'a';
            idx[pos].add(i);
            exist[pos] = true;
        }

        long ans = 0;
        int pos = -1;

        int tidx = 0;
        for (;tidx < T.length();) {
            int t = T.charAt(tidx) - 'a';
            if (!exist[t]) {
                System.out.println(-1);
                return;
            }
            Integer npos = idx[t].higher(pos);
            if (npos == null) {
                ans += (S.length() - 1) - pos; // go to $
                pos = -1;
            } else {
                ans += npos - pos;
                pos = npos;
                tidx++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 34276
#include<bits/stdc++.h>
#define int long long
const int inf=8938103643641919514ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int a,b,c,d;
int p[15],q[15];
signed main(){
	int i,j,k;
	cin>>a>>b;
	for(i=0;i<a;i++)
		cin>>q[i];
	int ans=inf;
	for(i=0;i<(1ll<<a);i++){
		copy(q,q+15,p);
		if(__builtin_popcount(i)<b)
			continue;
		int u=0,v=0;
		for(j=0;j<a;j++){
			if(i&(1ll<<j)){
				if(u>=p[j]){
					v+=u+1-p[j];
					p[j]=u+1;
				}
			}
			if(u<p[j])
				u=p[j];
		}
		if(ans>v)
			ans=v;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    r = 0
    for i1 in range(1, n + 1,2):
        cnt = 0
        for i2 in range(1,i1+1):
            cnt += i1 % i2 == 0
        r += cnt == 8
    print(r)

if __name__ == '__main__':
    main()


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

unsigned GetDigit(unsigned num){
    return log10(num)+1;
}

int main()
{
    long long int n,root,div,maxnumber,keep;
    cin >> n;
    root = (int)sqrt(n);
    keep = 11;

    for (int i = 1; i <= root; i++)
    {
        div = n / i;
        if (n % i == 0)
        {
            maxnumber = max(GetDigit(i),GetDigit(div));
            keep = min(keep,maxnumber);
        }
    }
    cout << keep << endl;
}   

Measured memory_bytes: 3888
#include <iostream>
#include <math.h>

int main (){
  int N;
  scanf("%d", &N);
	int a[N], b[N], c[N];
  for (int i=0; i<N; i++){
    scanf("%d", &a[i]);
  }
	int ans = 0;
  for (int i=0; i<N; i++){
    scanf("%d", &b[i]);
		ans += b[i];
  }
  for (int i=0; i<N-1; i++){
    scanf("%d", &c[i]);
  }
	for (int i=0; i<N-1; i++){
		if (a[i]+1 == a[i+1]){
			ans += c[a[i]-1];
		}
	}

  printf("%d\n", ans);
  return 0;
}

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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;
using Si = set<int>;
using vSi = vector<Si>;
using vvSi = vector<vSi>;

#define fi first
#define se second
#define INF 1e9 + 5
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int n;
	while(cin >> n) {
		double ans = 0.0;
		for (int i = 0; i < n; ++i) {
			double d;
			cin >> d;
			ans += 1.0/d;
		}
		cout << 1.0/ans << '\n';
	}
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var s = CRL();
        var k = CRL().ToInt();

        var target = s[k - 1];
        for (int i = 0; i < n; i++)
        {
            Console.Write(s[i] == target ? target : '*');
        }
        CWL("");
    }
}

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();

    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();

    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);

    //テンプレここまで
}

Measured memory_bytes: 13268
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    String a = s.next();

    if(a.contains("A")){
      System.out.println("T");
    }else if(a.contains("T")){
      System.out.println("A");
    }else if(a.contains("C")){
      System.out.println("G");
    }else if(a.contains("G")){
      System.out.println("C");
    }
  }
}


Measured memory_bytes: 21716
mod1,mod2=10**9+7,998244353
mod=mod1
dp=[0]*13
dp[0]=1
for i in input():
    if i=="?":
        dp=[sum(dp[4*(j-k)%13]for k in range(10))%mod for j in range(13)]
    else:
        x=int(i)
        dp=[dp[4*(j-x)%13]for j in range(13)]
    
    #print(dp)
print(dp[5])

Measured memory_bytes: 9204
import collections
N = int(input().strip())
Adj = []
for u in range(N):
    Adju = [0 for _ in range(N)]
    Adjlst = collections.deque(list(map(int,input().strip().split(" "))))
    Adjlst.popleft()
    K = Adjlst.popleft()
    for k in range(K):
        v = Adjlst.popleft()
        Adju[v-1] = 1
    Adj.append(Adju)
for i in range(N):
    for j in range(N-1):
        print(Adj[i][j],"",end="")
    print(Adj[i][N-1])


Measured memory_bytes: 7480
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

struct Edge {
  int v, w;
};

bool solve() {
  int n;
  if (scanf("%d", &n) != 1) { return false; }
  vector <vector<Edge>> ed(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    ed[u].push_back(Edge({v, w}));
    ed[v].push_back(Edge({u, w}));
    dbg("%d %d %d\n", u, v, w);
  }

  vector <int> xor_sum(n, 0);
  for (int i = 0; i < n; ++i) {
    for (auto & e : ed[i]) {
      xor_sum[i] ^= e.w;
    }
  }
  vector <int> cnt(16, 0);
  for (int i = 0; i < n; ++i) {
    if (xor_sum[i]) {
      cnt[xor_sum[i]] += 1;
    }
  }
  int mask = 0;
  int ans = 0;
  for (int i = 0; i < 16; ++i) {
    dbg("cnt[%d] = %d\n", i, cnt[i]);
    ans += cnt[i] / 2;
    cnt[i] %= 2;
    mask |= (cnt[i] << i);
  }
  vector <int> dp(1 << 16, -1);
  vector <int> q[3];
  q[0].push_back(mask);
  dp[mask] = 0;
  int cntQ = 1;
  while (cntQ) {
    while (q[0].empty()) {
      q[0].swap(q[1]);
      q[1].swap(q[2]);
    }

    --cntQ;
    int v = q[0].back();
    q[0].pop_back();
    dbg("dp[%d] = %d\n", v, dp[v]);
    
    for (int j = 0; j < 16; ++j) {
      if (!(v & (1 << j))) { continue; }
      for (int k = 0; k < 16; ++k) {
        if (!(v & (1 << k)) || j == k) { continue; }

        int u = v ^ (1 << j) ^ (1 << k) ^ (1 << (k ^ j));
        int d = 1;
        if (v & (1 << (j ^ k))) {
          d += 1;
        }
        if (dp[u] == -1 || dp[u] > dp[v] + d) {
          dp[u] = dp[v] + d;
          q[d].push_back(u);
          ++cntQ;
        }
      }
    }
  }
  dbg("ans %d dp[%d^0] = %d\n", ans, mask, dp[0]);
  printf("%d\n", ans + dp[0]);
  return true;
}

int main() {
  while (solve());
  return 0;
}

Measured memory_bytes: 7156
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, sta, n) for (int i = sta; i < (n); ++i)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const int mod = 1000000007;

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

    priority_queue<ll> p;
    rep(i, n) p.push(a[i]);

    ll ans = 0;
    while(m > 0) {
        ll tmp = p.top();
        tmp /= 2;
        --m;
        p.pop();
        p.push(tmp);
    }
    while(!p.empty()) {
        ll tmp = p.top();
        ans += tmp;
        p.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
#include<cstdio>
#define MAX(x,y) ((x>y)? x:y)
#define MIN(x,y) ((x>y)? y:x)

 double max=0.0,min=0.0;

int main()
{
	double n;
	while(scanf("%lf",&n)!=EOF)
	{
		if(max==0.0&&min==0.0)
		{
			max=n;
			min=n;
		}
		max=MAX(max,n);
		min=MIN(min,n);
	}
	printf("%lf",max-min);
	return 0;
}

Measured memory_bytes: 0
while line = gets do
  n = line.chomp.to_i
  if n==0
    break
  end
  s = gets.chomp.split(" ").map{|x| x.to_f}
  m = s.inject(:+) / n
  sum = 0
  for i in 1..n do
    sum += (s[i-1]-m)**2
  end
  a = (sum/n)**0.5
  printf("%f\n",a)
end


Measured memory_bytes: 6980
#include <iostream>

using namespace std ;

int main()
{
    int s ;
    int a[100000] ;
    while(cin >> s)
    {
        a[0] = s ;
        int c = 0,ans = 0 ;

        for(int i = 0;i < 100000;i++)
        {
            if(a[i]%2 == 0)
            {
                a[i+1] = a[i]/2 ;
                c++ ;
            }
            else
            {
                a[i+1] = ((a[i]*3)+1) ;
                c++ ;
            }

            for(int j = 0;j < c;j++)
            {
                if(a[c] == a[j])
                {
                    ans++ ;
                    break ;
                }
            }

            if(ans == 1)
            {
                cout << c+1 ;
                break ;
            }
        }
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
neighbor = 1
nei = []
for i in range(1,n):
    if a[i] == a[i-1]:
        neighbor+=1
    else:
        if neighbor >1:
            nei.append(neighbor)
            neighbor = 1
if neighbor >1:
    nei.append(neighbor)
ans = 0
for x in nei:
    ans += x//2 
    
print(ans)

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

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> A(1000005, vector<int>(0));
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    A[a].push_back(b);
  }
  for (int i = 0; i < m + 1; i++) {
    if (A[i].size() != 0) {
      sort(A[i].begin(), A[i].end());
    }
  }
  
  ll mo = 0;
  priority_queue<int> q;
  for (int i = 1; i < m + 1; i++) {
    for (int x : A[i]) {
      q.push(x);
    }
    if (!q.empty()) {
      mo += q.top();
      q.pop();
    }
  }
  printf("%lld\n", mo);
}

Measured memory_bytes: 26752
program snack
    implicit none
    integer(8):: a, b
    integer(8):: gcd

    read*, a, b
    gcd = calc_gcd(a,b)
    print*, a*b/gcd
contains
recursive function calc_gcd(x,y) result(ret)
    integer(8):: x, y, ret

    if (mod(x,y) == 0) then
        ret = y
    else
        ret = calc_gcd(y,mod(x,y))
    end if

end function
end program snack

Measured memory_bytes: 512
#include<stdio.h>

int main(void){
	int a,b,c,i,j;
	i=0;
	while(scanf("%d %d",&a,&b)!=EOF&&i<200){
		c=a+b;
		j=0;
		while(c>0){
			c/=10;
			j++;
		}
		printf("%d\n",j);
		i++;
	}
	return 0;
}

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

int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(a-c) <= d) cout << "Yes" << endl;
    else if (abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  int N,i;
  double a,s=0;
  cin >> N;
  for(i=0; i<N; i++) {
    cin >> a;
    s += 1.0/a;
  }
  cout << setprecision(16) << 1.0/s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a>b){
		swap(a,b);
	}
	if(a>c){
		swap(a,c);
	}
	if(b>c){
		swap(b,c);
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,as,bs;
cin>>a>>b;
a-=1;
if (a%4==0) as=a;
if (a%4==3) as=0;
if (a%4==1) as=1;
if (a%4==2) as=a+1;
if (b%4==0) bs=b;
if (b%4==3) bs=0;
if (b%4==1) bs=1;
if (b%4==2) bs=b+1;
long long print=bs^as;
cout<<print<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>


using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    vector<li> xs(n), ys(n);
    priority_queue<pair<li, li>> qx;
    priority_queue<pair<li, li>> qy;
    for (int i = 0; i < n; ++i) {
        cin >> xs[i] >> ys[i];
        qy.emplace(ys[i], i);
    }

    li sum = accumulate(xs.begin(), xs.end(), 0LL);

    bool ok = true;
    for (int i = 0; i < n; ++i) {
        while (not qy.empty() && qy.top().first >= sum) {
            li idx = qy.top().second; qy.pop();
            qx.emplace(xs[idx], idx);
        }
        if (qx.empty()) {
            ok = false;
            break;
        } else {
            sum -= qx.top().first;
            qx.pop();
        }
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 12908
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll n;
  cin >> n;

  multimap<ld, ll> par;
  for (ll i = 1; i <= n; i++) {
    ld x;
    cin >> x;
    par.insert({x, 1});
  }

  while (par.size() > 1) {
    ld first1 = par.begin()->first;
    par.erase(par.begin());
    ld second1 = par.begin()->first;
    par.erase(par.begin());

    par.insert({(first1 + second1) / 2, 1});
  }

  cout << fixed << setprecision(10) << (par.begin()->first) << en;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

#include <vector>
#include <functional>

template <class Monoid> class SegmentTree {
  private:
    using F = std::function<Monoid(Monoid, Monoid)>;

    int sz;
    std::vector<Monoid> seg;

    const F f;
    const Monoid M1;

  public:
    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
      sz = 1;
      while(sz < n) sz *= 2;
      seg.assign(2 * sz, M1);
    }

    void update(int k, const Monoid &x) {
      k += sz - 1;
      seg[k] = x;
      while(k > 0) {
        k = (k - 1) / 2;
        seg[k] = f(seg[2 * k + 1], seg[2 * k + 2]);
      }
    }

    void add(int k, const Monoid &x) {
      k += sz - 1;
      seg[k] += x;
      while(k > 0) {
        k = (k - 1) / 2;
        seg[k] = f(seg[2 * k + 1], seg[2 * k + 2]);
      }
    }

    Monoid query(int a, int b, int k = 0, int l = 0, int r = -1) {
      if(r == -1) r = sz;

      if(b <= l || r <= a) return M1;
      if(a <= l && r <= b) return seg[k];
      Monoid vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      Monoid vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return f(vl, vr);
    }
};

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

  int n, m;
  string s;
  cin >> n >> m >> s;

  SegmentTree<pi> seg(n + 1, [](pi a, pi b){ return min(a, b); }, {INF, INF});
  seg.update(0, {0, 0});
  vt<int> log(n + 1, -1);
  rep(i, 1, n + 1) {
    if(s[i] == '1') continue;

    auto Min = seg.query(max(0, i - m), i);
    if(Min.first == INF) continue;
    seg.update(i, {Min.first + 1, i});
    log[i] = Min.second;
  }

  if(seg.query(n, n + 1).first == INF) return cout << -1 << endl, 0;

  int pos = n;
  vt<int> ans(seg.query(n, n + 1).first);
  for(int i = ans.size() - 1; i >= 0; --i) {
    ans[i] = pos - log[pos];
    pos = log[pos];
  }
  rep(i, 0, ans.size()) cout << ans[i] << " \n"[i + 1 == ans.size()];
}

Measured memory_bytes: 3536
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

struct Edge
{
	int s, t, cost;
	Edge(int s, int t, int cost) :s(s), t(t), cost(cost) {}
	Edge() :Edge(-1, -1, -1) {}
};

vector<Edge> G[110];
int d[110];
int pre[110];
int V, E;
map<pii, bool> bmap;

void shortest_path(int s)
{
	rep(i, 0, V)
	{
		d[i] = INF;
		pre[i] = INF;
	}
	d[s] = 0;

	priority_queue<pii, vector<pii>, greater<pii>> pq;
	pq.push(mp(0, s));

	while (!pq.empty())
	{
		pii p = pq.top(); pq.pop();
		if (d[p.second] < p.first)
		{
			continue;
		}
		if (pre[p.second] != INF)
		{
			bmap[mp(min(p.second, pre[p.second]), max(p.second, pre[p.second]))] = true;
		}
		for (auto& e : G[p.second])
		{
			if (d[e.t] > d[e.s] + e.cost)
			{
				d[e.t] = d[e.s] + e.cost;
				pre[e.t] = e.s;
				pq.push(mp(d[e.t], e.t));
			}
		}
	}
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> V >> E;
	int a, b, c;
	rep(i, 0, E)
	{
		cin >> a >> b >> c;
		a--, b--;
		bmap[mp(min(a, b), max(a, b))] = false;
		G[a].push_back(Edge(a, b, c));
		G[b].push_back(Edge(b, a, c));
	}

	rep(i, 0, V)
	{
		shortest_path(i);
	}

	int ans = 0;
	for (auto p : bmap)
	{
		if (!p.second)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384