akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define INF 100000000
#define WHITE 1
#define BLACK 2
#define N 105
#define NIL -1



typedef struct A{
  int num;
  int v[N];
  int c[N];
}DATA;

int G[N][N],d[N],pi[N],color[N];
DATA data[N];

void initializeSingleSource(int);
void dijkstra(int);

void relax(int,int);
  
int main() {
  int i,j,n,k;
  
  scanf("%d",&n);
 
  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      G[i][j] = NIL;
    }
  }
  
  for(i = 0; i < n; i++) {
    scanf("%d%d",&data[i].num,&k);
    for(j = 0; j < k; j++) {
      scanf("%d%d",&data[i].v[j],&data[i].c[j]);
      G[i][data[i].v[j]] = data[i].c[j]; 
    }  
  }
  /*
  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      printf("%d ",G[i][j]);
    }
    printf("\n");
    }
  */
  dijkstra(n);
  
  for(i = 0; i < n; i++) {
    printf("%d %d\n", data[i].num, d[i]);
  }
   
  return 0;
}


void initializeSingleSource(int n)
{
  int i;
  for(i = 0; i < n; i++) {
    d[i] = INF;
    pi[i] = NIL;
    color[i] = WHITE;
  }
  d[0] = 0;
}

void relax(int n,int u)
{
  if(d[n] > d[u] + G[u][n]) {
    d[n] = d[u] + G[u][n];
    pi[n] = u;
  }    
  }
 
void dijkstra(int n)
{
  int i,mincost,u;
  initializeSingleSource(n);
  while(1) {
    mincost = INF;
    for(i = 0; i < n; i++) {
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INF) break;

    color[u] = BLACK;

    for(i = 0; i < n; i++) {
      if(color[i] != BLACK && (d[u] + G[u][i]) < d[i] && G[u][i] != NIL) {
	pi[i] = u;
	d[i] = d[u] + G[u][i];
      }
    }
  }
  
  
} 
  



Measured memory_bytes: 2108
import copy

def partition(A,p,r):
    x=A[r-1]
    i=p-1
    for j in range(p-1,r-1):
        if int(A[j][1])<=int(x[1]):
            A_j=A[j]
            A[j]=A[i]
            A[i]=A_j
            i+=1
    A[r-1]=A[i]
    A[i]=x
    return i

def quicksort(A,p,r):
    if p<r:
        q=partition(A,p,r)
        quicksort(A,p,q)
        quicksort(A,q+1,r)

 
n=int(input())
a=[]
for i in range(n):
    a.append(input().split())
    
b=copy.deepcopy(a)
quicksort(b,1,n)
flag=True
for j in range(n-1):
    if int(b[j][1]) == int(b[j+1][1]): 
        if a.index(b[j]) > a.index(b[j+1]):flag=False ;break
if flag:print('Stable')
else:print('Not stable')

for i in b:
    print(*i)


Measured memory_bytes: 49788
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;


int main() {
  int N;
  cin >> N;
  vector<vector<int> > m(2, vector<int> (N, 0));
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> m[i][j];
    }
  }

  int tmp[2][110];
  for (int i = 0; i < 2; ++i) tmp[i][0] = 0;

  for (int i = 1; i <= N; ++i) {
    tmp[0][i] = tmp[0][i - 1] + m[0][i - 1];
    tmp[1][i] = max(tmp[0][i], tmp[1][i - 1]) + m[1][i - 1];
  }

  cout << tmp[1][N] << endl;
  return 0;
}


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

int main(){
    int A, B, C; cin >> A >> B >> C;
    int M=max({A,B,C});
    if( (M-A+M-B+M-C)%2 ){
        cout << (M-A+M-B+M-C+3)/2 << endl;
    }
    else{
        cout << (M-A+M-B+M-C)/2 << endl;
    }
}

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

int main(){
  string s; cin>>s;
  int k; cin>>k;
  set<string> sub;
  for (int i=0; i<k; i++){
    for (int j=0; j<s.size()-i; j++){
      sub.insert(s.substr(j,i+1));
    }
  }
  int cnt=0;
  for (auto d:sub){
    cnt+=1;
    if (cnt==k){
      cout<<d<<endl;
      return 0;
    }
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> t(N);
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> t[i];
    for (int i = 0; i < N; i++) cin >> a[i];
    
    vector<ll> h(N, 0);
    h[0] = t[0];
    for (int i = 1; i < N; i++) {
        if (t[i-1] < t[i]) h[i] = t[i];
    }
    
    if (h[N-1] > 0 && h[N-1] != a[N-1]) {
        cout << 0 << endl;
        return 0;
    } else {
        h[N-1] = a[N-1];
    }
    
    for (int i = N-2; i >= 0; i--) {
        if (a[i] > a[i+1]) {
            if (h[i] > 0 && h[i] != a[i]) {
                cout << 0 << endl;
                return 0;
            } else {
                h[i] = a[i];
            }
        }
    }
    
    ll ans = 1;
    for (int i = 0; i < N; i++) {
        if (h[i] > 0) {
            if (h[i] > t[i] || h[i] > a[i]) {
                cout << 0 << endl;
                return 0;
            }
            continue;
        } else {
            ans = ans * min(t[i], a[i]) % mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	
	int mx = -10000000; 
	int mn = 10000000;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mx = max(mx, A[i]);
		mn = min(mn, A[i]);
	}
	int type = 0;
	vector<int> X;
	vector<int> Y;
	if (mx <= 0) {
		type = 0;
	}
	else if (mn >= 0) {
		type = 1;
	}
	else {
		int mi = 0;
		if (-mn < mx) {	
			for (int i = 0; i < N; i++) {
				if (A[i] == mx) {
					mi = i;
					break;
				}
			}
			type = 1;
		}
		else {
			for (int i = 0; i < N; i++) {
				if (A[i] == mn) {
					mi = i;
					break;
				}
			}
			type = 0;
		}
		for (int i = 0; i < N; i++) {
			//if (i != mi) {
				X.push_back(mi + 1);
				Y.push_back(i + 1);
			//}
		}
	}
	if (type == 0) {
		for (int i = N - 1; i > 0; i--) {
			X.push_back(i + 1);
			Y.push_back(i);
		}
	}else{
		for (int i = 0; i < N - 1; i++) {
			X.push_back(i + 1);
			Y.push_back(i + 2);
		}
	}
	cout << X.size() << endl;
	for (int i = 0; i < X.size(); i++) {
		cout << X[i] << " " << Y[i] << endl;
		A[Y[i] - 1] += A[X[i] - 1];
	}
	/*for (int i = 0; i < N; i++) {
		cerr << A[i] << endl;
	}*/
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        l: usize,
        v: [usize; n]
    }
    let mut last = n;
    for i in 0..n - 1 {
        if v[i] + v[i + 1] >= l {
            last = i;
            break;
        }
    }
    if last == n {
        println!("Impossible");
        return;
    }
    println!("Possible");
    for i in 1..last + 1 {
        println!("{}", i);
    }
    for i in (last + 2..n).rev() {
        println!("{}", i);
    }
    println!("{}", last + 1);
}


Measured memory_bytes: 4860
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
s = SI()
if s.islower():
	print("a")
else:
	print("A")

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	FOR(i,0,n)cin >> a[i];
	int wa = 0;
	FOR(i,0,n)wa+=a[i];
	int ansi,ansa=9999999;
	FOR(i,0,n){
		if(abs(ansa*n-wa)>abs(a[i]*n-wa)){
			ansa = a[i];
			ansi = i;
		}
	}
	cout << ansi << endl;
}


Measured memory_bytes: 256
n=int(input())
r=n**(1/2)
w=0
for i in range(1,int(r)+1):
  if n%i==0:
    w=i
x,y=w,n//w
if x!=1 and y!=1:
  print(x+y-2)
else:
  print(max(x,y)-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	string st;
	cin>>st;
	int i,j,c=0;
	i=0;
	j=st.length()-1;
	while(i<j){
		if(st[i]!=st[j])
		c++;
		i++;
		j--;
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map.Entry;
import java.util.Comparator;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] S = new String[N];
        for(int i = 0; i < N; i++){
            S[i] = sc.next();
        }
        sc.close();
        HashMap<String, Integer> mp = new HashMap<>();
        for(int i = 0; i < N; i++){
            mp.put(S[i], mp.getOrDefault(S[i], 0) + 1);
        }
        List<String> res = new ArrayList<>();
        int max_val = 0;
        for(Entry<String, Integer> e: mp.entrySet()){
            max_val = Math.max(max_val, e.getValue());
        }

        for(Entry<String, Integer> e: mp.entrySet()){
            if(max_val == e.getValue()){
                res.add(e.getKey());
            }
        }
        res.sort(Comparator.naturalOrder());
        for(String s: res){
            System.out.println(s);
        }




    }
}

Measured memory_bytes: 77312
import os, sys, re, math, fractions

def gcd(a,b):
    if a == 0:
        return b
    else:
        return gcd(b % a, a)

N = int(input())
A = list(map(int,input().split(' ')))

memo_L = [1] * N
memo_R = [1] * N

for i in range(N):
    if i == 0:
        memo_L[i] = A[i]
        memo_R[i] = A[N-1]
    elif i == N - 1:
        memo_L[i] = gcd(A[i], memo_L[i-1])
        memo_R[i] = gcd(A[0], memo_R[i-1])
    else:
        memo_L[i] = gcd(A[i], memo_L[i-1])
        memo_R[i] = gcd(A[N-1-i], memo_R[i-1])

memo_R.reverse()

ret = 1
for j in range(N):
    if j == 0:
        ret = max(ret, memo_R[1])
    elif j == N-1:
        ret = max(ret, memo_L[j-1])
    else:
        common_gcd = fractions.gcd(memo_L[j-1], memo_R[j+1])
        ret = max(ret, common_gcd)

print(ret)


Measured memory_bytes: 16076
N, x=map(int,input().split())
a=list(map(int,input().split()))
count=0
for i in range(N):
    if i>0:
        if a[i-1]+a[i]>x:
            count += a[i - 1] + a[i] - x
            if a[i-1]>x:
                a[i-1]=x
                a[i]=0
            else:
                a[i]=x-a[i-1]
print(count)

Measured memory_bytes: 14252
#include <iostream>
#include <vector>

using namespace std; 

int main(void) {
	int nov;
	cin >> nov;
	vector< vector<int> > w(nov,vector<int>(nov));
	for (int i = 0; i < nov; ++i) {
		for (int j = 0; j < nov; ++j) {
			cin >> w[i][j];
		}
	}

	int wmin,v,res = 0;
	vector<int> term(nov,-1); 
	vector<int> check(nov,-1); 
	term[0] = 0;
	check[0] = 1;
	for (int i = 1; i < nov; ++i) {
		wmin = (1 << 28);
		for (int j = 0; j < i; ++j) {
			for (int k = 0; k < nov; ++k) {
				if (check[k] < 0 && w[term[j]][k] >= 0) {
					if (w[term[j]][k] < wmin) {
						wmin = w[term[j]][k];
						v = k;
					}
				}
			}
		}
		res += wmin;
		term[i] = v;
		check[v] = 1;
	}
	cout << res << endl;

	return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pa;

#define fst first
#define snd second
#define pb push_back

const int maxn=500005,maxm=512;
const double pi=acos(-1.0);
//const ll mod=1000000007;
const ll mod=1000000007;
const double eps=1e-8;

int n;
vector<int> E[maxn];

int dl[maxn],sta,dln;
int fat[maxn];

ll dp[maxn];

vector<int> v1,v2;

int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=0;i<n-1;i++)
    {
        int x,y;scanf("%d %d",&x,&y);
        --x;--y;
        E[x].pb(y);E[y].pb(x);
    }
    if(n==1) {printf("1\n");return 0;}
    else if(n==2) {printf("3\n");return 0;}
    for(i=0;i<n;i++) sort(E[i].begin(),E[i].end());
    sta=dln=0;dl[dln++]=0;
    memset(fat,-1,sizeof(fat));
    while(sta<dln)
    {
        int x=dl[sta++];
        for(i=0;i<E[x].size();i++)
        {
            int y=E[x][i];
            if(fat[x]!=y)
            {
                fat[y]=x;
                dl[dln++]=y;
            }
        }
    }
    for(i=n-1;i>=0;i--)
    {
        int x=dl[i];
        dp[x]=(x+1LL)*(n-x);
        v1.clear();v2.clear();
        for(j=0;j<E[x].size();j++)
        {
            int y=E[x][j];
            if(y==fat[x]) continue;
            dp[x]+=dp[y];
            if(y>x) v2.pb(y);
            else v1.pb(y);
        }
        sort(v2.begin(),v2.end());
        int sz=v2.size();
        for(j=0;j<sz;j++)
        {
            dp[x]-=(1LL+x)*(n-v2[j]);
        }
        sort(v1.begin(),v1.end());
        sz=v1.size();
        for(j=0;j<sz;j++)
        {
            dp[x]-=(n-x)*(v1[j]+1LL);
        }
    }
    printf("%lld\n",dp[0]);
    return 0;
}


Measured memory_bytes: 27812
from heapq import heappop,heappush
N,M=map(int,input().split())
X=sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x: x[0])
hq=[]
ans,j=0,0
for i in range(1,M+1):
    while(j<N) and(X[j][0]<=i):
        heappush(hq,-X[j][1])
        j+=1
    if len(hq):
        ans+=-heappop(hq)
#print(X)
print(ans)



Measured memory_bytes: 31976
#include <iostream>
#include <vector>
#include <complex>
#include <cstdlib>

using namespace std;

const double eps = 1e-10;
typedef complex<double> Point;

inline double cross(const Point& a, const Point& b){
    return imag(conj(a) * b);
}

inline double dot(const Point& a, const Point& b){
    return real(conj(a) * b);
}

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > eps) return  1;
    if(cross(b, c) < -eps)return -1;
    if(dot(b, c) < 0)     return  2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

struct Line : vector<Point> {
    Line(const Point& a, const Point& b):vector<Point>{a, b}{}
};

inline bool interSS(const Line& s, const Line& t){
    return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
           ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

int main(){
    int q;
    cin >> q;
    while(q--){
        int x0, y0, x1, y1, x2, y2, x3, y3;
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Line l(Point(x0, y0), Point(x1, y1)), m(Point(x2, y2), Point(x3, y3));
        cout << (interSS(l, m)? 1: 0) << '\n';
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s[0] >> s[1] >> s[2];
    int ss = atoi(s.c_str());
    if(ss % 4 == 0) cout <<"YES"<<endl;
    else cout <<"NO" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M_PI  3.1415926535
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }

 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin );
  ll t = 1;
  //cin>>t;
   while(t--)
  {
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m);
    vector<ll> prefa(n,0),prefb(m,0);
    ll ma = -1;
    for( ll i = 0 ; i<n ; i++ ) {
        cin>>a[i];
        if(i==0) prefa[i] = a[i];
        else
            prefa[i] = a[i] + prefa[i-1];
    }
    for( ll i = 0 ; i<m ; i++ ){
        cin>>b[i];
        if(i==0) prefb[i] = b[i];
        else
            prefb[i] = b[i] + prefb[i-1];
            if(prefb[i]<=k) ma=i+1;
    }
   for( ll i  = 0 ; i<n ; i++ )
    {
        ll temp = 0 ;
        ll tempmax = k;
        if( prefa[i]<=k ) { temp = i+1 ; tempmax -= prefa[i] ; }
        ll y = lower_bound( prefb.begin() , prefb.end() , tempmax ) - prefb.begin() ;
        if( (y<m && tempmax<prefb[y]) || y==m   ){ --y; }
        temp += (y+1);
        ma = max(ma,temp);


   }
    cout<<ma;

  }
  return 0;

}


Measured memory_bytes: 9536
#include <iostream>
#include <cmath>

using namespace std;

typedef int scalar;
class point{
	public:
	scalar x;
	scalar y;
	point(scalar a = 0, scalar b=0) : x(a), y(b){}
	void print(){
		cout << x << " " << y; 
	}
	scalar cross(point a){//??????
		return x * a.y - y * a.x;
	}
	scalar dot(point a){//??????
		return x * a.x + y * a.y;
	}
	scalar norm(void){
		return x * x + y * y;
	}
	scalar abs(void){
		return sqrt(norm());
	}
	point operator =(point a){
		x = a.x;
		y = a.y;
		return *this;
	}
	point operator +(point a){return point(x + a.x, y + a.y);}
	point operator -(point a){return point(x - a.x, y - a.y);}
};

int main(){
	point p0, p1, p2, p3;
	point v1,v2;
	int q;
	cin >> q;
	for(int i = 0;i < q;i++){
		cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
		v1 = p1 - p0;
		v2 = p3 - p2;
		//v1.print();v2.print();
		//??????????¨??????????0????????????
		if(v1.cross(v2)==0){
			cout << 2 << endl;
		}else if(v1.dot(v2)==0){
			cout << 1 << endl;
		}else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		int n = input();
		StringBuilder sb = new StringBuilder();

		for (int i = 1 ; i <= n; i++) {

			if (i % 3 == 0) {

				sb.append(" " + i);

			} else {

				int x = i;

				while (x != 0) {

					if (x % 10 == 3) {

						sb.append(" " + i);
						break;

					} else {

						x = x / 10;

					}
				}
			}
		}

		System.out.println(sb);

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 28376
N,K=map(int,input().split())
D=list(map(int,input().split()))

ans=N

for price in range(N,10**5+1):
    s=str(price)
    flag=True
    for i in range(len(s)):
        if int(s[i]) in D:
            flag=False
    if flag:
        ans=price
        break

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1ll << 60;
static const ll MOD = 1e9 + 7;
int N;

signed main() {
  cin >> N;
  int cnt[10][10];
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= N; i++) {
    string s = to_string(i);
    cnt[s.front() - '0'][s.back() - '0']++;
  }
  int res = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = i; j <= 9; j++) {
      if (i == j)
        res += cnt[i][j] * cnt[j][i];
      else
        res += cnt[i][j] * cnt[j][i] * 2;
    }
  }
  cout << res << endl;
  return 0;
}

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

// #define int long long
#define ll long long
#define pb push_back
#define vi vector<int>
#define vii vector<vector<int> >

template <class X>
void print(X Target)
{
  cout << Target << '\n';
}

signed main()
{
  ios::sync_with_stdio(false);
  int L, N;
  
  cin >> L >> N;
  vi s(2 * L + 1, 0);
  int r = 0, l = 0;
  for (int i = 0; i < N; i++){
    int x, w;
    cin >> x >> w;
    s[L + x] += w;
    if (L > L + x){
      l += abs(x * w);
    }
    else if (L < L + x){
      r += abs(x * w);
    }
  }

  if (r == l) print(0);
  else {
    if (r > l){
      print(r - l);
      for (int i = 0; i < r - l; i++){
        cout << -1 << " " << 1 << '\n';
      }
    }
    else if (r < l){
      print(l - r);
      for (int i = 0; i < l - r; i++){
        cout << 1 << " " << 1 << '\n';
      }
    }
  }

  return (0);
} 

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int max = 0;
		int maxnum = -1;
		int secmax = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] > secmax) {

				if (a[i] > max) {
					secmax = max;
					max = a[i];
					maxnum = i;
				} else {
					secmax = a[i];
				}

			}
//			System.out.println("i:" + i + ", m:" + max + ", s:" + secmax);
		}

		loop: for (int i = 0; i < n; i++) {
			if (max != secmax) {
				if (i == maxnum) {
					System.out.println(secmax);
					continue loop;
				}
			}

			System.out.println(max);
		}

		sc.close();
	}
}

Measured memory_bytes: 86248
#include <iostream>
#include <vector>
#include <tuple>
#include <string>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  using sii = std::tuple<std::string, int,int>;
  std::vector<sii> SP(N);
  for(int i=0;i<N;i++){
    auto &sp = SP[i];
    std::cin >> std::get<0>(sp) >> std::get<1>(sp);
    std::get<2>(sp) = i+1;
  }
  std::sort(SP.begin(),SP.end(),[](
    const sii &l, const sii &r){
      if(std::get<0>(l) == std::get<0>(r))
        return std::get<1>(l) > std::get<1>(r);
      return std::get<0>(l) < std::get<0>(r);
    }
    );
  for(auto &sp:SP)
    std::cout << std::get<2>(sp) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k,s1;
string s;
int main()
{
	cin>>s;
	s1=s.size()-1;
	for(int i=0;i<=s1;i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<=s1;j++)
			{
				if(s[j]=='F')
				{
					printf("Yes");
					return 0;
				}
			}
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
 
void setIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}
 
//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line


int main(){
    setIO();
    int n, m, k; cin >> n >> m >> k;
    int a[n], b[m];
    ll sa = 0;
    int ca = -1, cb = -1;
    ll cost = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        sa += a[i];
        if(sa <= k) {
            ca = i;
            cost = sa;
        }
    }
    bool canadd = true;
    for(int i = 0; i < m; ++i) {
        cin >> b[i];
        if(cost + b[i] <= k && canadd){
            cb = i;
            cost += b[i];
        }
        else{
            canadd = false;
        }
    }
    int p2 = cb + 1;
    int tot = ca + cb + 2;
    int mx = tot;
    for(int i = ca; i >= 0; --i){
        --tot;
        cost -= a[i];
        while(p2 < m && cost + b[p2] <= k){
            cost += b[p2++];
            ++tot;
        }
        mx = max(mx, tot);
    }
    cout << mx << "\n";
}

Measured memory_bytes: 5204
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
  
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

ll binpow(ll a, ll b, ll m) 
{
    a %= m;
    ll res = 1;
    while (b > 0) 
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
void test_case()
{
    ll n;
    string s;
    cin >> n >> s;
    ll res[n+1];
    for(int i = 0; i <= n; i++)
    {
        res[i] = -1;
    }
    res[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        ll x = __builtin_popcount(i);
        ll z = i % x;
        res[i] = res[z] + 1;
    }
    ll tot = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == '1')
            tot++;
    }
    ll x1 = 0, x2 = 0, x3 = 0;
    ll pow1 = 1, pow2 = 1, pow3 = 1;
    for(int i = n-1; i >= 0; i--)
    {
        if(s[i] == '1')
        {
            if(tot > 0)
                x1 = (x1 + pow1) % tot; 
            if(tot+1 > 0)
                x2 = (x2 + pow2) % (tot+1); 
            if(tot-1 > 0)
                x3 = (x3 + pow3) % (tot-1); 
        }
        if(tot > 0)
            pow1 =(pow1 * 2) % (tot);
        if(tot+1 > 0)
            pow2 =(pow2 * 2) % (tot+1);
        if(tot-1 > 0)
            pow3 =(pow3 * 2) % (tot-1);
    }
    for(int i = 0; i < n ;i++)
    {
        ll curr = tot;
        if(s[i] == '1')
            curr--;
        else
            curr++;
        if(curr == tot)
        {
            cout << res[x1] + 1 <<'\n';
        }
        else if(curr == tot+1)
        {
            ll xx = 0;
            if(tot+1 > 0)
                xx = binpow(2, n-1-i, (tot+1));
            // cout << xx << ' ';
            // cout << res[(x2 + xx) % (tot+1)] + 1 << '\n';
            ll ans = 0;
            if(tot+1 > 0)
                ans = res[(x2 + xx) % (tot+1)] + 1;
            cout << ans << '\n';
        }
        else if(curr == tot-1)
        {
            ll xx = 0;
            if(tot-1 > 0)
                xx = binpow(2, n-1-i, (tot-1));
            // cout << xx << ' ';
            ll ans = 0;
            if(tot-1 > 0)
                ans = res[(x3 - xx + tot -1) % (tot-1)] + 1;
            cout << ans << '\n';
        }
    }

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


Measured memory_bytes: 5344
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
const int maxn = 1e5+10;
int a[maxn];
LL b[maxn];
LL dp[maxn];
int main()
{
    int n,w;
    scanf("%d%d",&n,&w);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%lld",a+i,b+i);
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=w;j>=0;j--)
        {
            if(j-a[i]>=0)
            {
                dp[j]=max(dp[j],dp[j-a[i]]+b[i]);
            }
        }
    }
    printf("%lld\n",dp[w]);
    return 0;
}


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)
#define T 10

int main(){
    int k;
    long dp[10][10], sum[10], sum_table[10][10];
    cin >> k;
    rep(i, T){
        dp[0][i] = 1; 
    }
    sum[0] = 9;
    rep2(i, 1, T){
        sum[i] = sum[i-1];
        rep(j, T){
            if(j==0||j==9){
                if(j==0){
                    dp[i][j] = dp[i-1][0] + dp[i-1][1];
                }else{
                    dp[i][j] = dp[i-1][8] + dp[i-1][9];
                    sum[i] += dp[i][j];
                }
            }else{
                dp[i][j] = dp[i-1][j-1] + dp[i-1][j] + dp[i-1][j+1];
                sum[i] += dp[i][j];
            }
        }
    }

    

    rep(i, T-1){
        sum_table[i+1][0] = sum[i];
    }
    sum_table[0][0] = 0;

    rep(i, T){
        rep2(j, 1, T){
            sum_table[i][j] = sum_table[i][j-1] + dp[i][j];
        }
    }

    int digit;

    rep(i, T){
        if(k<=sum[i]){
            digit = i;
            //tmp = sum[i];
            break;
        }
    }

    int start = 9, tmp;

    for(int j=start;j>0;j--){   //最上位bit
        if(k>sum_table[digit][j-1]){
            cout << j;
            k -= sum_table[digit][j-1];
            // if(j!=1){
            //     start = j-1;
            // }else{
            //     start = 1;
            // }
            start = j - 1;
            break;
        }else{
            //tmp -= dp[i][j];
        }
    }

    for(int i=digit-1;i>=0;i--){
        for(int j=start;j<T;j++){
            if(k<=dp[i][j]){
                cout << j;
                if(j!=0){
                    start = j-1;
                }else{
                    start = 0;
                }
                break;
            }else{
                k -= dp[i][j];
                //tmp -= dp[i][j];
            }
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < X.length; ++i) {
            X[i] = sc.nextInt();
        }

        System.out.println(solve(X, A, B));

        sc.close();
    }

    static long solve(int[] X, int A, int B) {
        return IntStream.range(0, X.length - 1).mapToLong(i -> Math.min((long) A * (X[i + 1] - X[i]), B)).sum();
    }
}

Measured memory_bytes: 51804
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int n;
  cin >> n;
  int pay = 1000;
  while(pay < n) {
    pay += 1000;
  }
  cout << pay - n << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

///////////////////////////////////////////////////////////////////////////

int main(){
    ll n;
	ll flag[1003] = {};
    map<ll,ll> m;
    
    cin >> n;
    
	for(int i = 2; i < sqrt(n); i++){
		if(flag[i] == 0){
			for(int j = i*2; j < n; j+=i){
				flag[j] = 1;
			}
		}
	}

	rep(i,2,n+1){
	    int t = i;
        rep(j,2,n+1){
        //for(int j = t; j>0;j--){
            if(flag[j] == 0){
                while(t % j == 0){
                    t/= j;
                    m[j]++;
                    if(t <= 0)break;
                }
            }
            if(t <= 0)break;
        }
   /*     cout << i << " ";
        for(auto it:m)cout << it.ft << "^" << it.sd << ":";
        cout << endl;*/
	}
	ll ans = 1;
	for(auto it:m){
	    ans *= (it.sd + 1);
	    ans = mod(ans);
	}
	cout << ans << endl;
	return  0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int m=sc.nextInt();
    System.out.println((n==k||n==m||k==m)?(n==k&&k==m)?"No":"Yes":"No");
  }
}


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

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

fn main() {
    let v = read_vec::<i64>();
    let (n, d) = (v[0] as usize, v[1]);
    let mut ans = 0;
    for i in 0..n {
        let v = read_vec::<i64>();
        if v[0] * v[0] + v[1] * v[1] <= d * d {
            ans += 1;
        }
    }
    println!("{}", ans);
}

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

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


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

int asc(const void *a, const void *b) {
  return *(int *)b - *(int *)a;
}

int main() {
	string s;
	cin >> s;
	rep(i, s.size()){
		if(i % 2 != 0){
			if(s[i] == 'L' || s[i] == 'U'|| s[i] == 'D'){
				continue;
			}else{
				cout << "No" << endl;
				return 0;
			}
		}else{
			if(s[i] == 'R' || s[i] == 'U'|| s[i] == 'D'){
				continue;
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	s[4],t[4];
	
	
	scanf("%s", s);
	scanf("%s", t);
	
	for(i=0;i<3;i++) {
		if (s[i]==t[i]) ans++;
	}
	
	printf("%d\n",ans);


	return 0;
}

Measured memory_bytes: 128
s = input()
if int(s[:2]) > 0 and int(s[:2]) < 13 and (int(s[2:]) > 12 or int(s[2:]) == 0):
    print("MMYY")
elif int(s[2:]) > 0 and int(s[2:]) < 13 and (int(s[:2]) > 12 or int(s[:2]) == 0):
    print("YYMM")
elif int(s[:2]) > 0 and int(s[:2]) < 13 and int(s[2:]) > 0 and int(s[2:]) < 13:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3064
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   long double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 
dll dist(ll x, ll y, ll x1, ll y1) {
  dll tot = (dll)((x - x1) * (x - x1));
  tot+= (dll)((y - y1) * (y - y1));
  return (dll)sqrt(tot);
}

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vector<pll> arr(n);
  dll tot = 0.00;
  for(ll i = 0; i < n; i++) cin >> arr[i].ff >> arr[i].ss;
  sort(all(arr));
  ll ct = 0;
  do {
   ct++;
   for(ll i = 1; i < n; i++) {
    tot+= dist(arr[i].ff, arr[i].ss, arr[i-1].ff, arr[i-1].ss);
   }
  } while(next_permutation(all(arr)));
  dll ans = (dll)((tot)/(dll)(ct));
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int N=505;
int n,x,i,j,k;
ll s[2][N][N],f[N][N],ans=1ll<<60;
inline ll ask(int o,int x1,int x2,int y1,int y2){return s[o][x2][y2]-s[o][x1-1][y2]-s[o][x2][y1-1]+s[o][x1-1][y1-1];}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		for(j=1;j<i;++j)scanf("%d",&x),s[0][j][i]=x;
		for(j=i+1;j<=n;++j)scanf("%d",&x),s[1][i][j]=x;
	}
	for(i=1;i<=n;++i)for(j=2;j<=n;++j)s[0][i][j]+=s[0][i][j-1],s[1][i][j]+=s[1][i][j-1];
	for(i=2;i<=n;++i)for(j=1;j<=n;++j)s[0][i][j]+=s[0][i-1][j],s[1][i][j]+=s[1][i-1][j];
	for(i=2;i<=n+1;++i)for(j=i-1,f[i][1]=ask(1,1,i-1,1,i-1)-ask(0,1,i-1,1,i-1);j>1;--j){
		for(f[i][j]=1ll<<60,k=j-1;k>=1;--k)
			f[i][j]=std::min(f[i][j],f[j][k]+ask(1,j,i-1,j,i-1)
				-ask(0,j,i-1,j,i-1)-ask(0,k,j-1,j,i-1));
	}
	for(i=n;i;--i)ans=std::min(ans,f[n+1][i]);ans+=s[0][n][n];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6272
def examA():
    H,A = LI()
    ans = (H-1)//A+1
    print(ans)
    return

def examB():
    H, N = LI()
    A = LI()
    if H>sum(A):
        print("No")
    else:
        print("Yes")
    return

def examC():
    N, K = LI()
    H = LI()
    H.sort()
    ans = sum(H[:max(0,N-K)])
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 26880
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main() {
	string s;
	cin >> s;
	int l = (int)s.length();
	int S[100000];
	for (int i = 0;i<l;i++) S[i] = (int)s[i];

	int x;
	if (l % 2 == 1) {
		int hl = l / 2;
		x = 1;//中央から何個同じのが並ぶか
		for (int i = 1;i <= hl;i++) {
			if (s[hl + i] == s[hl] && s[hl - i] == s[hl]) x += 2;
			else i = hl + 1;
		}
	}
	else {
		int hl = l / 2;
		x = 0;//中央から何個同じのが並ぶか
		for (int i = 0;i <= hl - 1;i++) {
			if (s[hl + i] == s[hl] && s[hl - i - 1] == s[hl]) x += 2;
			else i = hl + 1;
		}
	}
	int ans = (x + l) / 2;
	cout << ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 long double r;
 cin>>r;
 cout<<setprecision(10)<<2*PI*r<<endl;

return 0;
}



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

        using namespace std;

        #define pb push_back
        #define mp make_pair
        #define fr first
        #define sc second

        typedef long long int lli;

        lli h, a, ans, n, sum = 0;

        int main(){
            cin>>h>>n;
            for(int i = 0;i<n;i++){
                cin>>a;
                sum += a;
            }
            if(sum >= h)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
            return 0;
        }


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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  double v[n];
  rep(i,n) cin >> v[i];
  sort(v,v+n);
  double ans=v[0];
  rep1(i,n-1){
    ans = (ans+v[i])/2.;
  }
  std::cout << std::fixed;
  std::cout << std::setprecision(10) << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
                    
                    
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int main() 
{
    string S;
    cin >> S;
    int count;
    vector<int> ans;
    bool p = S[0] == 'R';
    bool q = S[1] == 'R';
    bool r = S[2] == 'R';
    if(p and q and r) cout << 3 << endl;
    else if((p and q) or (q and r)) cout << 2 << endl;
    else if (p or q or r) cout << 1 << endl;
    else cout << 0 << endl;
    }

Measured memory_bytes: 3576
//2*10^9
//9*10^18
// __int128_t 
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long int
#define ll long long int

const ll M=1e9+7;

//to handle when remainder is -neg we add + M
//but when rem is +pos that time also we add so use %M
//so it will work for both
ll mod(ll n){
    return (n%M + M)%M; 
}
ll modAdd(ll a, ll b){
    return mod(mod(a)+mod(b));
}
ll modMul(ll a, ll b){
    return mod(mod(a)*mod(b));
}
ll modMinus(ll a, ll b){
    return mod(mod(a)-mod(b));
}
ll modpow(ll x, ll n) 
{ 
    if (n == 0) 
        return 1%M;
    if (n == 1)
        return x%M; 
    ll u = modpow(x,n/2); 
    u = modMul(u,u); 
    if (n%2) 
        u = modMul(u,x); 
    return u; 
}
ll gcd(ll a,ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}
bool isPrime(ll n){
    int end = sqrt(n);
    for(int i=2;i<=end;i++)
        if(n%i==0)
            return false;
    return true;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
  
    int t=1;
    //cin>>t;

    while(t--){
        int k;
        cin>>k;

        string ans;
        while(k--){
            ans.append("ACL");
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            //substr : iからd.size()分だけとる。
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
int n,m;
vector<int> g[maxn];
int a[maxn];
bool vis[maxn];
set<int> s;
void dfs(int u)
{
    s.insert(u);
    vis[u]=1;
    for(int v : g[u])if(!vis[v])
        dfs(v);
}
main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=m;i++)
    {
        int x,y;scanf("%d%d",&x,&y);
        g[x].push_back(y),g[y].push_back(x);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])dfs(i);
        for(int k : s)if(s.find(a[k])!=s.end())ans++;
        s.clear();
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 12928