akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return acos(-1.0);
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int n,ans=0;
	int ss[10000]={};
	while(cin>>n){
		ans=0;
		if(n>37) cout<<0<<endl;
		else{
			for(int a=0;a<10;a++){
				for(int b=0;b<10;b++){
					for(int c=0;c<10;c++){
						for(int d=0;d<10;d++){
							if(a+b+c+d==n) ans++;
						}
					}
				}
			}
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define N 1805
using namespace std;

const int fx[] = { 0, 1, 0,-1};
const int fy[] = { 1, 0,-1, 0};

int n,m,k,sx,sy;
char s[N];
bool vis[N][N],mp[N][N],flag;
queue<int> qx,qy,qs;
int main() {
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;i++) {
		scanf("%s",s+1);
		for (int j=1;j<=m;j++) mp[i][j] = s[j]!='#';
		for (int j=1;j<=m;j++) if (s[j]=='S') sx=i, sy=j;
	}
	
	if (sx == 1 || sx == n || sy == 1 || sy == m) return puts("0"), 0;
	
	vis[sx][sy] = 1;
	qx.push(sx), qy.push(sy), qs.push(0);
	while (!qx.empty()) {
		int ux = qx.front(); qx.pop();
		int uy = qy.front(); qy.pop();
		int us = qs.front(); qs.pop();
		if (us == k) continue;
		if (ux == 1 || ux == n || uy == 1 || uy == m) flag = 1;
		
		for (int i=0;i<4;i++) {
			int vx = ux + fx[i], vy = uy + fy[i];
			if (vx<1 || vx>n || vy<1 || vy>m) continue;
			if (!vis[vx][vy] && mp[vx][vy]) {
				vis[vx][vy] = 1;
				qx.push(vx), qy.push(vy), qs.push(us+1);
			}
		}
	}
	
	if (flag) return puts("1"), 0;

	int ans = 2147483647;	
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) if (vis[i][j]) {
			int t = min( min(i-1,j-1) , min(n-i,m-j) );
			int cur = (t+k-1) / k;
			ans = min(ans, cur+1);
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
import sys
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())
root=[-1]*(n+1)
def r(x):
    if root[x]<0:
        return x
    else:
        root[x]=r(root[x])
        return root[x]
def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if x>y:
        x,y=y,x

    root[x]+=root[y]
    root[y]=x
def size(x):
    x=r(x)
    return -root[x]
for i in range(m):
    x,y=map(int,input().split())

    unite(x,y)
ans=0
for i in range(n):
    ans=max(ans,size(i+1))
print(ans)


Measured memory_bytes: 79868
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<sstream>
#include<bitset>
using namespace std;

typedef long long ll;


struct union_find_tree{
	vector<int>data;
	union_find_tree(int n):data(n,-1){}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return data[x] < 0 ? x : data[x] = find(data[x]); }
	int size(int x) { return -data[find(x)]; }
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int,int>>es;
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		es.push_back(make_tuple(c, a, b));
	}
	sort(es.begin(), es.end());
	union_find_tree uf(n);
	int ans = 0;

	for (int i = 0; i < m; i++) {
		if (uf.unite(get<1>(es[i]), get<2>(es[i])))ans += get<0>(es[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4464
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut s: Vec<u32> = (0..(1 << n)).map(|_| it.next().unwrap().parse().unwrap()).collect();
    s.sort();
    let mut h = vec![std::collections::BinaryHeap::new(); n + 1];
    h[n].push(s[(1 << n) - 1]);
    for s in s[0..((1 << n) - 1)].iter().rev() {
        let mut ok = false;
        for i in (1..(n + 1)).rev() {
            if h[i].is_empty() {
                continue;
            }
            let v = h[i].pop().unwrap();
            if v > *s {
                h[i - 1].push(v);
                h[i - 1].push(*s);
                ok = true;
                break;
            } else {
                h[i].push(v);
            }
        }
        if !ok {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn main() {
    run();
}


Measured memory_bytes: 12404
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll h, w, d;
  cin >> h >>w >> d;
  vector<pair<ll,ll>> a(h*w);
  rep(i, h){
    rep(j, w){
      ll tm;
      cin >> tm;
      --tm;
      a.at(tm).first = j;
      a.at(tm).second = i;
    }
  }

  // ruisekiwa
  vector<ll> score(h*w);
  rep(i, d) score.at(i) = 0;
  for (int i = d; i < h * w; ++i) {
    score.at(i) = score.at(i-d) + abs(a.at(i).first-a.at(i-d).first) + abs(a.at(i).second - a.at(i-d).second);
  }


  ll q;
  cin >> q;

  rep(i, q){
    ll l, r;
    cin >> l >> r;
    --l; --r;
    cout << score.at(r) - score.at(l) << endl;
  }

  return 0;
}

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

int main(void){
    int n, m;
    cin >> n >> m;
    int ans = 1;
    
    for (int i = 1; i * i < m; i++) {
        if (m % i == 0) { // 約数である
            int j = m / i; // もう１つの約数
            if ((long)i * n <= m) {
                if (ans < i) {
                    ans = i;
                }
            }
            if ((long)j * n <= m) {
                if (ans < j) {
                    ans = j;
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
#define LL long long
int main(){
    long long  n,k;
    scanf("%lld%lld",&n,&k);
    if (k == 0){
        printf("%lld\n",n * n);
        return 0;
    }
    long long ans = 0;
    for (int i = k; i <= n; i++)
    {
        ans += (n / i) * (i - k);
        if (n % i >= k){
            ans += n % i - k + 1;
        } 
    }
    printf("%lld\n",ans);
}

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

int main(){
  int A,B,C,count;
  cin>>A>>B>>C;
  bool ans=true;
  
  count=0;
  if(A%2!=0||B%2!=0||C%2!=0){
    ans=false;
  }
  else if(A==B&&B==C){
    count=-1;
    ans=false;
  }
  
  while(ans==true){
    int a,b,c;
    a=A;
    b=B;
    c=C;
    A=b/2+c/2;
    B=a/2+c/2;
    C=a/2+b/2;
    count++;
    if(A%2!=0||B%2!=0||C%2!=0){
       ans=false;
    }
  }
  
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
    int W, H;
    while (cin >> W >> H) {
	if (W == 0) break;

	vector<string> board;
	inputVector(board, H);

	string ret = "";
	string dp[70][70];
	rep(y, H) rep(x, W) dp[y][x] = "";
	for (int y = H - 1; y >= 0; y--) {
	    for (int x = W - 1; x >= 0; x--) {
		if (board[y][x] < '0' || board[y][x] > '9') dp[y][x] = "";
		else {
		    string prev = "";
		    if (y < H - 1) prev = dp[y + 1][x];
		    if (x < W - 1 && (dp[y][x + 1].size() > prev.size()
				|| (dp[y][x + 1].size() == prev.size() && dp[y][x + 1] > prev))) prev = dp[y][x + 1];
		    dp[y][x] = board[y][x] + prev;
		    if (ret.size() > 0 && board[y][x] == '0') continue;
		    if (ret.size() > dp[y][x].size()) continue;
		    if (ret.size() == dp[y][x].size() && ret > dp[y][x]) continue;
		    ret = dp[y][x];
		}
	    }
	}
	cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 3216
import java.util.*;

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

    int n = sc.nextInt();
    int[] p = new int[n];
    int[] q = new int[n];

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

    Arrays.sort(q);

    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (p[i] != q[i]) cnt++;
      if (cnt > 2) break;
    }
    
    System.out.println(cnt > 2 ? "NO" : "YES");
  }
}


Measured memory_bytes: 21844
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	beginA := math.Ceil(float64(a) * 12.5)
	endA := math.Floor(float64(a + 1) * 12.5)
	beginB := math.Ceil(float64(b) * 10)
	endB := math.Floor(float64(b + 1) * 10)
	if beginA >= beginB && endB > beginA{
		fmt.Printf("%.0f\n", beginA)
	}else if beginB >= beginA && endA > beginB {
		fmt.Printf("%.0f\n", beginB)
	}else {
		fmt.Printf("-1\n")
	}
}


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

int main()
{
  int N, B=0, cnt=0;
  long long sum=0, sum2=0, sum3=0;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
    sum=sum+A.at(i);
  }
  rep(i, N){
    sum2=sum2+A.at(i);
    if(sum%2==0 && sum/2==sum2){
      cnt==0;
      B=1;
      break;
    }
    else if(sum2>sum/2){
      sum2=sum2-A.at(i);
      cnt=min(sum2,sum-sum2-A.at(i))+A.at(i)-max(sum2,sum-sum2-A.at(i));
      B=1;
      break;
    }
    if(B==1) break;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    char ball = 'A';
    char x, y, z;
    while (cin >> x >> z >> y){
        if (x == ball) {
            ball = y;
        }
        else if (y == ball){
            ball = x;
        }
    }
    cout << ball << endl;
}



Measured memory_bytes: 3096
#include <iostream>
using namespace std;
int main()
{
    int n, m, sum = 0;
    cin >> n >> m;
    int a[m];

    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
        sum += a[i];
    }

    if (sum > n)
        cout << -1 << "\n";
    else
        cout << n - sum << "\n";

    return 0;
}

Measured memory_bytes: 3636
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n);
	vector<pair<int, int> > cb(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> cb[i].second >> cb[i].first;
	}

	// firstが小さい順、secondが小さい順にソート
	sort(a.begin(), a.end());
	sort(cb.begin(), cb.end());
  
	int k = 0;
	long long int sum = 0;
	for (int i = m - 1; i >= 0; i--) {
		for (int j = 0; j < cb[i].second; j++) {
			if (a[k] < cb[i].first)
				sum += cb[i].first;
			else {
				sum += a[k];
				j--;
			}
			k++;
			if (k == n) {
				cout << sum;
				return 0;
			}
		}
	}
	for (int i = k; k < n; k++)
		sum += a[k];
	cout << sum;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
#include<iomanip>
using namespace std;
int main() {
	long long int X,Y;
	cin >> X>>Y; 
	long long int val=X;
	int count = 0;
	while (val <= Y) {
		val = val * 2;
		count++;
	}
	cout << count;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int64_t> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  sort(H.begin(), H.end());
  
  int64_t Htotal = 0;
  for (int i = 0; i < N - K; i++) {
    Htotal += H.at(i);
  }
  
  cout << Htotal << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
	int a,b,c,d,e,f;
	while(cin >> a >> b >> c >> d >> e >> f ){
	int det=a*e-b*d;
	int X,Y; X=c*e-b*f ; Y=a*f-c*d; 
	double x,y;
	if(X==0) x=0;if(Y==0) y=0;
	if(X!=0 && Y!=0) x=(double)X/det;y=(double)Y/det;
	cout << fixed << setprecision(3) ;
	cout << x << ' ' << y << '\n' ;
	};
}

Measured memory_bytes: 1236
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

K = I()
ans = int(50)
ansC = [0]*50
for i in range(50):
    ansC[i] = ((K+i)//50)+i

"""
ansC[0] +=(K+1)
ansC[0] -= (K // 2)
ansC[1] += (K // 2)
"""
print(ans)
print(" ".join(map(str,ansC)))



Measured memory_bytes: 38256
import numpy as np
def main(R,C,K,RCV):
    V=np.zeros((R+1,C+1),dtype=np.int64)
    for i in range(K):
        V[RCV[i][0]][RCV[i][1]]=RCV[i][2]
    d=np.zeros((R+1,C+1,4),dtype=np.int64)
    for i in range(R):
        for j in range(C):
            m=max(d[i][j+1])
            d[i+1][j+1][0]=m
            for k in range(3):
                d[i+1][j+1][k+1]=max(d[i+1][j][k+1],m+V[i+1][j+1],d[i+1][j][k]+V[i+1][j+1])
    return max(d[-1][-1])
import sys
readline=sys.stdin.buffer.readline
read=sys.stdin.buffer.read
if sys.argv[-1]=='ONLINE_JUDGE':
    from numba import*
    from numba.pycc import CC
    cc=CC('my_module')
    def cc_export(f,s):
        cc.export(f.__name__,s)(f)
        return njit(f)
    main=cc_export(main,(i8,i8,i8,i8[:,:],))
    cc.compile()
    exit()
R,C,K=np.array(readline().split(),dtype=np.int64)
RCV=np.array(read().split(),dtype=np.int64).reshape(K,3)
from my_module import main
print(main(R,C,K,RCV))


Measured memory_bytes: 387720
function Main(inputs) {
	const inputline = inputs.split("\n").map(x => parseInt(x, 10));
  	const line = inputline[0];
  
  	function base26(number) {
    	let remainder26 = number % 26;
    	let division26 = Math.floor(number / 26) ;
    	let output = (remainder26 != 0) ? String.fromCharCode(64 + remainder26) : (--division26, 'Z');
      	return (division26 != 0) ? base26(division26) + output : output;
	}
  
  	console.log(base26(line).toLowerCase());
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29556
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

constexpr ll MOD = 998244353;

ll MODpow(ll n, ll m) {
    ll result = 1;
    while (m) {
        if (m % 2 == 1) {
            result *= n;
            result %= MOD;
        }

        m /= 2;
        n *= n;
        n %= MOD;
    }

    return result;
}

ll w[(ll)1e6 + 1];
ll num[(ll)1e6 + 1];

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll V = 0;
    for (ll& a : A) {
        cin >> a;
        V = max(V, a);
        num[a]++;
    }

    for (ll k = 1; k <= V; k++) {
        w[k] += MODpow(k, MOD - 2);

        for (ll j = 2 * k; j <= V; j += k) {
            (w[j] += MOD - w[k]) %= MOD;
        }
    }

    ll ans = 0;
    for (ll d = 1; d <= V; d++) {
        ll less_than_i = 0;
        ll sum = 0;
        for (ll i = d; i <= V; i += d) {
            if (num[i] == 0) {
                continue;
            }

            //i同士
            (sum += i * i % MOD * num[i] % MOD * (num[i] - 1) % MOD * MODpow(2, MOD - 2) % MOD) %= MOD;

            //iとi未満
            (sum += i * less_than_i % MOD * num[i] % MOD) %= MOD;

            //iを未満の方に足す
            (less_than_i += i * num[i]) %= MOD;
        }

        (ans += w[d] * sum % MOD) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 17408
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i <= n/4; i++)
            for (int j = 0; j <= n/7; j++)
                if (4 * i +  7 * j == n) { Console.WriteLine("Yes"); goto end; }
        Console.WriteLine("No");
        end:;
    }
}


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

int main(){
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> b(n);
    b[0] = a[0];
    for (int i = 1; i < n; i++) b[i] = min(b[i - 1], a[i]);
    int max_num = 0;
    for (int i = 0; i < n; i++) max_num = max(max_num, a[i] - b[i]);
    int ans = 0;
    for (int i = 0; i < n; i++) if (a[i] - b[i] == max_num) ans++;
    cout << ans << endl;
}

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

int main(){
    int l,r;
    cin>>l>>r;
    if(l%2019==0||l/2019!=r/2019){
        cout<<0<<endl;
        return 0;
    }
    l%=2019; r%=2019;
    int ans=2020;
    for(int i=l;i<=r;i++){
        for(int j=i+1;j<=r;j++){
            ans=min((i*j)%2019,ans);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
B = False
kaisu = 0
array = list(map(int,input().split()))

def calc(n):
  return int(n) / 2
  
  
while not B:
  for i in range(N):
    if array[i] % 2 == 1:
      B = True
  if not B:
    array = list(map(calc, array))
    kaisu += 1
  else:
    break
        
print(kaisu)

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        ModLcm ml = new ModLcm((int)1e6+6);
        
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
            ml.lcm(a[i]);
        }
        
        int lcm = ml.getModLcm(MOD);
        //System.out.println(lcm);
        
        long ans = 0;
        for(int i=0; i<n; i++){
            long inv = ModLcm.mod_pow(a[i], MOD-2, MOD);
            ans += lcm * inv;
            ans %= MOD;
        }
        
        System.out.println(ans);
        
    }
    
}

class ModLcm{
    private int max;
    private int[] exponent;
    private TreeSet<Integer> base;
    
    public ModLcm(int max){
        this.max = max;
        exponent = new int[max];
        base = new TreeSet<>();
    }
    
    public void lcm(int n){
        for(int i=2; i*i<=n; i++){
            int ex = 0;
            while(n%i==0){
                ex++;
                n /= i;
                base.add(i);
            }
            exponent[i] = Math.max(exponent[i], ex);
        }
        if(n!=1){
            exponent[n] = Math.max(1, exponent[n]);
            base.add(n);
        }
    }
    
    public static long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
    
    public int getModLcm(int mod){
        long res = 1;
        for(int prm : base){
            res *= mod_pow(prm, exponent[prm], mod);
            res %= mod;
        }
        return (int)res;
    }
}

Measured memory_bytes: 34448
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val A = Array.fill(9)(in.nextInt)
  val N = in.nextInt

  (1 to N).foreach {i =>
    val b = in.nextInt
    A.indexWhere(_ == b) match {
      case -1 =>
      case n => A(n) = 0
    }
  }

  val bingos: Seq[Seq[Int]] =
    Seq(0, 4, 8) :: Seq(2, 4, 6) :: (0 to 2).flatMap { i =>
      Seq((0 to 2).map(j => j + i * 3), (0 to 2).map(j => j * 3 + i))
    }.toList

  println(if (bingos.exists(_.forall(A(_) == 0))) "Yes" else "No")
}

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

typedef long long ll;

int A[100005];
int B[100005];
int C[100005];

int main()
{
    int n;
    cin>>n;
    ll tot=0;
    for(int i=0;i<n;i++){
        cin>>A[i]>>B[i];
        C[i]=B[i]+A[i];
        tot+=1LL*B[i];
    }
    sort(C,C+n);
    for(int i=n-1;i>=0;i-=2)
        tot-=C[i];
    cout<<-tot;



}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, O = 0;
  cin >> N;
  for (ll i = 0; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) {O += i;}
  }
  cout << O << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll cnt[100010];
int main()
{
	int N, num = 0;
	ll K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		cnt[a] += b;
		num = max(num, a);
	}
	for (int i = 1; i <= num; i++) {
		K -= cnt[i];
		if (K <= 0) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1024
open Printf
open Scanf

let id x = x

let n = scanf "%d"id
let ns = Array.init n (fun _ -> scanf " %d" id)

let run () =
    let result = ref 0 in
    for i = 0 to n - 1 do
        if (i + 1) mod 2 = 1 && ns.(i) mod 2 = 1 then incr result
    done;
    printf "%d\n" !result

let () = run ()

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

#define ll long long

using namespace std;

int n[1005]={};
int m[1005]= {};

int s1[1005][105]={};
int s2[1005][105]={};

int sum1[1005]={};
int sum2[1005]= {};


int main(){
    int times = 0;
    while(1){
        
        scanf("%d %d",&n[times],&m[times]);
        if(n[times] == 0 && m[times] == 0) break;
        for(int i=0;i<n[times];i++){
            scanf("%d",&s1[times][i]);
            sum1[times] += s1[times][i];
        }
        for(int i=0;i<m[times];i++){
            scanf("%d",&s2[times][i]);
            sum2[times] += s2[times][i];
        }
        times ++;
    }
    for(int k=0;k<times;k++){
        int d = sum2[k]-sum1[k];
        if(abs(d%2) == 1){
            cout << "-1" << endl;
            continue;
        }
        int t[105] = {};
        int h[105] = {};
        for(int i=0;i<n[k];i++) t[i] = s1[k][i];
        for(int i=0;i<m[k];i++) h[i] = s2[k][i];
        sort(t,t+n[k]);
        sort(h,h+m[k]);
        for(int i=0;i<n[k];i++) s1[k][i] = t[i];
        for(int i=0;i<m[k];i++) s2[k][i] = h[i];

        int judge = 0;
        int a,b;

        for(int i=0;i<n[k];i++){
            a = s1[k][i];
            b = a + d/2;
            if(b < 0 || 100 < b) continue;
            for(int j=0;j<m[k];j++){
                if(b == s2[k][j]){
                    judge = 1;
                    break;
                }
                if(b < s2[k][j]) break;
            }
            if(judge) break;
        }
        if(judge) cout << a << " " << b << endl;
        else cout << "-1" << endl;
    }
}


Measured memory_bytes: 3244
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    //4
    int n;
    cin>>n;
    int arr[n];
    loop(n,i,0)
        cin>>arr[i];
    sort(all(arr,n));
    cout<<arr[n/2]-arr[n/2-1]<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 4012
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
 
using namespace std;
 
int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
 
    long long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
 
    if(2 * c > a + b) {
        long long res = x * a + y * b;
        cout << res << endl;
        return 0;
    }
 
    long long done = min(x, y);
    long long res = done * 2 * c;
    x -= done;
    y -= done;
 
    res += x * min(a, 2 * c);
    res += y * min(b, 2 * c);
 
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define f(i,s,n) for(int i=s;i<n;i++)
const int MAXN = 1e7+6 ;
typedef long long ll ;
vector<bool> sieve ;
vector<ll> ans ;
vector<int> temp ;
int n ;
void sieveOfEras()
{
    f(i,2,n+1)
    {
        // temp.clear() ;
        // temp.resize(n+1) ;
        // vector<int> temp(n+1) ;

        if(!sieve[i]) //prime
        {
            ans[i] = 2 ; //1 and itself
            temp[i] = 1 ;
            for(int j=i*2;j<=n;j+=i)
            {
                sieve[j] = true ;
                if((j/i)%i==0)
                    temp[j] = temp[(j/i)]+1 ;
                else temp[j] = 1 ;
                ans[j] *= (ll)(temp[j]+1) ;
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
    cin>>n; 
    sieve.resize(n+1) ;
    ans.resize(n+1,1) ;
    temp.resize(n+1) ;
    sieveOfEras() ;
    ll ret = 0 ;
    f(i,1,n+1) ret+=(i*ans[i]) ;
    cout<<ret<<"\n" ;

}

Measured memory_bytes: 121656
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int
lli dp[305][305][305] = {};
// dp[i][j][k] := iまで見てj回変更して最後の高さはh[k]に等しい
void solve(long long N, long long K, std::vector<long long> H)
{
  H.push_back(0);
  N++;
  rep(i, N + 1) rep(j, N + 1) rep(k, N + 1) dp[i][j][k] = 1e18;
  dp[1][0][0] = H[0];

  for (int i = 1; i < N; i++)
    dp[1][1][i] = H[i];
  for (int i = 1; i < N; i++)
  {
    rep(j, K + 1) rep(k, N)
    {
      chmin(dp[i + 1][j + 1][k], dp[i][j][k]);
      chmin(dp[i + 1][j][i], dp[i][j][k] + max(H[i] - H[k], 0ll));
    }
  }
  lli ans = 1e18;
  rep(i, K + 1) rep(j, N)
      chmin(ans, dp[N][i][j]);

  cout << ans << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &H[i]);
  }
  solve(N, K, std::move(H));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 221184
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(vector<int>& A, int K) {
        int n = A.size();
        int res = 0;
        for (int i = 0; i < n; ++i) {
            int d = A[(i + 1) % n] - A[i];
            if (d < 0) {
                d += K;
            }
            res = max(res, d);
        }
        
        res = K - res;
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int k, n;
    cin >> k >> n;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    Solution sol;
    cout << sol.solve(A, k) << "\n";
    return 0;
}

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

double n, m, d;

signed main() {
  // freopen("in", "r", stdin);
  while(cin >> n >> m >> d) {
    if(d == 0) {
      printf("%.15f\n", (m-1)/n);
    }
    else {
      printf("%.15f\n", 2.0*(n-d)*(m-1)/n/n);
    }
  }
  return 0;
}

Measured memory_bytes: 256
import 	java.util.Scanner;
public class Main{
	public static void main(String[] agrs){
    Scanner s=new Scanner(System.in);
      	int n=s.nextInt();
        int m=s.nextInt();
        
        int[][] a=new int[n][m];
       	int[] b=new int[m];
        int[] c =new int[n];
       
            for(int i=0;i<n;i++){
            	for(int j=0;j<m;j++){
                	a[i][j]=s.nextInt();
                }
            }
            for(int i=0;i<m;i++){
            	b[i]=s.nextInt();
            }
        for(int i=0;i<n;i++){
        	for(int o=0;o<m;o++){
          		c[i]+=a[i][o]*b[o];
            }
        }
        for(int i=0;i<n;i++){
        		System.out.println(c[i]);
        }
        
        s.close();
    }
}


Measured memory_bytes: 40564
import itertools

n,d=map(int, input().split()) 
x=[list(map(int, input().split()))  for i in range(n)]
v=[]
a=0
count=0
for i in itertools.combinations(x,r=2):
    for j in range(d):
        a+=(i[0][j]-i[1][j])**2
    v.append(a)
    a=0
c=round(n*(n-1)/2)
for i in range(c):
    if (v[i]**(1/2)).is_integer():
        count+=1
print(count)

Measured memory_bytes: 3188
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r="";for(int t,n,i,j;(t=s.nextInt())>0;){int[][]a=new int[t+1][t+1];for(i=0;i<t;++i,a[t][t]+=n)for(n=j=0;j<t;++j,n=a[i][t]+=n)a[t][j]+=n=a[i][j]=s.nextInt();for(i=0;i<=t;++i,r+="\n")for(j=0;j<=t;)r+=String.format("%5d",a[i][j++]);}System.out.print(r);}}

Measured memory_bytes: 13000
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<vector>
#include<iostream>
#include<set>
#include<map>
#include<functional>
#include<queue>
#include<string>

using namespace std;

const int MX=311,md=1000000007;
typedef pair<int,int> pii;
#define mp make_pair
#define se second
#define fr first
vector<pii>G[MX];
typedef vector<pii>::iterator vit;
int dp[MX][MX][MX];
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int l,r,x;scanf("%d%d%d",&l,&r,&x);
		G[r].push_back(mp(l,x));
	}
	dp[0][0][0]=1;
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<i;j++)
			for(int k=0;k<i;k++){
				bool flg=true;
				for(vit it=G[i].begin();it!=G[i].end();it++){
					if((i>=it->fr)+(j>=it->fr)+(k>=it->fr)!=it->se){flg=false;break;}
				}
				if(!flg)continue;
				if(j==i-1){
					for(int l=0;l<=i-1;l++)dp[i][j][k]=(dp[i][j][k]+dp[j][l][k])%md;
				}else if(k==i-1){
					for(int l=0;l<=i-1;l++)dp[i][j][k]=(dp[i][j][k]+dp[k][j][l])%md;
				}else{
					dp[i][j][k]=dp[i-1][j][k];
				}
				if(i==n)ans=(ans+dp[i][j][k])%md;
			}
	}
	printf("%d\n",((ans+ans)%md+ans)%md);
	return 0;
}


Measured memory_bytes: 112896
import sys
import math
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	a, b, x = MAP()
	c = x / (a**2)
	if c >= b/2:
		d = 2*b - 2*c
		#print(c, d)
		ans = math.degrees(math.atan(d/a))
		print(ans)
	else:
		e = 2*a*c/b
		tana = math.degrees(math.atan(e/b))
		ans = 90 - tana
		print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int comb(int n, int k) {
    if (k < 0 || n < k)
        return 0;
    int t = 1;
    for (int i = 0; i < k; ++i) {
        t *= n;
        n--;
    }
    for (int i = 1; i <= k; ++i) {
        t /= i;
    }
    return t;
}

int main() {
    string n;
    int k, ans = 0;
    cin >> n >> k;
    for (int i = n.size() - 1, s = 0; i >= 0 && k > 0; --i, ++s) {
        if (n[s] == '0')
            continue;
        ans += (n[s] - '0' - 1) * comb(i, k - 1) * pow(9, k - 1);
        if (k == 1)
            ans++;
        ans += comb(i, k) * pow(9, k);
        k--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
N, D = map(int, input().split())
lst=[]
for _ in range(N):
    lst.append(list(map(int, input().split())))

count=0

for i in range(N-1):
    for j in range(i+1, N):
        square=0
        for k in range(D):
            square+=(lst[i][k]-lst[j][k])**2
        distance=math.sqrt(square)
        if distance%1==0:
            count+=1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
#define INT_MAX 0x7f7f7f7f
int n, m, dis[105][105];
int floyd()
{
    for(int k = 0; k < n; k++)
        for(int i = 0; i < n; i++){
            dis[i][i] = 0;
            for(int j = 0; j < n; j++)
                if(dis[i][k] != INT_MAX && dis[k][j] != INT_MAX)
                    if(dis[i][j] > dis[i][k] + dis[k][j])
                        dis[i][j] = dis[i][k] + dis[k][j];
            if(dis[i][i] < 0) return 0;
        }
    return 1;
}
int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            dis[i][j] = INT_MAX;
    for(int i = 1; i <= m; i++)
    {
        int x, y, t;
        scanf("%d%d%d", &x, &y, &t);
        dis[x][y] = t;
    }
    if(floyd())
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++){
                if(dis[i][j] != INT_MAX) printf("%d", dis[i][j]);
                else printf("INF");
                putchar(" \n"[j == n-1]);
        }
    else printf("NEGATIVE CYCLE\n");
    return 0;
}


Measured memory_bytes: 2124
function Main(input) {

    input = input.split(" ");

    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var k = parseInt(input[2], 10);

    var count = 0;
    var value = 0;

    for (var i = 100; i > -1; i--) {

        if ((a % i == 0) && (b % i == 0)) {
            count++;
        }

        if (count == k) {
            value = i;
            break;
        }

    }




    console.log(value);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<stdio.h>
#include<stdbool.h>
 struct Card{
   char suit;
   char value;
 };
 void bubble(struct Card A[],int N){
  int i,j;
   for(i=0;i<N;i++){
     for(j=N-1;j>=i+1;j--){
       if(A[j].value<A[j-1].value){
        struct Card t=A[j];
         A[j]=A[j-1];
         A[j-1]=t;
       }
     }
   }
 }

void selection(struct Card A[],int N){
int i,j;
  for(i=0;i<N;i++){
    int minj=i;
    for(j=i;j<N;j++){
      if(A[j].value<A[minj].value)minj=j;
    }
struct Card t=A[i];
A[i]=A[minj];
A[minj]=t;
  }
}

void print(struct Card A[],int N){
int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%c%c",A[i].suit,A[i].value);
  }
printf("\n");
}
bool isS(struct Card C1[],struct Card C2[],int N){
int i;
for(i=0;i<N;i++){
  if(C1[i].suit != C2[i].suit)return false;
}
return true;
}

int main(){
  struct Card C1[100],C2[100];
  int N,i;
  char ch;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c %c",&C1[i].suit,&C1[i].value);
  }
for(i=0;i<N;i++)C2[i]=C1[i];
bubble(C1,N);
selection(C2,N);

print(C1,N);
printf("Stable\n");
print(C2,N);
if(isS(C1,C2,N)){
  printf("Stable\n");
}
else{
  printf("Not stable\n");
}
return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

typedef long long   ll;
typedef long double ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(int N, const vector<ll> & L) {
  ll res=0;
  ll a, b, c;
  rep(i, N)
    rep3(j, i, N)
    rep3(k, j, N)
    if (i!=j && j!=k && k!=i){
      a=L[i], b=L[j], c=L[k];
      if (a!=b && b!=c && c!=a)
        if (a+b>c && b+c>a && c+a>b)
          res++;
    }

  return res;
}

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

  int N;
  cin >> N;
  vector<ll> L(N);
  rep (i, N) {
    cin >> L[i];
  }

  auto ans = solve(N, L);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3168
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n;
	cin>>n;
	int a[101010]={},mx=0,sum=0;
	FOR(i,0,n){
		cin>>a[i];
		mx=max(mx,a[i]);
		sum+=a[i];
	}

	cout<<sum-mx/2<<endl;
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<ll>a(n+1);
    for (int i = 0; i < n + 1; ++i) {
        cin >>a[i];
    }
    ll ans=0;
    for (int i = 0; i < n; ++i) {
        ll b;cin >>b;
        if(a[i]>b){
            ans+=b;
            a[i]-=b;
        }
        else if(a[i]+a[i+1]>b){
            ans+=b;
            b-=a[i];
            a[i]=0;
            a[i+1]-=b;
        }
        else {
            ans+=a[i]+a[i+1];
            a[i]=0;a[i+1]=0;
        }
//        cout <<ans <<endl;
    }
//    for (int j = 0; j < n+1; ++j) {
//        cout <<a[j]<<" ";
//    }
//    cout <<endl;
    cout <<ans <<endl;
    return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define MOD 998244353
using namespace std;
typedef long long ll;
ll dp[3001][3001];
int main() {
  int n, s;
  int a[3000];
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0][0] = 1LL;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= s; j++) {
      dp[i + 1][j] = dp[i][j] * 2LL % MOD;
      if (j - a[i] >= 0) {
        dp[i + 1][j] += dp[i][j - a[i]];
      }
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[n][s] << endl;
}

Measured memory_bytes: 73940
#include <iostream>
#include <unordered_map>
#include <utility>
#include <cstdlib>

int main() {
  using namespace std;
  
  int n;
  unordered_map<int, int> even, odd;
  
  cin >> n;
  
  for (int i = 0; i < n; ++i) {
    int c;
    cin >> c;
    if ((i & 1)) {
      odd[c]++;
    } else {
      even[c]++;
    }
  }
  
  pair<int,int> em1,em2,om1,om2;
  for (auto &&x : even) {
    if (em1.second < x.second) {
      em2 = em1;
      em1 = x;
    } else if (em2.second < x.second) {
      em2 = x;
    }
  }
  for (auto &&x : odd) {
    if (om1.second < x.second) {
      om2 = om1;
      om1 = x;
    } else if (om2.second < x.second) {
      om2 = x;
    }
  }
  
  if (em1.first == om1.first) {
    if (em1.second + om2.second > em2.second + om1.second) {
      cout << (n - em1.second - om2.second) << endl;
    } else {
      cout << (n - em2.second - om1.second) << endl;
    }
  } else {
    cout << (n - em1.second - om1.second) << endl;
  }
      
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

int main()
{
	fast;
	int n;
	cin >> n;
	vi a(n), b(n);
	forn
	{
		cin >> a[i] >> b[i];
	}
	sort(all(a));
	sort(all(b));
	// print(a);
	// print(b);
	int x, y;
	// find median
	// a[i] always < b[i]
	if (n % 2)
	{
		x = a[n / 2];
		y = b[n / 2];
	}
	else
	{
		// no need to /2 because range stays the same
		x = a[n / 2] + a[n / 2 - 1];
		y = b[n / 2] + b[n / 2 - 1];
	}
	// range = (max - min + 1)
	// cout << x << " " << y << en;
	cout << y - x + 1 << en;
	return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll N;
    cin >> N;

    vll c(1000000, 0);
    REP(x, 1, 101) REP(y, 1, 101) REP(z, 1, 101){
        ll n = x*x + y*y + z*z + x*y + y*z + z*x;
        ++c[n];
    }
    REP(n, 1, N+1){
        cout << c[n] << endl;
    }
}


Measured memory_bytes: 11116
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i,n) cin >> h[i];
  
  sort(h.begin(), h.end());
  int ans = INF;
  rep(i,n-k+1) {
    ans = min(ans, h[i+k-1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;

int V,E,sta,fin,mon,cha,sum,inf=100000,cost[25][25],dist[25];
bool used[25];

int main(){
	char tmp;
	cin>>V>>E;
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			cost[i][j]=inf;
		}
	}
	for(int i=0;i<V;i++){
		cost[i][i]=0;
	}
	for(int i=0;i<E;i++){
		int a,b,c,d;
		cin>>a>>tmp>>b>>tmp>>c>>tmp>>d;
		cost[a-1][b-1]=c;
		cost[b-1][a-1]=d;
	}
	cin>>sta>>tmp>>fin>>tmp>>mon>>tmp>>cha;
	for(int k=0;k<2;k++){
		int x,y;
		if(k==0){
			x=sta;
			y=fin;
		}
		else{
			x=fin;
			y=sta;
		}
		fill(dist,dist+V,inf);
		fill(used,used+V,false);
		dist[x-1]=0;
		while(1){
			int v=-1;
			for(int i=0;i<V;i++){
				if(!used[i]&&(v==-1||dist[i]<dist[v])) v=i;
			}
			if(v==-1) break;
			used[v]=true;
			for(int i=0;i<V;i++){
				dist[i]=min(dist[i],dist[v]+cost[v][i]);
			}
		}
		sum+=dist[y-1];
	}
	cout<<mon-sum-cha<<endl;
}

Measured memory_bytes: 1160