akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n,m;
int x[110],y[110];
int t[10][10];
int win[10],lose[10];

void print() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << t[i][j] << " \n"[j+1==n];
    }
  }
  cout << "win : ";
  for (int i = 0; i < n; i++) {
    cout << win[i] << " \n"[i+1==n];
  }
}

int dfs(int p, int q) {
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (win[i] < (n-1)/2) ok = false;
  }
  if (ok) return 1;
  int res = 0;
  if (t[p][q]) {
    if (q+1 == n) res += dfs(p+1,p+2);
    else res += dfs(p,q+1);
  } else {
    if (win[p] < (n-1)/2 && lose[q] < (n-1)/2) {
      t[p][q] = 1; t[q][p] = -1;
      win[p]++; lose[q]++;
      if (q+1 == n) res += dfs(p+1,p+2);
      else res += dfs(p,q+1);
      win[p]--; lose[q]--;
      t[p][q] = 0; t[q][p] = 0;
    }
    if (win[q] < (n-1)/2 && lose[p] < (n-1)/2) {
      t[p][q] = -1; t[q][p] = 1;
      win[q]++; lose[p]++;
      if (q+1 == n) res += dfs(p+1,p+2);
      else res += dfs(p,q+1);
      win[q]--; lose[p]--;
      t[p][q] = 0; t[q][p] = 0;
    }
  }
  return res;
}

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

  while (cin >> n, n) {
    cin >> m;
    REP(i,m) cin >> x[i] >> y[i], x[i]--, y[i]--;
    ZERO(t);
    ZERO(win);
    ZERO(lose);
    REP(i,m) {
      t[x[i]][y[i]] = 1;
      t[y[i]][x[i]] = -1;
      win[x[i]]++;
      lose[y[i]]++;
    }
    cout << dfs(0,1) << endl;
  }

  return 0;
}


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

int main(){
    int n, i;
    cin >> n;
    while (n != 0)
    {
        vector<int> s(n);
        for(int i = 0; i < n; i++){
            cin >> s[i];
        }
        sort(s.begin(), s.end());
        int sum = 0;
        for(int i = 1; i < n - 1; i++){
            sum += s[i];
        }
        cout << sum / (n - 2) << endl;
        cin >> n;
    }
    
    return 0;
}


Measured memory_bytes: 3040
import sys

input = sys.stdin.readline

N, T = list(map(int,input().split()))
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda k: k[0])

resbmax = [0]*N
bmax = 0
for i in range(N-1,0,-1):
	bi = AB[i][1]
	bmax = max(bmax,bi)
	resbmax[i-1] = bmax

dp = [[[] for i in range(T)] for i in range(N+1)]
for i in range(T):
	dp[0][i] = 0

ans = 0
i = 0
for ai, bi in AB:
	for j in range(T):
		if j>=ai:
			dp[i+1][j] = max(dp[i][j-ai]+bi, dp[i][j])
		else:
			dp[i+1][j] = dp[i][j]

	ans = max(ans, dp[i+1][-1]+resbmax[i])
	i += 1

print(ans)

Measured memory_bytes: 457224
stdin = open(0).read().split('\n')
K, N = map(int,stdin[0].split())
A = list(map(int,stdin[1].split()))
max = K-A[-1]+A[0]
for i in range(N-1):
    if A[i+1]-A[i] > max:max=A[i+1]-A[i]
print(K-max)

Measured memory_bytes: 26124
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace AtCorder
{
	public class Program
	{
		public static void Main()
		{
			var input = Array.ConvertAll(ReadLine().Split(), int.Parse);
			var table = new List<string[]>();
			for(int i = 0; i<input[0]; i++)
			{
				var line = ReadLine();
				if(line.Contains("#"))
				{
					table.Add(line.Select(x => x.ToString()).ToArray());
				}
			}
			for(int i = 0; i<input[1]; i++)
			{
				bool empty = true;
				for(int j = 0; j<table.Count; j++)
				{
					if(table[j][i] == "#")
					{
						empty = false;
						break;
					}
				}
				if(empty)
				{
					for(int j = 0; j<table.Count; j++)
					{
						table[j][i] = "";
					}
				}
			}

			foreach(var line in table)
			{
				WriteLine(string.Join("", line));
			}
		}
	}
}


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

//ofstream outputfile("test.txt");
int main(){
    int n,m;
    while(cin>>n){
        if(n==0)break;
        vector<pair<int,int>>xy(n);
        for(int i=0;i<n;i++)cin>>xy[i].first>>xy[i].second;
        cin>>m;
        vector<pair<char,int>>mo(m);
        for(int i=0;i<m;i++)cin>>mo[i].first>>mo[i].second;
        auto now = make_pair(10,10);
//        now.first=10;now.second=10;
        int ans = 0;
        int v[n];
        memset(v,0,sizeof(v));
        //pair<int,int>before;
        for(int i=0;i<m;i++){
            //before = now;
            if(mo[i].first=='N'){   
                for(int j=0;j<mo[i].second;j++){
                    now = make_pair(now.first,now.second+1);
                    for(int k=0;k<n;k++){
                        if(now.first==xy[k].first&&now.second==xy[k].second){
                            if(v[k]==1)continue;
                            //cout<<"AAA:"<<now.first<<" "<<now.second<<endl;
                            v[k]=1;
                            ans++;
                        }
                    }
                }
            }else if(mo[i].first=='E'){
                for(int j=0;j<mo[i].second;j++){
                    now = make_pair(now.first+1,now.second);
                    for(int k=0;k<n;k++){
                        if(now.first==xy[k].first&&now.second==xy[k].second){
                            if(v[k]==1)continue;
                            v[k]=1;
                            ans++;
                        }
                    }
                }
            }else if(mo[i].first=='S'){
                for(int j=0;j<mo[i].second;j++){
                    now = make_pair(now.first,now.second-1);
                    for(int k=0;k<n;k++){
                        if(now.first==xy[k].first&&now.second==xy[k].second){
                            if(v[k]==1)continue;
                            v[k]=1;
                            ans++;
                        }
                    }
                }
            }else if(mo[i].first=='W'){
                for(int j=0;j<mo[i].second;j++){
                    now = make_pair(now.first-1,now.second);
                    //cout<<"test:"<<now.first<<" "<<now.second<<" ans:"<<ans<<endl;
                    for(int k=0;k<n;k++){
                        if(now.first==xy[k].first&&now.second==xy[k].second){
                            if(v[k]==1)continue;
                            //cout<<"test:"<<now.first<<" "<<now.second<<endl;
                            v[k]=1;
                            ans++;
                        }
                    }
                }
            }
        }
        if(ans==n){
            cout<<"Yes"<<endl;
            //outputfile<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
          //  outputfile<<"No"<<endl;
        }
    }
        //outputfile.close();
}


Measured memory_bytes: 3016
#include<iostream>
#include<cstdio>
#define gmi(a,b) a=(a)<(b)?(a):(b)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FOF(i,a,b) for(int i=a;i< b;i++)
using namespace std;
typedef long long ll;
const int N=550;
const ll INF=1e18;
int n,x;
ll ans,a[N][N],b[N][N],f[N][N];
ll SB(int x,int y){return b[x][x]-b[x][y]-b[y][x]+b[y][y];}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOF(i,0,n)FOF(j,0,n)if(i!=j){
		scanf("%d",&x);
		j<i?a[j+1][i]=x:b[i+1][j]=x;
	}
	FOR(i,1,n)FOR(j,1,n){
		a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
		b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
	}
	FOR(i,1,n)FOR(j,0,i) f[i][j]=INF;
	FOR(i,1,n)FOR(j,0,i)FOR(k,0,j)
		gmi(f[i][j],f[j][k]+a[k][i-1]-a[k][j-1]+SB(i-1,j));
	//FOR(i,1,n)FOR(j,0,i-1) cout<<f[i][j]<<" \n"[j==i-1];
	ans=INF;
	FOF(j,0,n) ans=min(ans,f[n][j]);
	cout<<ans<<'\n';
}

Measured memory_bytes: 7168
gets.to_i.times do
  score, count, base = 0, 0, [false] * 3
  
  while count < 3
    case gets.chomp
    
    when "HIT"
      if base[2]
        base[2] = false
        score += 1
      end
      base[1], base[2] = false, true if base[1]
      base[0], base[1] = false, true if base[0]
      base[0] = true
    
    when "HOMERUN"
      score += base.count(true) + 1
      base = [false] * 3
    
    when "OUT"
      count += 1
    end
  end
  
  puts score
end

Measured memory_bytes: 8632
#include <bits/stdc++.h>
#define int long long
//#define double long double
#define endre getchar();getchar();return 0
#define moder (int)(1e9+7)
#define inf (int)(5*1e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/
struct edge { int from, to, cost; };
vector<edge>as;
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
int n;
P p[114514], q[114514];

//Union-Find
int par[114514], siz[114514];
void init(int n) {
	rep(i, n) {
		par[i] = i;
		siz[i] = 1;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
bool same(int x, int y) {
	return find(x) == find(y);
}
void unite(int x, int y) {
	x = find(x), y = find(y);
	if (x == y)return;
	if (siz[x] < siz[y]) {
		par[x] = y;
		siz[y] += siz[x];
	}
	else {
		par[y] = x;
		siz[x] += siz[y];
	}
}

void kruscal() {
	sort(all(as), comp);
	int ans = 0;
	init(n);
	for (edge e : as) {
		if (!same(e.from, e.to)) {
			unite(e.from, e.to);
			ans += e.cost;
		}
	}
	cout << ans << endl;
}
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> p[i].first >> q[i].first;
		p[i].second = i; q[i].second = i;
	}
	sort(p, p + n);
	sort(q, q + n);
	rep(i, n - 1) {
		as.push_back({ p[i].second,p[i + 1].second,p[i + 1].first - p[i].first });
		as.push_back({ q[i].second,q[i + 1].second,q[i + 1].first - q[i].first });
	}
	kruscal();
	endre;
}

Measured memory_bytes: 11888
N,K=map(int,input().split())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
#####segfunc#####
def segfunc(x, y):
    return max(x,y)
#################

#####ide_ele#####
ide_ele =0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
Ma=max(A)
Tree=[0]*(Ma+1)
seg = SegTree(Tree, segfunc, ide_ele)
ans=0
for i in range(N):
    a=A[i]
    l=max(0,a-K)
    r=min(a+K,Ma)
    Ans=seg.query(l,r+1)
    seg.update(a, Ans+1)
    ans=max(ans,Ans+1)
print(ans)

Measured memory_bytes: 149280
a,b,c,d=map(int,input().split())

x1 = a*c
x2 = a*d
x3 = b*c
x4 = b*d

z = x1
if z < x2:
    z = x2
if z < x3:
    z = x3
if z < x4:
    z = x4

print(z)

Measured memory_bytes: 9116
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		int[] cnt = new int[3];
		for(;sc.hasNext();) {
			int a[] = new int[3];
			for(int i=0;i<3;i++) a[i] = sc.nextInt();
			sort(a);
			int b = triangle(a);
			if(b<0) break;
			cnt[b]++;
		}
		for(;sc.hasNext();)sc.next();
		System.out.println((cnt[0]+cnt[1]+cnt[2]) + " " + cnt[1] + " " + cnt[0] + " " + cnt[2]);
	}
	
	int triangle(int[] a) {
		if(a[0]+a[1] <= a[2]) return -1;
		if(a[0]*a[0] + a[1]*a[1] > a[2]*a[2])  return 0;
		if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2]) return 1;
		if(a[0]*a[0] + a[1]*a[1] < a[2]*a[2]) return 2;
		return -1;
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

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

int main(){
  int r,c,k;
  cin >> r >> c >> k;
  long v[r][c];
  rep(i,r)rep(j,c)v[i][j] = 0;
  //long dp[4][r][c];
  vector<vector<vector<long>>> dp(4,vector<vector<long>>(r, vector<long>(c)));
  rep(i,4)rep(j,r)rep(l,c)dp[i][j][l] = 0;
  rep(i,k){
    long ri,ci,vi;
    cin >> ri >> ci >> vi;
    ri--;ci--;
    v[ri][ci] = vi;
  }
  rep(i,r-1){
    rep(j,4){
      rep(l,c-1){
        if(j != 3)dp[j+1][i][l+1] = max(dp[j+1][i][l+1],dp[j][i][l]+v[i][l]);
        dp[j][i][l+1] = max(dp[j][i][l+1],dp[j][i][l]);
        if(j != 3)dp[0][i+1][l] = max(dp[0][i+1][l],dp[j][i][l]+v[i][l]);
        dp[0][i+1][l] = max(dp[0][i+1][l],dp[j][i][l]);
      }
      if(j != 3)dp[0][i+1][c-1] = max(dp[0][i+1][c-1],dp[j][i][c-1]+v[i][c-1]);
      dp[0][i+1][c-1] = max(dp[0][i+1][c-1],dp[j][i][c-1]);
    }
  }
  rep(j,4){
    rep(l,c-1){
      if(j != 3)dp[j+1][r-1][l+1] = max(dp[j+1][r-1][l+1],dp[j][r-1][l]+v[r-1][l]);
      dp[j][r-1][l+1] = max(dp[j][r-1][l+1],dp[j][r-1][l]);
    }
  }
  long ans = max(dp[0][r-1][c-1]+v[r-1][c-1],dp[1][r-1][c-1]+v[r-1][c-1]);
  ans = max(ans,dp[2][r-1][c-1]+v[r-1][c-1]);
  ans = max(ans,dp[3][r-1][c-1]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 424868
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

const long long MAX = 210000;

void check(vector<int> &A, vector<int> &data, int N, int K, int b){
	vector<int> ans;
	// cout<<"b = "<<b<<" "<<endl;
	for(int i = b; i < N*K; i++){
		if(data[i%N]+i > N*K){
			ans.push_back(A[i%N]);
		} else {
			i += data[i%N]-1;
		}
	}
	
	for(int i = 0; i < ans.size(); i++){
		cout<<ans[i]<<" ";
	}
	cout<<endl;
}
void solve(vector<int> &A, int N, int K){
	vector<vector<pair<int,int>>> storage(MAX+10);
	vector<int> used(N+10, -1), data(N+10,0);
	int maximum = 0, minimum = INF;
	
	for(int i = 0; i < N; i++){
		storage[A[i]].push_back(make_pair(i,0));
		maximum = max(maximum, A[i]);
		minimum = min(minimum, A[i]);
	}
	for(int i = minimum; i <= maximum; i++){
		for(int j = 0; j < storage[i].size(); j++){
			if(j == storage[i].size()-1){
				storage[i][j].second = storage[i][0].first + (N - storage[i][j].first);
			} else {
				storage[i][j].second = storage[i][j+1].first - storage[i][j].first;
			}
			data[storage[i][j].first] = storage[i][j].second+1;
		}
	}
	
	// for(int i = 0; i < N; i++){
		// cout<<"data "<<data[i]<<endl; 
	// }
	for(int i = 0, now = 0, con = 0;;){ //cout<<con<<" "<<now<<endl;
		if(used[now] != -1){
			int num = con - used[now];
			
			// for(;;){ cout<<"X "<<con<<" "<<num<<endl;
				// if(num+con < K)con += num;
				// else break;
			// }
			// cout<<"num "<<num<<" "<<con<<endl;
			// if((N*K-con)%num) con = N*K - (num-(N*K-con)%num);
			if((N*K-con)%num) con = N*K - (N*K-con)%num;
			else con = N*K;
			
			// cout<<"Y "<<con<<endl;
			now = con%N;
			
			for(;;){ //cout<<"Z "<<con<<endl; 
				if(data[now] + con > K){
					check(A,data,N,K,con);
					// simulation(A,N,K,con);
					break;
				} else {
					con += data[now];
				}
			}
			break;
		}
		used[now] = con;
		
		if(data[now] + con > K){
			check(A,data,N,K,con);
			// simulation(A,N,K,con);
			break;
		} else {
			con += data[now];
			now = (con)%N;
		}
	}
}

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N, K;
	vector<int> A;
	
	cin>>N>>K;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	solve(A,N,K);
	
	
	return 0;
}

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

int main()
{

        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

        int t=1;
        /// cin>>t;

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

            vector<double> v(n),v1(n);

            cin>>v[0];
            v[0]=(v[0]+1)/2;
            v1[0]=v[0];



            for(int i=1;i<n;i++)
            {
                cin>>v[i];
                v[i]=(v[i]+1)/2;

                v1[i]=v[i]+v1[i-1];


            }

            double max1=v1[k-1];

            for(int i=0;i<n-k;i++)
            {
                if(v1[i+k]-v1[i]>max1)
                    max1=v1[i+k]-v1[i];
            }


            cout<<fixed<<setprecision(13)<<max1<<endl;


        }


         return 0;

    }


Measured memory_bytes: 3456
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll kaijou(ll x){
  ll ans=1;
  while(1){
    if(x==0) return ans;
    ans*=x;
    ans%=1000000007;
    x--;
  }
}
int main(){
  ll n,m;
  cin >>n>>m;
  if(n>m) swap(n,m);
  if(m-n>1) cout <<"0"<<endl;
  else{
    if(m==n) cout <<((2*kaijou(m)%1000000007)*kaijou(n))%1000000007<<endl;
    else cout <<(kaijou(m)*kaijou(n))%1000000007<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[10010];
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	int sum = 0;
	int maxx = 0;
	for(int i = 0; i < n; i++){
		cin >> p[i];
		maxx = max(p[i],maxx);
		sum += p[i];
	}
	cout << sum - maxx / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (m > n) {
            System.out.println("No");
            sc.close();
            return;
        }
        int sum = 0;
        int[] rating = new int[n];
        for (int i = 0; i < n; i++) {
        	rating[i] = sc.nextInt();
        	sum += rating[i];
        }
        Arrays.sort(rating);
        double minimumVote = (double)sum / 4.0 / (double)m;
        for (int i = n - m; i < n; i++) {
        	if (rating[i] < minimumVote) {
        		System.out.println("No");
        		sc.close();
        		return;
        	}
        }
        System.out.println("Yes");
        sc.close();
    }
}

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


struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

struct UnionFind {
     //par[N-1]までしかない（Nがない）ことに注意
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2根の時は自分の番号parには根ではなく親が入っている

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化,コンストラクタ
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main(){

int N,K,L;
cin>>N>>K>>L;
int p[K];
int q[K];
int r[L];
int s[L];

UnionFind douro(N);
UnionFind tetudo(N);

rep(i,K){
    cin>>p[i]>>q[i];
    p[i]--;
    q[i]--;
    douro.unite(p[i],q[i]);

}

rep(i,L){
    cin>>r[i]>>s[i];
    r[i]--;
    s[i]--;
    tetudo.unite(r[i],s[i]);
}
int ans[N]={};
map <pair<int,int>,int> mp;//キーは
rep(i,N){
    mp[pair<int,int> (douro.root(i),tetudo.root(i))]++;
}

rep(i,N){
    cout<<mp[pair<int,int> (douro.par[i],tetudo.par[i])]<<endl;
}

return 0;
}

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

int main()
{
    long long int n ;
    cin>>n;
    map<long long int,long long int>freq;
    long long int arr[n];
    long long int i,val;
    for(i=0ll;i<n;i++)
    {
        cin>>arr[i];
        freq[arr[i]]++;
    }
    long long int sum=0;
    for(auto itr=freq.begin();itr!=freq.end();++itr)
    {
        val=itr->second;
        if(val>=2ll)
            sum+=(val*(val-1ll))/2ll;
    }
    for(i=0;i<n;i++)
    {
        long long int ans=sum;
        val = freq[arr[i]];
        if(val>=2ll)
            ans= ans - (val*(val-1ll))/2ll;
        val--;
        if(val>=2ll)
            ans+=(val*(val-1ll))/2ll;
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 12032
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
struct segT {
	int n, seg[200005];
	int val[4000005], idx[4000005], tp = 0;
	inline void modify(int pos, int x)
	{
		for (; pos <= n; pos += pos & -pos) {
			idx[tp] = pos;
			val[tp++] = seg[pos];
			seg[pos] = std::max(seg[pos], x);
		}
	}
	inline int query(int pos)
	{
		int res = -1e9;
		for (pos = std::min(pos, n); pos; pos -= pos & -pos) {
			res = std::max(res, seg[pos]);
		}
		return res;
	}
	inline void pop(int lim)
	{
		while (tp != lim) {
			tp--;
			seg[idx[tp]] = val[tp];
		}
	}
} seg[2];
char ans[200005];
int arr[200005], val[200005], enp[200005][2], suf[200005];
int main()
{
	// freopen("AGC028-E.in", "r", stdin);
	int n, cur_mn = 1e9;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", arr + i);
		arr[i] = n - arr[i] + 1;
		val[i] = arr[i] < cur_mn;
		if (arr[i] < cur_mn) {
			cur_mn = arr[i];
		}
	}
	seg[0].n = seg[1].n = n;
	memset(seg[0].seg, 0, sizeof(seg[0].seg));
	memset(seg[1].seg, -0x3f, sizeof(seg[1].seg));
	for (int i = n - 1; i >= 0; i--) {
		suf[i] = suf[i + 1] + val[i];
		int tmp[2];
		for (int j = 0; j < 2; j++) {
			enp[i][j] = seg[j].tp;
			tmp[j] = std::max(0, seg[j].query(arr[i]));
		}
		for (int j = 0; j < 2; j++) {
			int x = tmp[j] + val[i] + 1;
			seg[x & 1].modify(arr[i], x);
		}
	}
	std::vector<int> cur = {n + 1, n + 1}, len = {0, 0};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			seg[j].pop(enp[i][j]);
		}
		for (int j = 0; j < 2; j++) {
			auto ncur = cur, nlen = len;
			if (arr[i] < ncur[j]) {
				ncur[j] = arr[i];
				nlen[j]++;
			}
			bool flg = false;
			if (i + 1 == n) {
				flg = nlen[0] == nlen[1];
			} else {
				for (int k = 0; k < 2; k++) {
					int x = nlen[k] - nlen[k ^ 1] + suf[i + 1];
					if (x >= 0 && seg[x & 1].query(ncur[k ^ 1]) >= x) {
						flg = true;
					}
				}
			}
			if (flg) {
				ans[i] = j + '0';
				cur = ncur;
				len = nlen;
				break;
			}
		}
		if (!ans[i]) {
			puts("-1");
			return 0;
		}
	}
	puts(ans);
	return 0;
}


Measured memory_bytes: 43392
#include<bits/stdc++.h>
#define int long long
#define MAX 100001
using namespace std;
string LCS(string a,string b)
{
    int dp[a.size()+1][b.size()+1];
    memset(dp,0,sizeof(dp));
    char dp2[a.size()+1][b.size()+1];
    for(int i=1;i<=a.size();++i)
    {
        for(int j=1;j<=b.size();++j)
        {
            if(a[i-1] == b[j-1])
            {
                dp[i][j] = dp[i-1][j-1]+1;
                dp2[i][j] = 'D';
            }
            else if(dp[i-1][j] > dp[i][j-1])
            {
                dp[i][j] = dp[i-1][j];
                dp2[i][j] = 'U';
            }
            else
            {
                dp[i][j] = dp[i][j-1];
                dp2[i][j] = 'L';
            }
        }
    }
    int i=a.size(),j=b.size();
    string str= "";
    while(i!=0 && j!=0)
    {
        if(dp2[i][j] == 'D')
        {
            i--;
            j--;
            str += a[i];
        }
        else if(dp2[i][j] == 'U')
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(str.begin(),str.end());
    return str;
}
 
int32_t main()
{
    string a,b;
    cin>>a>>b;
 
    cout << LCS (a,b) <<endl;
    return 0;
}

Measured memory_bytes: 79488
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

sum = 0
for i in range(1, N+2):
    sum += abs(A[i] - A[i-1])

for i in range(1, N+1):
    print(sum - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]) + abs(A[i+1] - A[i-1]))


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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  LL N,X,ans=0;
  cin >> N >> X;
  VLL x(N);
  REP(i,N){
    cin >> x.at(i);
    x.at(i) -= X;
  }
  
  
  REP(i,N){
    ans = __gcd(ans,x.at(i));
  }
  
  cout << abs(ans) << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, t, c = 0;
  cin >> N;
  t = N;
  for(; t > 0; t /= 10){
    c += t % 10;
  }
  if(N % c == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    int n; cin >> n;
    for (int num = 1; num <= n; ++num) {
        if (num % 3 == 0) cout << " " << num;
        else {
            int tmp = num; 
            while (tmp) {
                if (tmp % 10 == 3) {
                    cout << " " << num;
                    break;
                }
                else tmp /= 10;
            }
        }
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3096
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        final int X=scanner.nextInt();
        boolean[] booleans=new boolean[1000];
        booleans[0]=true;
        for(int i=2;i<32;i++){
            for(int j=2;Math.pow(i,j)<=1000;j++){
                booleans[(int)Math.pow(i,j)-1]=true;
            }
        }
        for(int i=X-1;i>-1;i--){
            if(booleans[i]) {
                System.out.println(i+1);
                return;
            }
        }



    }

}

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

using namespace std;

int main(void){
    long long int n, a, b, c, d, e;
    vector<long long int> l;

    cin >> n >> a >> b >> c >> d >> e;

    l.push_back(a);
    l.push_back(b);
    l.push_back(c);
    l.push_back(d);
    l.push_back(e);

    sort(l.begin(), l.end());

    // cout << l[0] << endl;
    long long int s = (n + (l[0] - 1)) / l[0];
    if(s == 0){
        cout << 4 << endl;
    }
    else{
        cout << s+4 << endl;
    }
}

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

#define _ << " " <<
#define tr(x) cout << #x _ x << endl

#ifdef _WIN32
#define LD "%I64d"
#else
#define LD "%ld"
#endif

using namespace std;

typedef long long ll;

int a, b, c;

int read() {
    if (scanf("%d%d%d", &a, &b, &c) < 3) {
        return 0;
    }
    return 1;
}

void solve() {
    int cnt5 = 0, cnt7 = 0;

    cnt5 += (a==5);
    cnt5 += (b==5);
    cnt5 += (c==5);

    cnt7 += (a==7);
    cnt7 += (b==7);
    cnt7 += (c==7);

    if (cnt5 == 2 && cnt7 == 1) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
}

int main() {
//    freopen(in, r, stdin);
    while (1) {
        if (!read()) break;
        solve();
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	map<int, int> num;
	REP(i, n){
		int x;
		cin >> x;
		num[x]++;
	}
	int s = num.size();
	int list[s];
	int x = 0;
	for(map<int, int>::iterator it = num.begin(); it != num.end(); ++it){
		list[x] = it->second;
		x++;
	}
	sort(list, list+s);
	int ans = 0;
	for(int i = 0; i < s-k; i++){
		ans += list[i];
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int N, a, min, count;
  cin >> N;
  for (int i=0; i<N; i++) {
    count = 0;
    cin >> a;
    while (a%2 == 0) {
      a /= 2;
      count++;
    }
    if (i == 0)
      min = count;
    if (min > count)
      min = count;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
/**
 *    author:  Mohamad Milhem
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


void solve(){
	int n;
	cin >> n;
	vector<long long> v(n);
	long long sum = 0;


	lp(i, 0 , n){
		cin >> v[i];
		sum+= v[i];
	}


	long long bigsum = 0;


	lp(i , 0 , n){
		sum-= v[i];
		long long l = (v[i] * (sum%MOD)) % MOD;
		bigsum = (bigsum%MOD + l%MOD)%MOD;
	}

	cout << bigsum << endl;

}



int main()
{
    FAST;
    int t;
    t = 1;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    vvi a(n,vi(10));
    REP(i,n){
        REP(j,10){
            cin>>a[i][j];
        }
    }
    vvi b(n,vi(11));
    REP(i,n){
        REP(j,11){
            cin>>b[i][j];
        }
    }
    int ans=-INF;
    FOR(i,1,1<<10){
        int sum=0;
        REP(j,n){
            int cnt=0;
            REP(k,10){
                if(i&(1<<k)){
                    if(a[j][k]){
                        cnt++;
                    }
                }
            }
            sum+=b[j][cnt];
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;
int main() {
    string str;
    cin >> str;

    vector<int> idx;
    // O:n
    rep(i, 0, str.size() - 1) {
        if (str[i] == 'R' && str[i + 1] == 'L') {
            idx.push_back(i);
        }
    }

    idx.push_back(10001000);

    // rep(i, 0, idx.size()) {
    //     cout << idx[i];
    //     if (i < idx.size() - 1) {
    //         cout << " ";
    //     } else {
    //         cout << endl;
    //     }
    // }

    //
    int nextidx = 0;
    int previdx = -1;
    vector<int> pos(str.size(), 0);
    rep(i, 0, str.size()) {
        // printf("%d: \n", i);
        // update idx
        if (i > idx[nextidx]) {
            // printf("  over\n");
            nextidx++;
            previdx++;
        }

        // int len;
        // if (str[i] == 'R') {
        //     // nextidx
        //     len = idx[nextidx] - i;
        //     pos[nextidx + (len % 2)]++;
        // } else {
        //     // previdx
        //     len = i - idx[previdx];
        //     pos[previdx + (len % 2)]++;
        // }
        int _idx = -1;
        if (str[i] == 'R') {
            _idx = idx[nextidx];
        } else {
            _idx = idx[previdx];
        }
        int len = abs(_idx - i);
        int add = _idx + (len % 2);
        // printf("  %d %d %d\n", _idx, len, add);
        // printf("%d %d\n", i, idx[_idx] + (len % 2));
        // pos[idx[_idx] + (len % 2)]++;
        pos[add]++;
    }

    // print result
    rep(i, 0, pos.size()) {
        cout << pos[i];
        if (i < pos.size() - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<int> A(N + 5), B(N + 5);
    rep(i, 0, N) cin >> A[i];

    rep(i, 1, N) {
        B[i] = A[i] - A[i - 1];
    }
//    rep(i, 2, N) {
//        if (B[i] == 0) {
//            B[i] = B[i - 1];
//        }
//    }
//    for (int i = N - 2; i >= 1; i--) {
//        if (B[i] == 0) {
//            B[i] = B[i + 1];
//        }
//    }
    int mode = 0;
    int ans = 1;
    rep(i, 1, N) {
        if (mode == 0) {
//            ans++;
            if (B[i] > 0) {
                mode = 1;
            } else if (B[i] < 0) {
                mode = -1;
            }
        } else if (mode == 1) {
            if (B[i] < 0) {
                ans++;
                mode = 0;
            }
        } else if (mode == -1) {
            if (B[i] > 0) {
                ans++;
                mode = 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {

  vector<int> vec; 

  vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int k;
  cin >> k;

  cout << vec.at(k-1) << endl;
}
  


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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

int N;
int a[105];
int ans;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>a[i];
        if((i+1)%2==1&&a[i]%2==1)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3564
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=200005;
int a[N],b[N],a1[N],b1[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  cin>>n;
  rep(i,1,n+1) cin>>a[i];
  rep(i,1,n+1) cin>>b[i];
  int ans=0;
  rep(i,0,29)
    {
      ll sum=0;
      int pw=(1<<(i+1));
      rep(j,1,n+1) a1[j]=a[j]%pw,b1[j]=b[j]%pw;
      sort(a1+1,a1+n+1); sort(b1+1,b1+n+1);
      pw>>=1;
      rep(j,1,n+1)
	{
	  //count pairs such that a[i]+b[j]>=2^i and <2*2^i
	  int ind1=lower_bound(b1+1,b1+n+1,pw-a1[j])-b1;
	  int ind2=upper_bound(b1+1,b1+n+1,2*pw-1-a1[j])-b1;
	  ind2--;
	  if(a1[j]+b1[ind1]<pw || a1[j]+b1[ind2]>=(pw<<1)) continue;
	  sum+=(ind2-ind1+1);
	  //count pairs such that a[i]+b[j]>=3*2^i and <4*2^i
	  ind1=lower_bound(b1+1,b1+n+1,3*pw-a1[j])-b1;
	  ind2=upper_bound(b1+1,b1+n+1,4*pw-1-a1[j])-b1;
	  ind2--;
	  if(a1[j]+b1[ind1]<3*pw || a1[j]+b1[ind2]>=4*pw) continue;
	  sum+=(ind2-ind1+1);
	}
      if(sum&1) ans+=(1<<i);
    }
  cout<<ans<<endl;
  return 0 ;
}


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

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    int a;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        if(i % 2 != 0) {
            if(a % 2 != 0) cnt++;
        }
    }
    cout << cnt << endl;

return 0;
}

Measured memory_bytes: 3616
import sys

if __name__ == '__main__':
    N, K = map(int, input().split())
    xy_list = [list(map(int, input().split())) for i in range(N)]

    all_x = sorted(list(set([xy[0] for xy in xy_list])))
    all_y = sorted(list(set([xy[1] for xy in xy_list])))

    answer = sys.maxsize
    for i in range(len(all_x)):
        x1 = all_x[i]
        for j in range(i+1, len(all_x)):
            x2 = all_x[j]
            for k in range(len(all_y)):
                y1 = all_y[k]
                for l in range(k+1, len(all_y)):
                    y2 = all_y[l]
                    if answer > (x2-x1) * (y2-y1) and K <= sum(map(lambda xy: (x1 <= xy[0] <= x2) and (y1 <= xy[1] <= y2), xy_list)):
                        answer = (x2-x1) * (y2-y1)

    print(answer)


Measured memory_bytes: 66684
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll 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) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)


int main() {
	string s;
	cin >> s;
	rep(i, 3) {
		if (s[i] == s[i + 1]) {
			cout << "Bad";
			return 0;
		}

	}
	cout << "Good";
}
	



Measured memory_bytes: 3608
import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer

object Main {
  def getPrice(total:Int,a:Int,b:Int,c:Int,d:Array[Array[Array[Int]]]):Int = {
    if(total==0) {
      d(a)(b)(c)=((a/5)*5*380*0.8+((a%5)*380)*1.0+(b/4)*4*550*0.85+(b%4)*550*1.0+(c/3)*3*850*0.88+(c%3)*850).toInt
      d(a)(b)(c)
    } else if(d(a)(b)(c)>0) d(a)(b)(c)
    else {
      var min = Int.MaxValue
      if(total==200 || total>=400) {
        val p = getPrice(total-200,a+1,b,c,d)
        if(p<min) min = p
      }
      if(total==300 || total>=500) {
        val q = getPrice(total-300,a,b+1,c,d)
        if(q<min) min = q
      }
      if(total==500 || total>=700) {
        val r = getPrice(total-500,a,b,c+1,d)
        if(r<min) min = r
      }
      min
    }
  }

  def main(args:Array[String]) = {
    val b = new ArrayBuffer[Int]
    var n = 0
    while({n=readInt;n}!=0) {
      val d = Array.ofDim[Int](n/200+1,n/300+1,n/500+1)
      b+=getPrice(n,0,0,0,d)
    }
    println(b.mkString("\n"))
  }
}

Measured memory_bytes: 45192
#define z 1000000
a[z],b[z],n,i=1,x,c;main(){for(;i++<z;)a[i]=i;for(i=-1;i++<z;)if(a[i]){b[x++]=i;for(c=0;c<z;c+=i)a[c]=0;}for(;~scanf("%d",&n);){c=0;while(b[c]<=n&&b[c])c++;printf("%d\n",c);}exit(0);}

Measured memory_bytes: 0
/* 
 * Project: AtCoder Beginners Contest 053 
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/11
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstring>
using namespace std;

char s[200000];

void solve() {
    
    int cnt_a = 0;
    int cnt_z = 0;
    bool is_find_a = false;
    bool is_find_z = false;
    for (int i=0;i<strlen(s)-1;i++) {
        if (is_find_a) {
            ;
        } else if (!strncmp(&s[i], "A", 1)) {
            cnt_a = i;
            is_find_a = true;
        }
        if (is_find_z) {
            ;
        } else if (!strncmp(&s[strlen(s)-1-i], "Z", 1)) {
            cnt_z = i;
            is_find_z = true;
        }
    }
    printf("%ld\n", strlen(s)-cnt_z-cnt_a);
}

int main() {

    scanf("%s", s);

    solve();

}

Measured memory_bytes: 512