akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, A;
	bool ok = true;

	cin >> N;
	rep(i, 0, N)
	{
		cin >> A;
		if (A % 2 == 1)continue;
		if (A % 3 == 0 || A % 5 == 0)
		{
			continue;
		}
		ok = false;
	}

	if (ok)
	{
		cout << "APPROVED" << endl;
	}
	else
	{
		cout << "DENIED" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	if(N%2)
		cout<<2*N<<endl;
	else
		cout<<N<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    string s,t="abcdefghijklmnopqrstuvwxyz";
    cin>>s;
    if(s.size()<26){
        int num[30]={0};
        rep(i,s.size()) num[s[i]-'a']++;
        int a,z=1;
        rep(i,26){
            if(z&&num[i]==0){
                a=i,z=0;
            }
        }
        cout<<s<<t[a]<<"\n";
        return 0;
    }
    int x=s[25]-'a';
    vec C;
    C.push_back(x);
    rep(i,25){
        if(x<s[24-i]-'a') x=s[24-i]-'a',C.push_back(x);
        else{
            int ans=26;
            for(auto j:C) if(j>s[24-i]-'a'&&ans>j) ans=j;
            rep(j,s.size()-i-2) cout<<s[j];
            cout<<t[ans]<<"\n";
            return 0;
        }
    }
    cout<<-1<<"\n";
}

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

using namespace std;

int main(){
    int m, d;
    string day[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
    while (cin >> m >> d) {
        if (!m && !d){
            break;
        }
        int year = 2004, h;
        if (m == 1 || m == 2){
            year--;
            m += 12;
        }
        h = (year + year / 4 - year / 100 + year / 400 + (13 * m + 8) / 5 + d) % 7;
        cout << day[h] << endl;
    }

    return 0;
}

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

int main() {
  int N, M;
  string s[110], t[110];

  cin >> N;
  for (int i = 0; i < N; i++) cin >> s[i];
  cin >> M;
  for (int i = 0; i < M; i++) cin >> t[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int cnt_s = 0;
    for (int j = 0; j < N; j++) {
      if (s[i] == s[j]) cnt_s++;
    }
    int cnt_t = 0;
    for (int k = 0; k < M; k++) {
      if (s[i] == t[k]) cnt_t++;
    }
    ans = max(ans, cnt_s - cnt_t);
  }

  cout << ans << endl;
}

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

using namespace std;

void solve(void)
{
	int h, w, n, sr, sc;
	cin >> h >> w >> n >> sr >> sc;
	string s, t;
	cin >> s >> t;
	vector<int> ls(n+1), rs(n+1), us(n+1), ds(n+1);
	ls[0] = rs[0] = sc;
	us[0] = ds[0] = sr;
	for (int i = 0; i < n; i++)
	{
		ls[i + 1] = max(ls[i] - (t[i] == 'L'), 1);
		rs[i + 1] = min(rs[i] + (t[i] == 'R'), w);
		ds[i + 1] = min(ds[i] + (t[i] == 'D'), h);
		us[i + 1] = max(us[i] - (t[i] == 'U'), 1);
	}
	reverse(s.begin(), s.end());
	reverse(t.begin(), t.end());
	//kill zone
	int l = 0, r = w + 1, u = 0, d = h + 1;
	bool fall = 0;
	for (int i = 0; i < n; i++)
	{
		fall |= l+1 == r || u+1 == d;
		fall |= us[n-i] >= d || u >= ds[n-i] || ls[n-i] >= r || l >= rs[n-i];
		if (t[i] == 'L') r = min(r+1, w+1);
		if (t[i] == 'R') l = max(l-1, 0);
		if (t[i] == 'U') d = min(d+1, h+1);
		if (t[i] == 'D') u = max(u-1, 0);
		if (s[i] == 'L') l = min(l+1, w+1);
		if (s[i] == 'R') r = max(r-1, 0);
		if (s[i] == 'U') u = min(u+1, h+1);
		if (s[i] == 'D') d = max(d-1, 0);
		/*
		cout << l << ' ' << ls[n - i] << endl
			 << r << ' ' << rs[n - i] << endl
			 << u << ' ' << us[n - i] << endl
			 << d << ' ' << ds[n - i] << endl;
		*/
		if (fall)
		{
			break;
		}
	}
	fall |= l + 1 == r || u + 1 == d;
	fall |= us[0] >= d || u >= ds[0] || ls[0] >= r || l >= rs[0];

	cout << (!fall ? "YES" : "NO") << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 3848
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define int ll int 
#define ll long long
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
using namespace std::chrono;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int n;
	cin>>n;
	vi G[n+1];
	in(n-1)
	{
		int a;
		cin>>a;
		G[a].pb(i+2);
	}
	in(n+1)
	{
		if(i==0)
			continue;
		cout<<G[i].size()<<endl;
	}
	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "h" "h.cpp" -fsanitize=address
// -fsanitize=undefined -D_GLIBCXX_DEBUG -g

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

int main()
{
    int n;
    cin >> n;
    cout << "ABC" << n << "\n";
    return 0;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,k=get_i
ab=array(2,n)
n.times do|i|
  ab[i]=get_i
end
ab.sort!{|x,y| x[0]<=>y[0]}
i=0
while k>0
  if k-ab[i][1]>0
    k-=ab[i][1]
    i+=1
  else
    break
  end 
end
puts ab[i][0]

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	int x, n;
	cin >> x >> n;
	int a[n];
	bool b[101];
	memset(b, true, sizeof(b));
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		b[a[i]] = false;
	}
	int left = x - 1, right = x + 1;
	while (right <= 101)
	{
		if (b[x] == true)
		{
			cout << x << endl;
			break;
		}
		if (b[left] == true)
		{
			cout << left << endl;
			break;
		}
		if (b[right] == true)
		{
			cout << right << endl;
			break;
		}
		left--;
		right++;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	rep(i,n){
		char s; cin >>s;
		if(s=='Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c;
	cin >> a >> b >> c;
	char d=a[0]+'A'-'a';
	char e=b[0]+'A'-'a';
	char f=c[0]+'A'-'a';	
	cout << d << e << f << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin >> N;
  A=N%1000;
  B=N%1110;
  if(B<10){
    cout << "Yes" << endl;
  }
  else if(A%111==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ppi pair<int ,int >
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define MAXN 
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
const int MD = (int)1e9+7;
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};

int a[102];
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);	
 
 	int n,k;
 	cin>>n>>k;

 	ff(i, 0, k-1) {
 		int m;
 		cin>>m;

 		ff(j, 0, m-1) {
 			int b;
 			cin>>b;
 			a[b]++;
 		}
 	}

 	int ans = 0;
 	ff(i, 1, n) 
 		if(a[i]==0)
 			ans++;

 	cout<<ans;
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
  int64_t H, W;
  cin >> H >> W;

  char C[101][101];
  char D[201][101];
  
  
  for(int64_t i=1;i<=H;i++) {
    for(int64_t j=1;j<=W;j++) {
      cin >> C[i][j];
      D[i*2][j] = C[i][j];
      D[i*2+1][j] = C[i][j];
    }
  }

  for(int64_t i=2;i<=H*2+1;i++) {
    for(int64_t j=1;j<=W;j++)
      cout << D[i][j];
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = Console.ReadLine().Split(' ').Select((c => int.Parse(c))).ToArray();
            var A = list[0];
            var B = list[1];
            var T = list[2];
            Console.WriteLine(T / A * B);
        }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int Maxn=100;
ll f[Maxn+5][10][2];
char s[Maxn+5];
int n,k;
ll dfs(int n,int k,int flag){
	if(f[n][k][flag]!=-1){
		return f[n][k][flag];
	}
	if(n==0){
		if(k==0){
			return f[n][k][flag]=1;
		}
		return f[n][k][flag]=0;
	}
	f[n][k][flag]=0;
	if(flag>0){
		if(s[n]>'0'){
			if(k>0){
				f[n][k][flag]+=dfs(n-1,k-1,1);
				f[n][k][flag]+=(s[n]-'0'-1)*dfs(n-1,k-1,0);
			}
			f[n][k][flag]+=dfs(n-1,k,0);
		}
		else{
			f[n][k][flag]+=dfs(n-1,k,1);
		}
	}
	else{
		if(k>0){
			f[n][k][flag]+=9*dfs(n-1,k-1,0);
		}
		f[n][k][flag]+=dfs(n-1,k,0);
	}
	return f[n][k][flag];
}
void swp(char &a,char &b){
	char t=a;
	a=b;
	b=t;
}
int main(){
	scanf("%s",s+1);
	while(s[++n]!='\0');
	n--;
	for(int i=1,j=n;i<j;i++,j--){
		swp(s[i],s[j]);
	}
	scanf("%d",&k);
	memset(f,-1,sizeof f);
	cout<<dfs(n,k,1)<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC136C();
        }

        static void AC136C()
        {
            //https://atcoder.jp/contests/abc136/tasks

            string answer = "Yes";

            var n = int.Parse(Console.ReadLine());
            var listH = Console.ReadLine().Split().Select(long.Parse).ToArray();

            for (int i = n-1; 0 < i ; i-- )
            {
                if(listH[i -1] <= listH[i])
                {
                    continue;
                }
                else if(listH[i -1] -1 == listH[i])
                {
                    listH[i - 1] = listH[i - 1] - 1;
                    continue;
                }
                else
                {
                    answer = "No";
                    break;
                }
            }

            Console.WriteLine(answer);
            Console.ReadKey();

        }

    }
}


Measured memory_bytes: 27356
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C;
  cin >> A >> B >> C;
  if(B/A>=C)
  {
    cout << C << endl;
  }
  else
  {
    cout << B/A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong(); // Long Xを受け取る
		long K = sc.nextLong(); // Long Kを受け取る
		long D = sc.nextLong(); // Long Dを受け取る

		sc.close(); // 標準入力を終了

		long x = X; // 現在の座標

		if(Math.abs(K * D) < Math.min(Math.abs(X + D / 2), Math.abs(X - D / 2))) {
			// X,Kに比べて、Dが極端に小さい場合
			x = Math.min(Math.abs(x + K * D), Math.abs(x - K * D));
			System.out.println(x);
			return; // プログラムを終了
		}

		for (int i = 0; i < K; i++) {
			x = Math.min(Math.abs(x + D), Math.abs(x - D));

			if(Math.abs(x) <= D / 2) {
				// 座標の絶対値の最小値

				// 残り回数が偶数か奇数か判定
				if((K - i - 1) % 2 == 0) {
					break;
				} else {
					// 奇数の場合は1回だけ動かす
					x = Math.min(Math.abs(x + D), Math.abs(x - D));
					break;
				}
			}
		}
		System.out.println(x);
	}

}

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

int main()
{
  int N, K;
  cin >> N >> K;
  unordered_set<int> D(K);
  int d;
  for (int i = 0; i < K; i++)
  {
    cin >> d;
    D.insert(d);
  }

  int n, r;
  do
  {
    n = N++;
    r = 0;

    while (n)
    {
      r += D.count(n % 10);
      n /= 10;
    }
  } while (r);

  cout << N - 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

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

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

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    LL x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    VLL p(a), q(b), r(c);
    REP(i,0,a) cin >> p[i];
    REP(i,0,b) cin >> q[i];
    REP(i,0,c) cin >> r[i];
    sort(all(p)); reverse(all(p));
    sort(all(q)); reverse(all(q));
    sort(all(r)); reverse(all(r));
    LL ans = 0;
    VLL rup(a+1);
    VLL ruq(b+1);
    VLL rur(c+1);
    REP(i,0,a) rup[i+1] = rup[i] + p[i];
    REP(i,0,b) ruq[i+1] = ruq[i] + q[i];
    REP(i,0,c) rur[i+1] = rur[i] + r[i];

    REP(i,0,x+1) {
        int rem = x - i;
        if (rem > c) continue;
        LL sum = rup[i] + rur[rem];
        
        //cout << sum << endl;

        int ok = 0, ng = min(c - rem, y) + 1;
        while (abs(ok - ng) > 1) {
            int m = (ok + ng) / 2;
            if (r[rem+m-1] > q[y-m]) ok = m;
            else ng = m;
        }
        sum += rur[ok + rem] - rur[rem];
        sum += ruq[y - (ok)];
        /*
        int ok = rem, ng = rem + min(c - rem, y);
        while (abs(ok - ng) > 1) {
            int m = (ok + ng) / 2;
            int diff = m - rem;
            if (r[m] > q[y-1-diff]) ok = m;
            else ng = m;
        }
        sum += rur[ok] - rur[rem];
        sum += ruq[b - (ok - rem)];
        */
        chmax(ans, sum);
        
        //cout << i << ": " << sum << endl;
    }
    cout << ans << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

const int INF = 1e9;

//2次元ベクトルを表示
void printVec(const vector<vector<int>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(101 * 101, 0);
  vector<int> d(K);
  for (int i = 0; i < K; ++i) {
    cin >> d.at(i);
    for (int j = 0; j < d.at(i); ++j) {
      cin >> A.at(i * 100 + j);
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (!count(A.begin(), A.end(), i)) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

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

	int n, k;
	cin >> n >> k;
	vi a(n);
	int m = 0;
	loop(n) cin >> a[i], m = max(m, a[i]);
	int l = 1, r = m;
	int ans = m;
	while (l < r) {
		int mid = avg(l, r);
		int cuts = 0, x = 0;
		loop(n) {
			int y = (a[i] + mid - 1) / mid;
			cuts += y - 1;
			x = max(x, (a[i] + y - 1) / y);
		}
		if (cuts <= k) {
			r = mid;
			ans = min(ans, x);
		}
		else l = mid + 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3900
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int d[2002][2002][4];

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

  int h, w;
  cin >> h >> w;
  int H = h + 2;
  int W = w + 2;
  vector<string> s(H);
  s[0] = string(W, '#');
  rep(i, h) {
    int r = i + 1;
    cin >> s[r];
    s[r] = '#' + s[r] + '#';
  }
  s[H-1] = string(W, '#');

  rep(r, H) {
    rep(c, W) {
      if (s[r][c] == '#') {
        d[r][c][0] = -1;
      }
      else {
        d[r][c][0] = d[r][c-1][0] + 1;
      }
    }
  }

  rep(r, H) {
    rrep(c, W) {
      if (s[r][c] == '#') {
        d[r][c][1] = -1;
      }
      else {
        d[r][c][1] = d[r][c+1][1] + 1;
      }
    }
  }

  rep(c, W) {
    rep(r, H) {
      if (s[r][c] == '#') {
        d[r][c][2] = -1;
      }
      else {
        d[r][c][2] = d[r-1][c][2] + 1;
      }
    }
  }

  rep(c, W) {
    rrep(r, H) {
      if (s[r][c] == '#') {
        d[r][c][3] = -1;
      }
      else {
        d[r][c][3] = d[r+1][c][3] + 1;
      }
    }
  }

  int ma = 0;
  rep(r, H) {
    rep(c, W) {
      if (s[r][c] == '.') {
        chmax(ma, d[r][c][0] + d[r][c][1] + d[r][c][2] + d[r][c][3] + 1);
      }
    }
  }

  cout << ma << endl;

}


Measured memory_bytes: 133504
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,vector<T>(w)))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,vector<T>(w,i)))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in(), m = in();

	set<ll>r_exist; vector<ll>r_geq(n * m + 2);
	REP(i, n) {
		ll a = in();
		if (r_exist.count(a) == 1) {
			cout << 0 << endl;
			return 0;
		}
		r_exist.insert(a);
		++r_geq[1];
		--r_geq[a + 1];
	}
	REP1(i, n * m - 1) {
		r_geq[i + 1] += r_geq[i];
	}

	set<ll>c_exist; vector<ll>c_geq(n * m + 2);
	REP(i, m) {
		ll b = in();
		if (c_exist.count(b) == 1) {
			cout << 0 << endl;
			return 0;
		}
		c_exist.insert(b);
		++c_geq[1];
		--c_geq[b + 1];
	}
	REP1(i, n * m - 1) {
		c_geq[i + 1] += c_geq[i];
	}

	vector<ll>result(n * m + 1, 0);
	REPR1(i, n * m) {
		if (r_exist.count(i) == 1 && c_exist.count(i) == 1) {
			result[i] = 1;
		} else {
			if (r_exist.count(i) == 1) {
				result[i] = c_geq[i];
			} else if (c_exist.count(i) == 1) {
				result[i] = r_geq[i];
			} else {
				result[i] = r_geq[i] * c_geq[i] - (n* m - i);
			}
		}
	}

	ll ans = 1;
	REP1(i, n * m)ans = ((ans % MOD) * (result[i] % MOD)) % MOD;
	cout << ans << endl;
}

Measured memory_bytes: 23808
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 20000000;
const int MOD = 998244353;
int pow_mod(int b, int p) {
	int ret = 1;
	while( p ) {
		if( p & 1 ) ret = 1LL*ret*b%MOD;
		b = 1LL*b*b%MOD;
		p >>= 1;
	}
	return ret;
}
int fct[MAXN + 5], ifct[MAXN + 5];
void init() {
	fct[0] = 1;
	for(int i=1;i<=MAXN;i++)
		fct[i] = 1LL*fct[i-1]*i%MOD;
	ifct[MAXN] = pow_mod(fct[MAXN], MOD-2);
	for(int i=MAXN-1;i>=0;i--)
		ifct[i] = 1LL*ifct[i+1]*(i+1)%MOD;
}
int pw1[MAXN + 5], pw2[MAXN + 5];
int main() {
	init();	int N, M;
	scanf("%d%d", &N, &M);
	int ans = 0;
	pw1[0] = pw2[0] = 1;
	for(int i=1;i<=max(N, M);i++)
		pw1[i] = 1LL*pw1[i-1]*(N+1)%MOD, pw2[i] = 1LL*pw2[i-1]*(M+1)%MOD;
	for(int i=0,f=1;i<=min(N,M);i++,f=1LL*f*(MOD-1)%MOD) {
		int del = 1LL*ifct[N-i]*ifct[M-i]%MOD*ifct[i]%MOD;
		del = 1LL*del*pw1[M-i]%MOD*pw2[N-i]%MOD;
		ans = (ans + 1LL*f*del)%MOD;
	}
	printf("%lld\n", 1LL*ans*fct[N]%MOD*fct[M]%MOD);
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int B[200010];

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

	int N;
	cin >> N;

	int A;
	int c = 0;
	int p = N / 2;

	rep(i, 0, N)
	{
		cin >> A;
		if (N % 2 == 0)
		{
			if (c % 2 == 1)p -= c;
			else p += c;
		}
		else
		{
			if (c % 2 == 1)p += c;
			else p -= c;
		}
		B[p] = A;
		c++;
	}

	rep(i, 0, N)
	{
		cout << B[i] << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;

	

int main(){
	long long n,sum=0;
	cin >> n;
	for(long long i=1;i<n;i++){
		if( (double)(n-i)/(double)i <= i) break;
		if( (n-i)%i == 0 ){
			sum += (n-i)/i;
		}
	}
	
	printf("%lld\n",sum);
	return 0;
}
			

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

int main() {
	double L; cin >> L;
	cout <<setprecision(20) <<pow(L, 3) / 27 << endl;
}

Measured memory_bytes: 256
#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 = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// a^n mod を計算する
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;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

    ll N ,M ,K; cin >> N >> M >> K;

    ll ans = 0;
    rep(i, K + 1){
      ans += ( M * modpow(M - 1 , N - (i + 1) , MOD) % MOD ) * COM(N - 1, i) % MOD;
      ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15592
#include<stdio.h>
#include<iostream>
using namespace std;

int N;
int main (){
    cin >> N;
    int cnt = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        while( a % 2 == 0) {
            a /= 2;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　    int a,b,c;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            c = 0;
            if (a < b)
            {
              c += b;
              b--;
              if (a <= b)
              {
                c += b;
              }
              else
              {
                c += a;
              }
            }
            else if (a > b)
            {
              c += a;
              a--;
              if (a <= b)
              {
                c += b;
              }
              else
              {
                c += a;
              }
            }
            else
            {
              c = a + b;
            }
              
            
            Console.WriteLine(c);
        }
 }

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  set<int> s;

  int cmd, val;
  set<int>::iterator it;
  for (int i = 0; i < n; i++) {
    cin >> cmd >> val;

    switch (cmd) {
      case 0:
        s.insert(val);
        cout << s.size() << endl;
        break;

      case 1:
        it = s.find(val);
        if (it != s.end() && *it == val) {
          cout << 1 << endl;
        } else {
          cout << 0 << endl;
        }
        break;

      case 2:
        it = s.find(val);
        if (it != s.end()) {
          s.erase(it);
        }
        break;
    }
  }
}




Measured memory_bytes: 12444
/*
 * author: Tran Minh Khoa
 * Ho Chi Minh University of Science
 */

#include <bits/stdc++.h>

using namespace std;

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

const int N = 123456;
const int M = 1010;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sqrt(x) (x) * (x)

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(x) cerr << #x << " = " << x << '\n';
#define PR(x, a, b) { cerr << #x << " = "; REP(i, a, b) cerr << x[i] << ' '; cerr << '\n'; }

int main() {
  #ifdef KM777
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr); cout.tie(nullptr);
  
  int n, m;
  cin >> n >> m;
  pair<int, int> a[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
  } 
  sort(a + 1, a + n + 1);
  long long result = 0;
  for (int i = 1; i <= n && m; i++) {
    int canBuy = min(m, a[i].second);
    result += 1LL * canBuy * a[i].first;
    m -= canBuy;
  }
  cout << result << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

ll dp[100005];

int main(){
    int n, w;
    cin >> n >> w;

    rep(j, n){
        int wi, vi;
        cin >> wi >> vi;
        for (int i = w; i >= wi; i--){
            dp[i] = max(dp[i], dp[i-wi] + vi);
        }

        // repr(i, 0,w){
        //     cout << dp[i] << " ";
        // }
        // cout << endl;
    }

    cout << dp[w] << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

vector<pair<int,int>> P;

bool dfs(int N,int a,int b,int D)
{
	if (a == N-1 && b == N-1) { return true; }
	if (b < N-1)
	{
		if (a != b && a<b)
		{
			P.push_back(make_pair(a, b));
			//cout << a << " " << b << endl;
		}
		dfs(N, a, b+1, D);
	}
	if (b == N-1)
	{
		if (a != b && a<b)
		{
			P.push_back(make_pair(a, b));
			//cout << a << " " << b << endl;
		}
		b = 0;
		dfs(N, a + 1, b, D);
	}
}

int main()
{
	int N,D,a=0,b=0,count=0;
	vector<vector<double>> A;
	cin >> N >> D;

	for (int i = 0; i < N; i++)
	{
		vector<double> T;
		for (int j = 0; j < D; j++)
		{
			double a;
			cin >> a;
			T.push_back(a);
			if (j == D - 1)
			{
				A.push_back(T);
			}
		}
	}
	dfs(N,a,b,D);
	
	for (int i = 0; i < P.size(); i++)
	{
		double l=0;
		for (int j = 0; j < D; j++)
		{
			l = l + pow(A[P[i].first][j] - A[P[i].second][j],2);
			if (sqrt(l) == ceil(sqrt(l)) && j==D-1 ) { count++; }
		}
	}
	cout << count << endl;

}

Measured memory_bytes: 256
H, W = map(int,input().split())
S = [list(input()) for i in range(H)]
arr = [[0]*W for i in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      if i-1 >= 0 and S[i-1][j] == ".":
        arr[i-1][j] += 1
      if i+1 < H and S[i+1][j] == ".":
        arr[i+1][j] += 1
      if j-1 >= 0 and S[i][j-1] == ".":
        arr[i][j-1] += 1
      if j+1 < W and S[i][j+1] == ".":
        arr[i][j+1] += 1
      if i-1 >= 0 and j-1 >= 0 and S[i-1][j-1] == ".":
        arr[i-1][j-1] += 1
      if i-1 >= 0 and j+1 < W and S[i-1][j+1] == ".":
        arr[i-1][j+1] += 1
      if i+1 < H and j-1 >= 0 and S[i+1][j-1] == ".":
        arr[i+1][j-1] += 1
      if i+1 < H and j+1 < W and S[i+1][j+1] == ".":
        arr[i+1][j+1] += 1
      arr[i][j] = "#"
for i in range(H):
  print(*arr[i],sep="")


Measured memory_bytes: 3572
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
adjacent_hight = Array.new(h.size, 0)
$<.map{|l|
  a, b = l.split.map(&:to_i)
  adjacent_hight[a-1] = h[b-1] if adjacent_hight[a-1] < h[b-1]
  adjacent_hight[b-1] = h[a-1] if adjacent_hight[b-1] < h[a-1]
}
ans = 0
(h.size).times{|i|
  ans += 1 if adjacent_hight[i] < h[i]
}
p ans


Measured memory_bytes: 23444
package main

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

var dp [51][51][50*50 + 1]int

func main() {
	N, A := ReadInt(), ReadInt()
	x := ReadInts(N)
	dp[0][0][0] = 1
	for j := 1; j <= N; j++ {
		for k := 0; k <= j; k++ {
			for s := 0; s <= N*A; s++ {
				dp[j][k][s] += dp[j-1][k][s]
				if s >= x[j-1] && k > 0 {
					dp[j][k][s] += dp[j-1][k-1][s-x[j-1]]
				}
			}
		}
	}
	c := 0
	for k := 1; k <= N; k++ {
		c += dp[N][k][A*k]
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 27944
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#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 rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_p
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

#define N 100000
int r[N],p[N];

void init(int n){
    int i;
    rep(i,n){
        p[i]=i;
        r[i]=0;
    }
}

int find_set(int x){
    if(x!=p[x])
        p[x]=find_set(p[x]);
    return p[x];
}

void link(int x,int y){
    if(r[x]>r[y])
        p[y]=x;
    else{
        p[x]=y;
        if(r[x]==r[y])
            r[y]++;
    }
}
void unite(int x,int y){
    link(find_set(x),find_set(y));
}

int same(int x,int y){
    return find_set(x)==find_set(y);
}

void run(){
    int n,m;
    cin>>n>>m;
    init(n);
    int s,t;
    rep(i,m){
        cin>>s>>t;
        unite(s,t);
    }
    int q;
    cin>>q;
    rep(i,q){
        cin>>s>>t;
        yes(same(s,t));
    }
}


Measured memory_bytes: 4752
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)

int main(void){
  long long int a,b,c,d;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  long long int x,y,z,w;
  x = a*c;
  y = b*c;
  z = a*d;
  w = b*d;
  if(x<y) x=y;
  if(x<z) x=z;
  if(x<w) x=w;
  printf("%lld",x);
  return 0;
}


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

bool bs(int val, vector<int>& v){
   int l=0, r = v.size()-1;
   while(l<=r){
       int mid = (l+r)>>1;
       if(v[mid]==val)  return true;
       else if(v[mid] > val) r = mid-1;
       else l = mid+1;
     }
   return false;
}
 
int main(){
   int n;
   scanf("%d", &n);
   int v;
   vector<int> s, t;
   int ans=0;
   for(int i=0; i<n; i++){
     scanf("%d", &v);
     s.push_back(v);
   }
   scanf("%d", &n);
   while(n--){
      scanf("%d", &v);
      t.push_back(v);
    }
    for(int x: t){
      if(bs(x, s)){
         ans++;
       }
     }
   printf("%d\n", ans);
   return 0;
}


Measured memory_bytes: 3580
// C - Energy Drink Collector
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli h, k, n, m, w, ans = 0, count = 0;
  string s, t;
  cin >> n >> m;
  vlli a(n), b(n);
  using P = pair<lli, lli>;
  vector<P> vp;
  rep(i, 0, n)
  {
    cin >> a[i] >> b[i];
    vp.emplace_back(a[i], b[i]);
  }
  SORT(vp);
  for (auto p : vp)
  {
    w = p.first;
    k = p.second;
    count = min(m, k);
    ans += w * count;
    m -= k;
    if (m <= 0)
    {
      cout << ans << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3956
#include <stdio.h>
int main()
{
    int a,b;
    int i;
    scanf("%d%d",&a,&b);
    
    if((a==1&&b==2)||(a==2&&b==1))
    {
        printf("3\n");
    }
    else if((a==2&&b==3)||(a==3&&b==2))
    {
        printf("1\n");
    }
    else 
    {
        printf("2\n");
    }

    return 0;
}


Measured memory_bytes: 128
from collections import Counter
N, K = map(int, input().split())
a = [int(i) for i in input().split()]
s = len(set(a))
c = Counter(a)
L = sorted(c.items(), key=lambda x: x[1])

cnt = 0
i = 0
while s > K:
    cnt += L[i][1]
    s -= 1
    i += 1
print(cnt)

Measured memory_bytes: 48512
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
const int N=1e5;
int n,a[N+1];
int read()
{
	int ret=0;
	char c=getchar();
	while(!isdigit(c)) {
		c=getchar();
	}
	while(isdigit(c)) {
		ret=ret*10+c-'0';
		c=getchar();
	}
	return ret;
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i) {
		a[i]=read();
	}
	sort(a+1,a+n+1,[](const int x,const int y) {
		return x>y;
	});
	int x=0;
	while((x<n)&&(x+1<=a[x+1])) {
		++x;
	}
	if(a[x]-x&1) {
		puts("First");
	} else {
		int y=x;
		while((y<n)&&(x<=a[y+1])) {
			++y;
		}
		puts((y-x)&1?"First":"Second");
	}
	return 0;
}


Measured memory_bytes: 1832
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes") if n else print("No")    
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(repr(item))
        stderr.write(sep)
    stderr.write(end)

s = input()
flag = True
numC = 0
if s[0] != "A":
    flag = False
if not s[1].islower():
    flag = False
for i in range(2,len(s)-1):
    if s[i] == "C":
        numC += 1
    elif not s[i].islower():
        flag = False
if numC != 1:
    flag = False
if not s[-1].islower():
    flag = False
    
print("AC") if flag else print("WA")

Measured memory_bytes: 3828
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll a[300000];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  REP(i,n)cin>>a[i+1];
  REP(i,n)a[i+1]+=a[i];
  set<ll> s;
  REP(i,n+1)s.insert(a[i]);
  ll ans=0;
  sort(a,a+n+1);
  for(auto x:s){
    ll u1=lower_bound(a,a+n+1,x)-a;
    ll u2=upper_bound(a,a+n+1,x)-a;
    ans+=((u2-u1)*(u2-u1-1))/2;
  }
  P(ans);
  return 0;
}


Measured memory_bytes: 11264
#include<iostream>
#include<vector>
using namespace std;
#define ll long long
const int limit = 1000010;
using edge = struct{int to;ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v,int p,ll d){
  depth[v] = d;
  for(auto &e : tree[v]){
    if(e.to==p) continue;
    dfs(e.to,v,d+e.cost);
  }
}

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

  for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--; b--;
    tree[a].push_back({b,c});
    tree[b].push_back({a,c});
  }

  int q,k;
  cin>>q>>k;
  k--;

  dfs(k,-1,0);
  for(int i=0;i<q;i++){
    int x,y;
    cin>>x>>y;
    x--; y--;
    cout<<depth[x]+depth[y]<<endl;
  }
  return 0;
}


Measured memory_bytes: 37120
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

types = []
last = [-1] * 26
S = 0
for d in range(D):
    # search type
    M = -float('inf')
    for tt in range(26):
        _last = last[:]
        tmp = s[d][tt]

        _last[tt] = d
        for i in range(26):
            tmp -= c[i] * (d - _last[i])

        if tmp > M:
            M = tmp
            M_tt = tt

    S += s[d][M_tt]

    last[M_tt] = d
    for i in range(26):
        S -= c[i] * (d - last[i])
    types.append(M_tt)


last = [-1] * 26
S = 0
for d in range(D):
    seq = []
    for tt in range(26):
        _last = last[:]
        tmp = s[d][tt]

        _last[tt] = d
        for i in range(26):
            tmp -= c[i] * (d - _last[i])

        seq.append([tmp, tt])

    seq.sort(reverse=True)

    tmpmax = -float('inf')
    for i in range(10):
        tt = seq[i][1]
        _last = _last[:]
        _types = types[:]
        _types[d] = tt
        _S = S

        for dd in range(d, D):
            _S += s[dd][_types[dd]]

            _last[_types[dd]] = dd
            for i in range(26):
                _S -= c[i] * (dd - _last[i])

        if _S > tmpmax:
            cand = tt
            tmpmax  = _S

    S += s[d][cand]
    last[cand] = d
    for i in range(26):
        S -= c[i] * (d - last[i])

    print(cand + 1)


Measured memory_bytes: 70444
import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    val s1 = readLine
    val s2 = readLine
    if (s1(0) == s2(2) && s1(1) == s2(1) && s1(2) == s2(0)) {
      println("YES")
    }else{
      println("NO")
    }

  }


}


Measured memory_bytes: 25536
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;


int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  yn(c-a-b>0 && 4*a*b<(c-a-b)*(c-a-b));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,i,b,n,j;
    set<ll>s;
    cin>>a>>b;
    for(i=0;i<b;i++)
    {
        cin>>n;
        ll c;
        for(j=0;j<n;j++)
        {
            cin>>c;
            s.insert(c);
        }
    }
    cout<<a-s.size()<<endl;
}


Measured memory_bytes: 3636