akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


int main() {
	ll x, y, z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y;

	system("PAUSE");
}


Measured memory_bytes: 504
# A - Frog 1
# https://atcoder.jp/contests/dp/tasks/dp_a

N = gets.chomp.to_i
H = gets.chomp.split.map(&:to_i)

@dp = Array.new(N+3) { 0 }
(0...N).each do |i|
  if i == 0
   @dp[i] = 0
   next
  elsif i == 1
   @dp[i] = @dp[i-1] + (H[i-1] - H[i]).abs
   next
  else
    @dp[i] = [@dp[i-1] + (H[i-1] - H[i]).abs,
              @dp[i-2] + (H[i-2] - H[i]).abs].min
  end
end

puts @dp[N-1]


Measured memory_bytes: 21560
#include <iostream>
#include <algorithm>
using namespace std;
int N;
int arr[101010];
int main(){
    cin>>N;
    for(int i = 0;i<N;i++) scanf("%d",&arr[i]);
    int tag = 1;
    for(int i = 0;i<N;i++){
        if(arr[i] % 2 == 0){
            if(arr[i] %3 != 0 && arr[i]%5 !=0) {
                tag = 0;
                break;
            }
        }
    }
    if(tag) puts("APPROVED");
    else puts("DENIED");
    return 0;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

int main()
{
	int a[3], b[3];
	int c[3][3];
	rep(i, 3) rep(j, 3) cin >> c[i][j];
	a[0] = 0;
	rep(i, 3) {
		b[i] = c[0][i] - a[0];
	}
	rep(i, 3) {
		a[i] = c[i][0] - b[0];
	}
	bool f = true;
	rep(i, 3) rep(j, 3) {
		if(a[i]+b[j]!=c[i][j]) f = false;
	}
	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
bool a[300][300];
int c[300];
bool solve(int t) {
	for (int i = 0; i < n; i++) {
		if (a[t][i]) {
			if (c[i] == 0) {
				c[i] = 3 - c[t];
				if (solve(i) == 0) return 0;
			}
			else if (c[i] == c[t]) return 0;
		}
	}
	return 1;
}
int b[300][300];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < n; j++) {
			a[i][j] = (int)(s[j] - '0');
		}
	}
	c[0] = 1;
	if (solve(0)) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				b[i][j] = Inf;
				if (a[i][j]) b[i][j] = 1;
			}
			b[i][i] = 0;
		}
		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				ans = max(ans, b[i][j] + 1);
			}
		}
		cout << ans << endl;
	}
	else cout << -1 << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){

  char S[3];
  int num = 0;

  scanf("%s", S);

  for(int i=0; i<3; i++){
    if(S[i] == 'o') num += 100;
  }

  printf("%d\n", num+700);

  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc154_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] moji =  Console.ReadLine().Split(' ');
            List<int> num = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            string mojiU = Console.ReadLine();

            if (moji[0] == mojiU)
            {
                num[0]--;
            }
            else
            {
                num[1]--;
            }


            string output = num[0] + " " + num[1];




            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iomanip>
using namespace std;

int findindex(int n, int x[]) {
    for (int i = 0; i < 6; i++) {
        if (x[i] == n) {
            return i;
        }
    }
    return -1;
}

int main() {
    int d[6], n, u, f, U, F, r;
    for (int i = 0; i < 6; i++) {
        cin >> d[i];
    }

    int dice_face[6][5] = {{1, 2, 4, 3, 1}, {0, 3, 5, 2, 0}, {0, 1, 5, 4, 0}, {0, 4, 5, 1, 0}, {0, 2, 5, 3, 0}, {1, 3, 4, 2, 1}};

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> f;
        U = findindex(u, d);
        F = findindex(f, d);
        r = dice_face[U][findindex(F, dice_face[U]) + 1];
        cout << d[r] << endl;
    }
    return 0;
}

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

/*
 a=>2*b
 */
int main(){
    int a;
    int b;
    cin >> a;
    cin >> b;
    if(a >= 2 * b){
        cout << a - 2 * b << endl;
    }
    else{
        cout << 0;
    }
    
    return 0;
}


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

void optimize_cpp_stdio() {
    std::ios::sync_with_stdio(false);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

struct BinaryIndexTree {
    BinaryIndexTree(int n): tree(n) {
        for (int i = 0; i < n; i++)
            tree[i] = i & -i;
    }
    void add(int i, int v) {
        for (; i < (int)tree.size(); i += i & -i)
            tree[i] += v;
    }
    int prefix(int i) {
        int result = 0;
        for (; i != 0; i -= i & -i)
            result += tree[i];
        return result;
    }
private:
    std::vector<int> tree;
};

int main() {
    optimize_cpp_stdio();
    int n;
    std::cin >> n;
    std::vector<int> white(n + 1), black(n + 1);
    for (int i = 1; i <= n + n; i++) {
        char color;
        int value;
        std::cin >> color >> value;
        (color == 'W' ? white : black)[value] = i;
    }
    BinaryIndexTree tree(n + n + 1);
    std::vector<std::vector<int>> dp(n + 1, std::vector<int>(n + 1));
    for (int i = 0; i <= n; i++) {
        if (i != 0) tree.add(white[i], -1);
        for (int j = 0; j <= n; j++) {
            if (j != 0) tree.add(black[j], -1);
            if (i == 0 && j == 0) continue;
            dp[i][j] = INT_MAX;
            if (i != 0) dp[i][j] = std::min(dp[i][j], dp[i - 1][j] + tree.prefix(white[i]));
            if (j != 0) dp[i][j] = std::min(dp[i][j], dp[i][j - 1] + tree.prefix(black[j]));
        }
        for (int j = 1; j <= n; j++)
            tree.add(black[j], 1);
    }
    std::cout << dp[n][n] << "\n";
    return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	
	complex<double> p = (0,0);
	double ang = 90;
	while(1){
		double v_mov;
		double tmp_ang;
		char c;
		cin>> v_mov>> c>> tmp_ang;
		tmp_ang *= -1;
		if(v_mov==0 && tmp_ang==0) break;
		p.real() += v_mov * cos(ang/180*M_PI);
		p.imag() += v_mov * sin(ang/180*M_PI);
		ang += tmp_ang;
		if(ang>180)   ang -= 360;
		if(ang<=-180) ang += 360;
	}
	
	cout<< (int)p.real()<<endl;
	cout<< (int)p.imag()<<endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1228
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;
class UnionFind{
	int32_t *par;
	int32_t *rank;
	int64_t *movable_size;
private:
	int32_t root(int32_t num){
		if(par[num]==num){
			return num;
		}else{
			return par[num]=root(par[num]);
		}
	}
public:
	UnionFind(const int32_t size){
		par = new int32_t[size];
		rank=new int32_t[size];
		movable_size=new int64_t[size];
		for(int32_t i=0;i<size;i++){
			par[i]=i;
			rank[i]=0;
			movable_size[i]=1;
		}
	}
	bool same(int32_t a,int32_t b){
		return root(a)==root(b);
	}
	void unite(int32_t a,int32_t b){
		if(root(a)==root(b)){
			return;
		}
		a=root(a);
		b=root(b);
		if(rank[a]<rank[b]){
			par[a]=b;
			movable_size[b]=movable_size[a]+movable_size[b];
		}else if(rank[a]==rank[b]){
			par[a]=b;
			rank[b]++;
			movable_size[b]=movable_size[a]+movable_size[b];
		}else{
			par[b]=a;
			movable_size[a]=movable_size[a]+movable_size[b];

		}

	}
	int64_t getSize(int64_t a){
		return movable_size[root(a)];
	}
	virtual ~UnionFind(){
		delete[] par;
		delete[] rank;
	}
};


int main(){
	int64_t n,m;
	cin>>n>>m;
	vector<pair<int64_t,int64_t>> edge;
	edge.reserve(m);
	for(int64_t i1=0;i1<m;i1++){
		int64_t t1,t2;
		cin>>t1>>t2;
		edge.push_back(make_pair(t1-1,t2-1));
	}
	reverse(edge.begin(),edge.end());
	vector<int64_t> ans;
	ans.reserve(m);
	int64_t movable_conv=0;
	UnionFind uf(n);
	for(auto i1=edge.begin();i1!=edge.end();i1++){
		//cout<<"size of"<<i1->first<<"="<<uf.getSize(i1->first)<<endl;
		//cout<<"size of"<<i1->second<<"="<<uf.getSize(i1->second)<<endl;
		if(!uf.same(i1->first,i1->second)){
			movable_conv-=((uf.getSize(i1->first)*(uf.getSize(i1->first)-1)))/2;
			movable_conv-=((uf.getSize(i1->second)*(uf.getSize(i1->second)-1)))/2;
			uf.unite(i1->first,i1->second);
			movable_conv+=((uf.getSize(i1->second)*(uf.getSize(i1->second)-1)))/2;
		}



		ans.push_back(movable_conv);
	}
	reverse(ans.begin(),ans.end());
	int64_t def=(n*(n-1))/2;
	for(auto i1=ans.begin()+1;i1!=ans.end();i1++){
		//cout<<(*i1)<<endl;
		cout<<def-(*i1)<<endl;
	}
	cout<<def<<endl;



	return 0;



}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> vec(N);
  ll a = 0;
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  for(int i = 0; i < N; i++){
    if(vec.at(i)>= K) a++;
  }
  
  cout << a << endl;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
co=[0]*50
check=False
for i in range(49,-1,-1):
    for j in range(n):
        if (a[j]>>i)&1:
            co[i]+=1
    if (k>>i)&1:
        if co[i]>=n-co[i]:
            ans+=(co[i]*(2**i))
            check=True
        else:
            ans+=((n-co[i])*(2**i))
    else:
        if check:
            if co[i]>=n-co[i]:
                ans+=(co[i]*(2**i))
            else:
                ans+=((n-co[i])*(2**i))
        else:
            ans+=(co[i]*(2**i))
print(ans)

Measured memory_bytes: 14712
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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

bool graph[101][101];
bool visit[101];
vector<ll> to[101010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	ll ans = 0;
	rep(i, n) {
		if (a[a[i]] == i)ans++;
	}
	ans /= 2;
	cout << ans << endl;
	return 0;
}


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

typedef long long           ll;
typedef unsigned long long  ull;

#define sf                  scanf
#define pf                  printf
#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define PF                  first
#define PS                  second
#define si(n)               scanf("%d",&n)
#define sii(x,y)            scanf("%d %d",&x,&y)
#define siii(x,y,z)         scanf("%d %d %d",&x,&y,&z)
#define sl(n)               scanf("%lld",&n)
#define sll(x,y)            scanf("%lld %lld",&x,&y)
#define slll(x,y,z)         scanf("%lld %lld %lld",&x,&y,&z)
#define FOR(i,x,y)          for(int i=x;i<y;i++)
#define RFOR(i,x,y)         for(int i=x;i>=y;i--)
#define CLR(arr,val)        memset(arr,val,sizeof arr);
#define vout(v)             for(int ind=0;ind<v.size();ind++){ cout<<v[ind]; if(ind<v.size()-1) cout<<' '; else cout<<endl;}
#define TCL(test,t)         for(test=1;test<=t;test++)
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("input.txt", "w", stdout)
#define fastIO()            {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define MAXN                100005
#define MOD                 1000000000
#define PI                  acos(-1)

bool mark[MAXN];
int save[MAXN];

int main(){
    int n,m,x,y,ansac=0,anspen=0;
    string s;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>x>>s;
        if(s=="AC"){
            mark[x]=true;
        }
        else if(s=="WA"&&!mark[x]){
            save[x]++;
        }
    }
    for(int i=0;i<=n;i++){
        if(mark[i]){
            ansac++;
            anspen+=save[i];
        }
    }
    cout<<ansac<<' '<<anspen<<endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      // 一年の秒数
      int N, A, N2;
      int Bnum;
      
      cin >> N;
      cin >> A;
      N2 = N*N;
      Bnum = N2 - A;
      // 以下のコメント/* */を消して追記する
      cout << Bnum << endl;
    }

Measured memory_bytes: 256
K=str(input())
K=list(K) #いらないかも
K=[int(i) for i in K]
n=K[-1]

if n==2 or n==4 or n==5 or n==7 or n==9:
    print("hon")
elif n==0 or n==1 or n==6 or n==8:
    print("pon")
elif n==3:
    print("bon")

Measured memory_bytes: 9188
#include <iostream>
using namespace std;
int main () {
	long long n, d;
	cin >> n >> d;
	int o = 0;
	long long x, y;
	for (int i=0; i<n; i++) {
		cin >> x >> y;
		if (x*x+y*y <= d*d) o++;
	}
	cout << o << endl;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
#define ll long long
int main()
{
  ll n;
  cin>>n;
  ll sum = 0;
  for(ll i=1;i<=n;i++)
  {
    if(i%3==0 || i%5==0)
    {
      continue;
    }
    else
    {
      sum+=i;
    }
  }
  cout << sum <<"\n";
  return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 2000003;
const int MOD = 1000000007;

        signed main() {
    cout<<fixed<<setprecision(15);
    int n,ans=0,ans2=0;bool t,x;
    cin>>n;
   string s;
   cin>>s;
   for(int i=0;i<n;i++){
           ans=0;
           for(char a='a';a<='z';a++){
                   t=false;x=false;
                   for(int j=0;j<i;j++)if(s[j]==a)t=true;
                   for(int j=i;j<n;j++)if(s[j]==a)x=true;
                   if(t&&x)ans++;
           }
           ans2=max(ans2,ans);
   }
cout<<ans2;

    
      }

        


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

long long int n,i,mod,dp[100010][15],j,k,x;
string s;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>s;
	n=s.size();mod=1e9+7;
	for (i=0;i<13;i++) for (j=0;j<n+1;j++) dp[j][i]=0;dp[0][0]=1;
	for (i=1;i<n+1;i++) if (s[i-1]!='?')
	{
		x=(s[i-1]-'0');
		for (j=0;j<13;j++) dp[i][(j*10+x)%13]=(dp[i][(j*10+x)%13]+dp[i-1][j])%mod;
	}
	else
	{
		for (j=0;j<13;j++) for (x=0;x<10;x++)
		dp[i][(j*10+x)%13]=(dp[i][(j*10+x)%13]+dp[i-1][j])%mod;
	}
	cout<<dp[n][5];
}


Measured memory_bytes: 12240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
const ll max_n = 2e5+5;

int main() {
    // your code goes here
    ll n, d, a, x[max_n], h[max_n];
    ll j, l[max_n], sum[max_n], ans = 0;
    vector<pair<ll, ll> > vp;
    vector<ll> v;
    cin >> n >> d >> a;
    rep(i,0,n-1) {
        cin >> x[i] >> h[i];
        h[i] = (h[i] - 1) / a + 1;
        vp.push_back({x[i], h[i]});
        v.push_back(x[i]);
    }
    sort(vp.begin(), vp.end());
    sort(v.begin(), v.end());
    rep(i,0,n-1) {
        x[i+1] = vp[i].first;
        h[i+1] = vp[i].second;
    }
    rep(i,1,n) {
        auto it = upper_bound(v.begin(), v.end(), x[i] + 2*d);
        ll memo = it - v.begin();
        for(;j<=memo;j++) l[j] = i;
    }
    sum[0] = 0;
    rep(i,1,n) {
        ll attack = h[i] - min(sum[i-1] - sum[l[i]-1], h[i]);
      	sum[i] = sum[i-1] + attack;
        ans += attack;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 13548
#include<stdio.h>
int main(void)
{
    int n,m,a[100],i,w,j,z,x;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
	    scanf("%d",&a[i]);
	}
	for(i=1;i<=m;i++){
	    for(j=0;j<n-1;j++){
			if(a[j]%i>a[j+1]%i){
			    w=a[j];
				a[j]=a[j+1];
				a[j+1]=w;
			}
		}
	}
	for(i=0;i<n;i++){
	    printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 2668
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: usize = read();

  let mut ans = 1;
  let mut max = 0;
  for i in 1..n+1 {
    let mut tmp = i;
    let mut count = 0;
    while tmp % 2 == 0 {
      tmp /= 2;
      count += 1;
    }
  if count >  max {
    ans = i;
    max = count;
    }
  }

  println!("{}", ans);
}


Measured memory_bytes: 4352
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,a[101010],sum[101010],l,r,ans,m;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

  cin >> n >> m;
  for(int i=1;i<=m;i++){
    cin >> l >> r;
    a[l]++;
    a[r+1]--;
  }

  for(int i=1;i<=n;i++){
    sum[i] = sum[i-1]+a[i];
  }
  for(int i=1;i<=n;i++){
    if(sum[i]>=m)ans++;
  }
  cout << ans << endl;



return 0;
}
///....


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

int main() {
	int N;
  	cin >> N;
  
  	if(N % 2 == 0) {
    	N /= 2;
      	cout << N * N << endl;
    }else {
    	cout << ((N + 1) * (N - 1)) / 4 << endl;
    }
}

Measured memory_bytes: 256
using System;
//using System.Collections.Generic;
public class ProCon
{
    public static void Main(){     
        string[] line1 =　Console.ReadLine().Split(' ');

        if(line1[0].Substring(2,1) == line1[0].Substring(3,1)
           &&line1[0].Substring(5,1) == line1[0].Substring(4,1))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  ll n;
  string s;
  cin>>n>>s;
  ll ans=0;
  for(ll i=0;i<n;i++){
    if(s[i]=='R')ans++;
  }
  if(ans*2>n)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int s,c; cin>>s>>c;
	int ans=min(s,c/2);
	s-=ans;
	c-=ans*2;
	if(c>=2){
		ans+=(s*2+c)/4;
	}
	cout<<ans<<"\n";
	return 0;
}





























Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int main() {
    string s;
    cin >> s;
    if (s == "A") cout << "T" << endl;
    else if (s == "C") cout << "G" << endl;
    else if (s == "G") cout << "C" << endl;
    else if (s == "T") cout << "A" << endl;
}

Measured memory_bytes: 888
#include <stdio.h>

int main()
{
    long long s=100,X,cnt=0,i;

    scanf("%lld", &X);
    for(i=1;; i++)
    {
        s+=s/100;

        if(s>=X)
        {

            break;
        }
    }
    printf("%lld\n",i);
    return 0;
}


Measured memory_bytes: 1736
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(T a){
	cout << a << '\n';
}
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
string as[4] = {"Yes", "YES", "No", "NO"};

int x[55]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
int main(){
	g(n); o(x[n-1]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
	int n,p;
	scanf("%d%d",&n,&p);
	int n0=0,n1=0;
	for(int x,i=0;i<n;i++) {
		scanf("%d",&x);
		if(x&1) n1++;
		else n0++;
	}
	if(p==1&&n1==0) printf("0\n");
	else printf("%lld\n",(1LL<<max(n1-1,0))*(1LL<<(n0)));
	return 0;
} 

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

using namespace std;

bool query (const vector<int> &v) {
  cout << "? ";
  for (int u : v) {
    cout << u + 1 << " ";
  }
  cout << endl;

  string ans;
  cin >> ans;
  if (ans[0] == '-') exit(0);
  return ans[0] == 'R';
}

const int MAX_N = 205;

char str [MAX_N];
int insep [MAX_N];

int n;
bool askpre (int k) {
  vector<int> q;
  for (int i = 0; i < k; i++) {
    q.push_back(i);
  }

  for (int i = k; i < n; i++) {
    q.push_back(i + n);
  }

  return query(q);
}

int main () {
  ios::sync_with_stdio(false);
  
  cin >> n;

  bool orig = askpre(0);
  int ans = 0; // a thing that has the same as orig
  for (int k = 64; k != 0; k /= 2) {
    if (ans + k < n) {
      if (askpre(ans + k) == orig) {
        ans += k;
      }
    }
  }

  vector<int> sep; // the intersection of askpre(ans) and askpre(ans + 1)
  for (int i = 0; i < ans; i++) {
    sep.push_back(i);
    insep[i] = 1;
  }
  for (int i = ans + 1; i < n; i++) {
    sep.push_back(i + n);
    insep[i + n] = 1;
  }

  // query the non-sep things;
  for (int i = 0; i < 2 * n; i++) {
    if (!insep[i]) {
      sep.push_back(i);
      if (query(sep)) {
        str[i] = 'R';
      } else {
        str[i] = 'B';
      }
      sep.pop_back();
    }
  }

  sep.clear(); // build a new separator
  for (int i = 0; i < 2 * n; i++) {
    if (str[i] == 'R' && (int) sep.size() < n / 2) {
      sep.push_back(i);
    }
  }

  for (int i = 0; i < 2 * n; i++) {
    if (str[i] == 'B' && (int) sep.size() < 2 * (n / 2)) {
      sep.push_back(i);
    }
  }

  for (int i = 0; i < 2 * n; i++) {
    if (insep[i]) {
      sep.push_back(i);
      if (query(sep)) {
        str[i] = 'R';
      } else {
        str[i] = 'B';
      }
      sep.pop_back();      
    }
  }

  cout << "! ";
  for (int i = 0; i < 2 * n; i++) {
    cout << str[i];
  }
  cout << endl;
}


Measured memory_bytes: 3804
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a; double b; cin >> a >> b;

  ll nb = b * 100.001;
  // cout << nb << endl;
  ll ans = a * nb;
  // cout << ans << endl;
  ans /= 100;
  cout << ans << endl;
}


Measured memory_bytes: 3716
#include <iostream>

using namespace std;

int main(){
    int n; 
    long sum = 0;
    cin >> n;
    while(n--){
        if((n + 1) % 5 == 0 || (n + 1) % 3 == 0)continue;
        sum += (n + 1);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>

bool judge(std::vector<int> const& xs,
           std::vector<int> const& ys) {
  auto mx = *std::max_element(xs.cbegin(), xs.cend());
  auto my = *std::min_element(ys.cbegin(), ys.cend());

  return mx < my;
}

int main() {
  int N, M, X, Y;

  std::cin >> N >> M >> X >> Y;

  std::vector<int> xs(N+1);
  std::vector<int> ys(M+1);

  for (size_t i=0; i<N; i++)
    std::cin >> xs[i];
  xs[N] = X;

  for (size_t i=0; i<M; i++)
    std::cin >> ys[i];
  ys[M] = Y;

  std::cout << (judge(xs, ys) ? "No War" : "War") << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;


int main(){
	int n,count;
	while(scanf("%d",&n)!=EOF){
		if(n >= 37){
			printf("0\n");
		}else{
			count = 0;

			for(int a=0;a<=9;a++){
				for(int b=0;b<=9;b++){
					for(int c=0;c<=9;c++){
						for(int d=0;d<=9;d++){
							if(a+b+c+d==n)count++;
						}
					}
				}
			}
			printf("%d\n",count);
		}
	}

    return 0;
}

Measured memory_bytes: 2568
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<unordered_map>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<complex>
#include<cmath>
using namespace std;

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

ll n, k, x[10000], y[10000], d[10000];
vector<P> v[3];
double ans = 10000000.0;
double sqrt3 = sqrt(3);

double check(ll i, ll j, ll k) {
  return sqrt3 * (y[j] + y[k] - 2 * y[i]) + 3 * (x[j] - x[k]);
}

int main() {
  while (scanf("%lld", &n), n) {
    ans = 100000000.0;
    scanf("%lld", &k);
    for (ll i = 0; i < n; i++) {
      scanf("%lld%lld", &x[i], &y[i]);
      v[0].push_back(P(y[i], i));
      v[1].push_back(P(sqrt3 * x[i] + y[i], i));
      v[2].push_back(P(-sqrt3 * x[i] + y[i], i));
      d[i] = 0;
    }
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    sort(v[2].begin(), v[2].end());
    for (ll i = 0; i <= k; i++) {
      for (ll j = 0; j < n; j++) if (d[j] != -1) d[j] = 1;
      ll counter = i, l = n-1, r = n-1;
      while (counter < k) {
        if (d[v[2][l].second] != -1) d[v[2][l].second] = 0, counter++;
        l--;
      }
      while (d[v[2][l].second] == -1) l--;
      while (d[v[1][r].second] != 1) {
        if (d[v[1][r].second] != -1) d[v[1][r].second] = -2;
        r--;
      }
      ans = min(ans, check(v[0][i].second, v[1][r].second, v[2][l].second));

      while (1) {
        l++;
        while (l < n && d[v[2][l].second] < 0) l++;
        if (l == n) break;
        d[v[2][l].second] = 1;
        d[v[1][r].second] = -2;
        r--;
        while (d[v[1][r].second] != 1) {
          if (d[v[1][r].second] != -1) d[v[1][r].second] = -2;
          r--;
        }
        ans = min(ans, check(v[0][i].second, v[1][r].second, v[2][l].second));
      }
      d[v[0][i].second] = -1;
    }
    printf("%.7f\n", ans);
    for (ll i = 0; i < 3; i++) v[i].clear();
  }
}



Measured memory_bytes: 3324
#B問題
N, K = map(int, input().split())
Result = [True] * N
Count = 0
for i in range(K):
    d = int(input())
    A = input().split()
    for j in range(len(A)):
        Result[int(A[j])-1] = False

Count = Result.count(True)
print(Count)

Measured memory_bytes: 66660
while True:
    n, x = map(int, raw_input().split())
    if (n+x) == 0:
        break

    comb = []
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            c = i + j
            tmp = x - c
            if (tmp <= n) & (tmp > j):
                comb.append([i, j, tmp])

    print len(comb)

Measured memory_bytes: 6408
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, k = load_list()

N = [i for i in range(0, n+1)]

cnt = 0

lowd = [i for i in range(0, n+1)]
for i in range(1, n+1):
    lowd[i] = lowd[i-1] + lowd[i]
highd = [i for i in range(0, n+1)]
for i in range(n-1, -1, -1):
    highd[i] = highd[i] + highd[i+1]

for i in range(k, n+2):
    low = lowd[i-1]
    high = highd[n+1-i]
    cnt += high - low + 1

print(int(cnt % (math.pow(10, 9) + 7)))
    

    

Measured memory_bytes: 109336
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(auto& it:v)cin>>it;
	//compute prefix and suffix gcd
	vector<int> pref(n+1),suffix(n+1);
	pref[0]=0,suffix[n]=0;
	for(int i=0;i<n;i++){
	  pref[i+1]=__gcd(v[i],pref[i]);	
	}
	for(int i=n;i>0;i--){
	  suffix[i-1]=__gcd(v[i-1],suffix[i]);	
	}
	int ans=0;
	for(int i=0;i<n;i++){
		ans=max(ans,__gcd(pref[i],suffix[i+1]));
	}
	cout<<ans<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


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

int main()
{
	int n;
	cin >> n;
	if (n == 1)
	{
		cout <<"Hello World" << endl;
	}
	else
	{
		int a,b;
		cin >> a >> b;
		cout << a+b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
local n, k = io.read("*n", "*n")
local left, right = {}, {}
for i = 1, n do
  local d = io.read("*n")
  if(d == 0) then k = k - 1
  elseif(0 < d) then table.insert(right, d)
  else table.insert(left, -d) end
end
table.sort(left)
table.sort(right)
local leftusemin = math.max(0, k - #right)
local leftusemax = math.min(k, #left)

local minlen = 0
for leftuse = leftusemin, leftusemax do
  local rightuse = k - leftuse
  local leftlen, rightlen = 0, 0
  if(0 < leftuse) then leftlen = left[leftuse] end
  if(0 < rightuse) then rightlen = right[rightuse] end
  local curlen = leftlen + rightlen + math.min(leftlen, rightlen)
  if(minlen == 0) then minlen = curlen else minlen = math.min(minlen, curlen) end
end
print(minlen)


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


int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  vector<int> ans(N);
  for(int i=0; i<N;i++){
    cin>>vec.at(i);
  }
    int max1=0;
    int max2=0;
  //max1
  for(int i=0;i<N;i++){
    if(vec.at(i)>max1){
      max1=vec.at(i);
    }
    else if(vec.at(i)==max1){
      max2=max1;
    }
  }
  //max2
  for(int i=0;i<N;i++){
    if(vec.at(i)>max2 && vec.at(i)!=max1){
      max2=vec.at(i);
    }
  }
  //cout
  for(int i=0;i<N;i++){
    if(max2==0){
     cout<<max1<<endl; 
    }
    else if(vec.at(i)!=max1){
     cout<<max1<<endl;
    }
    else {
     cout<<max2<<endl;      
    }
  }  
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main(){
    ll n,k; cin>>n>>k;
    vector<ll> v[n+1];
    for(ll i=1;i<=k;i++){
        ll q; cin>>q;
        while(q--){
            ll x; cin>>x;
            v[x].pb(i);
    }
    }
    ll count=0;
    for(ll i=1;i<n+1;i++){
        if(v[i].size()==0)
            count++;
    }
    cout<<count;
    
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;

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


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

using namespace std;

#define ll  long long
#define ld  double

#define all(x)  x.begin(),x.end()
#define sz(x)   (int)x.size()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

int a[N];
ll  f[N];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;

    priority_queue<ii>  pq;

    for(int i = 0 ; i < n ; ++i)    {
        int x;  cin >> x;
        pq.push(ii(x,-i));
    }
    int cnt = 0;
    int idx = n;

    while (pq.size())   {
        int x =  pq.top().X;
        if (idx > -pq.top().Y)
            idx = -pq.top().Y;

        while (pq.size() && pq.top().X == x)
            cnt++,
            pq.pop();

        int nxt = 0;

        if (pq.size())
            nxt = pq.top().X;

        f[idx] += 1ll * (x - nxt) * cnt;
    }
    for(int i = 0 ; i < n ; ++i)
        cout << f[i] << "\n";
}

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


ll n,m,x[200005],ob[200005];
vector<pair<ll,ll>> adj[200005];

void dfs(ll a)
{
    ob[a]=1;
    for(auto u: adj[a])
    {
        if(!ob[u.first])
        {
            x[u.first]=x[a]+u.second;
            dfs(u.first);
        }

    }
}

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

    cin>>n>>m;
    for(ll i=1;i<=m;i++)
    {
        ll x,y,w;
        cin>>x>>y>>w;
        adj[x].push_back({y,w});
        adj[y].push_back({x,-w});
    }

    for(ll i=1;i<=n;i++)
        if(!ob[i])
        {
            x[i]=0;
            dfs(i);
        }
    ll ind=0;
    for(ll i=1;i<=n;i++)
        for(auto u: adj[i])
            if(x[u.first]-x[i]!=u.second)
            {
                ind=1;
                break;
            }


    if(!ind)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 22880
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll
#define MOD (1000*1000*1000+7)

int t, n, m, k, a[300010], q, l, r;

int32_t main(){
INIT
cin>>n;
int sum=0;
int pr=0;
for(int i=1; i<=n; i++){
    cin>>a[i];
}
for(int i=n; i>=1; i--){
    pr=(pr+(sum*a[i])%MOD)%MOD;
    sum=(sum+a[i])%MOD;
}
cout<<pr;


return 0;
}





Measured memory_bytes: 5208
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main() {
	int N, K;
	cin>>N>>K;
	int R, S, P;
	cin>>R>>S>>P;
	string T;
	cin>>T;
	long ans = 0;
	map<char, int> score;
	score['r'] = P;
	score['s'] = R;
	score['p'] = S;
	for(int i=0;i<N;++i){
		ans += score[T[i]];
	}
	for(int i=0;i<K;++i){
		char mae;
		for(int j=i;j<N;j+=K){
			if(j==i)mae = T[j];
			else {
				if(T[j]==mae){
					ans -= score[T[j]];
					T[j] = 'w';
				}
				mae = T[j];
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>

using namespace std;

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

    vector<int> v(N);

    for (auto &x : v)
    {
        cin>>x;
    }
    int ans=0;
    for (int i = 1; i < N-1; i++)
    {
        if(v[i-1]>v[i]&&v[i]>=v[i+1]||v[i-1]<=v[i]&&v[i]<v[i+1]){
            ans++;
        }
    }

    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())
As = list(mi())

TL = [[], [], []]
#[0] : zeroList
#[1] : minusList
#[2] : plusList

for a in As:
  if a == 0: TL[0].append(a)
  elif a < 0: TL[1].append(a)
  else: TL[2].append(a)

#print(TL)

ans = 0
printlist = []
#全てxxの場合（3パターン）
if len(TL[0])==N: #全てゼロの場合
  print(0)
  for i in range(N-1):
    print(0, 0)
  exit()
elif len(TL[1])==N: #全てminusの場合
  TL[1] = sorted(TL[1], reverse=True) #降順に並べる（-値の低いものから）
  printlist.append((TL[1][0],TL[1][1])) #痛みを最小に
  hand = TL[1][0]-TL[1][1] #これでプラスになった
  idx = 2
  while idx < N:
    printlist.append((hand, TL[1][idx]))
    hand -= TL[1][idx]
    idx += 1
  ans = hand
  #答えを出力する
  print(ans)
  for x, y in printlist:
    print(x, y)
  exit()
elif len(TL[2])==N: #全てplusの場合
  TL[2] = sorted(TL[2]) #昇順に並べる
  printlist.append((TL[2][0],TL[2][1])) #痛みを最小に
  hand = TL[2][0]-TL[2][1] #これで-になった
  idx = 2
  while idx < N-1:
    printlist.append((hand, TL[2][idx]))
    hand -= TL[2][idx]
    idx += 1
  #idx==N-1
  printlist.append((TL[2][idx], hand))
  hand = TL[2][idx]-hand
  ans = hand
  #答えを出力する
  print(ans)
  for x, y in printlist:
    print(x, y)
  exit()

# ここから先は、0,-,+のうちどれか2つはあるので、全て集合させられる
# ただし、0と-が1つずつ、0と+が1つずつというパターンは別途処理する必要がある
# 以下、そのパターンを処理
if len(TL[0])==1 and len(TL[1])==1:
  #0と-が1つずつ。0から-を引いて終わり
  left, right = TL[0].pop(), TL[1].pop()
  print(left-right)
  print(left, right)
  exit()
elif len(TL[0])==1 and len(TL[2])==1:
  #0と+が1つずつ。+から0を引いて終わり
  left, right = TL[2].pop(), TL[0].pop()
  print(left-right)
  print(left, right)
  exit()

# ここから先は、0,-,+のうちどれか2つはあり、前述のパターンも無いので、全て集合させられるし、最後に-と+が1つずつという最終処理パターンに持っていける
# よって一律のループ処理でOK
# 0が0個、+が1つ、-が1つになったら処理を抜け、最終手順に向かう
# 最初からそうなら、while文は実行されないのでＯＫ
# また、全てを集合させられる＝取り出す順番はどうでもいいので、高速化のため全てpop()で取り出していく
while not (len(TL[0])==0 and len(TL[1])==1 and len(TL[2])==1):
  left = 0
  right = 0
  if len(TL[0])>=1:
    #0があれば、まず0を消化する
    if len(TL[1])==0: #-がなければ、0を使って-を作る
      left, right = TL[0].pop(), TL[2].pop()
      printlist.append((left, right))
      TL[1].append(left-right)
    elif len(TL[2])==0: #+がなければ、0を使って+を作る
      left, right = TL[0].pop(), TL[1].pop()
      printlist.append((left, right))
      TL[2].append(left-right)
    else: #-も+もあるなら消化するだけなので、どっちでもいいが、-で消化する
      left, right = TL[1].pop(), TL[0].pop()
      printlist.append((left, right))
      TL[1].append(left-right)
    continue
  #ここからは、0がなくなったパターン
  #0がなくなったということは、+と-は必ず両方あることになる
  #またwhile文の条件から、「どちらも1つしかない」ということはありえない
  if len(TL[1])>=len(TL[2]): #-のが多い、もしくは同じ（もちろん2:2以上）
    left, right = TL[2].pop(), TL[1].pop()
    printlist.append((left, right))
    TL[2].append(left-right)
  else: #+のが多いパターン
    left, right = TL[1].pop(), TL[2].pop()
    printlist.append((left, right))
    TL[1].append(left-right)

# 最後に、プラス-マイナスでプラス数字を作って終わり
left, right = TL[2].pop(), TL[1].pop()
printlist.append((left, right))
ans = left-right


#答えを出力する
print(ans)
for x, y in printlist:
  print(x, y)



Measured memory_bytes: 65556