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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define int long long

const int N = 2e5 + 10;
const int MOD = 1e9 + 7;

int n, k;
int pre[N], BIT[N];
map<int, int> pos;
set<int> tmp;

void upd(int pos, int val){
    for(int i = pos; i <= n; i += (i & -i))
        BIT[i] = (BIT[i] + val);
    return;
}

int getm(int pos)   {
    int res = 0ll;
    for(int i = pos; i >= 1; i -= (i & -i))
        res = (res + BIT[i]);
    return res;
}

signed main()
{
    //freopen("b05.inp", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    FOR(i, 1, n)    {
        cin >> pre[i];
        pre[i] -= k; pre[i] += pre[i - 1];
        tmp.insert(pre[i]);
    }

    int idem = 0, lasmax = -1;
    for(auto it = tmp.begin(); it != tmp.end(); ++it)  {
        pos[(*it)] = ++idem;
        if(lasmax == -1) {
            if((*it) >= 0) lasmax = idem;
        }
    }
    if(lasmax != -1) upd(lasmax, 1);
    int sum = 0ll;
    FOR(i, 1, n)    {
        int tmp = getm(pos[pre[i]]);
        sum = (sum + tmp);
        upd(pos[pre[i]], 1ll);
    }
    cout << sum;
}


Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>

int main() {
    std::string temp;
    std::cin >> temp;
    int ans = 700;
    for (auto t : temp) {
        if (t == 'o') {
            ans += 100;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}



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

int main(){
	long n, q, C = 0;
	cin >> n;
	vector<long> S(n);
	for (long i = 0; i < n; i++) cin >> S[i];
	cin >> q;
	vector<long> T(q);
	for (long i = 0; i < q; i++) cin >> T[i];
	for (long i = 0; i < q; i++){
		for (long j = 0; j < n; j++){
			if (T[i] == S[j]){
				C++;
				break;
			}
		}
	}
	cout << C << endl;
	return 0;
}

Measured memory_bytes: 1272
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000000;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int,PP> PPP;
struct edge { int to; int to2; int cost; };

signed main() {
	double t, x; cin >> t >> x;
	printf("%.9lf\n", t / x);
}

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

#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)

#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FFE(i,L,R) for (int i = L; i >= R; i--)

#define wez(n) int (n); cin >> n
#define wez2(n,m) int (n),(m); cin >> n >> m
#define wez3(n,m,k) int (n),(m),(k); cin >> n >> m >> k

#define whileZ int T; cin >> T; while(T--)

#define ALL(c) (c).begin(),(c).end()
#define ll long long 
#define ull unsigned long long
#define ld long double

#define fi first
#define se second

// for debug
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) if(a.size()) printA(a,0,a.size()-1)

#define pb push_back
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> ii;
//  priority_queue <int, vector<int>, greater<int> > pq; // min heap

ll a[200005];
ll pre[200005];
const ll m = 1000000007LL;
ll ans;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    wez(n);
    for (int i=1; i<=n; i++) {
        cin >> a[i];
        pre[i] = (pre[i-1] + a[i]) % m;
    }
    for (int i=1; i<=n; i++) 
        ans = ( ans + a[i]*pre[i-1] ) % m;

    cout << ans << '\n';    
    return 0;
}

Measured memory_bytes: 6776
/*--ILRS-- sr4saurabh  */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define popb pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=10000000+6;
#define M_PI           3.14159265358979323846
//--------------------------------------------



//--------------------------------------------





//============================================
int main() {
    ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
    #ifndef ONLINE_JUDGE
       freopen ("INPUT.txt" , "r" , stdin);
       freopen ("OUTPUT.txt", "w" , stdout);
    #endif

	//THE WATER WAS DEEP, I DROWNED AND THEN CAME FLOATING UP,DEAD!!

     int n;
     cin>>n;
     ll ans = 0;
     for(int i = 1; i < n ; i++)
     {
     	int g = n/i;
     	if(n%i == 0)
     		g--;

     	ans += g;
     }
        
     cout<<ans;








return 0;
} 

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

P,Q,R = inputIL()

print(P+Q+R-max(P,Q,R))

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

const int maxn=2e5+7,p=1e9+7;
long long ans,fac[maxn],inv[maxn];
int n,a,b;

long long poww(long long a,long long b)
{
	long long ans=1,tmp=a;
	while(b) {
		if(b&1) ans=(ans*tmp)%p;
		tmp=(tmp*tmp)%p;
		b>>=1;
	}
	return ans;
}

long long c(int x)
{
	long long ans=1;
	for(int i=n;i>=n-x+1;--i) ans=(ans*i)%p;
	ans=(ans*inv[x])%p;
	return ans;
}

int main()
{
	scanf("%d %d %d",&n,&a,&b);
	fac[0]=inv[0]=1;
	for(int i=1;i<maxn;++i) fac[i]=(fac[i-1]*i)%p;
	inv[maxn-1]=poww(fac[maxn-1],p-2);
	for(int i=maxn-2;i;--i) inv[i]=(inv[i+1]*(i+1))%p;
	ans=poww(2,n)-1;
	ans=((((ans-c(a))%p+p)-c(b))%p)+p;
	printf("%lld",ans%p);
}

Measured memory_bytes: 3328
#include <cstdio>
#include <functional>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;

int main() {
    // input
    int n, m; scanf("%d%d", &n, &m);
    vector<vector<int> > g(n);
    repeat (i, m) {
        int a, b; scanf("%d%d", &a, &b); -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    // solve
    vector<char> used(n);
    function<int (int)> go = [&](int i) {
        used[i] = true;
        int cnt = 1;
        for (int j : g[i]) if (not used[j]) {
            cnt += go(j);
        }
        return cnt;
    };
    ll k0 = go(0);
    ll k1 = go(1);
    if (k0 > k1) swap(k0, k1);
    k1 += (n - k0 - k1);
    ll result = k0 * (k0 - 1) / 2 + k1 * (k1 - 1) / 2 - m;
    // output
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 12032
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  ll p[n];
  ll pd[n];
  rep(i,n) cin >> p[i];
  ll q[n];
  ll qd[n];
  rep(i,n) cin >> q[i];
  rep (i,n){
    pd[i]=p[i];
    qd[i]=q[i];
  }
  sort(p,p+n);
  ll co = 0;
  ll ans = 0;
  ll ans2  = 0;
  do{
    co++;
    rep (i,n){
      //pri3(i,p[i],pd[i]);
      if(p[i]!=pd[i]) break;
      if(i+1==n)ans = co;
    }
  }while(next_permutation(p,p+n));
  //pri(co);
  sort(q,q+n);
  ll co2 = 0;
  do{
    co2++;
    rep (i,n){
      if(q[i]!=qd[i]) break;
      if(i+1==n)ans2 = co2;
    }
  }while(next_permutation(q,q+n));
  pri(abs(ans-ans2));

  return 0;
}


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


Measured memory_bytes: 256
import sys

def solve(N: int, M:int, p_list:list, S_list:list):
    AC_count = [False for _ in range(N)]
    WA_count = [0 for _ in range(N)]
    point = 0
    pena = 0

    for i in range(M):
        if S_list[i] == 'AC':
            AC_count[p_list[i]-1] = True
        else:
            if AC_count[p_list[i]-1] == False:
                WA_count[p_list[i]-1] += 1
        
    for i in range(N):
        if AC_count[i]:
            point += 1
            pena += WA_count[i]

    print(str(point) + " " + str(pena))

    return

 
if __name__ == "__main__":
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    
    tokens = iterate_tokens()
    N = int(next(tokens))
    M = int(next(tokens))
    p_list = []
    S_list = []
    for i in range(M):
        p_list.append(int(next(tokens)))
        S_list.append(next(tokens))

    solve(N, M, p_list, S_list)

Measured memory_bytes: 14928
#include <stdio.h>
#include <stdlib.h>

void swap(int *, int *);

int main(void) 
{
  int i, j, N, min, *sequence, operation = 0;

  scanf("%d", &N);

  sequence = (int *) malloc(sizeof(int) * N);

  for (i = 0; i < N; i++) 
    scanf(" %d", &sequence[i]);

  for (i = 0; i < N; i++) {

    min = i;

    for (j = i; j < N; j++) 
      if (sequence[j] < sequence[min]) 
	min = j;

    if (min != i) {
      swap(&sequence[i], &sequence[min]);
      operation++;
    }
  }

  for (i = 0; i < N - 1; i++) 
    printf("%d ", sequence[i]);

  printf("%d\n", sequence[N - 1]);
  printf("%d\n", operation);

  return 0;
}

void 
swap(int *x, int *y) {

  int tmp;

  tmp = *x;
  *x  = *y;
  *y  = tmp;
}

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

public class Main {
	private static void solve(){
	//Implement solution here.
		long n = nl();
		long[] ta = new long[5];
		for(int i = 0; i < 5; i++) {
			ta[i] = nl();
		}		
		long maxd = 0;
		for(long t:ta) {
			maxd = n % t == 0 ? Math.max(maxd, n / t - 1) : Math.max(maxd, n / t);
		}			
		System.out.println(5L + maxd);		
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
    string n; cin >>n;
    int cnt=0;
    for(int i=0;i<4;i++){
    	if(n[i]=='2')cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<long long>a;
void solve()
{
  long long sum=0;
  for(int i=0;i<=10;i++)
  {
    sum+=i;
    a.push_back(sum);
  }
}
int main()
{
  solve();
  long long  n;
  cin>>n;
  map<long long,int>mp;
  set<long long>st;
  
  
  int ans=0;
  for(int i=2;(long long)i*i<=n;i++)
  {
    long long t=i;
    while(n%t==0)
    {
      st.insert(t);
      n/=t;
      mp[t]++;
    }
  }
  if(n>1 && mp[n]==0)
  {
    mp[n]=1;
    st.insert(n);
  }
  for(auto x:st)
  {
    int p=0;
    while(mp[x]>a[p])++p;
    ans+=p-1*(mp[x]!=a[p]);
    
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define itn int
#define rep(i, n) for(int i = 0; i < n; i++)
#define irep(i,n) for(int i = n-1; i>=0; i--)
#define FOR(a,b) for(int i=a; i<b+1; i++)
using namespace std;
typedef long long ll;
int a[100]={};
int main() {
    int n;
    cin >> n;
    for(int i=2;i!=n+1;i++){
        int tmp=i;
        for(int j=2;j!=i+1;j++){
            while(tmp%j==0){
                a[j]++;
                tmp/=j;
            }
        }
    }
    int sf=0;
    int tf=0;
    int ft=0;
    int f=0;
    int t=0;
    rep(i,n){
        if(a[i]>=74){
            sf++;
        }
        if(a[i]>=24){
            tf++;
        }
        if(a[i]>=14){
            ft++;
        }
        if(a[i]>=4){
            f++;
        }
        if(a[i]>=2){
            t++;
        }
    }
    cout << sf+tf*(t-1)+ft*(f-1)+f*(f-1)*(t-2)/2 <<  endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Kongo Type
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n--!=0){
			long X = Long.parseLong(sc.next(), 16);
			long a = (X&0x7fffff80)>>7;
			double b = 0, dt = 0.5;
			long f = X&0x7f;
			long pos = 1L<<6;
			while(0 < pos){
				if((f&pos)>0){
					b+=dt;
				}
				pos >>= 1;
				dt/=2;
			}
			String t = (b+"").substring(2);
			System.out.printf("%s%d.%s\n", ((X&0x80000000)>0)?"-":"", a, t);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using P   = pair<int, int>;
using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    string ans = "Yes";
    if(int(s.size()) < 4) ans = "No";
    if(s.substr(0, 4) != "YAKI") ans = "No";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
S = input()
cp, cg = 0, 0
ans = 0
for s in S:
    if s == 'g':
        if cp < cg:
            cp += 1
            ans += 1
        else:
            cg += 1
    elif s == 'p':
        if cp < cg:
            cp += 1
        else:
            cg += 1
            ans -= 1
print(ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int n;cin>>n;
	string ans="";
	while(n>0)
	{
		int d=(n-1)%26;
		ans=(char)(d+'a') + ans;
		n--;
		n/=26;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
strings = [input() for _ in range(n)]

sd = {}
for s in strings:
  if s in sd:
    sd[s] += 1
  else:
    sd[s] = 1

sorted_sd = sorted(sd.items(), key=lambda x:x[1], reverse=True)
pre_c = 0
ans = []
for s, c in sorted_sd:
  if c < pre_c:
    break
  ans.append(s)
  pre_c = c
for a in sorted(ans):
  print(a)

Measured memory_bytes: 48912
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	long long arr[50];
	int i;
	double sol;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf("%lld", &arr[i]);
	}

	sort(&arr[0], &arr[n]);

	sol = (double)arr[0];

	for (i = 1; i < n; i++)
	{
		sol = (sol + (double)arr[i]) / 2.0;
	}

	printf("%.7lf\n", sol);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
set<P> wh;
set<P> bl;

int main(){
    int A, B; cin >> A >> B;
    for(int i=0;i<A-1; i++){
        wh.insert( make_pair(i/50 *2 , i%50 *2) );
    }
    for(int j=0; j<B-1; j++){
        bl.insert( make_pair(99-j/50*2, j%50*2 ) );
    }

    cout <<100 <<" " <<100 << endl;
    for(int i=0; i<50; i++){
        for(int j=0; j<100; j++){
            if( wh.count( make_pair(i,j)) ){
            cout << '.';
            }
            else{
                cout << '#';
            }
        }
        cout << endl;
    }
    for(int i=0; i<50; i++){
        for(int j=0; j<100; j++){
            if( bl.count( make_pair(i+50,j)) ){
            cout << '#';
            }
            else{
                cout << '.';
            }
        }
        cout << endl;
    }
    
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#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 DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, p[60];
	cin>>n;
	REP(i, n){
		cin>>p[i];
	}
	bool ok=false;
	REP(i, n){
		REP(j, n){
			int tmp[60];
			REP(k, n){
				tmp[k]=p[k];
			}
			swap(tmp[i], tmp[j]);
			bool can=true;
			REP(k, n-1){
				if(tmp[k]>tmp[k+1]){
					can=false;
					break;
				}
			}
			if(can){
				ok=true;
				break;
			}
		}
	}
	cout<<(ok ? "YES" : "NO")<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#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 all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    int N;
    cin >> N;

    vl a(1000010, 0);
    set<ll> m;
    set<ll> m2;
    rep (i, N) {
        ll tmp = 0;
        cin >> tmp;

        if (m.count(tmp)) {
            m2.insert(tmp);
        } else {
            m.insert(tmp);
        }

        a[tmp] = 1;
    }

    rep (i, a.size()) {
        if (!a[i]) continue;
        // ll n = a[i];
        for (int j = i*2; j<=a.size(); j += i) {
               a[j] = 0;
        }
    }

    for (auto st : m2) {
        a[st] = 0;
    }

    ll ans = 0;
    rep (i, a.size()) {
        if (a[i]) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 20344
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string str;
    getline(cin, str);

    size_t k;
    cin >> k;

    vector<int64_t> dp_less(k + 1, 0);
    vector<int64_t> dp_equal(k + 1, 0);
    dp_equal[0] = 1;

    for (const auto &dig : str) {
        vector<int64_t> next_dp_less(k + 1, 0);
        vector<int64_t> next_dp_equal(k + 1, 0);

        for (size_t i = 0; i <= k; i += 1) {
            next_dp_less[i] = dp_less[i];
            if (dig > '0') {
                next_dp_less[i] += dp_equal[i];
            }
            if (i > 0) {
                next_dp_less[i] += dp_less[i - 1] * 9;
            }
            if (i > 0 && dig > '0') {
                next_dp_less[i] += dp_equal[i - 1] * (dig - '1');
            }

            if (dig == '0') {
                next_dp_equal[i] = dp_equal[i];
            } else if (i > 0) {
                next_dp_equal[i] = dp_equal[i - 1];
            }
        }

        dp_less = next_dp_less;
        dp_equal = next_dp_equal;
    }

    cout << dp_less[k] + dp_equal[k] << "\n";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

cnt = 1
def dfs(x):
    global cnt
    if s[x] == None:
        s[x] = cnt
        cnt += 1
    for v in edges[x]:
        if s[v] == None:
            dfs(v)
    g[x] = cnt
    cnt += 1
    return 

n = I()
edges = [[] for _ in range(n)]
for i in range(n):
    edges[i] = list(map(lambda x:x-1,LI()[2:]))

s = [None]*n
g = [None]*n
for i in range(n):
    if s[i] == None:
        dfs(i)
for i in range(n):
    print(i+1,s[i],g[i])
    
    



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

int main(){
    int n, m; cin >> n >> m;
    vector<int> memo(3, -1);
    
    for(int i=0; i<m; i++){
        int s, c; cin >> s >> c;
        if(memo[s-1] == -1){
            memo[s-1] = c;
        }else if(memo[s-1] == c){
            continue;
        }else if(memo[s-1] != c){
            cout << -1 << endl;
            return 0;
        }
    }
    int ans=0;
    if(n==1){
        if(memo[0]==-1) ans = 0;
        else ans = memo[0];
    }else if(n==2){
        if(memo[0]==-1 && memo[1]==-1) ans = 10;
        if(memo[0]==-1 && memo[1]!=-1) ans = 10 + memo[1];
        if(memo[0]!=-1 && memo[1]==-1) ans = memo[0]*10;
        if(memo[0]!=-1 && memo[1]!=-1) ans = memo[0]*10 +memo[1];
    }else if(n==3){
        if(memo[0]==-1 && memo[1]==-1 && memo[2]==-1) ans = 100;
        if(memo[0]==-1 && memo[1]==-1 && memo[2]!=-1) ans = 100 + memo[2];
        if(memo[0]==-1 && memo[1]!=-1 && memo[2]==-1) ans = 100 + memo[1]*10;
        if(memo[0]!=-1 && memo[1]==-1 && memo[2]==-1) ans = memo[0]*100;
        if(memo[0]==-1 && memo[1]!=-1 && memo[2]!=-1) ans = 100 + memo[1]*10 + memo[2];
        if(memo[0]!=-1 && memo[1]==-1 && memo[2]!=-1) ans = memo[0]*100 + memo[2];
        if(memo[0]!=-1 && memo[1]!=-1 && memo[2]==-1) ans = memo[0]*100 + memo[1]*10;
        if(memo[0]!=-1 && memo[1]!=-1 && memo[2]!=-1) ans = memo[0]*100 + memo[1]*10 +memo[2];
    }
    
    
    if((n!=1 && memo[0]==0 && memo[1]!=0 && memo[2]!=0)|| (n!=1 && memo[0]==0 && memo[1]==0 && memo[2]!=0)){
        cout << -1 << endl; return 0;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int n,x;
    int count;
    int flag ;

    cin >> n >> x;

    while((n!=0)||(x!=0)){
        count = 0;
        flag =0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                   if(i+j+k == x){
                        count++;
                        break;
                   }
                }
            }
        }
        cout << count <<endl;
        cin >> n >> x;
    }




    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	int stu[51][51];
	int check[51][51];
	int a[51], b[51], c[51], d[51];
	int min;
	int sub;
	
	cin >> n >> m;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}
	
	for (int i = 0; i < n; i++) {
		min = abs(a[i] - c[0]) + abs(b[i] - d[0]);
		sub = 1;
		for (int j = 0; j < m; j++) {
			if (min > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				sub = j + 1;
			}
		}
		cout << sub << endl;
	}
	
	return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll num[21];

bool flag(){
    bool f=true;
    for(ll i=0;i<21;i++){
        if(num[i]>1) f=false;
    }
    return f;
}

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ll l=0;
    ll r=0;
    ll ans=0;
    while(r<n){
        while(true && r<n){
            ans+=r-l+1;
            for(ll i=0;i<21;i++){
                num[i]+=(a[r]>>i & 1);
            }
            if(!flag()){
                ans-=r-l+1;
                break;
            }
            //cout<<num[2]<<num[1]<<num[0]<<endl;
            //cout<<l<<" "<<r<<" "<<ans<<endl;
            r++;
        }
        while(l<r){
            for(ll i=0;i<21;i++){
                num[i]-=(a[l]>>i & 1);
            }
            l++;
            if(flag()){
                for(ll i=0;i<21;i++){
                    num[i]-=(a[r]>>i & 1);
                }
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <ctype.h>

using namespace std;

int main()
{
	char s;
	cin >> s;
	if (isupper(s)) {
		s = 'A';
	} else {
		s = 'a';
	}
	cout << s << endl;
}


Measured memory_bytes: 3040
def dfs(s)
  return 0 if s.to_i > N #終了条件
  ret = 0
  ret = 1 if s.include?(?3) && s.include?(?5) && s.include?(?7)
  "753".chars do |i| #末尾に7,5,3をつける3分岐
    ret += dfs( s + i )
  end
  return ret
end

N = gets.to_i
p dfs('0')

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

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

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s; int k;
	cin >> s >>k;
	
	int n=sz(s);
	rep(i,n){
		if(s[i]=='a') continue;
		if(k<1) break;
		int cr = s[i]-'a';
		if(26-cr <= k){
			k -= 26-cr; s[i]='a';
		}
	}
	
	//printf("k=%d\n",k);
	int cr = s[n-1]-'a';
	s[n-1] = (cr + k)%26 + 'a';
	cout << s <<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    long double sum=0;
    for(int i=0;i<n;i++)
    {
    cin>>a[i];
    sum=sum+(1.0/a[i]);
    }
    sum=1/sum;
    cout<< sum;
    
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N, sum = 0;
    cin >> N;
    vector<Pint> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i).first;
        sum += A.at(i).first;
        A.at(i).first *= N;
        A.at(i).second = i;
    }
    for (int i = 0; i < N; i++){
        A.at(i).first = abs(A.at(i).first - sum);
    }
    sort(ALL(A));
    cout << A.at(0).second << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    vector<int> a(5);
    for(int i=0; i<5; i++) cin >> a[i];
    int time=0, min1=a[0]%10, argmin=0;
    for(int i=1; i<5; i++){
        if(a[i]%10!=0){
            if(min1 == 0){
                min1 = a[i]%10;
                argmin = i;
            }
            else if(min1 > a[i]%10){
                min1 = a[i]%10;
                argmin = i;
            }
        }
    }
    for(int i=0; i<5; i++){
        if(i == argmin){
            time += a[argmin];
        }
        else{
            if(a[i]%10 == 0) time += a[i];
            else time += a[i] - a[i]%10 + 10;
        }
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int A,B;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> A >> B;
}

void printS(vector<vector<char>> s){
    int h=s.size();
    int w=s[0].size();
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << s[i][j];
        }
        cout << "\n";
    }
    
}

int solve(){
    int h=100,w=100;
    A--;
    B--;
    vector<vector<char>> S(h,vector<char>(w,'.'));
    cout << h << " " << w << endl;
    int cntA=0,cntB=0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(cntA<A && i%2==0){
                if(j%2==1) S[i][j]='#';
                if(j%2==0) cntA++;
            }
            else{
                S[i][j]='#';
            }
        }
        
    }

    for (int i = h-1; i > h/2; i--)
    {
        for (int j = 0; j < w; j++)
        {
            if(cntB<B && i%2==0){
                if(j%2==1) S[i][j]='.';
                if(j%2==0) cntB++;
            }
            else{
                S[i][j]='.';
            }
        }
        
    }

    printS(S);
    
    return 0;
}   

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


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n = int(input())
    xy = []
    for _ in range(n):
        x, y = map(int, input().split())
        xy.append((x, y))
    dist = 0
    for j in range(n):
        x1, y1 = xy[j]
        for i in range(j):
            x0, y0 = xy[i]
            dist += ((x0 - x1) ** 2 + (y0 - y1) ** 2) ** 0.5
    print(dist * 2 / n)

main()


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

using namespace std;

int main(int argc, const char * argv[])
{
    int N;
    int P[8], Q[8];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> P[i];
    for (int i = 0; i < N; ++i) cin >> Q[i];

    int a = 1, b = 1;
    int kaijo = 1;
    for (int i = N - 2; i >= 0; --i) {
        int cp = 0, cq = 0;
        for (int j = i + 1; j < N; ++j) {
            if (P[i] > P[j]) cp++;
            if (Q[i] > Q[j]) cq++;
        }
        a += kaijo * cp;
        b += kaijo * cq;
        kaijo *= N - i;
    }

    cout << abs(a - b);
    return 0;
}


Measured memory_bytes: 256
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):
 l=len(A);global c;c+=l
 s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
c=0
n=int(input())
print(*d(list(map(int,input().split()))))
print(c-n)


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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

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

const int N = int(2e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

int n, m;

struct bus {
    int cost, val;
}a[N];

bool cmp (bus a, bus b){
    if (a.cost == b.cost) return a.val < b.val;
    return a.cost < b.cost;
}

int main (){
    scanf ("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i){
        scanf ("%d %d", &a[i].cost, &a[i].val);
    }
    sort (a + 1, a + n + 1, &cmp);
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        if (m > 0){
            ans += (a[i].cost * 1ll * min(m, a[i].val));
            m -= min(m, a[i].val);
        }
    }
    return !printf ("%lld\n", ans);
}


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

#define int long long
#define F first
#define S second

const int MOD = 1000 * 1000 * 1000 + 7;
int32_t main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a[n], dis[n], sum[n], fact[n + 10], inv[n + 10];
	fact[0] = fact[1] = 1;
	inv[0] = inv[1] = 1;
	for (int i = 2; i < n + 10; i++) {
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	}
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int ans = 0;
	sum[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		ans += ((sum[i] + i + 1) * inv[i + 1] % MOD * (a[i + 1] - a[i])) % MOD;
		sum[i + 1] = (sum[i] + (sum[i] + i + 1) * inv[i + 1] % MOD) % MOD;
	}
	ans %= MOD;
	cout << ans * fact[n - 1] % MOD;
}



Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC148D - Brick Break

        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 ans = 0;
        int idx = 0;
        for (int i = 0; i < n; i++) {
            if (n == idx) break;
            for (int j = idx; j < n; j++) {
                idx++;
                if (a[j] == i + 1) {
                    break;
                } else {
                    ans++;
                }
            }
        }

        if (ans == n) ans = -1;

        System.out.println(ans);
    }
}


Measured memory_bytes: 80324
#include <stdio.h>

int main(void){
    int N;
    scanf("%i", &N);
    int A[N];
    double bunbo = 0;
    double B[N];
    for (int i = 0; i < N; i++){
        scanf("%i", &A[i]);
        B[i] = 1.0 / A[i];
        bunbo += B[i];
    }
    printf("%f", 1.0 / bunbo);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

//fixed << setprecision(8)

using namespace std;

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

int main()
{
	ll n,ans=0;
	string s;

	cin >> n;

	vector<ll> a(n);

	forll(i, 0, n)
		cin >> a[i];

	sort(a.begin(), a.end(), greater<ll>());

	ans+=a[0] / 2;

	forll(i, 1, n)
	{
		ans += a[i];
	}

	cout << ans;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main()
{
    ll A, B;
    string op;

    cin >> A >> op >> B;

    if (op == "+") { cout << A + B << endl; }
    else { cout << A - B << endl; }
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

double E(double p){
    return p*(p+1.0)/(2.0*p);
}

int main(){
    LL n,k;
    cin>>n>>k;
    Vll p(n);
    REP(i,n) cin>>p[i];
    
    V<double> e;
    REP(i,n){
        e.pb(E(double(p[i])));
    }

    V<double> e_sum(e.size()+1);
    REP2(i,1,e_sum.size()){
        e_sum[i] = e_sum[i-1] + e[i-1];
    }

    double max_e = 0.0;
    REP(i,n-k+1){
        max_e = max(max_e,e_sum[i+k]-e_sum[i]);
    }

    cout<<fixed<<setprecision(10)<<max_e<<endl;

    return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include <numeric>
#include <vector>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 998244353;
using mint = ModInt<MOD>;

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;
    int s = std::accumulate(xs.begin(), xs.end(), 0);

    std::vector<mint> dp(s + 1, 0), ndp(s + 1, 0);
    dp[0] = 1;
    ndp[0] = 1;
    for (auto x : xs) {
        for (int y = s; y >= 0; --y) {
            dp[y] *= 2;
            if (y >= x) {
                dp[y] += dp[y - x];
                ndp[y] += ndp[y - x];
            }
        }
    }

    mint out = std::accumulate(dp.begin() + (s + 1) / 2, dp.end(), mint(0));
    if (s % 2 == 0) out -= ndp[s / 2];

    std::cout << mint(3).pow(n) - out * 3 << std::endl;
}

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

    solve();

    return 0;
}


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

string solve(int n) {
    int x;
    for (int i = 1; i < 10; i++) {
        if (n % i == 0) {
            x = n / i;
            if (x < 10) {
                return "Yes";
            }
        }
    }
    return "No";
}

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

    cout << solve(n);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    bool not_zero = false;
    int min_not_zero = INT64_MAX;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 10 != 0) {
            not_zero = true;
            min_not_zero = min(min_not_zero, a[i]);
        }
        sum += a[i];
    }
    if (sum % 10 != 0) {
        cout << sum << "\n";
    }
    else if (not_zero) {
        cout << sum - min_not_zero << "\n";
    } else {
        cout << "0\n";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <functional>
#include <tuple>

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define fst first
#define scd second

using pii=pair<int,int>;
using vpii=vector<pii>;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

struct edge{
};

int y, x;

void print()
{
    cout << "(" << x << ", " << y << ")\n";
}

void moveL()
{
    x--;
    cout<<'L';
}
void moveR()
{
    x++;
    cout<<'R';
}
void moveU()
{
    y++;
    cout<<'U';
}
void moveD()
{
    y--;
    cout<<'D';
}

signed main()
{
    int sy, sx; cin >> sx >> sy;
    int ty, tx; cin >> tx >> ty;

    y = sy;
    x = sx;

    while (y != ty) moveU();
    while (x != tx) moveR();

    moveD();

    while (x != sx + 1) moveL();
    while (y != sy) moveD();

    moveL();

    moveL();

    while (y != ty+1) moveU();
    while (x != tx) moveR();

    moveD();
    moveR();
    moveD();
    moveD();

    while (x != sx+2) moveL();
    while(y!=sy-1) moveD();
    while(x!=sx) moveL();
    while(y!=sy) moveU();
    cout<<endl;
}


Measured memory_bytes: 384