akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

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

    if(c < b)
    {
        int t;
        t = b;
        b = c;
        c = t;
    }
    if(b < a)
    {
        int t;
        t = a;
        a = b;
        b = t;
    }
    if(c < b)
    {
        int t;
        t = b;
        b = c;
        c = t;
    }
    cout << a << " " << b << " " << c << endl;

    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 998244353LL;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    constexpr int lim = 1000000;
    cin >> n;
    vector<int> a(n);
    vector<mint> co(lim + 10), s(lim + 10), t(lim + 10);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        co[a[i]] += a[i];
    }
    for (int k = 1; k <= lim; k++) {
        for (int i = k; i <= lim; i += k) {
            t[k] += co[i];
        }
        t[k] = t[k] * t[k];
    }
    mint ans = 0;
    for (int k = lim; k >= 1; k--) {
        s[k] = t[k];
        for (int i = 2 * k; i <= lim; i += k) {
            s[k] -= s[i];
        }
        ans += s[k] / mint(k);
    }
    for (int i = 0; i < n; i++) {
        ans -= mint(a[i]);
    }
    ans /= mint(2LL);
    cout << ans.a << endl;
}

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

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a=Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
        var ap=new primenum[n];
        var l=new Dictionary<int,int>();
        var mf=MinFactors(a.Max());
        for(var i=0;i<n;i++){
            var tmp=PrimeFactors(a[i],mf);
            ap[i]=new primenum(i,tmp);
            foreach(var v in tmp) {
                if(l.ContainsKey(v.Key)){
                    if(l[v.Key]<v.Value){
                        l[v.Key]=v.Value;
                    }
                }else{
                    l.Add(v.Key, v.Value);
                }
            }
        }
        var ldn=1L;
        var mdn=(long)(Math.Pow(10,9)+7);
        foreach(var v in l) {
            for(var i=0;i<v.Value;i++){
                ldn*=(long)v.Key%mdn;
                ldn%=mdn;
            }
        }
        var ans=0L;
        for(var i=0;i<n;i++){
            ans+=ldn*modinv((long)a[i],mdn)%mdn;
            ans%=mdn;
        }
        Console.WriteLine(ans);
    }

    static Dictionary<int,int> PrimeFactors(int n,Dictionary<int,int> mf)
    {
        var cnt=new Dictionary<int,int>();

        while (n > 1)
        {
            var prime=mf[n];
            var exp=0;
            while(mf[n]==prime){
                exp++;
                n /= prime;
            }
            cnt.Add(prime,exp);
        }
        return cnt;
    }
    
    static Dictionary<int,int> MinFactors(int n){
        var mf=new Dictionary<int,int>();
        
        for(var i=0;i<=n;i++){
            mf.Add(i,i);
        }
        
        for(var i=2;i*i<=n;i++){
            if(mf[i]==i){
                mf[i]=i;
                for(var j=i*i;j<=n;j+=i){
                    if(mf[j]==j) mf[j]=i;
                }
            }
        }
        
        return mf;
    }
    
    static long modinv(long a,long m){
        var b=m;
        var u=1L;
        var v=0L;
        while(b>0){
            long t=a/b;
            a-=t*b;Swap(ref a,ref b);
            u-=t*v;Swap(ref u,ref v);
        }
        u%=m;
        if(u<0) u+=m;
        return u;
    }
    
    static void Swap<T>(ref T lhs, ref T rhs)
    {
        T temp;
        temp = lhs;
        lhs = rhs;
        rhs = temp;
    }
}

public class primenum{
    public int num;
    public Dictionary<int,int> prime;
    
    public primenum(int n,Dictionary<int,int> p){
        this.num=n;
        this.prime=p;
    }
}


Measured memory_bytes: 48408
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define INF 2000000000	//int型は2 * 10^9ぐらいまで
#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

bool check(string str){
	if(str.size() % 2 != 0) rtn false;
	for(unsigned i = 0;i < str.size() / 2;i++){
		if(str[i] != str[i + str.size()/2]) rtn false;
	}
	rtn true;
}
signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	s.pop_back();
	while(!s.empty()){
		if(check(s) == true){
			cout << s.size() << endl;
			rtn 0;
		}
		else s.pop_back();
	}
}

Measured memory_bytes: 256
use std::io;

fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

// https://abc079.contest.atcoder.jp/tasks/abc079_a

fn main(){
    let line = read_line();
    let split : Vec<&str> = line.trim().split(' ').collect();
    let n : i32= split[0].parse().unwrap();

    let mut vec = Vec::new();
    vec.push(2 as i64);
    vec.push(1);

    for i in 0..n-1{
        let len = vec.len();
        let v = vec[len-1] + vec[len-2];
        vec.push(v);
    }

    println!("{}",vec[n as usize]);

}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	if(N%2){
		out("No");
		return 0;
	}
	string S=in<string>();
	string T = S.substr(0,S.size()/2);
	string U = T+T;
	out(S==U?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int N = 190;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

template <typename T> inline void cmax(T &x, T y) {
	if (x < y) x = y;
}

char s[N];
int n, m, g[N][N];
int dp[2][N][N][N];

void init() {
	read(n); read(m);
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s + 1);
		for (int j = 1; j <= m; ++j) {
			g[i][j] = ((s[j] == '#')? 1 : 0);
			g[i][j] += g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1];
		}
	}
}

void solve() {
	for (int l = 1; l <= m; ++l) {
		for (int r = l; r <= m; ++r) {
			for (int i = 1; i <= n; ++i) {
				int x = max(i - 1, dp[0][i - 1][l][r]);
				while (x < n) {
					int cnt = g[x + 1][r] - g[i - 1][r] - g[x + 1][l - 1] + g[i - 1][l - 1];
					if (cnt == 0 || cnt == (x - i + 2) * (r - l + 1)) ++x;
					else break;
				}
				dp[0][i][l][r] = x;
			}
		}
	}
	int k = 1, pre = 0, cur = 1;
	for (; dp[pre][1][1][m] < n; ++k) {
		mset(dp[cur], 0);
		for (int i = 1; i <= n; ++i) {
			for (int l = 1; l <= m; ++l) {
				int p = l;
				for (int r = l; r <= m; ++r) {
					if (dp[pre][i][l][r] == n) {
						dp[cur][i][l][r] = n;
						continue;
					}
					dp[cur][i][l][r] = dp[pre][ dp[pre][i][l][r] + 1 ][l][r];
					while (p + 1 < r && dp[pre][i][l][p + 1] >= dp[pre][i][p + 2][r]) {
						++p;
					}
					cmax(dp[cur][i][l][r], min(dp[pre][i][l][p], dp[pre][i][p + 1][r]));
					if (p + 2 > r) continue;
					cmax(dp[cur][i][l][r], min(dp[pre][i][l][p + 1], dp[pre][i][p + 2][r]));
				}
			}
		}
		swap(pre, cur);
	}
	printf("%d\n", k - 1);
}

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

Measured memory_bytes: 54016
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	long double a, b; //long double は10進数で約19桁の精度
	cin >> a >> b;
	cout << (ll)(b*a) << endl; //Aとの積を100で割って出力
}

Measured memory_bytes: 3664
#include <iostream>
#include <queue>

using namespace std;

int main(){

    int n, x;
    int sum;
    int cnt = 0;
    queue<int> result;
    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0){
            break;
        }
        cnt  = 0;
        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){
                for(int k=j+1; k<=n; k++){
                    sum = 0;
                    sum = i+j+k;
                    if(sum == x) cnt++;
                }
            }
        }
        result.push(cnt);
    }

    int length = result.size();
    for(int i=0; i<length; i++){
        cout << result.front() << endl;
        result.pop();
    }

    return  0;
}

Measured memory_bytes: 3076
#include<iostream>

using namespace std;

int main(){
  int n,mon;
  long def=0;
  cin >> n;
  int a[n+1],b[n];
  for(int i=0;i<n+1;i++){
    cin >> a[i];
  }
  for(int j=0;j<n;j++){
    cin >> b[j];
  }

  mon=a[n];
  for(int i=n-1;i>=0;i--){
      if(mon-b[i]>=0){
        def+=b[i];
        mon=a[i];
      }else{
        if(a[i]+mon-b[i]>=0){
          def+=b[i];
          mon=a[i]+mon-b[i];
        }else{
          def+=mon+a[i];
          mon=0;
        }
      }


  }
  cout << def << endl;

  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var M = sc.ReadInt();
        var p = new int[N];
        for (int i = 0; i < M; i++)
        {
            var a = sc.ReadInt() - 1;
            var b = sc.ReadInt() - 1;
            p[a]++;
            p[b]++;
        }
        for (int i = 0; i < N; i++)
        {
            Console.WriteLine(p[i]);
        }
    }
    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 11092
a = list(map(int, input().split()))
w = 0
z = 0
x = 0
y = 0

w = a[0] * a[2]
z = a[0] * a[3]
x = a[1] * a[2]
y = a[1] * a[3]
print(max(w,z,x,y))

Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
str s;
int main(){
  cin>>s;
  int ss=s.size();
  int l,r;
  rep(i,ss){
    if(s[i]=='A'){
      l=i;
      break;
    }
  }
  rep(i,ss){
    if(s[ss-1-i]=='Z'){
      r=ss-1-i;
      break;
    }
  }
  prin(r-l+1);

  
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define NMAX 103
#define MMAX 103
 
//コメントアウトするとdebug()を実行しない
#define DEBUG
 
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
int N,T[NMAX],M,P[MMAX],X[MMAX],sum = 0;
char C;
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};
 

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> T[i];
		sum += T[i];
	}
	cin >> M;
	for (int i = 0; i < M; ++i)
	{
		cin >> P[i] >> X[i];
		cout << sum-T[P[i]-1]+ X[i] << "\n";
 
	}
 
	return 0;
}

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

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

	int n; cin >> n;
	vector<long long> a(n);
	map<long long,long long> acnt;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(acnt.count(a[i])){
			acnt[a[i]] = acnt[a[i]] + 1;
		}else{
			acnt[a[i]] = 1;
		}
	}
	vector<long long> asum(1000000,-1);
	vector<long long> asum2(1000000);
	long long sum = 0;
	for(int i = 0; i < n; i++){
		if(asum[a[i]] == -1LL){
			asum[a[i]] = (long long)(acnt[a[i]] * (acnt[a[i]] - 1) / 2);
			asum2[a[i]] = (long long)((acnt[a[i]]-1) * (acnt[a[i]] - 2) / 2);
			sum += (long long)asum[a[i]];
		}
	}
	for(int i = 0; i < n; i++){
		long long tmp = (asum[a[i]] - asum2[a[i]]);
		cout << (sum-tmp) << endl;
	}
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	bool ok = false;
	rep(i, n -1){
		if(a.at(i) == a.at(i + 1)){
			ok = true;
			break;
		}
	}
	if(ok) cout << "NO" << endl;
	else cout << "YES" << endl;	
} 

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

int main(){
  string s, t;
  cin >> s >> t;
  if (s.size() < t.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  int l = s.size() - t.size() + 1;
  bool judge = 0;
  string ans;
  rep(i, l){
    string tmp = s;
    rep(j, t.size()){
      if (tmp[i+j] == '?' || tmp[i+j] == t[j]) tmp[i+j] = t[j];
      else break;
      
      if (j == t.size() - 1){
        rep(i, tmp.size()){
          if (tmp[i] == '?') tmp[i] = 'a';
        }
        judge = 1;
        ans = tmp;
      }
    }
  }
  
  if (judge) cout << ans << endl;
  else cout << "UNRESTORABLE" << endl;
    
      
      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

using ll = long long;

mint solve(ll A,ll B,ll C,ll D){
	if(C<=D+1) return 0;
	vector<ll> hs;
	rep(x,D+2){
		hs.pb(C*x/A+1);
		hs.pb(C*x/B+1);
		hs.pb(C*(A-x)/A+1);
		hs.pb(C*(B-x)/B+1);
	}
//	rep1(i,C-D) hs.pb(i);
	{
		vector<ll> tmp;
		for(ll h:hs){
			if(1<=h && h<=C-(D+1)) tmp.pb(h);
		}
		hs = tmp;
	}
	hs.pb(C-(D+1)+1);
	sort(all(hs));
	hs.erase(unique(hs.begin(),hs.end()),hs.end());
	int K = hs.size();
	mint res = 0;
	rep(i,K-1){
		ll h = hs[i];
		ll Alen=0,Blen=0;
		{
			ll h_ = min(h,C-h);
			Alen = min(A*h_/C+1+D,min(2*D+1,A));
		}
		{
			ll h_ = min(h,C-h);
			Blen = min(B*h_/C+1+D,min(2*D+1,B));
		}
		res += mint(1) * (hs[i+1]-hs[i]) * Alen * Blen;
	}
	return res;
}

int main(){
	ll A,B,C,D;
	cin>>A>>B>>C>>D;
	mint ans = mint(1) * min(A,D+1) * min(B,D+1) * min(C,D+1);
	ans += solve(A,B,C,D);
	ans += solve(B,C,A,D);
	ans += solve(C,A,B,D);
	cout << ans << endl;
}


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

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    ll n, p; cin >> n >> p;

    ll ans = 1;
    if (n == 1) ans = p;
    else {
        auto res = primeFactorize(p);
        for (auto x : res) {
            if (x.second >= n)
                ans *= pow(x.first, (x.second / n));
        }
    }

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

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

using namespace std;

int main() {
    
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if (j < m) dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
            if (i < n) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (i < n && j < m) 
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]));
        }
    }
    
    cerr << dp[n][m] << endl;
    int pi = n, pj = m;
    string ans = "";
    while (pi > 0 && pj > 0) {
        if (s[pi - 1] == t[pj - 1] && dp[pi][pj] == 1 + dp[pi - 1][pj - 1]) {
            ans += s[pi - 1];
            --pi; --pj;
        } else if (dp[pi][pj] == dp[pi - 1][pj]) --pi;
        else --pj;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35584
n = int(input())
a = list(map(int,input().split()))

mod = 10**9+7

array = [0] * 60

for i in a:
    for j in range(len(bin(i))-2):
        # print(bin(i),i >> j & 1)
        array[j] += (i >> j) & 1

ans = 0
# print(array)

for i in range(60):
    ans += array[i] * (n-array[i]) * 2**i

print(ans % mod)

Measured memory_bytes: 122808
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	ll n, d; cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		ans += (a * a + b * b <= d * d);
	}
	cout << ans;


}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 3544
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                                               \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \
       << " " << __FILE__ << endl;

void solve(long long P, long long Q, long long R) {
  vector<LL> a;
  a.PB(P);
  a.PB(Q);
  a.PB(R);
  SORT(a);
  cout << a[0]+a[1] <<endl;
}

int main() {
  long long P;
  scanf("%lld", &P);
  long long Q;
  scanf("%lld", &Q);
  long long R;
  scanf("%lld", &R);
  solve(P, Q, R);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=100100,P=1000000007;
int i,j,k,n,m,ch,ff,ans;
int a[N],b[N],z[N],fg[N],num[N],f[N],Jc[N],Jc_[N],tm2[N],d[N],dp[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
int ksm(int x,int y) {
	int z=1;
	for (;y;y>>=1,x=(ll) x*x%P) if (y&1) z=(ll) z*x%P;
	return z;
}
void pre(int n) {
	int i;
	Jc[0]=Jc_[0]=f[0]=tm2[0]=1;
	for (i=1;i<=n;i++) tm2[i]=(tm2[i-1]+tm2[i-1])%P;
	for (i=1;i<=n;i++) f[i]=(ll) f[i-1]*(2*i-1)%P;
	for (i=1;i<=n;i++) Jc[i]=(ll) Jc[i-1]*i%P;
	Jc_[n]=ksm(Jc[n],P-2);
	for (i=n-1;i;i--) Jc_[i]=(ll) Jc_[i+1]*(i+1)%P;
}
int C(int n,int m) {
	return (ll) Jc[n]*Jc_[m]%P*Jc_[n-m]%P;
}
int Js(int n,int m) {
	int i,k,ans=0;
	if ((m&1) && m>1) {
		for (i=0,k=1;i+i<=n;i++,k=(ll) k*m%P) ans=((ll) f[i]*k%P*C(n,i+i)%P*tm2[n-i-i]%P+ans)%P;
	}
	else {
		for (i=0,k=1;i+i<=n;i++,k=(ll) k*m%P) ans=((ll) f[i]*k%P*C(n,i+i)%P+ans)%P;
	}
	return ans;
}
int main() {
	R(n);
	pre(n);
	for (i=1;i<=n;i++) R(a[i]);
	for (i=1;i<=n;i++) d[a[i]]++;
	for (i=1;i<=n;i++) if (!z[i]) {
		for (j=i;z[j]!=i && !z[j];j=a[j]) z[j]=i;
		if (z[j]==i) {
			fg[j]=1;
			for (k=a[j];k!=j;k=a[k]) fg[k]=1;
		}
	}
	for (i=1;i<=n;i++) if (d[i]>fg[i]+1) return puts("0"),0;
	for (i=1;i<=n;i++) if (!fg[i]) b[a[i]]=i;
	for (i=1;i<=n;i++) if (fg[i]) {
		for (j=b[i];j;j=b[j]) dp[i]++;
	}
	memset(z,0,sizeof z);
	ans=1;
	for (i=1;i<=n;i++) if (!z[i] && fg[i]) { 
		int nm=0,Fg=0;
		for (j=i;!z[j];j=a[j]) {
			z[j]=1;
			nm++;
			if (dp[j]) Fg=j;
		}
		if (!Fg) num[nm]++;
		else {
			k=0;
			for (j=a[Fg];j!=Fg;j=a[j]) {
				k++;
				if (dp[j]) {
					if (dp[j]>k) ans=0;
					if (dp[j]<k) ans=(ans+ans)%P;
					k=0;
				}
			}
			k++;
			if (dp[Fg]>k) ans=0;
			if (dp[Fg]<k) ans=(ans+ans)%P;
		}
	}
	for (i=1;i<=n;i++) if (num[i]) ans=(ll) ans*Js(num[i],i)%P;
	printf("%d\n",ans);
}

Measured memory_bytes: 4480
from collections import deque
def bfs(s):
    visited = [-1 for _ in range(n)]
    visited[0] = 0
    inf = float("inf")
    que = deque()
    que.append(s)
    while que:
        p = que.popleft()
        for i in grid[p]:
            if visited[i]==-1:
                que.append(i)
                visited[i] = p
    return visited

n, m = map(int, input().split())
grid = [[] for _ in range(n)]

for i in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    grid[a].append(b)
    grid[b].append(a)

v=bfs(0)

if - 1 in v:
    print("No")
else:
    print("Yes")
    [print(i+1) for i in v[1:]]

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
const lint mod = 1000000007;

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

lint pow_two(lint n)
{
    lint tmp = 1;
    REP(i, n) tmp = (tmp * 2) % mod;
    return tmp;
}

int main()
{
    lint n;
    cin >> n;
    vector<lint> a(n),b(n);
    map<plint, lint> m;
    lint zerozero = 0;
    REP(i, n) {
        cin >> a[i] >>b[i];
        if (a[i] == 0&&b[i]==0)
        {
            zerozero++;
            continue;
        }
        if(a[i]==0){
            b[i] = -1;
        }else if (b[i] == 0)
        {
            a[i] = 1;
        }else{
        lint x = gcd(abs(a[i]), abs(b[i]));
        a[i] /= x;
        b[i] /= x;
        if(a[i]<0&&b[i]<0){
            a[i] = -a[i];
            b[i] = -b[i];
        }
        if (a[i] < 0 && b[i] > 0)
        {
            a[i] = -a[i];
            b[i] = -b[i];
        }
        }
        plint p = make_pair(a[i], b[i]);
        if(!m.count(p)){
            m[p] = 1;
        }else{
            m[p] = m[p] + 1;
        }
    }
    lint ans = 1;
    for(auto pp:m){
        plint p = pp.first;
        plint p1 = make_pair(p.second, -p.first);
        plint p2 = make_pair(-p.second, p.first);
        lint z = 0;
        if (m.count(p1))
        {
            z =z+ m.at(p1);
            m[p1] = 0;
        }
        if (m.count(p2))
        {
            z =z+ m.at(p2);
            m[p2] = 0;
        }
        lint now = pow_two(z) + pow_two(pp.second) - 1;
        ans = ((ans*now)%mod) + mod;
        //ans *= tmp;
        plint p3 = make_pair(-p.first, -p.second);
        if (m.count(p3))
        {
            m[p3] = 0;
        }
        m[p] = 0;
    }
    cout << (((ans + mod +zerozero)-1)%mod) << "\n";
    //cout << ans-1 << "\n";

    return 0;
}

Measured memory_bytes: 18680
#include <iostream>

using namespace std;

int main() {
    char c;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c;
            if (i == j) {
                cout << c;
            }
        }
    }
    cout << "\n";
}

Measured memory_bytes: 256
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N,K= map(int,input().split())
mod = 10**9+7
for i in range(1,K+1):
    remain = N-K-i+1
    #間の選び方
    if remain < 0:
        ans = 0
    else:
        bet = cmb(K-1,i-1)
        ass = cmb(remain+i,i)
        ans = ass*bet%mod
    print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int building[4][3][10];
    for(int i = 0; i < 4; i++){ //棟
        for(int j = 0; j < 3; j++){ //階
            for(int k = 0; k < 10; k++){
                building[i][j][k] = 0;
            }
        }
    }
    // vector<vector<vector<int>>> building(4, vector<vector<int>>(3,vector<int>(10,0)));
    for(int i = 0; i < n; i++){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        building[b-1][f-1][r-1] += v;
    }
    for(int i = 0; i < 4; i++){ //棟
        for(int j = 0; j < 3; j++){ //階
            for(int k = 0; k < 10; k++){
                cout << " " <<  building[i][j][k];
            }
            cout << endl;
        }
        if(i != 3) cout << "####################" << endl;
    }
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)

#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;



using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m,h,x,w,y,xcmp,ycmp,sum=0,xx,yy,black=0;

string s[100],qq;

vector<int> z;


int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

bool mem[55][55];

int aa(){
	queue<pair<pair<int, int>,int>> que;
	que.push(pair<pair<int,int>,int>(pair<int,int>(0, 0), 1));
	while (!que.empty()) {
		pair<pair<int,int>,int> p=que.front(); que.pop();
		if (p.first.first==h - 1 && p.first.second==w - 1) return p.second;
		rep(i, 4) {
			int nx = p.first.second + dx[i], ny = p.first.first + dy[i];
			if (nx<0 || nx>=w || ny<0 || ny>=h || mem[ny][nx] || s[ny][nx]=='#') continue;
			mem[ny][nx] = true;
			que.push(pair<pair<int,int>,int>(pair<int,int>(ny,nx), p.second + 1));
		}
	}
}

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

       cin >> h >> w;
       rep(i,h){
        cin >> s[i];
        rep(j,w){
            if(s[i][j]=='#'){
                black++;
            }
        }
       }
        cmp=aa();
       if(mem[h-1][w-1]){
           Cout(h*w-black-cmp);
       }
       else{
           Cout(-1);
       }
       
return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
li = [0 for _ in range(N + 1)]
for i in range(N):
	li[i + 1] = li[i] + (1 if S[i:i+2] == 'AC' else 0)
for _ in range(Q):
	l, r = map(int, input().split())
	print(li[r - 1] - li[l - 1])


Measured memory_bytes: 7772
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int k, t;
int a[100];

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

	cin >> k >> t;
	rep(i, t)cin >> a[i];
	int s = accumulate(a, a + t, 0);
	int ma = *max_element(a, a + t);

	cout << max(0, 2 * ma - s - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
import math
A, B, C, D = map(int, input().split())
CD = C * D // math.gcd(C, D)
ab = B - A + 1
c = B // C - (A - 1) // C
d = B // D - (A - 1) // D
cd = B // (CD) - (A - 1) // (CD)

print(ab - (c + d - cd))

Measured memory_bytes: 9124
import java.util.*;
import java.util.Arrays;

public class Main{
  static int sum(int a,int b){
    int sum= 0;
    while(a!=0){
      sum += a%10;
      a /=10;
    }
    while(b!=0){
      sum += b%10;
      b /=10;
    }
    return sum;
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int [] a = new int[N];
    int [] b = new int[N];
    for(int i=1;i<N;i++){
      a[i] = i;
      b[i] = N-i;
    }
    int [] c = new int[N];
    for(int i=1;i<N;i++){
      c[i] = sum(a[i],b[i]);
    }
    Arrays.sort(c);

    System.out.println(c[1]);
    
    
  }
}
                          
                         
                    
    
    
    
    
    
    


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

int main(){
    long long q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    long long m=min(4*q,min(2*h,s));
    long long ans=min(m*n,n/2*d+n%2*m);
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 

using namespace std;

int main(){

    int x;
    cin >> x;

    vector<int> v;
    v.pback(0);

    for(int i = 0; true ; i++){
        if(v[i] >= x) break;

        v.pback(v[i] + i + 1);
    }


    cout << v.size() - 1 << endl;

    return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod1e7(ll a){
  return (a % 1000000007);
}

ll mod1e9(ll a){
  return (a % 1000000009);
}

ll mod998(ll a){
  return (a % 998244353);
}

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

vector<ll> fac(200001);
void factorial(){
  fac[0] = 1; 
  for(ll i=1; i < 200001; i++){
    fac[i] = mod998(fac[i-1]*i);
  }
}
    
ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return mod998(fac[n]/fac[r]/fac[n-r]);
}

int main(){
  ll n; cin >> n; vl price(n); ll ans = 0;
  
  rep(i,n){
    cin >> price[i];
    ans += price[i];
  }
  
  sort(all(price));
  
  cout << ans - price[n-1]/2 << endl;
  
  
}

Measured memory_bytes: 4652
import java.util.*;

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

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a+b+c >= 22) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}
		
	}

}




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

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

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

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int N;
    cin >> N;

    int c4=0, c2=0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a % 4 == 0) {
            c4++;
        }
        if (a % 2 == 0 && a % 4 != 0) {
            c2++;
        }
    }

    if (c4 >= N / 2) {
        cout << "Yes" << endl;
    }else if ( (N - 2*c4) <= c2 ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
void solve(){
    int n,m;
  cin >> n>>m;
  cout << pow(n,2)-m <<endl;
}

int main(){
/*/Debug by file input
    ifstream fin("input");
    cin.rdbuf(fin.rdbuf());// */
    solve();
    return 0;
}


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

#define ll long long
using namespace std;

ll grafo[305][305];

void fw(int n, ll g[305][305]){
    
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(g[i][k] == -1 || g[k][j] == -1)
                    continue;
                
                ll new_dist = g[i][k] + g[k][j];
                
                if(g[i][j] == -1 || new_dist < g[i][j]){ 
                    g[i][j] = new_dist;
                }
            }
        }
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,m,l;
    int a,b,c;
    
    cin >> n >> m >> l;

    memset(grafo, -1, sizeof(grafo));
    
    for(int i=0; i<n; i++)
        grafo[i][i] = 0;
        
    while(m--){
        
        cin >> a >> b >> c;
        a--;
        b--;
        
        if(c <= l){
            grafo[a][b] = grafo[b][a] = c;
        }
    }
    
    fw(n, grafo);
    
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++)
            if(grafo[i][j] != -1 && grafo[i][j] <= l)
                grafo[i][j] = grafo[j][i] = 1;
            else
                grafo[i][j] = grafo[j][i] = -1;
    }
    
    fw(n, grafo);
    
    int q,s,t;
    cin >> q;
    while(q--){
    
        cin >> s >> t;
        s--; t--;
        if(grafo[s][t] != -1)
            cout << grafo[s][t]-1 << endl;
        else
            cout << -1 << endl;
    
    }

}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S 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*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    ll x; cin >> x;
    ll m = 100;
    for(ll i = 1; m < x; ++i){
        m = (double)m * 1.01;
        if(m>=x) cout << i << endl;
    }


    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3564
#!/usr/bin/env python3
import sys
from bisect import bisect_left,bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [i+A[i] for i in range(N)] 
    B.sort()
    C = [i-A[i] for i in range(N)] 
    C.sort()
    ans = 0
    for i in range(N):
        ans += bisect_right(C,B[i]) - bisect_left(C,B[i])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34048