akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

	int n,k;
	cin >> n >> k;
	vi a(n);
	rep(i,n){
		cin >> a[i];
	}
	
	int cnt = 1;
	n -=  k;
	if(n==0){cout << cnt << endl; return 0;}
	cnt += (n+k-2)/(k-1);
	cout << cnt << endl;  

	return 0;

}


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

#define PI 3.1415 
  
int main(){
	
	float radius;
	float circum;
	
	scanf("%f",&radius);
	
	circum =(2 * PI * radius);
	
	
	printf("%f",circum);
	
	
	return 0;
	
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
const ld TAU=2*acos(-1);
const ld eps=1e-7;
const int inf=1e9+99;
const ll linf=1e18+88;
const int P=1e9+7;




int32_t main() {
	ll Z=1;
	int n; scanf("%d",&n);
	int ct=0;
	for(;n--;) {
		int x; scanf("%d",&x);
		++ct;
		if(x<=ct*2-2) Z=Z*ct%P, --ct;
		// cerr<<"got "<<x<<" curans "<<Z<<" and ct "<<ct<<endl;
	}
	for(;ct;) Z=Z*ct--%P;
	cout<<Z<<endl;
}




Measured memory_bytes: 256
# coding: utf-8

n = int(input())    # 2 <= n <= 10^5
h = list(map(int, input().rstrip().split()))
dp = [0]
for i in range(1, n):
    dp.append(min( \
        dp[i - 1] + abs(h[i - 1] - h[i]), \
        float('inf') if i < 2 else dp[i - 2] + abs(h[i - 2] - h[i])))
print(dp[- 1])

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

int main()
{
  string s;
  cin >> s;
  string a, b;
  a = s.substr(0, 2);
  b = s.substr(2, 4);
  int x, y;
  x = stoi(a);
  y = stoi(b);

  if (x > 12)
  {
    if (y > 12 || y == 0)
    {
      cout << "NA" << endl;
      return 0;
    }
    cout << "YYMM" << endl;
    return 0;
  }
  else
  {
    if (x == 0)
    {
      if (y > 12 || y == 0)
      {
        cout << "NA" << endl;
        return 0;
      }

      cout << "YYMM" << endl;
      return 0;
    }

    if (y > 12 || y == 0)
    {
      cout << "MMYY" << endl;
      return 0;
    }
    if (y <= 12 && y > 0)
    {
      cout << "AMBIGUOUS" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3624
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
    public static long mod = (long) (1e9+7);
	public static void main(String[] args) {
		
		FastReader sc = new FastReader();
	   int n = sc.nextInt();
	   int a = sc.nextInt();
	   int b = sc.nextInt();
	   out.println(Math.min(n*a, b));
		out.close();
		
	}
	
}

Measured memory_bytes: 22612
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main() {
	double r;

	cin >> r;
	cout << fixed << setprecision(6) << r * r * M_PI << " " << 2 * r * M_PI << endl;

	return 0;
}


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

int linearSearch(int A[], int n, int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main(){
    int n;
    cin >> n;
    int A[10001];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    
    int q = 0;
    cin >> q;
    int key;
    int count = 0;
    for(int i = 0; i < q; i++){
        cin >>key;
        if (linearSearch(A, n, key)) count++;
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3128
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
dict={}
N.times do
  cmd=get
  if cmd[0]=="insert"
      dict[cmd[1]]=1
  else
      puts yn_judge(dict[cmd[1]]!=nil,"yes","no")
  end
end


Measured memory_bytes: 44532
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    ll pow2 = 1;
    ll sum = 0;
    ll mod = 7LL + 1e9;
    rep(_i, 61) {
        ll one = 0, zero = 0;
        rep(i, n) {
            ll v = A[i] % 2;
            if (v == 1) one++;
            else zero++;
            A[i] /= 2;
        }

        sum += (one * zero % mod) * pow2 % mod;
        sum %= mod;

        pow2 *= 2;
        pow2 %= mod;
    }

    put(sum);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 5556
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	ps := scanInts(n)

	var cnt int
	m := ps[0]
	for _, p := range ps {
		if p <= m {
			cnt++
		}
		m = min(m, p)
	}

	fmt.Println(cnt)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 3584
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#include <float.h>
#include <iomanip>
#define mod 1000000007
using namespace std; 
const double pi = acos(-1);

int main(){
	double a,b,h,m; cin >> a >> b >> h >> m;
	double d=m/60*2*pi;
	double f=(60*h+m)/720*2*pi;
	double j=fabs(f-d);
	cout << setprecision(100) << sqrt(a*a+b*b-2*a*b*cos(j)) << "\n";
}




Measured memory_bytes: 4208
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;
typedef pair<int,int> P;

string ans;

void ps(int n,char a){
    for(int i=0;i<n;i++) ans+=a;
    return;
}

int sumd(int n){
    int res=0;
    while(n>0){
        res=n%10;
        n/=10;
    }
    return res;
}

int F(ll a,ll b){
    string s,t;
    s=to_string(a);
    t=to_string(b);
    return max(s.size(),t.size());
}

double dis(int x1,int y1,int x2,int y2){
    int s=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    return pow(s,0.5);
}
int main(){
    int k,s;cin>>k>>s;
    int ans=0;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(0<=z&&z<=k) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}    

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;


int big=-1,small=-1,bign=0,smalln=0;

int main(){
    
    int big=-1,small=-1,bign=0,smalln=0;

    int n;scanf("%d",&n);
    bool flag=true;
    for(int i=1;i<=n;i++){
        int a;scanf("%d",&a);
        if(big==-1){
            big=a;
            bign++;
        }else if(big==a){
            bign++;
        }else if(small==-1){
            small=a;
            smalln++;
        }else if(small==a){
            smalln++;
        }else{
            flag=false;
        }
    }
    if(big<small){
        int s=big,sn=bign;
        big=small;small=s;
        bign=smalln;smalln=sn;
    }
    if(flag==false)printf("No");
    else{
        if(small==-1){
            if(n/big>=2||n==big+1)printf("Yes");
            else printf("No");
        }else if(big==small+1){
            n=n-smalln;
            big=big-smalln;
            if(big<=0)printf("No");
            else if(n>=2*big)printf("Yes");
            else printf("No");
        }else{
            printf("No");
        }
        
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define pll pair<long long,long long>
using namespace std;
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y;
    cin>>x>>y;
    if(y>=x*2&&y<=x*4&&y%2==0)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll a, b, k;
  cin >> a >> b >> k;

  ll cnt = 0;
  for(int i = 100; i >= 1; i--){
    if(a % i == 0 && b % i == 0){
      cnt++;
      if(cnt == k){
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n,a;
    int Max;
    int Min;
    while(cin>>n)
    {
        Min=1000000010;
        Max=0;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            Min=min(a,Min);
            Max=max(a,Max);
        }
        cout<<Max-Min<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from math import floor, ceil


if __name__ == "__main__":
    n = int(input())

    ans = n * 100 / 108

    if ceil(ans) * 108 // 100 == n:
        print(ceil(ans))
    elif floor(ans) * 108 // 100 == n:
        print(floor(ans))
    else:
        print(':(')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<ll,ll>
#define mp make_pair
using namespace std;
int n,m;
string s;
/// Segment Tree
const int max_node = 10000000;
ii tree[max_node];

int fa[200005];
void update(int node , int start , int _end , int idx , int val)
{
    if(start == _end)
    {
        tree[node] = mp(val,start);
    }
    else
    {
        int mid = (start+_end)/2;
        if(start <= idx && idx <= mid)
        {
            update(node*2,start,mid,idx,val);
        }
        else
        {
            update(node*2+1,mid+1,_end,idx,val);
        }
        tree[node] = min(tree[2*node],tree[2*node+1]);
    }
 }

ii query(int node , int start , int _end, int l , int r)
{
    if(r < start || l > _end)
    {
        return mp(1e9,-1);
    }
    if(l <= start && _end<= r)
    {
        return tree[node];
    }
    int mid = (start+_end)/2;
    ii x1 = query(2*node  ,start , mid , l , r);
    ii x2 = query(2*node+1,mid+1 ,_end , l , r);
    return min(x1,x2);
}
int main()
{
    cin>>n>>m;
    n = n+1;
    cin>>s;
    s = 'Z'+s;
    for(int i=1;i<=n;i++)
    {
        update(1,1,n,i,1e9);
    }
    if(s[n] == '0')
        update(1,1,n,n,0);
    for(int i=n-1;i>=1;i--)
    {
        ii q = query(1,1,n,i+1,i+m);
        if(s[i] == '1')
        {
            q.fr = 1e9;
        }
        update(1,1,n,i,q.fr+1);
        fa[i] = q.sc;

    }
    ii ans = query(1,1,n,1,1);
    if(ans.fr > n)
        {
            cout<<-1<<endl;
        }
    else
    {
      int id = 1;
      while(id < n)
      {
          int r = fa[id];
          int len = fa[id]-id;
          id = fa[id];
          cout<<len<< " ";
      }
    }
    return 0;
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pll >
#define all(x) x.begin(), x.end()
#define M vector<VI >

const int N = 202020;

using namespace std;

ll n, ans;
VI g[N];

int main(){

	cin >> n;
	for(int i=1; i<n; i++){
		int u, v;
		cin >> u >> v;
		if(u>v) swap(u, v);
		g[u].pb(v);
	}

	for(ll x=1; x<=n; x++){
		ans += (n-x+1LL)*x;
	}

	for(ll i=1; i<=n; i++){
		for(ll j : g[i]){
			ans -= i*(n-j+1LL);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 14552
/*
h s, d't skp th si tll i's svedclTabCtrl
 * ABC141 E
 * ABC145 D
 * ABC147 F
 * ABC174 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll n,k;
cin>>n>>k;
ll p[n];
ll c[n];
for(ll i=0;i<n;i++)
{
cin>>p[i];
}
for(ll i=0;i<n;i++)
{
cin>>c[i];
}
vector< vector<ll> > vc;
vector<set<ll> > st;
map<ll,ll> mp;
bool ok[n+1]={};
for(ll i=0;i<n;i++)
{
if(!ok[p[i]])
{
ll sm=0;
ll j=p[i];
vector<ll> arr;
set<ll> stt;
ll cnt=1;
arr.push_back(0);
ll ps=i;
while(!ok[j])
{
sm+=c[ps];
arr.push_back(sm);
stt.insert(j);
mp[j]=cnt;
cnt++;
ok[j]=1;
ps=j-1;
j=p[j-1];
}
vc.push_back(arr);
st.push_back(stt);
}
}
ll res=-1e19;
ll u=k;
for(ll i=1;i<=n;i++)
{
for(ll o=0;o<st.size();o++)
{
k=u;
if(st[o].count(i))
{
ll pp=mp[i];
ll ans=-1e19;
if(k>=vc[o].size()-pp)
{
for(ll j=pp;j<vc[o].size();j++)
{
ans=max(ans,vc[o][j]-vc[o][pp-1]);
}
ll kk=vc[o][vc[o].size()-1]-vc[o][pp-1];
ll ff=k-(vc[o].size()-pp);
for(ll j=1;j<=min((ll)vc[o].size()-1,ff);j++)
{
ans=max(ans,kk+vc[o][j]);
}
ll gg=0;
gg+=vc[o][vc[o].size()-1]-vc[o][pp-1];
k-=(vc[o].size()-pp);
ll f=k/(vc[o].size()-1);
gg+=vc[o][vc[o].size()-1]*f;
k%=(vc[o].size()-1);
ll nn=-1e18;
for(ll w=1;w<=k;w++)
{
nn=max(nn,vc[o][w]);
}
if(nn!=-1e18)
{
gg+=nn;
}
ans=max(ans,gg);




k=u;
gg=0;
gg+=vc[o][vc[o].size()-1]-vc[o][pp-1];
k-=(vc[o].size()-pp);
f=k/(vc[o].size()-1);
f--;
if(f>=0)
{
gg+=vc[o][vc[o].size()-1]*f;
nn=-1e18;
for(ll w=1;w<=vc[o].size()-1;w++)
{
nn=max(nn,vc[o][w]);
}
if(nn!=-1e18)
{
gg+=nn;
}
ans=max(ans,gg);
}


k=u;

}
else
{
for(ll j=pp;j<pp+k;j++)
{
ans=max(ans,vc[o][j]-vc[o][pp-1]);
}
}
res=max(res,ans);
break;
}
}
}

cout<<res<<endl;
}

/*
 *||||

 */


Measured memory_bytes: 4552
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    if A[i] > B[i]:
        A[i] -= B[i]
        ans += B[i]
    else:
        B[i] -= A[i]
        ans += A[i]
        A[i] = 0
        tmp = max(A[i+1]-B[i], 0)
        ans += A[i+1] - tmp
        A[i+1] = tmp
print(ans)

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

int main() {
  // 入力
  int N;
  cin >> N;

  int sum = 0;
  int i;
  for (i = 1; i <= N; i++) {
    sum += i;
    if (sum >= N) break;
  }

  // 解答
  for (int j = 1; j <= i; j++) {
    if (sum - j == N) continue;
    cout << j << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








int main()
{
	
	int h, w, n;
	cin >> h;
	cin >> w;
	cin >> n;

	int ans = 0;
	ans = (n + max(h, w) - 1) / max(h, w);

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;


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

	int n,k;
	vector<int> aa;
	cin >> n >> k;
	int t;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		aa.pb(t);
	}
	int i=0;
	int sum=0;
	sort(all(aa));
	for(i=0;i<k;i++)
	{
		sum+=aa[i];
	}
	cout << sum <<'\n';


	return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stack>
#include <ctype.h>
#include <cstring>
#include <cmath>
#include <set>
using namespace std;

#define rep(i,n)  for(int i=0;i<(n);++i)
#define ALLOC_SIZE  (1000000)



int main(){
    set<string> st;
    
    int n;
    cin>>n;
    string str1;
    string str2;
    bool flag;
    
    
    for(int i=0;i!=n;++i){
        cin>>str1;
        cin>>str2;
        switch(str1[0]){
            case 'i':
                st.insert(str2);
                break;
            case 'f':
                flag=true;
                set<string>::iterator it=st.find(str2);
                if(it!=st.end()){
                    cout<<"yes"<<endl;
                }else{
                    cout<<"no"<<endl;
                }
                
                
                break;
                
        }
    }
}


Measured memory_bytes: 32624
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int a[3];
    for(int i =0; i < 3; i++){
        cin >> a[i];
    }
    sort(a, a + 3, greater<>());
    
    int ans = 0;
    ans = a[0] - a[1];
    int b = a[0] - (a[2] + ans);
    if(b % 2 == 0){
        ans += b / 2;
    }else {
        ans += b / 2 + 2;
    }
    cout << ans << endl;
    return 0;
}
 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 1001
  
int LCS_Length(char [] ,char []);
char X[N],Y[N];
int c[N][N];
int x,y;



int main(void){
  int i,n;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%s %s",X,Y);
  
    printf("%d\n",LCS_Length(X,Y));}
   
   
  return 0;
}




int LCS_Length(char X[] ,char Y[]){
  int i,j;
  
  x = strlen(X);
  y = strlen(Y);
   
  for(i=1;i<=x;i++){
    c[i][0] = 0;
  }
  for(j=0;j<=y;j++){
    c[0][j] = 0;
  }
  
   
  for(i=1;i<=x;i++){
    for(j=1;j<=y;j++){
      if(X[i-1]==Y[j-1]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else if(c[i-1][j]>=c[i][j-1]){
	c[i][j]=c[i-1][j];
      }
      else{
	c[i][j]=c[i][j-1];
      }
    }
  }

  
  return c[x][y];
}

Measured memory_bytes: 4524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define vi vector<int>
#define vpii vector<pii>
#define vp3i vector<p3i>
#define vpll vector<pll>
#define vp3l vector<p3l>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, a[200005], b[200005];
int32_t main(){
    cin >> n;
    fox(l, n){
        cin >> a[l];
        b[l]=a[l];
    }
    sort(a, a+n);
    fox(l, n){
        if (b[l]<=a[n/2-1]) printf("%i\n", a[n/2]);
        else printf("%i\n", a[n/2-1]);
    }
    return 0;
}


Measured memory_bytes: 3712
def find_primes(n):
    ps = []
    t = [True] * n
    t[0] = t[1] = False
    for i in range(2, n):
        if not t[i]:
            continue
        ps.append(i)
        for j in range(i, n, i):
            t[j] = False
    return ps


def solve(string):
    n = int(string)
    if n == 1:
        return "0"
    rn = int(n**0.5 + 1)
    ps = find_primes(rn)
    ans = 0
    for i in ps:
        k = 1
        while n % (i**k) == 0:
            ans += 1
            n //= i**k
            k += 1
    return str(ans + (n >= rn))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 20224
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int n = in.nextInt();

      ArrayList<Long> s = new ArrayList();
      ArrayList<Long> d = new ArrayList();

      for (int i = 0; i < n; i++) {
         long x = in.nextLong();
         long y = in.nextLong();

         s.add(x + y);
         d.add(x - y);
      }
      Collections.sort(s);
      Collections.sort(d);

      out.println(Math.max(s.get(n - 1) - s.get(0), d.get(n - 1) - d.get(0)));
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

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

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

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

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

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 66564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

vector<pair<ll, ll>>prime_fact(ll n) {
  vector<pair<ll, ll>>res;
  for(ll a = 2; a * a <= n; a++) {
    if(n % a != 0) continue;
    ll ex = 0;
    while(n % a == 0) {
      ex++;
      n /= a;
    }
    res.push_back({a, ex});
  }
  if(n != 1) {res.push_back({n, 1});}
  return res;
}


int main() {
  ll n;
  cin >> n;
  const auto &res = prime_fact(n);
  ll ans = 0;
  for(auto p :res) {
    //cout << p.first << " " << p.second << endl;
    ll count = p.second;
    ll i = 1;
    while(count - i >= 0) {
      count -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , m;
    cin >> n >> m;
    ll a[n][n] , b[m][m];
    for (int i = 0 ; i < n ; i++ ) cin >> a[i][0] >> a[i][1];
    for (int i = 0 ; i < m ; i++ ) cin >> b[i][0] >> b[i][1];
    for (int i = 0 ; i < n ; i++ ) {
        ll x = abs( a[i][0] - b[0][0] ) + abs( a[i][1] - b[0][1] ) , y = 1;
        for (int j = 0 ; j < m - 1 ; j++ ) {
            if ( x > abs( a[i][0] - b[j + 1][0] ) + abs( a[i][1] - b[j + 1][1] ) ) {
                y = j + 2;
                x = abs( a[i][0] - b[j + 1][0] ) + abs( a[i][1] - b[j + 1][1] );
            }
        }
        cout << y << endl;
    }
}

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

int main()
{
    string c;
    cin>>c;
    if(c=="a"||c=="e"||c=="i"||c=="o"||c=="u"){
        cout<<"vowel";
    }
    else{
        cout<<"consonant";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
int main(){
    cin>>N;
    cout<<((N==0)?1:0)<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define re register
#define N 1000005
#define mod 1000000007
using namespace std;
template<typename _int>
inline void read(re _int&x){
	re _int res=0,flag=1;re char opt;
	while((opt=getchar())<'0'||opt>'9')if(opt=='-')flag=-1;
	while(opt>='0'&&opt<='9'){res=(res<<1)+(res<<3)+opt-48;opt=getchar();}
	x=res*flag;
}
typedef long long ll; 
ll n,dp[N],sum[N],ans;
int main(void){
	re ll i;*dp=1;*sum=1;
	read(n);ans=(n>2);
	if(n==1)return puts("1"),0;
	for(i=1;i<=n;++i){
		(dp[i]+=(sum[i-1]-((i>=2)?dp[i-2]:0)+mod)%mod)%=mod;
//		printf("%lld %lld\n",sum[i-1],((i>=2)?dp[i-2]:0));
		sum[i]=(sum[i-1]+dp[i])%mod;
		if(i<n-1)(ans+=(1ll*(n-1)*(n-1)%mod+min(i+2,n-1))*dp[i]%mod)%=mod;
	}
	printf("%lld\n",((ans+1ll*n*dp[n-1]%mod)%mod+1ll*(n-1)*(n-1)%mod+1)%mod);
	return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using graph = vector<vector<int>>;
using P = pair<int,int>;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    n++;
    ll num[n]={0};
    ll cum[n]={0};
    rep1(i,n-1){
        cin >> num[i];
        cum[i] = cum[i-1] + num[i];
    }
    sort(cum,cum+n);
    vector<ll> count(220000,0);
    ll k = 0;
    ll p = 0;
    rep(i,n){
        if(p == cum[i]){
            count[k]++;
        }
        else{
            k++;
            p = cum[i];
            count[k]++;
        }
    }
    ll ans = 0;
    rep(i,k+1){
        ans += count[i]*(count[i]-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int N, R;
    cin >> N;
    cin >> R;

    int ans;

    if(N>=10){
        ans = R;
    }  else{
        ans = R + 100*(10-N);
    }
    cout << ans << "\n"; 

    return 0;
}

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

int main() {
	
	int n;
	cin >> n;
	
	float ans = 0;
	for(int i=0; i<=n; i++){
		if(i%2==1) ans++;
	}
	ans /= n;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define umap unordered_map
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
const ll mod = 1e9 + 7; 
const int inf = 0x3f3f3f3f;
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second  << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; } 

ll binpow(int a, int b) {
	if (!b) return 1;
	if (b == 1) return a%mod;
	ll temp = binpow(a, b/2);
	temp = (temp * temp)%mod;
	if (b & 1) temp = (temp * a)%mod;
	return temp;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	ll total = binpow(10, n);
	ll none = binpow(8, n);
	ll only_one = (binpow(9, n) * 2)%mod;
	cout << (total - only_one + none + mod)%mod << '\n';
} 
 


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, k, arr[100001];
bool dp[100001];


int main()
{
    IOS
    cin >> n >> k;
    for (int i= 0; i < n; ++i) {
        cin >> arr[i];
    }
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i>=arr[j] && !dp[i-arr[j]]) {
                dp[i] = 1;
            }
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;


    return 0;
}


Measured memory_bytes: 384
#coding:utf-8
#1_11_C

class Dice:
    def __init__(self, ary):
        self.top, self.south, self.east, self.west, self.north, self.bottom = ary

    def roll_n(self):
        self.top, self.north, self.bottom, self.south = self.south, self.top, self.north, self.bottom

    def roll_e(self):
        self.top, self.east, self.bottom, self.west = self.west, self.top, self.east, self.bottom

    def twist(self):
        self.north, self.east, self.south, self.west = self.west, self.north, self.east, self.south

    def isEqual(self, dice):
        if self.top == dice.top and self.south == dice.south and self.east == dice.east and self.west == dice.west and self.north == dice.north and self.bottom == dice.bottom:
            return True
        else:
            return False

dice1 = Dice(map(int,input().split()))
dice2 = Dice(map(int,input().split()))

flag = False

for i in range(6):
    if i % 2 == 0:
        dice1.roll_n()
    else:
        dice1.roll_e()

    for j in range(4):
        if dice1.isEqual(dice2):
            flag = True
            break
        else:
            dice1.twist()

    if flag:
        break

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6748
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a<=c&&c<=b)||a>=c&&c>=b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K=int(input())
a=[]
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            a.append(gcd(i,j,k))
print(sum(a))


Measured memory_bytes: 188948
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	int ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int k = 0; k <= 9; k++) {
				int x = 10001 * i + 1010 * j + 100 * k;
				if (a <= x && x <= b) {
					ans++;
				}
			}
		}
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
__int128 a,b,c;
int main()
{
    read(a),read(b),read(c);
    if(a*a+b*b+c*c-2*a*c-2*b*c-2*a*b>0&&c-a-b>=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;
int dp[102][102];
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int h,w;
	cin>>h>>w;
	string a[h];
	for(int i=0;i<h;i++) cin>>a[i];
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(i==0&&j==0)
			{
				if(a[i][j]=='#') dp[i][j]=1;
				else dp[i][j]=0;
				continue;
			}
			dp[i][j]=1e14;
			if(a[i][j]=='#')
			{
				if(i-1>=0)
				{
					if(a[i-1][j]=='#') dp[i][j]=min(dp[i][j],dp[i-1][j]);
					else dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
				}
				if(j-1>=0)
				{
					if(a[i][j-1]=='#') dp[i][j]=min(dp[i][j],dp[i][j-1]);
					else dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
				}
			}
			else{
				if(i-1>=0) dp[i][j]=min(dp[i][j],dp[i-1][j]);
				if(j-1>=0) dp[i][j]=min(dp[i][j],dp[i][j-1]);
			}
		}
	}
	cout<<dp[h-1][w-1];
}
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

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

int main() {
  int n, k, result;
  cin >> n >> k;
  
  n -= k;
  k--;
  result = 1;
  if (n != 0) {
    if (n % k != 0) {
      result++;
    }
    result += (n / k);
  }
  
  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 256
n = int(input())
X = []
Y = []
for i in range(n):
    x,y = [int(i) for i in input().split()]
    X.append(x)
    Y.append(y)

s = 0
for i in range(n):
    for j in range(n):
        s += ((X[i]-X[j])**2 + (Y[i]-Y[j])**2)**.5

print(s/n)

Measured memory_bytes: 3188
#include <iostream>
#define INF 1000000000

using namespace std;


int main(){
        int n;
        cin >> n;
        while(n){
                int m;
                cin >> m;
                int map[n][n];
                for(int i = 0; i < n ;i++){
                        for(int j = 0; j < n; j++){
                                map[i][j] = INF;
                        }   
                }   
                for(int i = 0; i < m; i++){
                        int a,b,c;
                        char d,e;
                        cin >> a >> d >> b >> e >> c;
                        map[a][b] = map[b][a] = c/100;
                }   
                bool used[100] = {false};
                used[0] = true;
                long long cost = 0;
                for(int i = 0; i < n-1; i++){
                        int min = INF;
                        int next = 0;
                        for(int j = 0; j < n; j++){
                                for(int k = 0; k < n; k++){
                                        if(used[j] && !used[k] && map[j][k] < min){
                                                min = map[j][k];
                                                next = k;
                                        }   
                                }   
                        }   
                        used[next] = true;
                        cost += min-1;
                }   
                cout << cost << endl;
                cin >> n;
        }   
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
  
  int A,B,ans;
  
  scanf("%d %d",&A,&B);
  
  ans = A + B;
  if(ans < A - B){
    ans = A - B;
  }
  if(ans < A * B){
    ans = A * B;
  }
  
  
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
if x==2 or y==2:
    if x==y:
        print("Yes")
    else:
        print("No")
else:
    if (x in a and y in a) or (x in b and y in b):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#define MAX_N 200005

int par[MAX_N]; //親
int ran[MAX_N]; //木の深さ

//n要素で初期化
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        ran[i] = 0;
    }
}

//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unit(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(ran[x] < ran[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(ran[x] == ran[y]) ran[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}

int main(void){
    ll n, m;
    cin >> n >> m;

    ll k[n];
    vector<ll> l[n];

    init(n + m);

    rep(i, 0, n){
        cin >> k[i];
        rep(j, 0, k[i]){
            ll tmp;
            cin >> tmp;
            tmp--;
            l[i].push_back(tmp);
        }

        rep(j, 0, l[i].size()){
            unit(l[i][j], m + i);
        }
    }

    rep(i, 0, n - 1){
        if(!same(m, m + i)){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s, ans = "";
int dp[N][5];

int fun(int pos, int lst) {
    if (pos == s.size()) {
        return 0;
    }
    int &tmp = dp[pos][lst];
    if (tmp != -1) {
        return tmp;
    }
    tmp = 0;
    if (s[pos] == '?') {
        int x = (lst == 1) + 1 + fun(pos + 1, 2);
        int y = fun(pos + 1, 2);
        tmp += max(x, y);
    } else if (s[pos] == 'D') {
        tmp += ((lst == 1) + 1 + fun(pos + 1, 2));
    } else {
        tmp += fun(pos + 1, 1);
    }
    return tmp;
}

void makeAnswer(int pos, int lst, int cnt) {
//    cout << pos << " " << ans << " " << cnt << endl;
    if (pos == s.size()) {
        return;
    }
    if (s[pos] == '?') {
        if (fun(pos + 1, 1) == cnt) {
            ans += 'P';
            makeAnswer(pos + 1, 1, cnt);
        } else {
            ans += 'D';
            makeAnswer(pos + 1, 2, cnt - 1 - (lst == 1));
        }
    } else if (s[pos] == 'D') {
        ans += s[pos];
        makeAnswer(pos + 1, 2, cnt - 1 - (lst == 1));
    } else {
        ans += s[pos];
        makeAnswer(pos + 1, 1, cnt);
    }
}

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    cin >> s;
    memset(dp, -1, sizeof dp);
//    cout << fun(0, 0) << '\n';
    int cnt = fun(0, 0);
    makeAnswer(0, 0, cnt);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 17124
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
int main(){
    int n; cin>>n;
    vi a(n*3);
    rep(0,i,n*3) cin>>a[i];
    sort(a.begin(),a.end());
    ll sum = 0;
    for(int i=n; i<n*3; i+=2){
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T> struct grid : public vector<vector<T>> {
    int n, m;
    grid(int n, int m) : vector<vector<T>>(n, vector<T>(m)), n(n), m(m) {}
    grid(int n, int m, T zero) : vector<vector<T>>(n, vector<T>(m, zero)), n(n), m(m) {}
    grid(const grid& a) : vector<vector<T>>(a), n(a.n), m(a.m) {}
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    partial_sum(a.begin(), a.end(), a.begin());
    auto rsq = [&](int L, int R) { return a[R - 1] - (L ? a[L - 1] : 0); };
    grid<ll> opt(n, n + 1);
    for(int len = 1; len <= n; len++) {
        for(int i = 0, j = i + len; j <= n; i++, j++) {
            if(len == 1) {
                opt[i][j] = 0;
            } else {
                opt[i][j] = lim<ll>::max();
                for(int k = i + 1; k < j; k++) {
                    opt[i][j] = min(opt[i][j], opt[i][k] + opt[k][j] + rsq(i, k) + rsq(k, j));
                }
            }
        }
    }
    cout << opt[0][n] << endl;
    return 0;
}


Measured memory_bytes: 1536
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def tree_diameter(graph): # 木の直径
    def dijkstra(start):
        INF = 10 ** 15
        dist = [INF] * (N+1)
        dist[start] = 0
        que = [(0, start)]
        length = 0; far = 0
        while que:
            d, prev = heappop(que)
            if dist[prev] < d:
                continue
            for next in graph[prev]:
                d1 = d + 1
                if dist[next] > d1:
                    dist[next] = d1
                    if d1 > length:
                        length = d1; far = next
                    heappush(que, (d1, next))
        return length, far
    _, f = dijkstra(1)
    l, f = dijkstra(f)
    return l

N = ir()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

daiameter = tree_diameter(graph)
bl = daiameter % 3 != 1
print('First' if bl else 'Second')


Measured memory_bytes: 69320
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	double n;
	int k;
	cin >> n >> k;
	double psum=0;
	for(int i=1; i<=n; i++){
		int s=i;
		double p=1/n;
		while(s<k){
			p*=0.5;
			s*=2;
		}
		psum+=p;
	}
	cout << fixed << setprecision(9) << psum << endl;
	return 0;
}

Measured memory_bytes: 256