akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int arr[n][3];
	int dp[n][3];
	int res=0;
	//vector<ll>maxi(n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>arr[i][j];
			dp[i][j]=arr[i][j];
		}
	}
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{
			dp[i][j]=dp[i][j]+max(dp[i-1][(j-1+3)%3],dp[i-1][(j+1)%3]);
		}
	}
	res=max(dp[n-1][0],dp[n-1][1]);
	res=max(res,dp[n-1][2]);
	cout<<res;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	int k;

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

	for (int i = 0; i < n; i++) {
		if (s[i] == 'a') {
			continue;
		}

		if ('z' - s[i] + 1 <= k) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	}

	k %= 26;

	s.back() = (26 + s.back() - 'a' + (k % 26)) % 26 + 'a';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<set>
#include<queue>
#include<map>
using namespace std;

typedef long long ll;
const int MAXN=100005;

int n;
int fa[MAXN];
set<int> s[MAXN];
queue<pair<int,int> > q;
map<ll,int> g;

int find(int u){return fa[u]==u?u:(fa[u]=find(fa[u]));}

 ll getID(int x,int y){
    if(x>y) swap(x,y);
    return 1ll*n*y+x;
}

void addEdge(int u,int v){
    s[u].insert(v);
    s[v].insert(u);
    ll eid=getID(u,v);
    int t=g[eid]+1;
    g[eid]++;
    if(t==2) q.push(make_pair(u,v));
}

void re(int u,int v){
    s[u].erase(v);
    s[v].erase(u);
    g.erase(getID(u,v));
}

bool solve(){
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i<n;i++){
        int u,v;
        if(q.empty()) return 0;
        u=q.front().first;
        v=q.front().second;
        q.pop();
        u=find(u); v=find(v);
        if(s[u].size()>s[v].size()) swap(u,v);
        fa[u]=v;
        re(u,v);
        for(set<int>::iterator i=s[u].begin(),j;i!=s[u].end();i=j){
            j=i;
            j++;
            int x=*i;
            x=find(x);
            re(u,x);
            addEdge(v,x);
        }
    }
    return 1;
}

int main(){
    scanf("%d",&n);
    int u,v;
    for(int i=1;i<=(n-1)<<1;i++){
        scanf("%d%d",&u,&v);
        addEdge(u,v);
    }
    puts(solve()?"YES":"NO");
}


Measured memory_bytes: 36608
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  cin >> n;
  set<string> setS;
  map<string, vector<pair<int, int>>> mapS;
  
  for(int i=0; i<n; i++)
  {
    string s;
    int p;
    cin >> s >> p;
    setS.insert(s);
    mapS[s].push_back({-1 * p, i + 1});
  }
  
  for(auto s:setS)
  {
    vector<pair<int,int>> v = mapS[s];
    sort(v.begin(), v.end());
    for(int i=0; i<v.size(); i++)
      cout << v[i].second << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N;
    cin >> N;
    cout << (N - 2) * 180 << endl;
}



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

using namespace std;

#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)

template<typename T>
void err(T a){
    cerr<<a<<'\n';
    cerr<<"END OF DEBUG"<<'\n'<<'\n';
}

const long double PI=acos(-1.0);  
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;

using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

/*head------[@cordercorder]*/

const ll maxn=110ll;

ll N,W;
ll w[maxn],v[maxn];
ll dp[100010];

void solve(){
    for(ll i=1;i<=N;i++){
        for(ll j=W;j>=w[i];j--){
            dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    printf("%lld\n",dp[W]);
}

int main(void){
    scanf("%lld %lld",&N,&W);
    for(ll i=1;i<=N;i++){
        scanf("%lld %lld",&w[i],&v[i]);
    }
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
const ll mod = 1e9 + 7;
const ll N = 2e5 + 200;
const ll INF = 0x3f3f3f;



int main(){
    string s;
    cin>>s;
    ll n = s.length();
    s = "";
    rep(i,n){
        s+='x';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    m,f,r=list(map(int,input().split()))
    if m==f==r==-1:
        break
    if m==-1 or f==-1 or m+f<30:
        print("F")
    elif m+f<50 and r<50:
        print("D")
    elif m+f<65 or r>=50:
        print("C")
    elif m+f<80:
        print("B")
    else:
        print("A")
    
    



Measured memory_bytes: 5596
A,B,K=map(int,input().split())
result = []
L = min(B-A+1,K)
for i in range(A,A+L):
    if i not in result:
        result.append(i)
for j in range(B,B-L,-1):
    if j not in result:
        result.append(j)
result.sort()
for x in result:
    print(x)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define N_MAX 100001

pair<int, int> original[N_MAX];
vector<int> edge[N_MAX];
int visited[N_MAX];
map<pair<int, int>, int> color;

void dfs(int index,int exclude)
{
	int col = 0;
	for (int i = 0; i < edge[index].size(); i++){
		if (0 == visited[edge[index][i]]){
			col++;
			if (col == exclude){
				col++;
			}
			visited[edge[index][i]] = 1;
			color.insert(make_pair(make_pair(index, edge[index][i]), col));
			color.insert(make_pair(make_pair(edge[index][i], index), col));
			dfs(edge[index][i], col);
		}
	}
	return;
}

void solv()
{
	int N; scanf("%d", &N);
	for (int i = 0; i < N - 1; i++){
		int a, b; scanf("%d%d", &a, &b);
		a--; b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
		original[i] = make_pair(a, b);
	}

	int K = 0;
	for (int i = 0; i < N; i++){
		K = max(K, (int)edge[i].size());
	}

	fill(visited, visited + N, 0);
	visited[0] = 1;
	dfs(0, -1);

	printf("%d\n", K);
	for (int i = 0; i < N - 1; i++){
		printf("%d\n", color.at(original[i]));
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

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

class unionfind {
public:
    vector<int> par;
    int n;
    unionfind(int m) : n(m), par(vector<int>(m, -1)) {}
    int find(int i) {
        if (par[i] < 0) return i;
        return par[i] = find(par[i]);
    }
    bool same(int i, int j) {
        return find(i) == find(j);
    }
    int size(int i) {
        return -par[find(i)];
    }
    void unite(int i, int j) {
        if (find(i) == find(j)) return;
        if (size(i) < size(j)) swap(i, j);
        int I = find(i), J = find(j);
        par[I] += par[J];
        par[J] = I;
    }
};

main() {
    map<int, int> soins;
    int n; cin >> n;
    vector<int> a(n);
    rep (i, n) cin >> a[i];
    unionfind uf(n);
    rep (i, n) {
        bool found = false;
        for (int j = 2; j * j <= a[i]; j++) {
            if (a[i] % j == 0) {
                found = true;
                if (soins.find(j) != soins.end()) {
                    uf.unite(soins[j], i);
                } else {
                    soins[j] = i;
                }
                int J = a[i] / j;
                if (j * j != a[i]) {
                    if (soins.find(J) != soins.end()) {
                    uf.unite(soins[J], i);
                    } else {
                        soins[J] = i;
                    }   
                }
            }
        }
        if (!found) {
            if (soins.find(a[i]) != soins.end()) {
                uf.unite(soins[a[i]], i);
            } else {
                soins[a[i]] = i;
            }
        }
    }
    vector<int> res(n);
    vector<int> tmpidx[n];
    vector<int> tmpnum[n];
    rep (i, n) {
        tmpidx[uf.find(i)].push_back(i);
        tmpnum[uf.find(i)].push_back(a[i]);
    }
    rep (i, n) {
        sort(tmpnum[i].begin(), tmpnum[i].end());
        rep (j, tmpidx[i].size()) {
            res[tmpidx[i][j]] = tmpnum[i][j];
        }
    }
    bool ok = true;
    rep (i, n - 1) {
        if (res[i] > res[i + 1]) ok = false;
    }
    cout << ok << endl;
}


Measured memory_bytes: 15136
fn main(){
    let lrd: Vec<u32> = read_vec();
    let l = lrd[0];
    let r = lrd[1];
    let d = lrd[2];
    
    println!("{}", r / d - (l - 1) / d);

}

#[allow(dead_code)]
fn read_vec<T>() -> Vec<T>
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

const int INF = 100000000;

struct Edge {
  int to;
  int cap;
  int rev;
  Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

typedef vector<vector<Edge> > Graph;

void add_edge(Graph& g, int from, int to, int cap) {
  g[from].push_back(Edge(to, cap, g[to].size()));
  g[to].push_back(Edge(from, 0, g[from].size() - 1));
}

// 幅優先探索で増加道を探す
vector<Edge*> compute_augmented_path(Graph& g, int s, int t) {
  int n = g.size();

  // ある頂点の　「直前の頂点」と「直前の辺のインデックス」を格納しておく配列
  vector<int> prevv(n, -1);  // まだ訪れていないなら-1
  vector<int> preve(n);

  queue<int> que;
  que.push(s);
  prevv[s] = -2;  // スタート時点より前はないのでダミーで-2とする

  while (!que.empty()) {
    int v = que.front();
    que.pop();
    rep(ei, g[v].size()) {
      Edge& e = g[v][ei];
      if (e.cap > 0 && prevv[e.to] == -1) {
        // 容量に余裕があり、e.to が未訪問なら記録しつつキューに入れる
        prevv[e.to] = v;
        preve[e.to] = ei;
        que.push(e.to);
      }
    }
  }

  // 逆順に増加道を格納していく。
  // 後に容量を更新したい & 参照型のvectorは作れない　ため、エッジへのポインタのvectorを作る
  vector<Edge*> ret;
  if (prevv[t] == -1) return ret;  // 増加道がない

  for (int v = t; prevv[v] != -2; v = prevv[v]) {
    Edge* e = &g[prevv[v]][preve[v]];
    ret.push_back(e);
  }
  return ret;
}

// gのsからtの最大流を求める。
// gは破壊される（残余ネットワークとなる）。
int max_flow(Graph& g, int s, int t) {
  int f = 0;  // 現在の最大フロー　初期値0

  while (1) {
    // 増加道を探す。増加道がなければその時点のfが最大フローである
    vector<Edge*> augpath = compute_augmented_path(g, s, t);
    if (augpath.empty()) break;

    // 増加道に流れるフローを求め、最大フローに加える
    int inc = INF;
    rep(i, augpath.size()) inc = min(inc, augpath[i]->cap);
    f += inc;

    rep(i, augpath.size()) {
      Edge* e = augpath[i];
      Edge& rev_e = g[e->to][e->rev];
      // 増加道の辺eの容量をincだけ減らし、eの逆辺の容量をincだけ増やす
      e->cap -= inc;
      rev_e.cap += inc;
    }
  }

  return f;
}


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

int solve(int m, int n) {
  vector<int> b(m);
  vector<int> r(n);

  rep(i, m) cin >> b[i];
  rep(i, n) cin >> r[i];

  // グラフを構築　各頂点の意味は以下の通り
  // 0: 始点
  // 1 + i: i番目の青のカード
  // 1 + m + i: i番目の赤のカード
  // 1 + m + n: 終点
  int gn = 1 + m + n + 1;
  Graph g(gn);
  rep(mi, m) rep(ni, n) {
    if (gcd(b[mi], r[ni]) > 1) {
      add_edge(g, 1 + mi, 1 + m + ni, 1);
    }
  }
  rep(mi, m) add_edge(g, 0, 1 + mi, 1);
  rep(ni, n) add_edge(g, 1 + m + ni, 1 + m + n, 1);

  return max_flow(g, 0, 1 + m + n);
}

int main() {
  int m, n;
  while (cin >> m >> n, n||m) cout << solve(m, n) << endl;

  return 0;
}

Measured memory_bytes: 5564
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

bool isInFirld(int row, const int &point)
{
	const int r = point;
	return (0 <= r && r < row);
}

void bfs(vecll& length, ll start, ll n, ll x, ll y)
{
	vecll memo(n,0);

	memo[start] = -1;
	
	const int points[2] = {
		-1,1
	};
	
	queue<int> data;
	data.push(start);

	while (!data.empty()) {

		int cur = data.front();
		data.pop();

		if (cur == x)
		{
			const int pointsX[3] = {
				-1,1,(y-x)
			};
			for (const auto &point : pointsX) {

				int next = cur + point;

				if (isInFirld(n, next)) {
									   
					if (memo[next] == 0 || memo[next] > memo[cur] + 1) {

						data.push(next);
						memo[next] = max((ll)1, memo[cur] + 1);
					}
				}
			}
		}
		else if (cur == y)
		{
			const int pointsY[3] = {
				-1,1,(x - y)
			};
			for (const auto &point : pointsY) {

				int next = cur + point;

				if (isInFirld(n, next)) {

					if (memo[next] == 0 || memo[next] > memo[cur] + 1) {

						data.push(next);
						
						memo[next] = max((ll)1,memo[cur] + 1);
					}
				}
			}
		}
		else
		{
			for (const auto &point : points) {

				int next = cur + point;

				if (isInFirld(n, next)) {

					if (memo[next] == 0 || memo[next] > memo[cur] + 1) {

						data.push(next);
						memo[next] = max((ll)1, memo[cur] + 1);
					}
				}
			}
		}
	}

	forll(i, start, memo.size())
	{
		if (memo[i] < 0)continue;
		length[memo[i]-1]++;
	}

}

int main()
{
	ll n,x,y,ans;
	string s;

	cin >> n >> x >> y;

	vecll len(n-1,0);

	forll(i, 0, n - 1)
	{
		bfs(len,i,n,x-1,y-1);
	}

	forll(i,0,len.size())
		cout << len[i] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pil pair<int,long long>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define pb push_back
#define mk make_pair
#define sd(x) scanf("%d", &x)
#define pd(x) printf("%d\n",x)
#define pdl(x) printf("%lld\n",x)
#define sdl(x) scanf("%lld", &x)
#define eps 1e-12l
#define maxn 100009
using namespace std;
map<pll,int> mp;
int ff[]={-2,-2,-2,-1,-1,-1,0,0,0};
int ss[]={-2,-1,0,-2,-1,0,-2,-1,0};
ll h,w,n;
inline bool check(int xx,int yy)
{
	if(xx>=1&&xx<=h&&yy>=1&&yy<=w&&(xx+2<=h)&&(yy+2<=w))
	{
		return true;
	}
	return false;
}
ll ans[10];
int main()
{
	sdl(h);
	sdl(w);
	sdl(n);
	for(int i=0;i<n;i++)
	{
		ll x,y;
		sdl(x);
		sdl(y);
		for(int j=0;j<9;j++)
		{
			if(check(x+ff[j],y+ss[j]))
			{
				mp[mk(x+ff[j],y+ss[j])]++;
			}
		}
	}
	for(auto it=mp.begin();it!=mp.end();it++)
	{
		int x=(it->second);
		ans[x]++;
	}
	ll fans=0;
	for(int i=1;i<=9;i++)
	{
		fans=fans+ans[i];
	}
	ans[0]=(h-2)*(w-2);
	ans[0]-=fans;
	for(int i=0;i<=9;i++)
	{
		pdl(ans[i]);
	}
}

Measured memory_bytes: 56448
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>
using namespace std;

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

  int N; 
  cin >> N;
  
  vector<double> v(N);
    
  for (int i=0; i<N; ++i) {
    cin >> v[i];
  }
  
  sort(v.begin(), v.end());
  
  double temp = (v[0] + v[1]) / 2;
  
  for (int i=0; i<N-1; ++i) {        
    if (i == 0) {      
      if (0 == N-2) {
        cout << fixed << setprecision(10) << temp;
      }
    } else {
      double h = (temp + v[i+1]) / 2;
      temp = h;
      
      if (i == N-2) {
        cout << fixed << setprecision(10) << h;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 1000000007;
const int INF = 2000000000;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	string s;
	cin >> s;

	sort(all(s));

	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mx = 100000;
vector<bool> prime(mx + 1, true);
vector<int> cnt_prime(mx + 1, 0);

void sieve(){
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<=mx;i++){
    cnt_prime[i] = cnt_prime[i-1];
    if(prime[i]){
      int cnt = 2;
      while(cnt * i <= mx) prime[cnt++ * i] = false;
      if(i % 2 == 1 && prime[(i+1)/2]) cnt_prime[i]++;
    }
  }
}

int main(){
  int q;
  cin >> q;
  int l, r;
  sieve();
  for(int i=0;i<q;i++){
    cin >> l >> r;
    cout << cnt_prime[r] - cnt_prime[l-1] << endl;
  }
}

Measured memory_bytes: 1024
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];

void solve(){
	ll n,k;
	cin>>n>>k;
	if(n==0){
		cout<<0;
		return ;
	}
	VI ans;
	
	while(n){
		ans.pb(n%k);
		n/=k;
	} 
	cout<<sz(ans);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll n,m;
  cin>>n>>m;
  vector<vector<ll>> st(n);
  vector<ll> as(m);
  vector<ll> bs(m);
  rep(i,m)cin>>as[i]>>bs[i];
  rep(i,m) {
    as[i]--;
    bs[i]--;
  }
  vector<ll> par(n);
  rep(i,n) {
    st[i].push_back(i);
    par[i]=i;
  }
  vector<ll> a_ans(m+1);
  a_ans[m]=0;
  revrep(i,m) {
    ll a,b;
    a=par[as[i]];
    b=par[bs[i]];
    if(a==b) {
      a_ans[i]=a_ans[i+1];
    } else {
      if(st[a].size()>st[b].size()) {
        swap(a,b);
      }
      // st[par[a]].size()<=st[par[b]].size()
      ll sa=st[a].size();
      ll sb=st[b].size();
      a_ans[i]=a_ans[i+1]-sa*(sa-1)/2-sb*(sb-1)/2+(sa+sb)*(sa+sb-1)/2;
      for(auto& e : st[a]) {
        par[e]=b;
        st[b].push_back(e);
      }
      st[a].clear();
    }
  }
  rep(i,m) {
    //cout << "a_ans="<<a_ans[i+1] <<endl;
    cout << n*(n-1)/2-a_ans[i+1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 17516
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	int h,i,j,k,n;cin>>n;
	int one=0,two=0,san=0;
	for(i=0;i<n;i++){
		int a;cin>>a;
		if(a==1){one++;}
		if(a==2){two++;}
		if(a==3){san++;}
	}
	static double dp[301][301][301]={0};
	static double kak[301][301][301]={0};
	kak[san][two][one]=1;
	for(i=san;i>=0;i--){
		for(j=two+san-i;j>=0;j--){
			for(k=one+two+san-j-i;k>=0;k--){
				if(i+j+k==0){break;}
				int m=(i+j+k);
				double a=dp[i][j][k]+kak[i][j][k]*n/m;
				double b=kak[i][j][k];
				
				if(i>0){dp[i-1][j+1][k]+=a*i/m;kak[i-1][j+1][k]+=b*i/m;}
				if(j>0){dp[i][j-1][k+1]+=a*j/m;kak[i][j-1][k+1]+=b*j/m;}
				if(k>0){dp[i][j  ][k-1]+=a*k/m;kak[i][j  ][k-1]+=b*k/m;}
			}
		}
	}
	//cerr<<kak[0][0][0]<<endl;
	cout<<dp[0][0][0]/kak[0][0][0]<<endl;
	return 0;
}


Measured memory_bytes: 426240
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define Mod 1000000007
typedef long long ll;
int h, w;
char grid[1003][1003];
ll memo[1003][1003];
int solve(int i, int j) {
	if (i == h || j == w)
		return 0;
	if (i == h - 1 && j == w - 1)
		return 1;
	ll &ret = memo[i][j];
	if (ret != -1)return ret;
	ret = 0;
	if (grid[i + 1][j] == '.')
		ret = (ret+solve(i+1,j)%Mod)%Mod;
	if(grid[i][j+1]=='.')
		ret = (ret + solve(i,j+1) % Mod) % Mod;
	return ret % Mod;

}
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	//write; read;
#endif 
	memset(memo, -1, sizeof memo);
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> grid[i][j];
	cout << solve(0, 0) << endl;
//	cout << endl;

	return 0;
}

Measured memory_bytes: 9216
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		String s = String.valueOf(sc.nextInt());
		if (s.contains("7"))out.println("Yes");
		else out.println("No");
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


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

int main(void) {
    int64_t L,R;
    
    cin >> L >> R;
    
    if((R-L) >= 2019) {
        cout << "0\n";
        return 0;
    }
    int cnt = 0;
    vector<pair<int64_t,int64_t>> m;
    for(int64_t i=L;(i<=R) &&(i<=(L+4038));i++) {
        m.push_back(make_pair(i%2019,i));
    }

//    sort(m.begin(), m.end());
    vector<int> lastchk;
    for(int i=0;i<(m.size()-1);i++) {
        for(int j=i+1;j<m.size();j++) {
            lastchk.push_back((m[i].first * m[j].first) % 2019);
        }
    }

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

    cout << lastchk[0] << endl;
    return 0;
}


Measured memory_bytes: 10220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

#define COUT(x) cout << x << endl
#define CIN(x) cin >> x
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define EXIST(s, e) (s.find(e) != s.end())
#define SORT(c) sort(c.begin(), c.end())
#define ERASEUNIQE(v) v.erase(unique(v.begin(), v.end()), v.end())

// 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 long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

// container util
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()

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

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

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

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

int main(int argc, char const *argv[])
{
  int n, b, f, r, v;
  int count[4][3][10] = {};
  cin >> n;
  REP(i, n) {
    cin >> b >> f >> r >> v;
    count[b-1][f-1][r-1] += v;
  }
  for(int i = 0; i < 4; i++) {
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 10; k++) {
        cout << " " << count[i][j][k];
      }
      cout << endl;
    }
    if(i < 3) cout << "####################" << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int read(){
	char c;int num,f=1;
	while(c=getchar(),!isdigit(c))if(c=='-')f=-1;num=c-'0';
	while(c=getchar(), isdigit(c))num=num*10+c-'0';
	return f*num;
}
int n,k;
double t,a,clo=10000000;
double h[10009];
int main()
{
	n=read();t=read();a=read();
	for(int i=1;i<=n;i++){
		h[i]=read();
		h[i]=(double)t-h[i]*0.006;
		if(abs(h[i]-a)<clo){
			clo=abs(h[i]-a);
			k=i;
		}
	}
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl


namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int MOD = 1000000007;
	const lli LIMIT = 10'000'000'000'000'000 * 5;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<lli> s(A), t(B), x(Q);
	for (int i = 0; i < A; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < Q; i++) {
		cin >> x[i];
	}
	//ps_t ... s[i]から最も近いt[i]のindex
	vector<lli> ps_t(A), pt_s(B);
	for (int i = 0; i < A; i++) {
		auto it = lower_bound(t.begin(), t.end(), s[i]);
		auto dist = distance(t.begin(), it);
		if (dist != 0 && dist != B) {
			if (abs(s[i] - t[dist]) < abs(s[i] - t[dist - 1])) {
				ps_t[i] = dist;
			}
			else {
				ps_t[i] = dist - 1;
			}
		}
		else if (dist == 0) {
			ps_t[i] = dist;
		}
		else if (dist == B) {
			ps_t[i] = dist - 1;
		}
		else {
			cerr << "what ps_t:" << i<< endl;
		}
	}
	for (int i = 0; i < B; i++) {
		auto it = lower_bound(s.begin(), s.end(), t[i]);
		auto dist = distance(s.begin(), it);
		if (dist != 0 && dist != A) {
			if (abs(t[i] - s[dist]) < abs(t[i] - s[dist - 1])) {
				pt_s[i] = dist;
			}
			else {
				pt_s[i] = dist - 1;
			}
		}
		else if (dist == 0) {
			pt_s[i] = dist;
		}
		else if (dist == A) {
			pt_s[i] = dist - 1;
		}
		else {
			cerr << "what pt_s:" << i << endl;
		}
	}
	for (int i = 0; i < Q; i++) {
		lli ans = LIMIT;
		{
			auto it = lower_bound(s.begin(), s.end(), x[i]);
			auto dist = distance(s.begin(), it);
			if (dist != 0) {
				ans = min(ans, abs(x[i] - s[dist - 1]) + abs(s[dist - 1] - t[ps_t[dist - 1]]));
			}
			if (dist != A) {
				ans = min(ans, abs(x[i] - s[dist]) + abs(s[dist] - t[ps_t[dist]]));
			}
		}
		{
			auto it = lower_bound(t.begin(), t.end(), x[i]);
			auto dist = distance(t.begin(), it);
			if (dist != 0) {
				ans = min(ans, abs(x[i] - t[dist - 1]) + abs(t[dist - 1] - s[pt_s[dist - 1]]));
			}
			if (dist != B) {
				ans = min(ans, abs(x[i] - t[dist]) + abs(t[dist] - s[pt_s[dist]]));
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9)+7>;

num cnt[26];

const int MAXN = 1.1e5;
int N;
char S[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> S;
	for (int i = 0; i < N; i++) cnt[S[i] - 'a'] ++;
	num res = 1;
	for (int i = 0; i < 26; i++) {
		res *= cnt[i] + 1;
	}
	res -= 1;
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 384
import itertools

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
nodes = [i for i in range(N)]
count = 0
for node_order in itertools.permutations(nodes, N):
    if node_order[0] != 0:
        break
    for i in range(N-1):
        if not node_order[i+1] in graph[node_order[i]]:
            break
    else:
        count += 1
print(count)

Measured memory_bytes: 39920
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int d;
	ll g;
	cin >> d >> g;
	vector<ll> p(d), c(d);
	rep(i, d) cin >> p[i] >> c[i];
	int ans = 1001001001;
	for (int bit = 0; bit < (1 << d); bit++) {
		ll sum = 0;
		int cnt = 0;
		rep(i, d) {
			if (bit & (1 << i)) {
				sum += (ll)(i+1) * 100 * p[i] + c[i];
				cnt += p[i];
			}
		}
		for (ll i = d - 1; i >= 0; i--) {
			if (!(bit & (1 << i))) {
				rep(j, p[i] - 1) {
					if (sum < g) {
						sum += (ll)100 * (i + 1);
						cnt++;
					}
					else break;
				}
			}
		}
		if (sum >= g) ans = min(ans, cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

  static int n, m, q, ans;
  static int[] a, b, c, d, t;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    m = Integer.parseInt(in[1]);
    q = Integer.parseInt(in[2]);

    a = new int[q];
    b = new int[q];
    c = new int[q];
    d = new int[q];

    for(int i = 0; i < q; i++){
      in = br.readLine().split(" ");
      a[i] = Integer.parseInt(in[0]);
      b[i] = Integer.parseInt(in[1]);
      c[i] = Integer.parseInt(in[2]);
      d[i] = Integer.parseInt(in[3]);
    }

    br.close();

    t = new int[n];

    makeArr(0, 1);

    System.out.println(ans);
    
    
  }

  static void makeArr(int idx, int mi){

    if(idx == n) {
      calcScore();
      return;
    }

    for(int i = mi; i <= m; i++){
      t[idx] = i;
      makeArr(idx+1, i);
    }

    return;
  }

  static void calcScore(){

    int tmpAns = 0;
    for(int i = 0; i < q; i++){
      if(t[b[i]-1] - t[a[i]-1] == c[i]) tmpAns += d[i];
    }

    ans = Math.max(tmpAns, ans);
  }

}

Measured memory_bytes: 33852
#include <cstdio>
#include <algorithm>

using namespace std;

int N;
int M[101], P[101][101];
int K, L[101];

int main() {
  while (true) {
    scanf("%d", &N);
    if (N == 0) break;
    for (int i=0;i<N;i++) {
      scanf("%d", &M[i]);
      for (int j=0;j<M[i];j++) scanf("%d", &P[i][j]);
    }
    scanf("%d", &K);
    for (int i=0;i<K;i++) scanf("%d", &L[i]);
    int ans = -1;
    for (int i=0;i<N;i++) {
      if (M[i] < K) continue;
      bool ok = true;
      for (int j=0;j<K;j++) {
        const int* p = find(P[i], P[i]+M[i], L[j]);
        if (p == P[i]+M[i]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        if (ans >= 0) {
          ans = -1;
          break;
        }
        ans = i+1;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2792
// 2020/07/13 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

	int x_max = -1;			// 最も東の地点
	int x_min = 2001;		// 最も西の地点

	for(int i=0; i<N; i++){
		int x;
		cin >> x;

		x_max = max(x, x_max);
		x_min = min(x, x_min);
	}

	cout << (x_max-x_min+1)/2 << endl;	// .5を切り上げるために

	return 0;
}



Measured memory_bytes: 3108
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n - 1];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int[] num = new int[n];
        for (int i : a) {
            num[i - 1]++;
        }

        // 出力
        for (int i : num) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 65896
#include <stdio.h>
#define max(x, y) ((x)<(y) ? (y) : (x))

int main(){
  int d;  scanf("%d", &d);
  int c[30], s[370][30], t[370] = {0}, last[30] = {0};
  for(int i=1; i<=26; i++)  scanf("%d", c+i);
  for(int i=1; i<=d; i++){
    int high = 0, idx;
    for(int j=1; j<=26; j++){
      scanf("%d", &s[i][j]);
      if(s[i][j] > high){
	high = s[i][j];
	idx  = j;
      }
    }
    t[i] = idx;
  }
  
  for(int i=1; i<=d; i++)
    printf("%d\n", t[i]);

  return 0;
}


Measured memory_bytes: 1780
N,K=map(int,input().split())
p=list(map(int,input().split()))

for i in range(N):
    p[i]=(p[i]+1)/2

for i in range(1,N):
    p[i]+=p[i-1]
p+=[0]

ans=0
for i in range(K-1,N):
    ans=max(ans,p[i]-p[i-K])

print(ans)

Measured memory_bytes: 71944
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 5e3 + 5;
 
int A[N];
 
int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
	ll sum = 0;
	int n, k, ans = 0; cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A, A + n, greater<int>());
	for (int i = 0; i < n; i++) {
		sum += A[i];
		if (sum < k) ans++;
		else sum -= A[i], ans = 0;
	}
	cout << ans << endl;
 
	return 0;
}

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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

int main()
{
  IOS;
  ll n;
  cin >> n;
  vector<ll> arr;
  for (int i=0, x; i<n; i++)
    {
      cin >> x;
      arr.push_back(x);
    }
  sort(arr.begin(), arr.end());
  for (int i=0; i<n-1; i++)
    {
      if (arr[i]==arr[i+1])
	{
	  cout << "NO" << endl;
	  return 0;
	}
    }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

bool isNumber(string line) 
{

}

int main(){
    ll a,b; cin>>a>>b;
    string s; cin>>s;
    bool f=true;
    rep(i,0,a+b+1){
        if(s[a]!='-'){
            f=false;
            break;
        }else if(i!=a){
            if(s[i]<'0'||s[i]>'9'){
                f=false;
                break;
            } 
        }
    }
    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int>a(n + 1);
	vector<int>b(m + 1);
	rep(i, n + 1) {
		if (i == 0) {
			a[i] = x;
		}
		else {
			cin >> a[i];
		}
	}
	rep(i, m + 1) {
		if (i == 0) {
			b[i] = y;
		}
		else {
			cin >> b[i];
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (a[n] < b[0]) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import core.stdc.stdio;
import std.algorithm;
import std.math;
import std.conv;
  
void main(){
 int n,a,b;
 scanf("%d%d%d",&n,&a,&b);
 int[] cs = new int[n];
 int kc;
 scanf("%d",&kc);
 for(int i=0;i<n;i++){
  scanf("%d",&cs[i]);
 }
 cs.sort!"a>b";
 double ans = kc.to!double/a;
 int csum = kc;
 for(int i=0;i<n;i++){
  csum+=cs[i];
  ans = max(ans,csum.to!double/(a+b*(i+1)));
 }
 printf("%d\n",ans.floor.to!int);
}

Measured memory_bytes: 2476
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#ifdef __debug_leywart
#include<debug/to_string.h>
#else
#define db1(x) ;
#define db2(x,begin,end) ;
#define db3(x) ;
#define db4(x,begin,end) ;
#define dbmat1(x,begin_v,end_v,begin_h,end_h) ;
#define dbmat2(x,begin_v,end_v,begin_h,end_h) ;
#define dbin1(x) ;
#define dbin2(x,begin,end) ;
#define dbtree(x,size) ;
#endif
using namespace std;
#define F first
#define S second
#define int long long

///My functions
void sread ( string &s ){ cin >> s ; s = '_' + s ; }
void sprint ( string &s ){ cout << s.substr( 1 , s.size() ) ; } 

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
int n,m,Q,k,a,b,c,sum,ans,MAXans,MINans,sc,pos,acc[mxn],racc[mxn],ar[mxn];
vector<int>vf,vb;
bitset<mxn>flag;
bool sol ;
string s;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n ;

    vf.push_back( 0 ) ; 
    vb.push_back( 0 ) ;

    for(int i = 1 ; i <= n ; i++){
        cin >> a >> b ; 
        vf.push_back( a ) ;
        vb.push_back( b ) ; 
    }

    sort( vf.begin(), vf.end() ) ; 
    sort( vb.begin(), vb.end() ) ; 

    db1( vf ) 
    db1( vb )

    if( n & 1 ) {

        int x , xend ; 
        x = vf[( n + 1 ) / 2] ; xend = vb[( n + 1 ) / 2] ;

        cout << xend - x + 1 ; 
    
    }

    else {

        int x1 , x2 , xend1 , xend2 ;  

        x1 = vf[n / 2] , x2 = vf[( n / 2 ) + 1] ;
        xend1 = vb[ n / 2 ] , xend2 = vb[( n / 2) + 1] ;  

        ans = abs( (x1 + x2) - (xend1 + xend2) ) + 1 ;

        cout << ans ; 

    }





    return 0;
}
























Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define iter vector<int>::iterator
#define mod 998244353
#define inf 1e16



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

    int n,W;
    cin>>n>>W;

    int v[n],w[n];

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

    int dp[n][100001];
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<100001;j++)
    	{
    		dp[i][j]=inf;
    	}
    }

    for(int i=0;i<n;i++)
    {
    	dp[i][v[i]]=w[i];
    }

    for(int i=1;i<n;i++)
    {
    	for(int j=1;j<100001;j++)
    	{
    		if(j-v[i]>=0)
    		{
    			dp[i][j]=min(dp[i][j],min(dp[i-1][j],w[i]+dp[i-1][j-v[i]]));
    		}
    		else
    		{
    			dp[i][j]=dp[i-1][j];
    		}
    	}
    }

    int max=-inf;
    for(int j=0;j<100001;j++)
    {
    	if(dp[n-1][j]<=W)
    	{
    		if(max<j)
    		{
    			max=j;
    		}
    	}
    }

    cout<<max<<"\n";
    
}

Measured memory_bytes: 78336
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[300300];

signed main() {
    cin >> N;
    rep(i, 3 * N) {
        cin >> A[i];
    }
    //[0,b)前半
    //[b,3*N)後半
    map<int, int> left, right, removedRight;
    int ans = -INF;
    int sl = 0, sr = 0;//sum left,right
    int rl = 0, rr = 0;//remove lefr,right
    for (int b = N; b <= 2 * N; ++b) {
        if (b == N) {
            //初期化
            rep(i, N) {
                left[A[i]]++;
                sl += A[i];
            }
            for (int i = N; i < 3 * N; ++i) {
                right[A[i]]++;
                sr += A[i];
            }
            for (int cnt = 0; cnt < N; ++cnt) {
                int maxRight = right.rbegin()->first;
                rr += maxRight;
                removedRight[maxRight]++;
                right[maxRight]--;
                if (right[maxRight] == 0)right.erase(maxRight);
            }
            ans = sl - sr + rr;
        } else {
            sl += A[b - 1];
            sr -= A[b - 1];
            left[A[b - 1]]++;
            right[A[b - 1]]--;

            if (right[A[b - 1]] == -1) {
                rr -= A[b - 1];
                right.erase(A[b - 1]);
                removedRight[A[b - 1]]--;
                if (removedRight[A[b - 1]] == 0)removedRight.erase(A[b - 1]);
            } else {
                int minRemoved = removedRight.begin()->first;
                right[minRemoved]++;
                rr -= minRemoved;
                removedRight[minRemoved]--;
                if (removedRight[minRemoved] == 0) {
                    removedRight.erase(minRemoved);
                }
            }
            if (right[A[b - 1]] == 0)right.erase(A[b - 1]);

            int minLeft = left.begin()->first;
            rl += minLeft;
            left[minLeft]--;
            if (left[minLeft] == 0)left.erase(minLeft);

            //cerr << sl << " " << rl << " " << sr << " " << rr << endl;
            ans = max(ans, sl - rl - sr + rr);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21376
# abc 153
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

H, A = map(int, readline().split())

answer = H // A
if (H % A != 0):
  answer += 1
  
print(answer)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n;
cin >> n;
vi d(n);
rep(i,n) cin >> d[i];

sort(all(d));
cout << d[n/2] - d[n/2 -1] << endl;

return 0;
}

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

int main(){
	int n;
	cin>>n;
	int a[n],dist[n],cnt[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		dist[i] = a[i] - (i+1);
	}
	sort(dist,dist + n);
	int p = (dist[n/2]+dist[(n-1)/2])/2;
	long long ans = 0;
	for(int i=0;i<n;i++){
//		ans += abs(a[i] - (p + (i+1)));
		ans += abs(dist[i]-p);
	}

	cout << ans << endl;

}


Measured memory_bytes: 1792