akhauriyash/Code-Regression huggingface dataset:
import Control.Monad
import Data.Maybe
import qualified Data.Map as M

main = do
    [n, m] <- map read <$> words <$> getLine
    m <- foldl update M.empty <$> map convert <$> map words <$> replicateM m getLine
    putStrLn $ show (M.size $ M.filter (>= 0) m) ++ " " ++ show (M.foldl (+) 0 $ M.map (max 0) m)

convert [i, r] = (read i, r)

update :: M.Map Int Int -> (Int, String) -> M.Map Int Int
update m (i, "AC") | v == Nothing    = M.insert i 0 m
                   | fromJust v >= 0 = m
                   | otherwise       = M.insert i (-(fromJust v)) m
  where
    v = M.lookup i m
update m (i, "WA") | v == Nothing    = M.insert i (-1) m
                   | fromJust v >= 0 = m
                   | otherwise       = M.insert i (fromJust v - 1) m
  where
    v = M.lookup i m

Measured memory_bytes: 69148
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string a, b, c;
	char turn = 'a';
	
	cin >> a >> b >> c;
	
	while (1) {
		if (turn == 'a') {
			if (a.empty() == 1) break;
			turn = a[0];
			a.erase(0, 1);
		}
		else if (turn == 'b') {
			if (b.empty() == 1) break;
			turn = b[0];
			b.erase(0, 1);
		}
		else if (turn == 'c') {
			if (c.empty() == 1) break;
			turn = c[0];
			c.erase(0, 1);
		}
	}
	
	if (turn == 'a') {
		cout << "A" << endl;
	}
	else if (turn == 'b') {
		cout << "B" << endl;
	}
	else {
		cout << "C" << endl;
	}
	
	return (0);
}

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

vector<int> hamming;

void ham() {
  int temp;
  for(int i=0;i<21;i++) {
    for(int j=0;j<21;j++) {
      for(int k=0;k<21;k++) {
        temp = pow(2.0,(double)i)*pow(3.0,(double)j)*pow(5.0,(double)k);
        if(temp <= 1000000 && temp >= 0) {
        hamming.push_back(temp);
        }
        else {
          break;
        }
      }
    }
  }
}

int main() {
  int m,n,from,to;
  vector<int>::iterator low,up;
  ham();
  sort(hamming.begin(),hamming.end());
  while(cin >> m >> n) {
    low=lower_bound(hamming.begin(), hamming.end(), m);
    up=upper_bound(hamming.begin(),hamming.end(),n);
    from = int(low-hamming.begin());
    to = int(up-hamming.begin());
    cout << to-from << endl;
  }
}

Measured memory_bytes: 0
N = int(input())
val = []
max_len = [2,4]
def comb(val, max_len, depth=0):
    if depth==len(max_len):
        yield val
        return 

    for i in range(max_len[depth]+1):
        yield from comb(val+[i], max_len, depth+1)
# for it in comb(val, max_len):
# #     print('a')
#     print(it)


import math
def primeFactor(num):
    prime = {}
    x = 2
    MAX =  math.sqrt(num)+1
    while x <MAX:
        if num%x==0:
            if x in prime:
                prime[x] += 1
            else:
                prime[x]=1
            num //= x
        else:
            x += 1
    if num != 1:
        prime[num]=1
    return prime

divisor = primeFactor(N)


ans = 0
val = []
for it in comb(val, list(divisor.values())):
    total = 1
    for i, j in zip(list(divisor.keys()), it):
    #     print(i, j)
        total *= i**j
#     print(total)
    
    m = total - 1
    if m < 1:
        continue
    if N%m==N//m:
#         print('{0} mod {1} = {2}, {0}/{1} = {3}'.format(N, m, N%m, N//m))
        ans += m
        
print(ans)

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

ll G[150][150];

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

    // input
    ll N, K;
    cin >> N >> K;

    ll ma = (N-1)*(N-2)/2;
    if(K>ma){
        p(-1);
        return 0;
    }

    vector<pair<ll, ll> > V;
    // 0-indexedで、頂点0を中心としたスターグラフを考える
    FOR(i, 1, N){
        G[0][i] = 1;
        G[i][0] = 1;
        V.push_back(make_pair(0, i));
    }
    
    // 最大まで作ったので削る
    ll surplus = ma - K;
    FOR(i, 1, N){
        FOR(j, i+1, N) if(surplus>0) {
            if(G[i][j]==1) continue;

            // まだ張られていないので、張る
            G[i][j] = 1;
            G[j][i] = 1;
            V.push_back(make_pair(i, j));
            surplus--;
        }
    }

    p(V.size());
    for(auto pa : V){
        p2(pa.first+1, pa.second+1);
    }

    return 0;
}

Measured memory_bytes: 640
n,m = map(int,input().split())

from_1 = []
to_n = []

for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
      from_1.append(b)
    if a == n:
      to_n.append(b)
    if b == 1:
      from_1.append(a)
    if b == n:
        to_n.append(a)

if len(set(from_1) & set(to_n)) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

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

int main() {
  string S;
  cin >> S;
  int n = (int)S.size();
  for (int i=0; i<n; ++i) {
    if (i&1) {
      if (S[i] == 'R') {
        cout << "No\n";
        return 0;
      }
    } else {
      if (S[i] == 'L') {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
}


Measured memory_bytes: 256
<?php
$input = explode(' ', trim(fgets(STDIN)));
 
$a = (int)$input[0];
$b = (int)$input[1];
$c = (int)$input[2];
 
if (($a === $b && $a !== $c) || ($a === $c && $a !== $b)  || ($b === $c && $a !== $b)) {
	echo 'Yes';
}else{
	echo 'No';
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

int main () {
	//#ifndef ONLINE_JUDGE
		////freopen("inputf.txt", "r", stdin);
		//freopen("outputf.txt", "w", stdout);
	//#endif

	int a, b, c;
	SCD(a);
	SCD(b);
	SCD(c);
	printf("%d %d %d", c, a, b);


    return 0;
}



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

using namespace std;

#define rep(i,m,n) for(int i=m;i<n;i++)

int main(){
 string s;
  cin >> s;
 
  long res=0;
  
  rep(i,0,1<<(s.length()-1)){ 
    long val=s[0]-'0';
     rep(j,0,s.length()-1){
       if(i&(1<<j)) {
         res+=val;
         val=0;
       }
       val=val*10+s[j+1]-'0';
     }
    res+=val;
  }
 
  cout << res << endl;
 }

Measured memory_bytes: 256
A, B, K = map(int, input().split())
a_list = []
b_list = []
for i in range(1, A+1):
    if A % i == 0:
        a_list.append(i)

#print(a_list)
for j in range(1, B+1):
    #print(j)
    if B % j == 0:
        b_list.append(j)
#print(b_list)
a_b_list = list(set(a_list) & set(b_list))
a_b_list.sort(reverse=True)
#print(a_b_list)
print(a_b_list[K-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int t;cin>>t;
  if(t<=599)cout<<8;
  else if(t<=799)cout<<7;
  else if(t<=999)cout<<6;
  else if(t<=1199)cout<<5;
  else if(t<=1399)cout<<4;
  else if(t<=1599)cout<<3;
  else if(t<=1799)cout<<2;
  else if(t<=1999)cout<<1;
  
  return 0;
}
//2020.07.25 20:01:06


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n, s[10001], q, t, result = 0;
  cin >> n;
  rep(i, n) cin >> s[i];
  cin >> q;
  rep(i, q) {
    cin >> t;
    rep(i, n) {
      if (s[i] == t) {
        result++;
        break;
      }
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 3216
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	string s;

	cin >> s ;

	s[5] = ' ';
	s[13] = ' ';

	cout << s << endl;
}



Measured memory_bytes: 256
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

o_p = 0
o_q = 0
count = 0
for i in itertools.permutations(range(1, n + 1)):
    count += 1
    if p == i:
        o_p = count
    if q == i:
        o_q = count
print(abs(o_p - o_q))


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

using namespace std;

int main(){
  map<string,int> day = {{"MON",1},{"TUE",2},{"WED",3},{"THU",4},{"FRI",5},{"SAT",6},{"SUM",7}};
  string s;
  cin >> s;
  int now = day[s];
  if(7-now)cout << 7-now;
  else cout << 7;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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



int32_t  main()
{ 
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
 
 
int h,w;
cin>>h>>w;

if(h==1||w==1){
  cout<<1<<"\n"; return 0;
}
int v=(h+1)/2,u=(h-(h+1)/2);
int x=(w+1)/2,y=(w-(w+1)/2);

cout<<max(x*u+y*v,x*v+y*u);


   
 


}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, X, M = map(int,input().split())
A = [0 for _ in range(M+1)]
A[1] = X
S = [0 if i == 0 else X for i in range(M+1)]
first = [-1 for i in range(M+1)]
if X <= M:
	first[X] = 1

n = 1
a = X
l,r = -1, -1
while True:
	if n == N:
		break
	a2 = (a*a) % M
	if a2 == 0:
		print(S[n])
		exit()
	if first[a2] > 0:
		l = first[a2]
		r = n
		break
	first[a2] = n + 1
	A[n+1] = a2
	S[n+1] = S[n] + a2
	a = a2
	n += 1

if n == N:
	print(S[N])
	exit()
t = r - l + 1
loop = (N-l+1) // t
rest = (N-l+1) % t
print(S[l-1] + loop * (S[r] - S[l-1]) + S[l + rest - 1] - S[l-1])

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X;
    cin >> X;
    int ans = 1;
    while((ans*X) % 360 != 0) ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;

using namespace std;

int main(){
    ll n,m;
    ll s = 0;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int d;
        cin >> d;
        s += d;
    }

    if(n < s){
        cout << -1 << endl;
    } else {
        cout << n-s << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX 300000
int n;
bool tf[MAX];
vector<int> prime;

void set(int num){
	for (int i = num * 2; i < MAX;i += num){
		tf[i] = true;
	}
}

int main(){
	for (int i = 6; i < MAX; i += 7){
		if (!tf[i]){
			set(i);
			prime.push_back(i);
		}
	}
	for (int i = 8; i < MAX; i += 7){
		if (!tf[i]){
			set(i);
			prime.push_back(i);
		}
	}
	sort(prime.begin(),prime.end());
	while (1){
		cin >> n;
		if (n == 1) break;
		cout << n << ":";
		for (int i = 0;i < prime.size(); i++){
			if (n%prime[i] == 0){
				cout << " " << prime[i];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1640
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % MOD;
		x = x * x % MOD;
		n = n >> 1;
	}
	return ans;
}

//MODを考慮して階乗を計算
int fact_mod(int n) {
	ll res = 1;
	FOR(i, 1, n + 1) {
		res *= i;
		res = res & MOD;
	}
	return res;
}

//MODを考慮して、組み合わせ数を計算
class CombMod {
public:
	CombMod(int maxNo) {
		fac.resize(maxNo + 3);
		ifac.resize(maxNo + 3);
		//大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
		fac[0] = 1;
		ifac[0] = 1;
		for (ll i = 0; i < fac.size() - 1; i++) {
			fac[i + 1] = fac[i] * (i + 1) % MOD; // n!(mod M)
			ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
		}
	}
	ll comb(ll a, ll b) { //aCbをmod計算
		if (a == 0 && b == 0)return 1;
		if (a < b || a < 0)return 0;
		ll tmp = ifac[a - b] * ifac[b] % MOD;
		return tmp * fac[a] % MOD;
	}
private:
	vector<ll> fac; //n!(mod M)
	vector<ll> ifac; //k!^{M-2} (mod M)
};

int main() {
	CombMod *cm = new CombMod(2000000);

	int k, n;
	cin >> k;
	string s;
	cin >> s;
	n = s.size();

	ll ans = 0;
	FOR(i, 0, k + 1) {
		ll x = k - i;
		ll y = cm->comb(x + n - 1, n - 1);
		ll x25 = mpow(25, x);
		ll i26 = mpow(26, i);
		ans += ((y * x25) % MOD * i26) % MOD;
		ans = ans % MOD;
	}
	cout << ans << endl;
}






Measured memory_bytes: 36652
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main(){
    int N;cin>>N;
    vector<queue<int>> tbl(N);
    rep(i,N) {
        rep(j,N-1) {
            int a;cin>>a;
            a--;
            tbl[i].push(a);
        }
    }
    rep(i,N*(N-1)/2) {
        bool finished = true;
        vector<bool> seen(N,false);
        int cnt = 0;
        rep(j,N) {
            if(!tbl[j].empty()&&!seen[j]) {
                finished = false;
                seen[j] = true;
                int fst = tbl[j].front();
                int snd = tbl[fst].front();
                if(!seen[fst]&&snd == j) {
                    seen[fst] = true;
                    tbl[j].pop();
                    tbl[fst].pop();
                    cnt++;
                }
            }
        }
        if(finished) {
            cout<<i<<endl;
            return 0;
        } 
        if(cnt==0) {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<N*(N-1)/2<<endl;
}

Measured memory_bytes: 7916
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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




int main() {

	string s, t;
	cin >> s >> t;
	cout << t << s;
	system("PAUSE");


}


Measured memory_bytes: 504
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <list>

using namespace std;


int n, m, r;
long long d[201][201];
long long rr[9];
long long res;
bool used[9];


void dfs(int c, int las, long long dist){
  if (c==r+1) {
    if (res > dist)res = dist;
      return;
  }

  for (int i=1;i<=r;i++) {
    if (used[i])continue;
    used[i] = true;
    if (las==-1) {
      dfs(c+1, i, 0);
    } else {
      dfs(c+1, i, dist+d[rr[las]][rr[i]]);
    }
    used[i]=false;
  }
}


int main(){
  cin >> n >> m >> r;
  // initialize  
  for (int i=1;i<=n;i++) {
    for (int j=1;j<=n;j++) {
      d[i][j] = 1<<29;
    }
  }
  for (int i=1;i<=r;i++) {
    cin >> rr[i];
  }
  for (int i=1;i<=m;i++) {
    int a, b;
    long c;
    cin >> a >> b >> c;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k=1;k<=n;k++) {
    for (int i=1;i<=n;i++) {
      for (int j=1;j<=n;j++) {
	if (d[i][j] > d[i][k] + d[k][j]) {
	  d[i][j] = d[i][k] + d[k][j];
	}
      }
    }
  }
  /*  for (int i=1;i<=n;i++) {
    for (int j=1;j<=n;j++) {
      cout << d[i][j] << " ";
    }
    cout << endl;
    }*/
  res = 1<<29;
  dfs(1, -1, 0);
  cout << res << endl;
}


Measured memory_bytes: 512
// Aizu Vol-1 0180: Demolition of Bridges
// 2017.8.9

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 0x77777777
#define MAX 100
#define EMAX 500
int n;
typedef struct { int b, c; } ND;
ND d[MAX + 2][MAX + 2];
int w[MAX + 2];
int visited[MAX];

int qsize;
typedef struct { int a, b, c; } QUE;
QUE que[EMAX + 1];

#define PARENT(i) ((i)/2)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

static void min_heapify(int i)
{
	int l, r, smallest;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].c < que[i].c) smallest = l; else smallest = i;
	if (r < qsize && que[r].c < que[smallest].c) smallest = r;
	if (smallest != i) {
		QUE t;
		memcpy(&t, que + i, sizeof(QUE)), memcpy(que + i, que + smallest, sizeof(QUE));
		memcpy(que + smallest, &t, sizeof(QUE));
		min_heapify(smallest);
	}
}

int deq(QUE *q)
{
	if (qsize == 0) return -1;
	memcpy(q, &que[0], sizeof(QUE));
	memcpy(que, que + --qsize, sizeof(QUE));
	min_heapify(0);
	return 1;
}

void enq(QUE *q)
{
	int i;

	i = qsize++;
	memcpy(que + i, q, sizeof(QUE));
	while (i > 0 && que[PARENT(i)].c > que[i].c) {
		QUE t;
		memcpy(&t, que + i, sizeof(QUE)), memcpy(que + i, que + PARENT(i), sizeof(QUE));
		memcpy(que + PARENT(i), &t, sizeof(QUE));
		i = PARENT(i);
	}
}


int main()
{
	int m, a, b, c;
	int i, k, ans;
	QUE q;

	while (1) {
		scanf("%d%d", &n, &m); if (!n) return 0;
		memset(w, 0, sizeof(w));
		for (i = 0; i < m; i++) {
			scanf("%d%d%d", &a, &b, &c);
			d[a][w[a]].b = b, d[a][w[a]++].c = c;
			d[b][w[b]].b = a, d[b][w[b]++].c = c;
		}
		memset(visited, 0, sizeof(visited));
		ans = 0, visited[0] = 1, k = 1, qsize = 0;
		for (i = 0; i < w[0]; i++) q.a = 0, q.b = d[0][i].b, q.c = d[0][i].c, enq(&q);
		while (k < n) {
			do deq(&q);
			while (visited[q.a] && visited[q.b]);
			k++;
			a = visited[q.a] ? q.b : q.a;
			visited[a] = 1, ans += q.c;
			for (i = 0; i < w[a]; i++) {
				b = d[a][i].b;
				if (!visited[b]) q.a = a, q.b = b, q.c = d[a][i].c, enq(&q);
			}

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

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

int main() {
    long long a, b, k;
    cin>>a>>b>>k;
    long d= a+b;
    if (a > k)
    {
        cout<<a-k<<" "<<b;
    }
    else if (d>=k)
    {
        cout<<0<<" "<<d-k;
    }
    else 
    {
        cout<<0<<" "<<0;
    }
    
    
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N;cin>>N;
  set<string> used;
  string S;
  char c;
  cin>>S;used.insert(S);
  c=S.at(S.size()-1);
  REP(i,0,N-1){
    cin>>S;
    if(c!=S.at(0)||used.count(S)){
      print("No");
      re 0;
    }
    used.insert(S);
    c=S.at(S.size()-1);
  }
  print("Yes");

}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <vector>
#include <queue>
#include <tuple>

using namespace std;

constexpr auto Infinity = numeric_limits<long long>::max() / 2;
using pii = pair<int, int>;

vector<long long> dijkstra(vector<vector<pii>> const& graph, int start) {
  using pii = pair<int, int>;
  size_t const n_vertex = graph.size();
  vector<long long> dist(n_vertex, Infinity);
  dist[start] = 0;
  priority_queue<pii, vector<pii>, greater<pii>> pque;
  pque.emplace(0, start);
  while (!pque.empty()) {
    int v, d;
    tie(d, v) = pque.top();
    pque.pop();
    if (d > dist[v]) continue;
    for (auto&& e : graph[v]) {
      int cost, destination;
      tie(cost, destination) = e;
      if (dist[destination] > d + cost) {
        dist[destination] = d + cost;
        pque.emplace(d + cost, destination);
      }
    }
  }
  return dist;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int v, e, r;
  cin >> v >> e >> r;
  vector<vector<pii>> graph(v);
  for (int i = 0; i < e; i++) {
    int s, t, d;
    cin >> s >> t >> d;
    graph[s].emplace_back(d, t);
  }
  auto const& dists = dijkstra(graph, r);
  for (auto i : dists) {
    if (i == Infinity)
      cout << "INF" << endl;
    else
      cout << i << endl;
  }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,d,a;
  cin>>n>>d>>a;
  vll x(n),h(n);
  REP(i,n)cin>>x[i]>>h[i];

  vector<pll> p(n);
  REP(i,n){
    p[i].FI=x[i];
    p[i].SE=h[i];
  }

  map<ll,ll> m;
  sort(x.begin(), x.end());
  sort(p.begin(), p.end());
  REP(i,n)
    m[p[i].FI]=i;


  ll ans=0;
  vll imos(n+2,0);

  REP(i,n){
    ll health = p[i].SE;
    if(i!=0)
      imos[i] += imos[i-1];
    health -= imos[i]*a;

    if(health<=0)
      continue;

    auto it = upper_bound(x.begin(), x.end(), x[i]+2*d);
    ll t = it-x.begin();

    ll k = health/a;
    if(health%a!=0)
      k++;

    imos[i] += k;
    imos[t] -= k;


    ans += k;
  }

  cout << ans << endl;
}


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

int gcd(long long int a,long long int b){
    if(a<b){
        long long int tmp = b;
        b = a;
        a = tmp;
    }
    long long int r = a%b;
    if(r==0){
        return b;
    }
    else{
        gcd(b,r);
    }
}

int main()
{
    long long int A,B;
    cin >> A >> B;
    cout << A*B/gcd(A,B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

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

using namespace std;

int n;
vector<int> G[200000];
int ans[200000];

void dfs(int u,int p){
	for(int v:G[u]) if(v!=p) ans[v]+=ans[u], dfs(v,u);
}

int main(){
	int q;
	scanf("%d%d",&n,&q);
	rep(i,n-1){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	rep(_,q){
		int p,x; scanf("%d%d",&p,&x); p--;
		ans[p]+=x;
	}

	dfs(0,-1);

	rep(u,n) printf("%d ",ans[u]);

	return 0;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string S;
    string T;
    cin >> S >> T;
    int s = S.size();
    int t = T.size();

    ll mx  = 0;
    rep(i,s-t+1){
        ll tmp = 0;
        rep(j,t){
            if(T[j] == S[i+j]) ++tmp;
        }
        mx = max(mx,tmp);
    }
    cout << T.size() - mx << endl;
}


Measured memory_bytes: 3580
n=int(input())
a=list(map(int, input().split()))
even_num=[0]*n

for i in range(n):
    cnt=0
    if a[i]%2==0:
        while a[i]%2==0:
            a[i]=a[i]/2
            cnt+=1

    even_num[i]=cnt

ans=sum(even_num)
print(ans)

Measured memory_bytes: 43248
import java.util.Scanner;

public class Main {
	int count = 0;

	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] num = new int[n];
		for (int i = 0; i < n; i++) {
			num[i] = scanner.nextInt();
		}
		mergeSort(num, 0, n);
		System.out.print(num[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" " +num[i]);
		}
		System.out.println();
		System.out.println(count);
	}

	private void mergeSort(int[] num, int left, int right) {
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(num, left, mid);
			mergeSort(num, mid, right);
			merge(num, left, mid, right);
		}
	}

	private void merge(int[] num, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int[] l = new int[n1 + 1];
		int[] r = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			l[i] = num[left + i];
		}
		for (int i = 0; i < n2; i++) {
			r[i] = num[mid + i];
		}
		l[n1] = Integer.MAX_VALUE;
		r[n2] = Integer.MAX_VALUE;

		int L = 0;
		int R = 0;
		for (int k = left; k < right; k++) {
			if (l[L] <= r[R]) {
				num[k] = l[L++];
			} else {
				num[k] = r[R++];
			}
			count++;
		}
	}

}

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

int main(void){
	string s,t;
	cin >> s >> t;
	int n,m;
	n = s.length();
	m = t.length();
	int dp[n+1][m+1];
	//dp[i][j] : sのi文字目,tのj文字目のLCSの長さ
	for(int i=0;i<n+1;i++)for(int j=0;j<=m;j++)dp[i][j]=0;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	
	string ans = "";
	int x = n;
	int y = m;
	//dp配列を逆から辿ってLCSを作成する
	//LCSの長さが更新されたときの文字を追加していく
	while(x>0&&y>0){
		if(dp[x][y] == dp[x-1][y]){
			x--;
		}else if(dp[x][y]== dp[x][y-1]){
			y--;
		}else{
			x--;
			y--;
			ans.push_back(s[x]);
		}
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
const int MAXN = 2e5 + 10;
int a[MAXN], n;
int main(){
    n = read();
    for (int i = 1; i < n; i++){
        int x = read();
        a[x]++;
    }
    for (int i = 1; i <= n; i++){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4348
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    H = tuple(map(int, input().split()))

    ans = 0
    max_h = 0
    for h in H:
        if h >= max_h:
            ans += 1
            max_h = h
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
  int a,p;
  cin >> a >> p;
  a *= 3;
  cout << (a+p)/2 << endl;
  return 0;
}


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

using namespace std;

int main() {
 string s, t;
 cin >> s >> t;
 t.erase(t.size() - 1, 1);
 if (s == t) {
    cout << "Yes";
 }
 else {
    cout << "No";
 }
 return 0;
}


Measured memory_bytes: 3580
def gcd(x,y):
    if x%y == 0:
        return y
    else:
        return gcd(y,x%y)

def lcm(x,y):
    return x*y//gcd(x,y)

def f(tmp):
    tmp.sort(reverse=True)
    result=[]
    for i in tmp[1:]:
        if tmp[0]%i == 0:
            tmp.remove(i)
    for i in range(1,len(tmp)):
        result.append(lcm(tmp[0],tmp[i]))
    else:
        if result:
            return result
        else:
            return tmp
if __name__ == "__main__":
    n=int(input())
    t=[]
    for _ in range(n):
        t.append(int(input()))
    t.sort(reverse=True)
    if len(t)<2:
        print(t[0])
        exit(0)
    tmp=[]
    for i in range(1,n):
        tmp.append(lcm(t[0],t[i]))
    while len(tmp) > 1:
        tmp=f(tmp)
    if tmp[0] >1000000000000000000:
        print(1000000000000000000)
    else:
        print(tmp[0])


Measured memory_bytes: 9252
#include <iostream>
#include <stdio.h>

int main() {
    int n;
    long min = 1000000;
    long max = -1000000;
    long sum = 0;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int tmp;
        std::cin >> tmp;
        sum += tmp;
        if (min > tmp) min = tmp;
        if (max < tmp) max = tmp;
    }
    
    std::cout << min << " " << max << " " << sum << std::endl;
    
    return 0;
}

Measured memory_bytes: 3228
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto AB = new long[2][](N);
	foreach (i; 0..N)
	{
		AB[i] = [RD, RD];
	}
	AB.sort!"a[0] < b[0]"();

	long ans;
	foreach (e; AB)
	{
		auto x = min(M, e[1]);
		ans += x * e[0];
		M -= x;
		if (M == 0) break;
	}
	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 4604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int r = 0;
    for (int i = 1; i < n - 1; i++) {
        int a = p[i - 1];
        int b = p[i];
        int c = p[i + 1];
        if ((a < b && b < c) || (a > b && b > c)) r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
p = list(map(int,input().split()))
maxn = 0
sum = 0
for i in range(n-k+1):
	if i == 0:
		for j in range(k):
			sum += p[j]
		maxn = sum
	else:
		sum -= p[i-1]
		sum += p[i+k-1]
		if maxn < sum:
			maxn = sum
print(0.5*(maxn+k))

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

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut ncr = vec![vec![0; 4005]; 4005];
    ncr[0][0] = 1;
    for i in 0..4001 {
        for j in 0..4001 {
            ncr[i + 1][j] += ncr[i][j];
            ncr[i + 1][j] %= M;
            ncr[i + 1][j + 1] += ncr[i][j];
            ncr[i + 1][j + 1] %= M;
        }
    }


    for i in 1..k + 1 {
        println!(
            "{}",
            ncr[k - i + (i - 1)][i - 1] * ncr[n - k - (i - 1) + i][i] % M
        );
    }
}


Measured memory_bytes: 151804
import java.util.*;

class Main {
  static int max_chairs = 10;
  static HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String s = sc.next();
    if (a >= 3200) {
      System.out.println(s);
    } else {
      System.out.println("red");
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
LL read()
{
	LL x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int main()
{
	int q=read();
	while(q--)
	{
		LL a=read(),b=read(),m=a*b;
		LL M=(LL)sqrt((long double)(m-1LL)),ans=M*2LL;
		LL t;
		if(a!=b)
		{
			if(a<=M)ans--;
			if(b<=M)ans--;
			if(m%M==0)t=m/M-1;
			else t=m/M;
			if(t==M)
			{
				ans--;
				if(a==M&&b==M)ans++;
			}
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>

using namespace std;

vector<int> parse() {
  int n, x;
  cin >> n;
  vector<int> A;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    A.push_back(x);
  }
  return A;
}

int main() {
  auto A = parse();
  int k;
  cin >> k; // skip q
  while (cin >> k) {
    auto p = equal_range(A.begin(), A.end(), k);
    cout << distance(A.begin(), p.first) << " " << distance(A.begin(), p.second)
         << endl;
  }
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y;
    cin>>a>>b>>c;
    x=a-b;
    y=c-x;
    if(y>=0)
    {
        cout<<y;
    }
    else
    {
       cout<<0;
    }



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << 1 << endl;
		return 0;
	}
	int num = H * W;
	int ans = (num + 2 - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int N, i, max_i;
    int max = 0;
    int sum = 0;
    fscanf(stdin, "%d", &N);
    int p[N];
    for(i = 0; i < N; i++){
        fscanf(stdin, "%d", &p[i]);
        if( max < p[i]){
            max = p[i];
            max_i = i;
        }
    }

    for(i = 0; i < N; i++){
        if( i == max_i){
            sum += p[i] / 2;
        } else {
            sum += p[i];
        }
    }

    fprintf(stdout, "%d\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int x = n-1;
	while(1){
		if(x<0)break;
		b.push_back(a[x]);
		x-=2;
	}
	x = n%2;
	while(1){
		if(x>n-1)break;
		b.push_back(a[x]);
		x+=2;
	}
	for(int i=0;i<n-1;i++){
		cout << b[i] << " ";
	}
	cout << b[n-1] << endl;
	return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
int main() {
    int n;
    cin >> n;
    ll a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll x = 0;
    for (int i = 1; i <= n; i++) {
        x = (x + a[i]) % mod;
    }
    x = x * x % mod;
    ll y = 0;
    for (int i = 1; i <= n; i++) {
        y = (y + a[i] * a[i] % mod) % mod;
    }
    ll ret = x - y;
    if (ret < 0) {
        ret += mod;
    }
    if (ret % 2) {
        ret = ((ret + mod) / 2) % mod;
    }
    else {
        ret /= 2;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 5180
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    long long N;
    cin >> N;
    long long res = 0;
    for (long long a = 1; a <= N; ++a) {
        res += (N - 1) / a;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 	
 	int a, b,c, d; cin >> a >> b >> c >> d; 

 	while(1){
 		c -= b;
 		if(c <= 0){
 			cout << "Yes\n";
 			return 0;
 		}
 		a -= d;
 		if(a <= 0){
 			cout << "No\n";
 			return 0;
 		}
 	}



	return 0;
}

Measured memory_bytes: 3640
A,B,Q = (int(i) for i in input().split())  
s =[]
t =  []
x = []
for _ in range(A):
    s.append(int(input()))
for _ in range(B):
    t.append(int(input()))
for _ in range(Q):
    x.append(int(input()))

import math
s_t = [0] * A #min dis form s to t
for i in range(A):
    max_ = B - 1
    min_ = 0
    k = int(max_ / 2)
    while(abs(max_ - min_)>1):
        if abs(t[k + 1] - s[i]) >  abs(t[k] - s[i]):
            max_ = k
            k =  int((k+min_) / 2)
        else:
            min_ = k
            k = int((k+max_)/2)
    k = max_
    if abs(t[max_] - s[i]) >  abs(t[min_] - s[i]):
        k = min_
    s_t[i] = abs(t[k] - s[i])

t_s = [0] * B #min dis form t to s
for i in range(B):
    max_ = A - 1
    min_ = 0
    k = int(max_ / 2)
    while(abs(max_ - min_)>1):
        if abs(s[k + 1] - t[i]) >  abs(s[k] - t[i]):
            max_ = k
            k =  int((k+min_) / 2)
        else:
            min_ = k
            k = int((k+max_)/2)
    k = max_
    if abs(s[max_] - t[i]) >  abs(s[min_] - t[i]):
        k = min_
    t_s[i] = abs(s[k] - t[i])


for i in range(Q):
    dis = []
    #first s
    max_ = A - 1
    min_ = 0
    k = int(max_ / 2)
    while(abs(max_ - min_)>1):
        if abs(s[k + 1] - x[i]) >  abs(s[k] - x[i]):
            max_ = k
            k =  int((k+min_) / 2)
        else:
            min_ = k
            k = int((k+max_)/2)
    k = max_
    if abs(s[max_] - x[i]) >  abs(s[min_] - x[i]):
        k = min_

    dis.append(abs(s[k] - x[i]) + s_t[k])
    if k > 0:
        dis.append(abs(s[k-1] - x[i]) + s_t[k-1])
    if k+1<A:
        dis.append(abs(s[k+1] - x[i]) + s_t[k+1])

    #first t
    max_ = B - 1
    min_ = 0
    k = int(max_ / 2)
    while(abs(max_ - min_)>1):
        if abs(t[k + 1] - x[i]) >  abs(t[k] - x[i]):
            max_ = k
            k =  int((k+min_) / 2)
        else:
            min_ = k
            k = int((k+max_)/2)
    k = max_
    if abs(t[max_] - x[i]) >  abs(t[min_] - x[i]):
        k = min_

    dis.append(abs(t[k] - x[i]) + t_s[k])
    if k > 0:
        dis.append(abs(t[k-1] - x[i]) + t_s[k-1])
    if k+1<B:
        dis.append(abs(t[k+1] - x[i]) + t_s[k+1])

    print(sorted(dis)[0])

    


Measured memory_bytes: 94040
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main (){

    int n;
    cin >> n;

    int nums[n];

    for (int i = 0; i < n; i++) cin >> nums[i];

    int result = 1000000;

    for (int i = -100; i <= 100; i++){

        int temp = 0;

        for (int j = 0; j < n; j++){
             temp += pow((nums[j] - i), 2.0);
        }

        result = min(result, temp);
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i=1;i<(n);i++)
ll a[45], b[45], c[45];
ll gcd(ll x, ll y) {
	if (x > y)swap(x, y);
	ll r = y % x;
	while (r) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}
int main() {
	ll n, x, y, inf = 1e15, ans = inf;
	cin >> n >> x >> y;
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i] >> c[i];
	ll dp[45][410][410];
	rep(i, 45)rep(j, 410)rep(k, 410)dp[i][j][k] = inf;
	dp[0][0][0] = 0;
	rep(i, n + 1)rep(j, 401)rep(k, 401) {
		if (dp[i][j][k] == inf)continue;
		dp[i + 1][j][k] = min(dp[i][j][k], dp[i + 1][j][k]);
		dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
	}
	rrep(i, 401)rrep(j, 401)if (i/gcd(i,j)==x&&j/gcd(i,j)==y)ans = min(dp[n][i][j], ans);
	cout << (ans == inf ? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 59392
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi zero(60), one(60);
    rep(i, n) {
        ll a;
        cin >> a;
        rep(j, 60) {
            if((a >> j) & 1) {
                one[j]++;
            } else {
                zero[j]++;
            }
        }
    }

    mint ans = 0;
    rep(i, 60) {
        ans += mint(2).pow(i) * one[i] * zero[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3660