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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e2 + 5;
const int NN=1e5 + 5;

int n;
int w;
int a[N][NN];
int dp[N][NN];

int solve(int i,int j)
{
	if(i>n || j>=w)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(a[i][1]<=(w-j))
	{
		dp[i][j] = max(a[i][2] + solve(i+1,j+a[i][1]) , solve(i+1,j));
		return dp[i][j];
	}
	else
	{
		dp[i][j] = solve(i+1,j);
		return dp[i][j];
	}
}

int32_t main()
{
	IOS;
	memset(dp,-1,sizeof(dp));
	cin >> n;
	cin >> w;
	rep(i,1,n)
	{
		cin >> a[i][1] >> a[i][2];
	}
	cout << solve(1,0) << endl;	
}


Measured memory_bytes: 162048
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> cc(n);
  vector< vector<int> > C(n);
  vector<int> P(n, -1);
  for (int i = 0; i < n; i++){
    int u;
    cin >> u;
    int k;
    cin >> k;
    cc[u] = k;
    for (int j = 0; j < k; j++){
      int c;
      cin >> c;
      C[u].push_back(c);
      P[c] = u;
    }
  }
  int r;
  for (int i = 0; i < n; i++){
    if (P[i] == -1){
      r = i;
      break;
    }
  }
  vector<int> d(n, 0);
  queue<int> Q;
  Q.push(r);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int i = 0; i < cc[v]; i++){
      d[C[v][i]] = d[v] + 1;
      Q.push(C[v][i]);
    }
  }
  for (int i = 0; i < n; i++){
    cout << "node " << i << ": parent = " << P[i] << ", depth = " << d[i];
    if (i == r){
      cout << ", root, [";
    } else if (cc[i] == 0){
      cout << ", leaf, [";
    } else {
      cout << ", internal node, [";
    }
    for (int j = 0; j < cc[i]; j++){
      cout << C[i][j];
      if (j < cc[i] - 1){
        cout << ", ";
      }
    }
    cout << "]" << endl;
  }
}


Measured memory_bytes: 7584
a = list(map(int, input().split()))

counter_5 = 0
counter_7 = 0

for i in range(len(a)):
  if a[i] == 5:
    counter_5 += 1
  if a[i]== 7:
    counter_7 += 1

if counter_5 == 2 and counter_7 ==1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9108
ar = [int(i) for i in input().split()]
n = ar[0]
m = ar[1]
res = 1
if(abs(n-m)>1):
  res = 0
elif(abs(n-m) == 1):
	max = max(n, m)
	min = min(n, m)
	for i in range(max-1):
		res = res * max * min
		res %= (10**9+7)
		max -= 1
		min -= 1
else:
	max = max(n, m)
	res = res * 2*n * m
	n -= 1
	m -= 1
	for i in range(max-2):
		res = res * n * m
		res %= (10**9+7)
		n -= 1
		m -= 1
res %= (10**9+7)
print(res)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
string s;
int main()
{
	cin>>s;
	int l=s.length();
	if(s[0]==s[l-1])
	{
		if(l%2==0) cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}
	else
	{
		if(l%2==0) cout<<"Second"<<endl;
		else cout<<"First"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 512
package main

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

const (
	maxBufferSize     = 2000000 // check
	initialBufferSize = 20000
)

func Max(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}

func JoinInt(a []int, sep string) string {
	aStrs := make([]string, len(a))
	for i := 0; i < len(a); i++ {
		aStrs[i] = strconv.Itoa(a[i])
	}
	return strings.Join(aStrs, sep)
}

func solve() {
	sc := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, initialBufferSize)
	sc.Buffer(buffer, maxBufferSize)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}

	m0 := make([]int, n+1)
	m1 := make([]int, n+1)
	for i := 1; i <= n; i++ {
		m0[i] = Max(m0[i-1], a[i-1])
	}
	for i := n - 1; i >= 0; i-- {
		m1[i] = Max(m1[i+1], a[i])
	}

	ans := make([]int, n)
	for i := 0; i < n; i++ {
		ans[i] = Max(m0[i], m1[i+1])
	}

	buf := JoinInt(ans, "\n")

	fmt.Println(buf)
}

func main() {
	solve()
}


Measured memory_bytes: 13440
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9+7;
const ll infll = 1 << 60LL;
const ll mod = 1e9 + 7;
// 0~3までは左右前後 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

// 型による変数のオーバーフローに気をつけろ！！
// 悩んだら図やグラフを書け！！悩む前から書け！！

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

	string s;
	ll k;
	cin >> s >> k;

	char ans = '1';
	// 5000兆 500000000000000 5*1e14
	// k番目以内に1以外の数が出てきたならそれ

	rep(i, s.size()) {
		if (s[i] != '1') {
			if (i <= k - 1) {
				ans = s[i];
				break;
			}
		}
	}

	std::cout << ans << endl;
	return 0;
}

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

using namespace std;

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


ll M=1e9+9;
ll dp[100][100][100];


int main(){
  ll w,h,n;
  ll T=1;

  while(cin>>w>>h>>n,w){

    vector<P> v;
    for(ll x,y,i=0;i<n;i++){

      cin>>x>>y;
      v.push_back(P(y-1,x-1));
      
    }
    
    sort(v.begin(),v.end());
    ll bt=0;

    memset(dp,0,sizeof(dp));
    
    for(ll i=0;i<w;i++)
      for(ll j=max(0LL,i-1);j<=min(w-1,i+1);j++)
	dp[0][i][j]=1;
  
    h--;

    while((1LL<<bt)<=h){
 
      for(ll i=0;i<w;i++)
	for(ll j=0;j<w;j++)
	  for(ll k=0;k<w;k++)
	    dp[bt+1][j][k]=(dp[bt][j][i]*dp[bt][i][k]+dp[bt+1][j][k])%M;
      
      bt++;
    }

    ll pr=0;

    v.push_back(P(h,-1));

    ll ans[100]={};

    ans[0]=1;
    
    for(ll p=0;p<=n;p++){
      bt=0;
      ll nh=v[p].first-pr;
      pr=v[p].first;
      while((1LL<<bt)<=nh){
	if((1LL<<bt)&nh){
	  ll tmp[100]={};
	  
	  for(ll i=0;i<w;i++)
	    for(ll j=0;j<w;j++)
	      tmp[j]=(tmp[j]+ans[i]*dp[bt][i][j])%M;
	  
	  for(ll i=0;i<w;i++)ans[i]=tmp[i];
	  
	}
	bt++;
      }

      ll yy=v[p].first;

      while(p<=n&&v[p].first==yy){
	if(v[p].second!=-1)ans[v[p].second]=0;
	p++;
      }
      
      p--;
      
    }
    cout<<"Case "<<T++<<": ";
    cout<<ans[w-1]<<endl;

  }



  return 0;
}

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

const int MAX_N = 100005;
const int MOD = 1000000007;

int N;
int a[MAX_N];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  
  sort(a, a + N);

  bool frag = true;

  if (N % 2 == 1) {
    if (a[0] != 0) frag = false;
    for (int i = 1; i < N; i = i + 2) {
      if (a[i] == a[i + 1] && a[i] == i + 1) continue;
      else {
        frag = false;
        break;
      }
    }
  }
  else {
    for (int i = 0; i < N; i = i + 2) {
      if (a[i] == a[i + 1] && a[i] == i + 1) continue;
      else {
        frag = false;
        break;
      }
    }
  }
  ll ans = 1;
  if (frag) {
    for (int i = 0; i < (N/2); i++) {
      ans *= 2;
      ans %= MOD;
    }
    cout << ans << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 640
while True:
    H, W = [int(i) for i in input().split()]
    if H ==0 and W ==0:
        break
    for i in range(2, H+2):
        if i%2 ==0:
            for k in range(1,W+1):
                if k%2 ==0:
                    print('.',end='')
                else:
                    print('#',end='')
            print()
        else:
            for h in range(1,W+1):
                if h%2 ==0:
                    print('#',end='')
                else:
                    print('.',end='')
            print()
    print()

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

const int MAX_N = 10000001;
bool is_p[MAX_N+1] = {false,false};

void sieve(){
	for(int i = 2 ; i <= MAX_N ; i++ ) is_p[i] = true;
	for(int i = 2 ; i*i <= MAX_N ; i++ ){
		if( is_p[i] ){
			for(int j = i+i ; j <= MAX_N ; j += i ){
				is_p[j] = false;
			}
		}
	}
}


int main(){
	sieve();
	int n;
	while( cin >> n , n ){
		int ans = -1;
		for(int i=n ; true ; i-- ){
			if( is_p[i-8] && is_p[i-6] && is_p[i-2] && is_p[i] ){
				ans = i;
				break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 10924
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);

    sort(a.begin(), a.end(), greater<int>());

    int AliceSum = 0, BobSum = 0;
    rep(i, N) {
        if(i % 2 == 0) {
            AliceSum += a.at(i);
        } else { //odd
            BobSum += a.at(i);
        }
    }

    int ans = AliceSum - BobSum;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include <string>

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main()
{
    int W, H, N;
    int w = 0, h = 0;

    cin >> W >> H >> N;

    vector<int> x(N);
    vector<int> y(N);
    vector<int> a(N);

    REP(i, N)
        cin >> x[i] >> y[i] >> a[i];

    REP(i, N){
        if (a[i] == 1)
            w = max(x[i], w);
        
        if (a[i] == 2)    
            W = min(x[i], W);

        if (a[i] == 3)
            h = max(y[i], h);

        if (a[i] == 4)
            H = min(y[i], H);

    }

    if (H > h && W > w)
        cout << (H - h)*(W - w) << endl;
    
    else
        cout << 0 << endl;
    
}

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

using LL = long long;

LL a[3030] = {};
LL dp[2][3030][3030] = {};
bool vis[2][3030][3030] = {};

LL rec(int l, int r, int t) {
	if(l>r) return 0;
	if(vis[t][l][r]) return dp[t][l][r];
	vis[t][l][r] = true;
	LL ret;
	if(t == 0) {
		ret = max(rec(l+1, r, t^1) + a[l], rec(l, r-1, t^1) + a[r]);
	} else {
		ret = min(rec(l+1, r, t^1) - a[l], rec(l, r-1, t^1) - a[r]);
	}
	dp[t][l][r] = ret;
	return ret;
}

int main() {
	int n;
	scanf("%d", &n);
	// cout << n << endl;
	for(int i=0;i<n;i++) {
		scanf("%d", &a[i]);
	}
	cout << rec(0, n-1, 0);
}

Measured memory_bytes: 160384
n = input()
a_lst = list(map(int, input().split()))
check = 0
tmpcnt = 0
anscnt = 0
lens = len(a_lst)
for i in range(lens):
    # print(i, check, a_lst[i])
    if check > a_lst[i]:
        # print(i, check - a_lst[i])
        anscnt += check - a_lst[i]
        tmpcnt = check - a_lst[i]

        # print('cnt', cnt)
        # print(i, a_lst[i])
        a_lst[i] += tmpcnt
    check = a_lst[i]
    # print(check)
print(anscnt)

Measured memory_bytes: 32240
#include <bits/stdc++.h>
using namespace std;
int ans[50][50];
int main(){
    int H,W;cin >> H >> W;
    vector<string> ma;
    string str;
    for(int a = 0;a < H;a++){
        cin >> str;
        ma.push_back(str);
    }
    for(int a = 0;a < H;a++){
        string s = ma.at(a);
        for(int b = 0;b < W;b++){
            if(s.at(b)=='#'){
                ans[a][b]+=10000;
                if(a!=0){
                    ans[a-1][b]++;
                }
                if(a!=H-1){
                    ans[a+1][b]++;
                }
                if(b!=0){
                    ans[a][b-1]++;
                }
                if(b!=W-1){
                    ans[a][b+1]++;
                }
                if(a!=0&&b!=0){
                    ans[a-1][b-1]++;
                }
                if(a!=0&&b!=W-1){
                    ans[a-1][b+1]++;
                }
                if(a!=H-1&&b!=0){
                    ans[a+1][b-1]++;
                }
                if(a!=H-1&&b!=W-1){
                    ans[a+1][b+1]++;
                }
            }

        }
    }
    for(int a = 0;a < H;a++){
        for(int b = 0;b < W;b++){
            if(ans[a][b]>=1000){
                cout<<"#";
            }else{
                cout<<ans[a][b];
            }

        }
        cout<<endl;
    }
    return 0;
}


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

int main() {
    int a[1000010]={};
    int sum[1000010]={};
    int s;
    cin >> s;
    sum[1]+=s;
    a[s]++;
    for(int i=1;i<1000000;i++){
        if(sum[i]%2==0){
            if(a[sum[i]/2]==1){
                cout << i+1 << endl;
                return 0;
            }
            else{
                a[sum[i]/2]++;
                sum[i+1] = sum[i]/2;
            }
        }
        else{
            if(a[sum[i]*3+1]==1){
                cout << i+1 << endl;
                return 0;
            }
            else{
                a[sum[i]*3+1]++;
                sum[i+1] = 3*sum[i] +1;
            }
        }
    }
}



Measured memory_bytes: 8064
#include<iostream>
using namespace std;
int Tc,ax,ay;
int x,y;
int main(){
  cin>>Tc;
  for(int tc=0;tc<Tc;tc++){
    x=y=ax=ay=0;
    while(1){
      int dx,dy;
      cin>>dx>>dy;
      if(dx==0&&dy==0)break;
      x+=dx,y+=dy;
      if(ax*ax+ay*ay<x*x+y*y)ax=x,ay=y;
      else if(ax*ax+ay*ay==x*x+y*y&&ax<x)ax=x,ay=y;
    }
    cout<<ax<<' '<<ay<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 1e5 + 5;
int n;
int a[MAXN], dp[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	dp[1] = 0;
	dp[2] = abs(a[1] - a[2]);
	for(int i = 2; i <= n; i++){
		dp[i+1]=min(dp[i-1]+abs(a[i-1]-a[i+1]),dp[i]+abs(a[i]-a[i+1]));
		dp[i+2]=min(dp[i+1]+abs(a[i+1]-a[i+2]),dp[i]+abs(a[i]-a[i+2]));
	}
	printf("%d\n", dp[n]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
const ll MOD = 1000000007;


class UnionFind {
    vector<int> parent, rank;

public:
    UnionFind(int size) {
        parent = rank = vector<int>(size, 0);
        rep(i, size) parent[i] = i;
    }

    int root(int x) {
        return parent[x] == x ? x : parent[x] = root(parent[x]);
    }

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

    void unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        parent[y] = x;
    }
};


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

    int n, m; cin >> n >> m;
    UnionFind uf(n + 1);
    vector<int> ps(n);
    rep(i, n) cin >> ps[i];
    rep(i, m) {
        int x, y; cin >> x >> y;
        uf.unite(x, y);
    }
    int ans = 0;
    rep(i, n) {
        if (uf.same(i + 1, ps[i])) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 3636
// 2020-08-15 16:36:39
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

const int X = 50000;
bool ab[2*X], ac[2*X], bc[2*X];
bool matched(char a, char b) {
  return (a == '?' || b == '?' || a == b);
}
void answer() {
  string a, b, c;
  cin >> a >> b >> c;
  int az, bz, cz;
  az = a.size();
  bz = b.size();
  cz = c.size();
  rep(ai, az) rep(bi, bz) ab[ai-bi+X] |= (!matched(a[ai], b[bi]));
  rep(ai, az) rep(ci, cz) ac[ai-ci+X] |= (!matched(a[ai], c[ci]));
  rep(bi, bz) rep(ci, cz) bc[bi-ci+X] |= (!matched(b[bi], c[ci]));
  int ans = 1e9;
  REPC(i, -4010, 4010) REPC(j, -4010, 4010) {
    if(ab[i+X]) continue;
    if(ac[j+X]) continue;
    if(bc[j-i+X]) continue;
    int l = min({i, j, 0});
    int r = max({az, i+bz, j+cz});
    chmin(ans, r-l);
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3688
package main

import "fmt"

func main() {
	// Code for A - A+...+B Problem
	var N, A, B int
	fmt.Scan(&N, &A, &B)

	if A > B {
		fmt.Println("0")
	} else if N == 1 {
		if A != B {
			fmt.Println("0")
		} else {
			fmt.Println("1")
		}
	} else {
		fmt.Println((B-A)*(N-2) + 1)
	}
}


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

int N;
vector<vector<int>> graph(200000);
vector<vector<int>> ko(200000);
vector<int> oya(200000);
vector<int> s(200000, 0);
vector<int> ans(200000, -1);

void ki(int u) {
    for (int v : graph[u]) {
        if (v != oya[u]) {
            ko[u].push_back(v);
            oya[v] = u;
            ki(v);
        }
    }
    return;
}

int fun(int u) {
    if (u == 0) {
        ans[0] = s[0];
        return ans[0];
    }
    if (ans[u] != -1) return ans[u];
    ans[u] = s[u] + fun(oya[u]);
    return ans[u];
}

int main() {
    int Q;
    cin >> N >> Q;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }
    vector<int> p(Q), x(Q);
    rep(i, Q) cin >> p[i] >> x[i];
    
    oya[0] = -1;
    ki(0);
    rep(i, Q) s[p[i] - 1] += x[i];
    
    rep(i, N - 1) cout << fun(i) << " ";
    cout << fun(N - 1) << endl;
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	int v[n], c[n];
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	for(int i = 0; i < n; i++){
		cin >> c[i];
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(v[i] - c[i] > 0){
			ans += v[i] - c[i];
		}
	}
	cout << ans;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string str;
  IN(str);
  REP(i,str.size()){
    printf("x");
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
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;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char b;
    cin >> b;
    if (b == 'A')
        cout << 'T' << endl;
    else if (b == 'T')
        cout << 'A' << endl;
    else if (b == 'C')
        cout << 'G' << endl;
    else
        cout << 'C' << endl;
    return 0;
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> v(n);
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }
    int c0,c1,c2,c3;
    c0=0;
    c1=0;
    c2=0;
    c3=0;
    for(int i = 0; i < n; i++){
        if(v[i]=="AC") c0 += 1;
    }
    for(int i = 0; i < n; i++){
        if(v[i]=="WA") c1 += 1;
    }
    for(int i = 0; i < n; i++){
        if(v[i]=="TLE") c2 += 1;
    }
    for(int i = 0; i < n; i++){
        if(v[i]=="RE") c3 += 1;
    }
    cout << "AC" << ' ' << 'x' << ' '<< c0 << endl;
    cout << "WA" << ' ' << 'x' << ' '<< c1 << endl;
    cout << "TLE"<< ' ' << 'x' << ' '<< c2 << endl;
    cout << "RE" << ' ' << 'x' << ' '<< c3 << endl;
    
}

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

int main() {
  int N;
  cin >> N;
  vector<string> judge(N);
  for (int i = 0; i < N; i++){
    cin >> judge.at(i);
  }
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  for (int j = 0; j < N; j++){
    if (judge.at(j) == "AC"){
      a++;
    }
    else if (judge.at(j) == "WA"){
      b++;
    }
    else if (judge.at(j) == "TLE"){
      c++;
    }
    else if (judge.at(j) == "RE"){
      d++;
    }
  }
  cout << "AC " << "x " << a << endl;
  cout << "WA " << "x " << b << endl;
  cout << "TLE " << "x " << c << endl;
  cout << "RE " << "x " << d << endl;

  }


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

int main()
{
  int w, a, b, rst;
  cin >> w >> a >> b;
  if (b - a - w > 0) {
    rst = b - a - w;
  } else if (b - a - w <= 0 && a - b - w <= 0) {
    rst = 0;
  } else {
    rst = a - b - w;
  }
  cout << rst << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a, b;
	cin >> a >> b;

	if (max(a,b) < 9)
	{
		cout << "Yay!";
	}
	else
	{
		cout << ":(";
	}
	cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void){

  //入力
  int K, S;
  cin >> K >> S;
  
  //処理
  int ans = 0;
  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= K; y++){
      int z = S - (x + y);
      if(0 <= z && z <= K){
        ans++;
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (a <= b) {
		ans += b;
		b--;
	}
	else {
		ans += a;
		a--;
	}
	if (a <= b) {
		ans += b;
		b--;
	}
	else {
		ans += a;
		a--;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

struct Sect
{
	int L, R;
	int x, len;
	int size;
};
Sect sects[100010];
int n;

bool compare(const Sect &a, const Sect &b)
{
	if (a.R == b.R)
		return a.L < b.L;
	else
		return a.R < b.R;
}

int calcStart(int startP) {
	int count = 1;
	int nextR = sects[startP].R;
	for (int i = startP + 1 ; i < n ; i++) {
		if (nextR <= sects[i].L) {
			count++;
			nextR = sects[i].R;
		}
	}
	
	return count;
}


int main()
{
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++) {
		scanf("%d%d", &(sects[i].x), &(sects[i].len));
		sects[i].L = sects[i].x - sects[i].len;
		sects[i].R = sects[i].x + sects[i].len;		
		sects[i].size = sects[i].R - sects[i].L + 1;
	}
	
	sort(sects, sects + n, compare);
	
	int maxNum = 0;
//	for (int i = 0 ; i < n ; i++) {
		int curNum = calcStart(0);
		if (curNum > maxNum)
			maxNum = curNum;
//	}
	
	
	printf("%d\n", maxNum);
	
	return 0;
}



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

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

    int ans[4];

    rep(i,4)ans[i]=0;
    rep(i,n){
        string s;
        cin>>s;
        if(s == "AC"){
            ans[0]++;
        }else if(s == "WA"){
            ans[1]++;
        }else if(s == "TLE"){
            ans[2]++;
        }else if(s== "RE"){
            ans[3]++;
        }
        
    }

    cout<<"AC x "<<ans[0]<<endl;
    cout<<"WA x "<<ans[1]<<endl;
    cout<<"TLE x "<<ans[2]<<endl;
    cout<<"RE x "<<ans[3]<<endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    REP(i, n)   cin >> a[i];
    ll sum=0, num=0;
    sort(ALL(a));
    bool flag=false;
    while(!flag){
        flag=true;
        FOR(i, num, n-1){
            sum += a[i];
            if(a[i+1]>2*sum){
                flag = false;
                num = i+1;
                break;
            }
        }
    }
    cout << n-num << endl;
}


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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const lli MOD = 1000000007ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;

using namespace std;

lli bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
lli bit(lli _mask,lli _i){return (_mask&(1<<_i))==0?0:1;}
lli powermod(lli _a,lli _b,lli _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli add(lli a,lli b,lli m=MOD){lli x=a+b;while(x>=m)x-=m;return x;}
lli sub(lli a,lli b,lli m=MOD){lli x=a-b;while(x<0)x+=m;return x;}
lli mul(lli a,lli b,lli m=MOD){lli x=a*1ll*b;x%=m;if(x<0)x+=m;return x;}



int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    int N;
    string s,t;
    cin>>N>>s>>t;
    s = ' ' + s;
    t = ' ' + t;
    int ans = N+N;

    for(int i=N,j=1;i>=1;i--,j++){
        //cout<<s.substr(N-i+1,i)<<" "<<t.substr(1,i)<<"\n";
        if(s.substr(N-i+1,i) == t.substr(1,i)){
            ans -= i;
            break;
        }
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 384
N=int(input())
L=list(map(int,input().split()))


L.sort()

M=0
for i in range(len(L)):
    for j in range(i+1,len(L)):
        for k in range(j+1,len(L)):
            if L[i]!=L[j] and L[j]!=L[k]:
                if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
                    M+=1
print(M)

Measured memory_bytes: 9068
#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;
const long long INF = 1LL << 60;
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; }
vector<int> vec(100001,0);
int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> A(N);
  ll sum = 0;
  rep(i,N) 
  {
    cin >> A[i];
    sum += A[i];
    vec[A[i]] ++;
  }
  int Q;
  cin >> Q;
  vector<int> B(Q),C(Q);
  rep(i,Q) cin >> B[i] >> C[i];
  rep(i,Q)
  {
    if(C[i]>=B[i])
    {
      sum += vec[B[i]] *(C[i]-B[i]);
    }
    else
    {
      sum -= vec[B[i]] *(B[i]-C[i]);
    }
    if(B[i]!=C[i])
    {
      vec[C[i]] += vec[B[i]];
      vec[B[i]] = 0;
    }
    cout << sum << endl;
  }
  return 0;
}


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

using namespace std;

long long n, a, b;

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

	cin >> n >> a >> b;

	if (a == 0)
    {
        cout << 0;
        return 0;
    }
    if (b == 0)
    {
        cout << n;
        return 0;
    }

	long long n1 = n / (a + b);

	long long ans = n1 * a;
	ans += min(n - (a + b) * n1, a);

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
/*Q-4---ATCODER-BEGINNER-#ROUND_177
*/

#include <bits/stdc++.h>
#define M 1000000007
#define endl '\n'
#define ll long long
using namespace std;

ll find(vector<ll> adj_list[],ll nodes){
	bool visited[nodes+1];
	for(ll i=1;i<=nodes;i++)
		visited[i]=false;

	ll maxi=INT_MIN;
	for(ll i=1;i<=nodes;i++){
		if(visited[i]==false){
			ll cnt{0};

			stack<ll> q;
			q.push(i);
			visited[i]=true;

			while(!q.empty()){
				ll temp=q.top();
				cnt++;
				q.pop();

				ll siz=adj_list[temp].size();
				for(ll j=0;j<siz;j++){
					if(visited[adj_list[temp][j]]==false){
						q.push(adj_list[temp][j]);
						visited[adj_list[temp][j]]=true;
					}
				}

			}

			if(cnt>maxi)
				maxi=cnt;	
		}
	}

	return maxi;

}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll nodes{0};
	ll edges{0};
	cin>>nodes>>edges;

	vector<ll> adj_list[nodes+1];

	while(edges--){
		ll u{0};
		ll v{0};
		cin>>u>>v;
		adj_list[u].push_back(v);
		adj_list[v].push_back(u);
	}

	cout<<find(adj_list,nodes)<<endl;

	return 0;
}


Measured memory_bytes: 17004
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
double PI=3.1415926535897932384626;
int main()
{
	long double a,b,x;
	cin>>a>>b>>x;
	if(x>a*a*b/2){
		//cout<<atan2((b-x/a/a)*2,a)/PI*180<<endl;
		double out=atan2((b-x/a/a)*2,a)/PI*180;
		//cout<<out<<endl;
		printf("%.12f\n",out);
	}
	else{
		//cout<<atan2(b,x/b*2/a)/PI*180<<endl;
		double out=atan2(b,x/b*2/a)/PI*180;
		printf("%.12f\n",out);
	}
}


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

int main() {
  long long N, M;  //塔　道
  cin >> N >> M;
  vector<long long> hi(N);
  vector<pair<long long, long long>> miti(M);

  for (int i = 0; i < N; i++) {
    cin >> hi[i];
  }
  vector<vector<long long>> aite(N);
  for (int i = 0; i < M; i++) {
    cin >> miti[i].first >> miti[i].second;
    aite[miti[i].first - 1].push_back(miti[i].second - 1);
    aite[miti[i].second - 1].push_back(miti[i].first - 1);
  }

  long long yoi = 0;
  for (int i = 0; i < N; i++) {
    bool takai = true;
    if (aite[i].size() == 0) {
      yoi++;
      continue;
    }
    for (int j = 0; j < aite[i].size(); j++) {
      if (hi[i] <= hi[aite[i][j]]) {
        takai = false;
      }
    }
    if (takai) {
      yoi++;
    }
  }
  cout << yoi << endl;
}


Measured memory_bytes: 11436
n=int(input())
for i in range(1,n+1):
    x,y,z=map(int,input().split())
    if x**2+y**2==z**2 or y**2+z**2==x**2 or z**2+x**2==y**2:
        print('YES')
    else:
        print('NO')



Measured memory_bytes: 5592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

vector<vector<int> >vec;
void dfs(vector<int>tmp){
    if(tmp.size() == 6){
        vec.push_back(tmp);
        return;
    }
    for(int i = 0; i < 6; i++){
        int check = 0;
        for(int j = 0; j < tmp.size(); j++)if(tmp[j] == i)check = 1;
        if(check)continue;
        vector<int>cp = tmp;
        cp.push_back(i);
        dfs(cp);
        if(tmp.size() % 2 == 0)break;
    }
}


int main(){
    dfs(vector<int>(0));
    for(int n; cin >> n, n; ){
        vector<int>X(n), Y(n), R(n), C(n);
        vector<int>en[4];
        // ue[a][b]//aの上にbがある
        int ue[32][32] = {};
        for(int i = 0; i < n; i++){
            cin >> X[i] >> Y[i] >> R[i] >> C[i];
            en[C[i] - 1].push_back(i);
        }
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                int RR = (R[i] + R[j]) * (R[i] + R[j]);
                int rr = (X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]);
                if(rr < RR)ue[j][i] = 1;
            }
        }
        int ans = 0;
        for(int i = 0; i < 4; i++){
            while(en[i].size() < 6)en[i].push_back(-1);
        }
        for(int a = 0; a < 15; a++){
            for(int b = 0; b < 15; b++){
                for(int c = 0; c < 15; c++){
                    for(int d = 0; d < 15; d++){
                        int tmp = 0;
                        int are[4] = {a, b, c, d};
                        int rm[32] = {};
                        for(int flg = 1; flg;){
                            flg = 0;
                            for(int i = 0; i < 4; i++){
                                for(int j = 0; j < 6; j+=2){
                                    int A = en[i][vec[are[i]][j]];
                                    int B = en[i][vec[are[i]][j + 1]];
                                    if(A == -1)continue;
                                    if(B == -1)continue;
                                    if(rm[A])continue;
                                    if(rm[B])continue;
                                    int aok = 1, bok = 1;
                                    for(int k = 0; k < n; k++){
                                        if(ue[A][k] && rm[k] == 0)aok = 0;
                                        if(ue[B][k] && rm[k] == 0)bok = 0;
                                    }
                                    if(aok && bok){
                                        rm[A] = 1;
                                        rm[B] = 1;
                                        tmp += 2;
                                        flg = 1;
                                    }
                                }
                            }
                        }
                        ans = max(ans, tmp);
                    }
                }
            }
        }
        

        cout << ans << endl;
    }
    
    return 0;    
}


Measured memory_bytes: 3148
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 262144
#define P ((int)1e9+7)

int ap[N], an[N];

int main()
{
    int n, m, np=0, nn=0;
    scanf("%d%d", &n, &m);
    for(int i=0;i<n;++i)
    {
        int a;
        scanf("%d",&a);
        (a<0 ? an[nn++] : ap[np++]) = a;
    }
    std::sort(ap,ap+np);
    std::sort(an,an+nn,std::greater<int>());
    int ans = 1;
    if(m&1)
    {
        if(!np)
        {
            for(int i=0;i<m;++i) ans = (lli) ans * an[i] % P;
            return printf("%d\n", ans<0 ? ans+P : ans), 0;
        }
        ans = (lli) ans * ap[--np] % P, --m;
    }
    while(m && np>=2 && nn>=2)
    {
        lli vp = (lli)ap[np-2]*ap[np-1];
        lli vn = (lli)an[nn-2]*an[nn-1];
        if(vp>vn)
            ans = ans * (vp%P) %P, np-=2;
        else
            ans = ans * (vn%P) %P, nn-=2;
        m -= 2;
    }
    while(m && np>=2)
    {
        ans = (lli)ans * ap[--np] % P, --m;
        ans = (lli)ans * ap[--np] % P, --m;
    }
    while(m && nn>=2)
    {
        ans = (lli)ans * an[--nn] % P, --m;
        ans = (lli)ans * an[--nn] % P, --m;
    }
    if(m)
    {
        assert(m==2 && np==1 && nn==1);
        ans = (lli)ans * ap[--np] % P, --m;
        ans = (lli)ans * an[--nn] % P, --m;
    }
    printf("%d\n", ans<0 ? ans+P : ans);
    return 0;
}


Measured memory_bytes: 2516
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= D; j += A[i]) {
            X++;
        }
    }
    cout << X << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a[]=new int[3];
    int total=0;
    for (int i=0;i<3;i++) {
      a[i]=sc.nextInt();
      total+=a[i];
    }
    if (total>21) {
      System.out.println("bust");
    }else{
      System.out.println("win");
    }
  }
}


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

int main(){
    int n;
    cin >> n;
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++){
        int k;
        cin >> k;
        int64_t d = 0, m = 0, dm = 0;
        int64_t ans = 0;
        for (int i = 0; i < n; i++){
            if (i - k >= 0){
                if (S[i - k] == 'D'){
                    d--;
                    dm -= m;
                }
                if (S[i - k] == 'M')
                    m--;
            }

            if (S[i] == 'D'){
                d++;
            }
            if (S[i] == 'M'){
                dm += d;
                m++;
            }
            if (S[i] == 'C'){
                ans += dm;
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const int MAX_N=100;
int N,A,B;
int a,b,c;	
int main(){
	cin>>N>>A>>B;
	REP(i,N){
		int p;
		cin>>p;
		if (p<=A){
			a++;
		}else if (p<=B){
			b++;
		}else{
			c++;
		}
	}
	cout<<min({a,b,c})<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val num = readLine()!!.trim().split(' ').map(String::toInt)
    println((1 until n).mapNotNull{i -> (0 until i).mapNotNull{j -> (num[i] * num[j]).takeIf { it.isIncrease() }}.max()}.max() ?: -1)
}
fun Int.isIncrease(): Boolean {
    var last = this % 10
    var current = this / 10
    while(current != 0 && current % 10 + 1 == last){
        last = current % 10
        current /= 10
    }
    return current == 0
}


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

using namespace std;
#define INF 1000000001

/* --- 陽に順番祖指定しなくてもよいようにメモ化再帰を用いることにする --- */
/* --- start_nodeからの最長経路を表す --- */
int solve(const int start_node,const vector<vector<int> > &adj_list,vector<int> &dp){
    
    if(dp[start_node] != -1) return dp[start_node]; // 更新されていたらそのまま返す。

    //　更新されていなければ、深さ優先探索にて最長経路を求める
    int res = 0;
    for(int i = 0;i < adj_list[start_node].size();i++){
        int next_node = adj_list[start_node][i];
        res = max(res,solve(next_node,adj_list,dp)+1);
    }
    return dp[start_node] = res;
}



int main()
{   
    int N,M;
    cin >> N >> M;
    int xi,yi;
    vector<vector<int> > adj_list(N);
    vector<int> dp(N,-1);
    for(int i = 0;i < M;i++){
        cin >> xi >> yi;
        xi--;yi--;
        adj_list[xi].push_back(yi);
    }

    int res = 0;
    for(int i = 0; i < N; i ++){
        res = max(res,solve(i,adj_list,dp));
    }
    
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll H, W;
    cin >> H >> W;
    //すべての下からhについて全探索する
    ll ans = H * W;
    ll s[3];
    for(int i = 0; i < 2; i++) {
        //縦と横
        for(ll h = 1; h < H; h++) {
            s[0] = h * W;
            s[1] = (H - h) * (W / 2);
            s[2] = H * W - s[0] - s[1];
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);
            //縦
            s[0] = h * W;
            s[1] = ((H - h) / 2) * W;
            s[2] = H * W - s[0] - s[1];
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);
        }
        swap(H, W);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100]={0},cou=0,flag=0;
ll k,ans;
set<ll>se;
queue<ll>que;
void bfs(ll step){
    que.push(step);
    ll m;
    while(!que.empty()){
        m=que.front();que.pop();
        //cout<<m<<"\n";
        for(int i=0;i<=9;i++){
            if(abs(i-m%10)<=1||m==0){
                if(m*10+i!=0){
                que.push(m*10+i);
                cou++;
                }
            }
            if(cou==k){
                ans=m*10+i;
                return;
            }
        }
    }
}
int main(){
    cin>>k;
    cou=0;
    bfs(0);
    cout<<ans;
    return 0;
}


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

int main()
{
      int n;cin>>n;
  vector<pair<int,int>> a(n);
  int x; int l;
  for (int i=0; i<n; i++){cin>>x; cin>>l; a[i]=make_pair(x+l,x-l);}
  sort(a.begin(),a.end());
  int tend=a[0].first;
  int ans=1;
  for(int i=1;i<n;i++){
if(a[i].second>=tend){tend=a[i].first; ans++;}    
  }
  cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 1272