akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define mper make_pair
#define PI 3.14159
#define fe first
#define se second
#define ll long long
//#define forik(i, a, b) for(ll i = a; i <= b; ++i)
#define vl vector<ll>
#define pll pair<ll, ll>
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;

const ll INF = 1e15;
const ll MAXN = 2011;
ll n, x, t[MAXN * 8], a[MAXN * 2];

void build(ll v = 1, ll tl = 1, ll tr = n) {

    if(tl == tr) {t[v] = a[tl]; return;}

    ll tm = (tl + tr) >> 1;

    build(v + v, tl, tm);
    build(v + v + 1, tm + 1, tr);

    t[v] = min(t[v + v], t[v + v + 1]);

}

ll get(ll l, ll r, ll v = 1, ll tl = 1, ll tr = n) {

    if(r < tl || tr < l) {return INF;}
    if(l <= tl && tr <= r) {return t[v];}

    ll tm = (tl + tr) >> 1;

    return min(get(l, r, v + v, tl, tm), get(l, r, v + v + 1, tm + 1, tr));

}

int main() {

mal

cin >> n >> x;

ll ans = 0;

for(int i = 1; i <= n; ++i) {
    cin >> a[i];
    ans += a[i];
}

n *= 2;

for(int i = (n / 2) + 1, j = 1; i <= n; ++i, ++j) {
    a[i] = a[j];
}

build();

for(int len = 1; len <= (n / 2); ++len) {

    ll sum = 0;
    ll ct = 0;

    for(int l = n - len, r = n; l >= 1; --l, --r) {
        ct++;
        if(ct == (n / 2) + 1) {break;}
        sum += get(l, r);

    }

    ans = min(ans, sum + (len * x));

}

cout << ans;

return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000;
int n, a[maxn + 10], fa[maxn + 10], m, ans;
ll totw[maxn + 10];
bool vis[maxn + 10];
struct edge {
	int l, r, w;
	bool operator < (const edge &t) const {
		return w < t.w;
	}
}b[maxn + 10];
bool is[maxn + 10];

struct edge2 {
	int to, w;
};
vector<edge2> g[maxn + 10];

int getf(int p) {
	return fa[p] == p ? p : fa[p] = getf(fa[p]);
}

void dfs(int p, int w) {
	vis[p] = 1;
	for (int i = 0; i < (int)g[p].size(); ++i) {
		edge2 e = g[p][i];
		if (!vis[e.to] && e.w <= w) dfs(e.to, w);
	}
}

int main() {
	scanf("%d%d", &n, &m); ans = m;
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1; i <= m; ++i) {
		scanf("%d%d%d", &b[i].l, &b[i].r, &b[i].w);
		g[b[i].l].push_back((edge2){b[i].r, b[i].w});
		g[b[i].r].push_back((edge2){b[i].l, b[i].w});
	}
	sort(b + 1, b + m + 1);
	for (int i = 1; i <= n; ++i) {
		fa[i] = i; totw[i] = a[i];
	}
	for (int i = 1; i <= m; ++i) {
		int x = getf(b[i].l), y = getf(b[i].r);
		if (x != y) {
			fa[x] = y; totw[y] += totw[x];
		}
		if (totw[y] >= b[i].w) is[i] = 1;
	}
	for (int i = m; i >= 1; --i) {
		if (vis[b[i].l]) --ans;
		else if (is[i]) {
			--ans;
			dfs(b[i].l, b[i].w);
		}
	}
	printf("%d", ans);
}

Measured memory_bytes: 13312
#include <iostream>
#include <unordered_set>

int main()
{
	int n = 0;
    std::cin >> n;
    
    std::unordered_set<int> intSet;
    
    for(int index = 0; index < n; ++index)
    {
        int a = 0;
        std::cin >> a;
        
        if(!intSet.emplace(a).second)
        {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }
    
    std::cout << "YES" << std::endl;
}

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



signed main(){
  while(true){
    int n;cin >> n;
    if(n == 0)break;
    
    // mp[e].first: 社員番号
    // mp[e].second.first: 売上の合計
    // mp[e].second.second: 入力に最初に入ったときの順番
    map<int, pair<int, int>> mp;
    for(int i = 0;i < n;i++){
      int e, p, q;cin >> e >> p >> q;
      if(mp.find(e) == mp.end()){
        mp[e] = make_pair(p*q, i);  // 一回目の処理
      }else{
        mp[e] = make_pair(mp[e].first+p*q, mp[e].second); // 二回目以降の処理
      }
    }
    
    // 条件を満たす社員をソートするためのvector
    // vec[i].first: 入力に最初に入ったときの順番
    // vec[i].second: 社員番号
    vector<pair<int, int>> vec;
    for(auto x: mp)if(x.second.first >= 1000000){
      vec.push_back(make_pair(x.second.second, x.first)); // 条件を満たす社員を追加
    }
    sort(vec.begin(), vec.end()); // ソート実行
    
    if(vec.size() == 0){
      cout << "NA" << endl;   // 該当する社員がいなかった時
      continue;
    }
    for(int i = 0;i < vec.size();i++){
      cout << vec[i].second << endl; // 社員出力
    }
  }
  return 0;
}







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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1L << 30
#define long long long

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

long N,K;
int main(){
	cin >> N >> K;
	long ans = N%K;

	chmin(ans, abs(ans-K));

	cout << ans << endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int x,s1=0,s2=0;
	for(int i=0;i<4;i++){
		cin >> x;
		s1+=x;
	}
	for(int i=0;i<4;i++){
		cin >> x;
		s2+=x;
	}
	cout << max(s1,s2) << endl;
	return 0;
}


Measured memory_bytes: 3100
x=list(map(int,input()))
if x[0]+x[1]+x[2]+x[3]==7:
  print(str(x[0])+"+"+str(x[1])+"+"+str(x[2])+"+"+str(x[3])+"=7")
  exit()
if x[0]-x[1]+x[2]+x[3]==7:
  print(str(x[0])+"-"+str(x[1])+"+"+str(x[2])+"+"+str(x[3])+"=7")
  exit()
if x[0]-x[1]-x[2]+x[3]==7:
  print(str(x[0])+"-"+str(x[1])+"-"+str(x[2])+"+"+str(x[3])+"=7")
  exit()
if  x[0]+x[1]-x[2]+x[3]==7:
  print(str(x[0])+"+"+str(x[1])+"-"+str(x[2])+"+"+str(x[3])+"=7")
  exit()
if x[0]+x[1]+x[2]-x[3]==7:
  print(str(x[0])+"+"+str(x[1])+"+"+str(x[2])+"-"+str(x[3])+"=7")
  exit()
if x[0]-x[1]+x[2]-x[3]==7:
  print(str(x[0])+"-"+str(x[1])+"+"+str(x[2])+"-"+str(x[3])+"=7")
  exit()
if x[0]-x[1]-x[2]-x[3]==7:
  print(str(x[0])+"-"+str(x[1])+"-"+str(x[2])+"-"+str(x[3])+"=7")
  exit()
if  x[0]+x[1]-x[2]-x[3]==7:
  print(str(x[0])+"+"+str(x[1])+"-"+str(x[2])+"-"+str(x[3])+"=7")
  exit()

Measured memory_bytes: 3192
# -*- coding: utf-8 -*-S
x,y = [int(i) for i in input().split()]

"""
if x == 2 or y == 2:
    print("No")
elif x == 4 or x == 6 or x == 9 and y == 6 or y == 9 or y == 11:
    print("Yes")
elif x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10　and y == 3 or y == 5 or y == 7 or y == 8 or y == 10 or y == 12:
    print("Yes")
else:
    print("No")
"""

A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
tmp = False

for i in range(7):
    if A[i] == x:
        for j in range(i,7):
            if A[j] == y:
                tmp = True
for i in range(4):
    if B[i] == x:
        for j in range(i,4):
            if B[j] == y:
                tmp = True
if tmp:
    print("Yes")
if not tmp:
    print("No")


Measured memory_bytes: 3064
///Astalavista Code........~boy_with_no_gf
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl; 
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2e6 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
// <=================================================================================================================================
// <=================================================================================================================================


void fun(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=c*(ceil)((double)a/b);
    cout<<ans;
}

signed  main() {
    lets_go

      int t;
      t=1;
// cin >> t;
    while (t--) {            
         fun();             
    }                        
                            
                            
    return 0;

}


Measured memory_bytes: 3648
import sys

h,w = map(int, input().split())
a = []
for i in range(w):
  a.append(0)
for i in range(h):
  for s in input():
    if s == "#":
      a.append(1)
    else:
      a.append(0)
for i in range(w):
  a.append(0)

for i,j in enumerate(a):
  if i < w:
    continue
  if i >= h*w+w:
    break
  if j == 1 and a[i-1]+a[i-w]+a[i+1]+a[i+w] == 0:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 3064
N, Y = map(int, input().split())
x = -1
y = -1
z = -1
for i in range(N+1):
    for j in range(N+1-i):
        k = N-i-j
        if 10000*i + 5000*j + 1000*k == Y:
            x = i
            y = j
            z = k
print(x, y, z)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
map<int,int> m;
while(n--)
{
	int x;
	cin>>x;
	m[x]++;
}
int ans=0;
tr(m,it)
{
	if((it->ss)%2)ans++;
}
ol(ans);
return 0;
}



Measured memory_bytes: 4992
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=1000100, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,dp[N][4];
signed main()
{
    n=read();
    dp[1][0]=8, dp[1][1]=dp[1][2]=1;
    for(ri int i=2;i<=n;i++)
    for(ri int j=0;j<10;j++)
    for(ri int k=0;k<4;k++)
    {
        int qwq=k;
        if(!j) qwq|=(1ll<<0);
        if(j==9) qwq|=(1ll<<1);
        dp[i][qwq]=(dp[i][qwq]+dp[i-1][k])%Mod;
    }
    int res=0;
    printf("%lld\n",dp[n][3]);
    return 0;
}

Measured memory_bytes: 34864
#include<stdio.h>
int main(){
	int x,s,m,h;
	scanf("%d",&x);
	h=x/3600;
	m=(x-h*3600)/60;
	s=x-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1812
import sys

def solve():
    input = sys.stdin.readline
    s = input().strip("\n")
    K = int(input())
    substr = set()
    N = len(s)
    for i in range(N):
        for j in range(1, min(6, N - i + 1)):
            substr |= {s[i:i+j]}
    sl = list(substr)
    sl.sort()
    print(sl[K-1])

    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 39920
#include <iostream>
#include <string>
using namespace std;
bool used_H[100];
bool used_W[100];
int main(void){
    int H,W;
    cin >> H >> W;
    string a[H];
    for(int i=0;i<H;i++){
        cin >> a[i];
    }
    int count = 0;
    for(int i=0;i<H;i++){
        count = 0;
        for(int j=0;j<W;j++){
            if(a[i][j] == '.'){
                count++;
            }
        }
        if(count == W){
            used_H[i] = true;
        }
    }
    for(int i=0;i<W;i++){
        count = 0;
        for(int j=0;j<H;j++){
            if(a[j][i] == '.'){
                count ++;
            }
        }
        if(count == H){
            used_W[i] = true;
        }
    }
    
    for(int i=0;i<H;i++){
        bool OK = false;
        for(int j=0;j<W;j++){
            if(!used_H[i] && !used_W[j]){
                OK = true;
                cout << a[i][j];
            }
        }
        if(OK)cout << endl;
    }
    
}


Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vpll path;
//***********//
int main() { 
	char C;
	cin >> C;
	if (C <= 'Z') cout << 'A';
	else cout << "a";
}

Measured memory_bytes: 3592
package main

import "fmt"

func reverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func main() {
	var N int
	fmt.Scan(&N)
	var S string
	fmt.Scan(&S)
	a := make([]int, N)
	b := make([]int, N)
	a[0] = 0
	for i, r := range S[0 : N-1] {
		if r == 'W' {
			a[i+1] = a[i] + 1
		}
		if r == 'E' {
			a[i+1] = a[i]
		}
	}
	T := reverse(S)
	b[0] = 0
	for i, r := range T[0 : N-1] {
		if r == 'E' {
			b[i+1] = b[i] + 1
		}
		if r == 'W' {
			b[i+1] = b[i]
		}
	}
	min := N
	for i := 0; i < N; i++ {
		if x := a[i] + b[N-1-i]; x < min {
			min = x
		}
	}
	fmt.Println(min)
}


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

int n,l,e[99];
int dp[99][999];

int main(){
  cin >> n;
  while(n--){
    cin >> l;
    for(int i=0;i<l;i++)cin >> e[i];
    if(l==1){
      cout << e[0] << endl;
      continue;
    }

    memset(dp,0,sizeof(dp));
    dp[0][e[0]] = e[1];
    
    for(int i=1;i<l-1;i++){
      for(int j=0;j<=4*l;j++){
	dp[i][dp[i-1][j]] = max(dp[i][dp[i-1][j]], e[i+1]);
	if(dp[i-1][j]>0){
	  dp[i][dp[i-1][j]-1] = max(dp[i][dp[i-1][j]-1], j+e[i+1]);
	}
      }
    }

    int ans = 0;
    for(int i=0;i<=4*l;i++){
      ans = max(ans, dp[l-2][i]);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1552
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int main()
{
	int n;
	cin >> n;
	ll a, b;
	cin >> a >> b;

	REP(i, n - 1)
	{
		ll x, y;
		cin >> x >> y;

		ll ta1, ta2, tb1, tb2;

		ta1 = (a + (x - 1)) / x * x;
		tb1 = ta1 / x * y;

		tb2 = (b + (y - 1)) / y * y;
		ta2 = tb2 / y * x;

		//cout << ta1 << " " << tb1 << endl;
		//cout << ta2 << " " << tb2 << endl;

		if (tb1 < b)
		{
			b = tb2; a = ta2;
		}
		else if (ta2 < a)
		{
			b = tb1; a = ta1;
		}
		else if (ta1 + tb1 < ta2 + tb2)
		{
			b = tb1; a = ta1;
		}
		else
		{
			b = tb2; a = ta2;
		}

	}

	cout << a + b << endl;

}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int n; cin >> n;
    vector<pair<int, int>> p[n];
    rep(i,n) {
        int a; cin >> a;
        rep(j,a) {
            int x,y; cin >> x >> y;
            p[i].push_back({x-1,y});
        }
    }
    int ans = 0;
    rep(i,1<<n) {
        int b[n];
        rep(j,n) {
            if (i&(1<<j)) {
                b[j] = 1;
            } else {
                b[j] = 0;
            }
        }
        bool flag = 1;
        rep(j,n) {
            if (i&(1<<j)) {
                for (auto pp : p[j]) {
                    if (b[pp.first] != pp.second) {
                        flag = 0;
                    }
                }
            }
        }
        if (!flag) continue;
        int anss = 0;
        rep(j,n) {
            if (i&(1<<j)) anss++;
        }
        ans = max(ans,anss);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010];
    cin >> N;
    rep(i,0,N) cin >> A[i];
    sort(A, A+N);
    ll cnt[100010] = {};
    rep(i,0,N) cnt[A[i]]++;
    ll v = 0;
    rep(i,0,100001){
        if(cnt[i] > 0 && cnt[i] % 2 == 0){
            v++;
        }
    }
    ll ans = 0;
    rep(i,0,100001){
        if(cnt[i] > 0) ans++;
    }
    if(v % 2 == 0){
        print(ans);
    }else{
        print(ans-1);
    }
}

Measured memory_bytes: 1792
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 1e6;
const int N = 1e3 + 5, M = 35;
const ll INF = 1e15;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;

#define pi acos(-1)

int vis[10];

int main()
{
    memset(vis, -1, sizeof vis);
    int n, m;
    cin >> n >> m;
    int flag = 1;
    while(m--)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        if(vis[x] == -1)
            vis[x] = y;
        else if(y != vis[x])
        {
            flag = 0;
        }    
    }
    if(!flag)
    {
        puts("-1");
    }
    else
    {
        if(vis[1] == 0)
        {
            if(n == 1)
                puts("0");
            else
            {
                puts("-1");
            }        
        }
        else
        {
            for(int i = 1; i <= n;i++)
            {
                if(vis[i] == -1)
                {
                    if(i == 1 && n != 1)
                        cout << 1;
                    else
                    {
                        cout << 0;
                    }   
                }
                else
                {
                    cout << vis[i];
                }
                
            }
        }
        
    }
    
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

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

const int MAXN = 100005;
bool _is_prime[MAXN];
vector<int> P;

void eratosthenes(const int N)
{
  for (int i = 0; i <= N; i++) {
    _is_prime[i] = true;
  }
  _is_prime[0]=_is_prime[1]=false;
  for (int i = 2; i <= N; i++) {
    if (_is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        _is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll q; cin>>q;
  vll l(q), r(q);
  rep(i,q) cin>>l[i]>>r[i];
  
  ll n=100000;
  eratosthenes(n);
  
  vll s(n+1);
  rep(i,n+1){
    if((i+1)%2==0 && _is_prime[i] && _is_prime[(i+1)/2]) s[i+1]=s[i]+1;
    else s[i+1]=s[i];
  }
  rep(i,q){
    cout<<s[r[i]+1]-s[l[i]]<<endl;
  }
  
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int p, q, r;

    cin >> p >> q >> r;

    OP(min({p + q, q + r, r + p}));

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k,a,b;cin>>k>>a>>b;
  unsigned long long ans=0;
  if(a+1>k) ans=k+1;
  else if(a+1==k) {
    if(a+1>=b) ans=k+1;
    else ans=b+k%(a+1);
  }
  else {
    if(a+1>=b) ans=k+1;
    else {
      ans+=b;
      if(k-a-1>1) ans+=(b-a)*((k-a-1)/2);
      ans+=(k-a-1)%2;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int a,b,c;

        do{
                scanf("%d%d%d",&a,&b,&c);
        }while(( a<0 || a>100) && (b<0 || b>100) && ( c<0 || c>100));

        if(b-a == c-b)printf("YES\n");
        else printf("NO\n");

        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll H, A; cin >> H >> A;
  cout << (H + (A-1)) / A << endl;

  return 0;
}



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

using namespace std;

#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())

int main()
{
    IOS;

    int a[6] = {0};
    for (int i = 0; i < 5; i++)
    {
        int x;
        cin >> x;

        a[x]++;
    }
    int c = -1;
    for (int i = 0; i < 6; i++)
    {
        if (a[i] != 1)
            c = i;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#ifdef WIN32
	#define LL "%I64d"
#else
	#define LL "%lld"
#endif

#ifdef CT
	#define debug(...) printf(__VA_ARGS__)
	#define setfile() 
#else
	#define debug(...)
	#define filename ""
	#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif

#define R register
#define getc() (_S == _T && (_T = (_S = _B) + fread(_B, 1, 1 << 15, stdin), _S == _T) ? EOF : *_S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char _B[1 << 15], *_S = _B, *_T = _B;
inline int F()
{
	R char ch; R int cnt = 0; R bool minus = 0;
	while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
	ch == '-' ? minus = 1 : cnt = ch - '0';
	while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
	return minus ? -cnt : cnt;
}
char s[100010];
int main()
{
//	setfile();
	int n, a, b, cnt = 0, cntb = 0;
	scanf("%d%d%d", &n, &a, &b);
	scanf("%s", s + 1);
	for (int i = 1; i <= n; ++i)
		if (s[i] == 'a')
			if (cnt < a + b) ++cnt, puts("Yes");
			else puts("No");
		else if (s[i] == 'b')
			if (cnt < a + b && cntb < b) ++cnt, ++cntb, puts("Yes");
			else puts("No");
		else puts("No");
	return 0;
}


Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from math import gcd
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7

n=I()
A=LI()
B=sorted(LI(),reverse=True)
s=[]
c=0
ret=0
g,h=Counter(A+B).most_common()[0]
if h>n:
    print("No")
    exit()

for i in range(n):
    if A[i]==B[i]:
        ret+=2
        s+=[i]
        c=A[i]



for j in range(n):
    if A[j]!=c and B[j]!=c and s:
        k=s.pop()
        B[k],B[j]=B[j],B[k]

print("Yes")
print(*B)


















Measured memory_bytes: 157096
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(void){

  int A, B, C, D;		cin >> A >> B >> C >> D;
  int keep1 = max(A , C), keep2 = min(B , D);
  if(keep2 > keep1)
    cout << keep2 - keep1 << endl;
  else
    cout << 0 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <complex>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

// 2円の共通接線。返される各直線に含まれる頂点は円との接点となる
vector<L> tangentLines(P a, D ar, P b, D br) {
  vector<L> ls;
  D d = abs(b-a);
  rep (i,2) {
    D sin = (ar - (1-i*2)*br) / d;
    if (!LE(sin*sin, 1)) break;
    D cos = sqrt(max(1 - sin*sin, 0.0));
    rep (j,2) {
      P n = (b-a) * P(sin, (1-j*2)*cos) / d;
      ls.push_back(L(a + ar*n, b + (1-i*2)*br*n));
      if (cos < EPS) break;  // 重複する接線を無視（重複していいならこの行不要）
    }
  }
  return ls;
}

int main() {
  int n;
  cin >> n;
  D xa, ya, ra, xb, yb, rb;
  rep (_,n) {
    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    vector<L> ls = tangentLines(P(xa,ya), ra, P(xb,yb), rb);
    if (ls.size() == 4) cout << 0;
    else if (ls.size() == 0) cout << ((ra < rb) ? -2 : 2);
    else cout << 1;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>

int main(void){
    int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?'){
            break;
        }
        else if(op=='+'){
            printf("%d\n",a+b);
        }
        else if(op=='-'){
            printf("%d\n",a-b);
    }
        else if(op=='*'){
        printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }
    }
    return 0;
}



Measured memory_bytes: 2044
n=int(input())
s=input().rstrip()

result = 0
for i in range(n-1):
  pre = set()
  suf = set()
  for j in range(i+1):
    pre.add(s[j])
  for k in range(i+1,n):
    suf.add(s[k])
  result = max(result,len(pre&suf))
print(result)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

// 1-indexed
type BIT [2][]int

func NewBIT(n int) *BIT {
	var b BIT
	for i := range b {
		b[i] = make([]int, n)
	}
	return &b
}

// [l,r)にxを加算
func (b *BIT) add(l, r, x int) {
	add_sub := func(p, idx, x int) {
		for idx < len(b[p]) {
			b[p][idx] += x
			idx += idx & (-idx)
		}
	}
	add_sub(0, l, -x*(l-1))
	add_sub(0, r, x*(r-1))
	add_sub(1, l, x)
	add_sub(1, r, -x)
}

// [l,r)の和
func (b *BIT) sum(l, r int) int {
	sum_sub := func(p, idx int) int {
		s := 0
		for idx > 0 {
			s += b[p][idx]
			idx -= idx & (-idx)
		}
		return s
	}
	return sum_sub(0, r-1) + sum_sub(1, r-1)*(r-1) - (sum_sub(0, l-1) + sum_sub(1, l-1)*(l-1))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	s := []byte(next())
	// bits[i]: 文字iについてのBIT
	bits := make([]*BIT, 26)
	for i := range bits {
		bits[i] = NewBIT(n + 1)
	}
	for i := range s {
		bits[int(s[i]-'a')].add(i+1, i+2, 1)
	}

	q := nextInt()
	for ; q > 0; q-- {
		t := nextInt()
		if t == 1 {
			i, c := nextInt()-1, next()[0]
			if s[i] == c {
				continue
			}
			bits[int(s[i]-'a')].add(i+1, i+2, -1)
			bits[int(c-'a')].add(i+1, i+2, 1)
			s[i] = c
		} else {
			l, r := nextInt(), nextInt()
			res := 0
			for i := 0; i < 26; i++ {
				if bits[i].sum(l, r+1) > 0 {
					res++
				}
			}
			puts(res)
		}
	}
}


Measured memory_bytes: 214416
import sys
input = sys.stdin.readline

N = int(input())
P = [0] * N
highest = 0
for n in range(N):
    P[n] = tuple([int(x) for x in input().strip().split()])
    highest = max(highest, P[n][2])

def calch(c, p):
    return max(c[2] - abs(p[0] - c[0]) - abs(p[1] - c[1]), 0)

def dh(c, p):
    return max(p[2] - (c[2] - abs(p[0] - c[0]) - abs(p[1] - c[1])), 0)

def f(p, P):
    h = -1
    th = -1
    for pp in P:
        if pp[2] == 0:
            if calch(p, pp) == 0:
                continue
            else:
                return -1
        th = dh(p, pp)
        if h == -1 or th == h:
            h = th
        else:
            return -1
    else:
        return th

for x in range(101):
    for y in range(101):
        h = highest
        while True:
            h_ = f((x, y, h), P)
            if h_ == -1:
                break
            elif h_ == 0:
                print(x, y, h)
                exit()
            else:
                h += h_

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


int main(){
    int N;
    cin >> N;
    vector<int> v (N);
    rep(i,N)cin >> v[i];

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

    double ans = v[0];
    for( int i = 1; i<N;i++){
        ans = (double) (ans+v[i])/2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3724
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VD a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    reverse(ALL(a));
    double x = 0.5, ans = 0.0;
    REP(i,n){
        ans += a[i] * x;
        if (i < n - 2) x *= 0.5;
    }
    printf("%.15f\n", ans);

    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author CompuWare
 */

#include <iostream>

class BCraneAndTurtle {
public:
    void solve(std::istream &in, std::ostream &out) {
        int64_t x, y;
        in >> x >> y;
        if (y % 2 != 0 || x > y / 2 || x * 4 < y) {
            out << "No";
            return;
        }
        if (x * 2 > y) {
            out << "No";
        } else
            out << "Yes";
    }
};


int main() {
    BCraneAndTurtle solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <algorithm>
#define int long long
using namespace std;

const int mod=1e9+7;
int n,k,ans=0,x[200005],y[2000005],x2[200005];

inline int read(){
	int s=0,t=1;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')c=getchar(),t=-1;
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return s*t; 
}

int ksm(int x,int y){
	int s=1;
	while(y){
		if(y%2==1)s=(s*x)%mod;
		x=(x*x)%mod;
		y/=2;
	}
	return s;
}

int ni(int x,int mod){
	return ksm(x,mod-2);
}

int c(int n,int m,int p,int ok){
    int xx,yy;
    if(ok==1)xx=x[n-m+1];
    else xx=x2[n-m+1];
    yy=y[m];
//    printf("%lld %lld\n",xx,n-m+1);
//  	for(int i=n;i>=n-m+1;i--)x=x*i%p;
//  	for(int i=1;i<=m;i++)y=y*i%p;
    return xx*ni(yy,p)%p;
}

signed main(void){
	n=read();
	k=read();
	x[n+1]=y[0]=x2[n]=1;
	for(int i=n;i>=1;i--)
	x[i]=(x[i+1]*i)%mod;
	for(int i=n-1;i>=1;i--)
	x2[i]=(x2[i+1]*i)%mod;
	for(int i=1;i<=n+1;i++)
	y[i]=(y[i-1]*i)%mod;
	for(int i=0;i<min(n,k+1);i++){
		int num=c(n,i,mod,1)%mod;
		num=num*c(n-1,i,mod,2)%mod;
		ans=(ans+num)%mod;
	}
	printf("%lld",ans);
} 

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  int sum=0;
  cin >> A >> B >> C >> K;
  
  if (A>K)
   cout << K << endl;
  else if (A+B > K)
    cout << A << endl;
  else
    cout << 2*A+B-K << endl;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
int cnt;

int dfs(int nn){
	if(nn==n){cnt++;return 0;}
	else if(nn>n){return 0;}
	dfs(nn+1);
	dfs(nn+2);
	dfs(nn+3);
	return 0;
}

int main(){
	while(cin>>n){
		cnt=0;
		if(!n)break;
	dfs(0);
	cout<<cnt/10/365+1<<endl;
	}
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c, t = 0, a;
    cin >> n >> c;
    rep(i, c) {
        cin >> a;
        t += a;
    }
    cout << (t + n) / (n + 1) << endl;
}


Measured memory_bytes: 3184
import heapq


class DynamicMedian():
    """値をO(logN)で追加し、中央値をO(1)で求める
    add(val): valを追加する
    median_low(): 小さい方の中央値(low median)を求める
    median_high(): 大きい方の中央値(high median)を求める
    """
    def __init__(self):
        self.l_q = []  # 中央値以下の値を降順で格納する
        self.r_q = []  # 中央値以上の値を昇順で格納する
        self.l_sum = 0
        self.r_sum = 0
        
    def add(self, val):
        """valを追加する"""
        if len(self.l_q) == len(self.r_q):
            self.l_sum += val
            val = -heapq.heappushpop(self.l_q, -val)
            self.l_sum -= val
            heapq.heappush(self.r_q, val)
            self.r_sum += val
        else:
            self.r_sum += val
            val = heapq.heappushpop(self.r_q, val)
            self.r_sum -= val
            heapq.heappush(self.l_q, -val)
            self.l_sum += val
            
    def median_low(self):
        """小さい方の中央値を求める"""
        if len(self.l_q) + 1 == len(self.r_q):
            return self.r_q[0]
        else:
            return -self.l_q[0]

    def median_high(self):
        """大きい方の中央値を求める"""
        return self.r_q[0]

    def minimum_query(self):
        """キューに追加されている値 a1,...,aN に対して、|x-a1| + |x-a2| + ⋯ + |x-aN|の最小値を求める
        x = (a1,...,aN の中央値) となる"""
        res1 = (len(self.l_q) * self.median_high() - self.l_sum)
        res2 = (self.r_sum - len(self.r_q) * self.median_high())
        return res1 + res2


q = int(input())
info = [list(map(int, input().split())) for i in range(q)]
dm = DynamicMedian()

b = 0
for i in range(q):
    if info[i][0] == 1:
        _, tmp_a, tmp_b = info[i]
        dm.add(tmp_a)
        b += tmp_b
    else:
        print(dm.median_low(), dm.minimum_query() + b)

Measured memory_bytes: 110168
program abc160c
  integer :: k, n, a(200000), diff(200000)
  read *, k, n, a(1:n)
  diff(1:n) = [a(2:n)-a(1:n-1),a(1)+k-a(n)]
  print *, sum(diff(1:n)) - maxval(diff(1:n))
end program abc160c


Measured memory_bytes: 3200
//
#include<stdio.h>

int main(void){
  int n,ai,a;
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    a=0;

    for(int i=0;i<n/4;i++){
      scanf("%d",&ai);
      a+=ai;
    }
    printf("%d\n",a);
  }
  return 0;
}



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

int main(void) {
    ll N;
    cin >> N;
    ll A[N], B[N], C[N];
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<N; i++) cin >> B[i];
    for (int i=0; i<N; i++) cin >> C[i];
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);
    int k=0;
    ll mem[N];
    for (int i=0; i<N; i++) mem[i] = 0;
    for (int i=0; i<N; i++) {
        while (true) {
            if (k == N) break;
            if (B[i] < C[k]) {
                mem[i] = N - k;
                break;
            }
            k++;
        }
    }
    for (int i=N-1; i>0; i--) mem[i-1] += mem[i];
    k = 0;
    ll ans = 0;
    for (int i=0; i<N; i++) {
        while (true) {
            if (k == N) break;
            if (A[i] < B[k]) {
                ans += mem[k];
                break;
            }
            k++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
int waru(int N, int kaisuu);

int main() {
	int N;
	cin >> N;
	int kekka = 0;

	for (int i = 1; i <= N; i = i * 2) {
		kekka = i;
	}
	cout << kekka << endl;
}



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

using namespace std;

using ll = long long;

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

    int n, d, x, a;
    cin >> n >> d >> x;

    int sum = x;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        sum += ceil(d / (double)a);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]


    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d"%(dice.get_Top()))





Measured memory_bytes: 6396
w, h = map(int,input().split())
 
if w == 1 or h == 1:
  print(1)
  exit()
  
if (w * h) % 2 == 0:
  print(w * h // 2)
else:    
  a = w // 2 + 1
  s = a * (h // 2 + 1)
  b = w // 2
  s2 = b * (h //2)
  print(s + s2)

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define FOR(i,s,e) for(int i = s; i < e; i++)
#define all(x) (x).begin(),(x).end()
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair

typedef vector<int>       VI;
typedef pair<int, int> pii;
typedef long long ll;


int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    string s;
    int shift;
    cin>>shift>>s;
    for (char c:s){
        char lo = (((int)c)+shift);
        if (lo>'Z'){
            lo-=26;
        }
        cout<<lo;
    }
    freopen("out.txt", "w", stdout);
    return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
ll H, W;
ll id(ll i, ll j){
  if(i%2==0){
    return i*W+j;
  }else{
    return (i+1)*W-1-j;
  }
}

ll N;
llvec a;

/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> H >> W;
  cin >> N;
  a = llvec(N, 0);
  rep(i, N){
    cin >> a[i];
  }
  llvec c;
  rep(i, N){
    rep(j, a[i]){
      c.push_back(i+1);
    }
  }
  rep(i, H){
    rep(j, W){
      cout << c[id(i, j)]<<" ";
    }
    cout << endl;
  }

  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <functional>
#include <map>
using namespace std;

long long N, K, Q, grund;

long long grundy(long long P) {
	if (P%K == 0) return P / K;
	long long nex = P - (P / K) - 1;
	if (nex / K != P / K) {
		return grundy(nex);
	}
	long long J = P / K + 1;
	long long G = (P / K)*K;
	long long I = (P - G) / J;
	return grundy(P - I*J);
}

int main() {
	cin >> Q;
	for (int i = 1; i <= Q; i++) {
		cin >> N >> K;
		grund ^= grundy(N);
	}
	if (grund == 0) cout << "Aoki" << endl;
	else cout << "Takahashi" << endl;
	return 0;
}

Measured memory_bytes: 256