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

int how_many_divs(int n)
{
  int cnt=0;
  for (int i = 1; i <= n; ++i)
  {
    if(n%i==0) cnt++;
  }
  return cnt;
}

int main()
{
  int n;
  cin>>n;
  int cnt=0;
  for (int i = 1; i <= n; i+=2)
  {
    if(8==how_many_divs(i)) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

int H,N;
int A[1514],B[1514];
int memo[20000];

int HP(int K){
    if(K<=0)return 0;
    if(memo[K]!=INF)return memo[K];
    int R=INF;
    REP(i,N){
        int r = B[i]+HP(K-A[i]);
        R=min(R,r);
    }
    memo[K]=R;
    return R;
}

signed main(void){
    cin >> H >> N;
    REP(i,N){
        cin >> A[i] >> B[i];
    }
    REP(i,20000){
        memo[i]=INF;
    }
    cout << HP(H) << endl;
    return 0;
}



Measured memory_bytes: 896
//???????????????????????????, ?????????????????????????????°????????????????????????????????????????????????2???????????¨???????????£?????\????????¨?????§????????????
//?????£???, 2??????????????????1?????????????????????????????????????????°??????????????????????£????, O(N^2)????????????????????????, ??¨?????§O(N^3)????????§?§£?????????
#include <iostream>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> Point;

int n;
double x[300], y[300];
vector<Point> points;	//????£???????

int main() {
	while (cin >> n) {
		if (n == 0) break;
		for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
		
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				Point p1 = Point(x[i], y[i]);
				Point p2 = Point(x[j], y[j]);
				if (norm(p1 - p2) < 4) {
					double h = sqrt(1.0 - norm(p1 - p2) / 4.0);
					Point t = p2 - p1; t /= abs(t);
					Point u = t * Point(0, 1);
					points.push_back(p1 + t * abs(p1 - p2) / 2.0 + u * h);
					points.push_back(p1 + t * abs(p1 - p2) / 2.0 - u * h);
				}
			}
		}
		
		double eps = 1e-10;
		int ans = 1;
		for (int i = 0; i < points.size(); i++) {
			double px = points[i].real();
			double py = points[i].imag();
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				if ((x[j] - px) * (x[j] - px) + (y[j] - py) * (y[j] - py) < 1 + eps) {
					cnt++;
				}
			}
			if (ans < cnt) ans = cnt;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 11308
def saiki(N,M):
  #print(N,M)
  if N == 1:
    return [[i]for i in range(1,M+1)]
  else:
    buf = saiki(N-1, M)
    res = []
    for val in buf:
      res += [val + [i] for i in range(val[-1],M+1)]
    return res
      

N, M, Q = map(int, input().split())
cases = saiki(N,M)
highest = 0
a = [0 for i in range(Q)]
b = list(a)
c = list(a)
d = list(a)

for i in range(Q):
  a[i], b[i], c[i], d[i] = map(int, input().split())
highest = 0

#print(a,b,c,d)
for case in cases:
  summ = 0
  for i in range(Q):
    if case[b[i]-1]-case[a[i]-1]==c[i]:
      summ += d[i]
  highest = max(highest, summ)
print(highest)

Measured memory_bytes: 30252
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

const int L = 1e9;

int main() {
    int H, N;
    cin >> H >> N;
    vi A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    const int I = * max_element(A.begin(), A.end()) + H;
    vvi DP(N+1, vi(I, 0));
    for (int i = 0; i < I; i++) {
        DP[0][i] = L;
    }
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < I; j++) {
            if (A[i] <= j) {
                DP[i+1][j] = min(DP[i+1][j-A[i]]+B[i], DP[i][j]);
            } else {
                DP[i+1][j] = DP[i][j];
            }
        }
    }
    int ans = L;
    for (int i = H; i < I; i++) {
        ans = min(DP[N][i], ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 44160
#include <iostream>
using namespace std;
int main(void){
    string str;
    int sum;
    while(cin >> str && str != "0"){
        sum = 0;
        for(int i=0; i<str.size(); i++){
            sum += str[i] - '0';
        }
        cout << sum << endl;
    }
}



Measured memory_bytes: 3228
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    X = int(input())

    ans = 0
    v = 100
    while True:
        ans += 1
        v = int(v * 1.01)
        if v >= X:
            print(ans)
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

map<int,int> mp;

void add(int n){
	++mp[n];
}

void del(int n){
	--mp[n];
	if(!mp[n]){
		mp.erase(n);
	}
}

int32_t main(){
	int n,m,t;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>t;
		++mp[t];
	}
	while(m){
		auto it = mp.end();
		--it;
		int x = it->first;
		del(it->first);
		add(x/2);
		--m;
	}
	int ans = 0;
	for(auto x:mp){
		ans += x.first*x.second;
	}
	cout<<ans;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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



bool ans;
int n;
bool vis[8][8];
int in[8][8];

void dfs(int rest,int x,int y,int visnum){
  if(ans)return;
  
  if(visnum==0 && rest==0){
    ans=true;
    return;
  }
  
  if(rest==0){
    rep(i,n)rep(j,n){
      if(vis[i][j])continue;
      if(in[i][j]<0){
	vis[i][j]=true;
	dfs(-in[i][j],i,j,visnum-1);
	vis[i][j]=false;
	return;
      }
    }
  }else{
    rep(i,4){
      int nx=x+dx[i],ny=y+dy[i];
      if(nx<0 || n<=nx || ny<0 || n<=ny ||
	 vis[nx][ny] || in[nx][ny]<0 || in[nx][ny]>rest)continue;
      vis[nx][ny]=true;
      dfs(rest-in[nx][ny],nx,ny,visnum-1);
      vis[nx][ny]=false;
    }
  }
}

main(){
  while(cin>>n,n){
    ans=false;
    memset(vis,0,sizeof(vis));
    rep(i,n)rep(j,n)cin>>in[i][j];

    dfs(0,0,0,n*n);
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 868
N, Q = map(int,input().split())
S = input()
LRlist = []
for i in range(Q):
    LRlist.append(list(map(int,input().split())))
t = [0] * (N + 1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0) #t[i]=i文字目までのACのAの数：累積和
for LR in LRlist:
     L = LR[0]
     R = LR[1]
     print(t[R-1] - t[L-1])

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

int main() {
    int n;
    cin>>n;
    int one=0,two=0,three=0;
    for(int i=0 ; i<n ; i++){
        int x;
        cin>>x;
        if(x==1)
        one++;
        else if(x==2)
        two++;
        else
        three++;
    }
    double dp[n+1][n+1][n+1];
    memset(dp,0,sizeof(dp));
    
    // dp[0][0][0]=1;
    for(int i=0 ; i<=n ; i++){
        for(int j=0 ; j<=n ; j++){
            for(int k=0 ; k<=n ; k++){
                if(i+j+k<=n && (i!=0 || j!=0 || k!=0)){
                    double p1=k/(double)n;
                    double p2=j/(double)n;
                    double p3=i/(double)n;
                    double p0=1-p1-p2-p3;
                    // cout<<k<<" "<<j<<" "<<i<<" "<<p1<<" "<<p2<<" "<<p3<<endl;
                    dp[k][j][i]+=(k-1>=0?n+k*dp[k-1][j][i]:n);
                    dp[k][j][i]+=(j-1>=0?j*dp[k+1][j-1][i]:0);
                    dp[k][j][i]+=(i-1>=0?i*dp[k][j+1][i-1]:0);
                    dp[k][j][i]/=(i+j+k);
                    // dp[k][j][i]=(1+p1*dp[k+1][j][i] + p2*dp[k-1][j+1][i] + p3*dp[k][j-1][i+1])/(1-p0);
                }
            }
        }
    }
    // cout<<dp[one][two][three]<<" "<<dp[one][two+1][three-1]<<" "<<dp[one+1][two][three-1];//<<" "<<dp[one-3][two][three]<<endl;
    printf("%.10lf",dp[one][two][three]);
    return 0;
}


Measured memory_bytes: 213248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vpll = vector<pll>;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for(ll i = n-1; i >= 0; i--)
#define FOR(i, a, b) for(ll i = a; i <= (ll)(b); i++)
#define RFOR(i, a, b) for(ll i = a; i >= (ll)(b); i--)

#define SIZE(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));

#define PB push_back
#define MP make_pair
#define F first
#define S second

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const string YES = "Yes";
const string NO = "No";

void func(std::string S, std::string T){
    bool flag = true;
    REP(i, S.length()) if (S[i] != T[i]) flag = false;
    if(flag) cout << YES << endl;
    else cout << NO << endl;
}

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

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    func(S, T);
    return 0;
}


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

import heapq as hp
from collections import Counter


def main():

    N = int(input())
    A = list(map(int, input().split()))
    graph = [[] for _ in range(1<<N)]

    for l in range(N):
        for n in range(1<<l):
            graph[n].append(n+(1<<l))

    C = Counter(A)
    Keys = sorted(C.keys(), reverse=True)
    
    q = [(-len(graph[0]), 0)]
    for key in Keys:
        num = C[key]
        if num > len(q):
            return False
        use = []
        for _ in range(num):
            _, p = hp.heappop(q)
            use.append(p)
        for p in use:
            for np in graph[p]:
                hp.heappush(q, (-len(graph[np]), np))

    return True

if __name__ == "__main__":
    print("Yes" if main() else "No")

Measured memory_bytes: 71064
// 2020-08-22 21:00:00
#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; }

void answer() {
  int n, x, t;
  cin >> n >> x >> t;
  int ans = 0;
  if(n%x==0) ans = t * (n / x);
  else ans = t * ((n / x) + 1);
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const ll inf=1e9;
const int MAX = 510000;
const ll MOD = 998244353;

inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

int main(){
  ll h,w;cin>>h>>w;
  vector<string> g(h);
  vll m(26,0);
  rep(i,0,h){
    cin>>g[i];
    rep(j,0,w){
      m[g[i][j]-'a']++;
    }
  }
  rep(i,0,26){
    m[i]%=4;
  }
  if(h%2==0&&w%2==0){
    rep(i,0,26){
      if(m[i]!=0){
        cout<<"No"<<endl;return 0;
      }
    }
  }
  else if(h%2&&w%2){
    ll cnt=0,c=0;
    rep(i,0,26){
      if(m[i]%2)cnt++;
      else if(m[i]!=0)c++;
    }
    if(c>(h+w-2)/2||cnt!=1){
      cout<<"No"<<endl;return 0;
    }
  }
  else{
    ll cnt=0;
    rep(i,0,26){
      if(m[i]%2){
        cout<<"No"<<endl;return 0;
      }
      else if(m[i]!=0){
        cnt++;
      }
    }
    ll t=(h%2==0?h/2:w/2);
    if(cnt>t){
      cout<<"No"<<endl;return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main(){
	int n, k;
	cin >> n >> k;
	map <int, int> mp;
	rep(i, n){
		int a;
		cin >> a;
		mp[a]++;
	}

	vi va;
	for(auto itr = mp.begin(); itr != mp.end(); itr++)
		if(itr->second != 0)va.push_back(itr->second);

	sort(all(va));
	if(va.size() <= k)
		cout << 0 << endl;
	else{
		int ans = 0;
		for(int i = 0; va.size() - i > k; i++)
			ans += va[i];
		cout << ans << endl;
	}
}


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

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

    ll a,b,n;
    cin >> a >> b>> n;
    cout << min(b-1,n)*a/b << endl;

    return 0;
}


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

int gcd(int x, int y) {
  int r;
  if(x < y) swap(x, y);
  
  while(y > 0) {
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  int K;
  cin >> K;
  
  int sum = 0;
  
  for(int a = 1; a <= K; a++) {
    for(int b = 1; b <= K; b++) {
      for(int c = 1; c <= K; c++) {
        sum += gcd(gcd(a, b), c);
      }
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)


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

  ll max=1;
  for(ll i=1;i*i<=n;i++)
  {
    if(n%i==0) max=i;
  }

  cout<<(int)(log10(n/max)+1)<<endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main()
{
  int x_1, y_1, x_2, y_2;
  cin >> x_1 >> y_1 >> x_2 >> y_2;
  int x_3, y_3, x_4, y_4;
  x_3 = x_2 + (y_1 - y_2);
  y_3 = y_2 + (x_2 - x_1);
  x_4 = x_1 + (y_1 - y_2);
  y_4 = y_1 + (x_2 - x_1);
  cout << x_3 << " " << y_3 << " " << x_4 << " " << y_4 <<endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/03  Problem: ABC 048 C / Link: http://abc048.contest.atcoder.jp/tasks/abc048_c  ----- */


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

	LL N, x; cin >> N >> x;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	LL ans = 0LL; {

	}
	FOR(i, 0, N - 1) {
		LL b = max(0LL, a[i] + a[i + 1] - x);
		LL c = min(a[i + 1], b);
		ans += c;
		a[i + 1] -= c;
		b -= c;
		if (b) {
			a[i] -= b;
			ans += b;
		}
	}


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    for(int i = 0; i < n; i++){
      x[i] = sc.nextInt();
    }
    int[] a = Arrays.copyOf(x, x.length);
    Arrays.sort(x);
    int mid1 = x[n/2 - 1];
    int mid2 = x[n/2];
    for(int i = 0; i < n; i++){
      System.out.println(a[i] <= mid1 ? mid2 :mid1);
    }
  }
}

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

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

  // 一番西の人をリーダーにした時の手数
  int cost = 0;
  for (int i = 1; i < n; i++)
    if (s[i] == 'E') cost++;

  // 左から一つづつリーダーをずらしていって、小さい方を採用する
  int ans = cost;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'W') cost++;
    if (s[i + 1] == 'E') cost--;
    ans = min(ans, cost);
  }

  cout << ans << endl;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
#define maxn 210
#define maxm 10000010
const int lim=1e7;
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
struct Edge
{
	int v;
	Edge *next;
	Edge(int a=0,Edge *b=NULL)
	{
		v=a;
		next=b;
	}
}*head[maxn];
int n,mx,tim,cnt,cnt1,cnt2,ans,maxflow,a[maxm];
int L[maxn],R[maxn],p[maxm],vis[maxn],flg[maxm],match[maxn];
bool Match(int k)
{
	for(Edge *i=head[k];i!=NULL;i=i->next)
	{
		if(vis[i->v]==tim)
			continue;
		vis[i->v]=tim;
		if(!match[i->v]||Match(match[i->v]))
		{
			match[i->v]=k;
			return true;
		}
	}
	return false;
}
void init()
{
	flg[0]=flg[1]=true;
	for(int i=2;i<=lim;i++)
	{
		if(!flg[i])
			p[++cnt]=i;
		for(int j=1;j<=cnt&&p[j]*i<=lim;j++)
		{
			flg[i*p[j]]=true;
			if(i%p[j]==0)
				break;
		}
	}
}
int main()
{
	init();
	read(n);
	for(int i=1;i<=n;i++)
	{
		int x;
		read(x);
		a[x]+=1;
		mx=max(mx,x);
	}
	for(int i=1;i<=mx+1;i++)
	{
		if(a[i]!=a[i-1])
		{
			if(i&1)
				L[++cnt1]=i;
			else
				R[++cnt2]=i;
		}
	}
	for(int i=1;i<=cnt1;i++)
		for(int j=1;j<=cnt2;j++)
			if(!flg[abs(L[i]-R[j])])
				head[i]=new Edge(j,head[i]);
	for(int i=1;i<=cnt1;i++)
	{
		tim+=1;
		maxflow+=Match(i);
	}
	ans=maxflow;
	ans+=(cnt1-maxflow)/2*2+(cnt2-maxflow)/2*2;
	ans+=((cnt1-maxflow)&1)*3;
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 82176
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int A, B, Q;
ll s[100000], t[100000], x;

int main() {
	cin >> A >> B >> Q;
	for (int i = 0; i != A; ++i)
		cin >> s[i];
	for (int i = 0; i != B; ++i)
		cin >> t[i];
	for (int i = 0; i != Q; ++i) {
		cin >> x;
		auto its = lower_bound(s, s + A, x);
		auto itt = lower_bound(t, t + B, x);
		auto itss = its;
		auto ittt = itt;
		--itss;
		--ittt;
		ll res = llmax;
		if (its != s + A&&itt != t + B)
			res = min(res, max(*its, *itt) - x);
		if (its != s + A&&ittt != t - 1)
			res = min(res, (*its - *ittt) + min(*its - x, x - *ittt));
		if (itss != s - 1 && itt != t + B)
			res = min(res, (*itt - *itss) + min(*itt - x, x - *itss));
		if (itss != s - 1 && ittt != t - 1)
			res = min(res, x - min(*itss, *ittt));
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2816
import java.util.Scanner;
public class Main {
  public static void main (String[]args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int counter = 0;
    for(int i = 0; i<a+1; i++) {
      for(int j = 0; j<b+1; j++) {
        for(int k =0; k<c+1; k++) {
          int total = 50*k+100*j+500*i;
          if(total == x){
            ++counter;
          }
        }
      }
    }
    System.out.println(counter);
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long
int main()
{
    ll t,n,i,j,k,l,m,f,a,b,c,d;
    cin>>n>>t;
    f=-1;
    d=INT_MAX;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        if(b<=t)
        {
            f=1;
            if(a<d){d=a;}
        }

    }
    if(f==1)
    {
    cout<<d<<endl;
    }
    else
    {
        cout<<"TLE"<<endl;
    }

    return 0;
}


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

public class Main{

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		String in = sc.nextLine();
		if(in.equals("ABC")) pw.println("ARC");
		else pw.println("ABC");

		pw.close();
	}	

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public boolean ready() throws IOException {return br.ready();}

		public double nextDouble(String x) 
		{

			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}


	}
}

Measured memory_bytes: 32464
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner();
        int n=scanner.nextInt();
        int i=scanner.nextInt();
        put(n-i+1);



    }

    public static void put(Object object) {
        System.out.println(object);
    }

    public static String format(String string, Object... args) {
        return String.format(string, args);
    }
}

final class Scanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


class Pair {
    final public int x, y;

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    Pair(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public String toString() {
        return String.format("(%d,%d)", x, y);
    }
}

Measured memory_bytes: 21460
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastScanner in = new FastScanner(System.in);
		int x = in.nextInt();
		int n = in.nextInt();
		int min = Integer.MAX_VALUE;
		int num = 0;
		boolean[] mark = new boolean[102];
		
		for(int i = 0; i < n; i++)
		{
			int pos = in.nextInt();
			mark[pos] = true;
		}
		
		for(int i = 0; i < mark.length; i++)
			if(!mark[i])
			{
				if(Math.abs(x - i) < min) {
					min = Math.abs(x - i);
					num = i;
				}
			}
		
		System.out.println(num);
	}

}
///////////////////////////////////TEMPLATE///////////////////////////////////
class FastScanner {
	BufferedReader br;
	StringTokenizer st;

	FastScanner(InputStream stream) {
		try {
			br = new BufferedReader(new InputStreamReader(stream));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	FastScanner(File input) {
		try {
			br = new BufferedReader(new FileReader(input));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	String nextLine() {
		String s = "";
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return s;
	}

	String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main (){
    string S, T, U;
    cin>>S>>T>>U;
    if(S.at(S.size()-1)==T.at(0)){
        if(T.at(T.size()-1)==U.at(0)){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    else{
        cout<<"NO"<<endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
//ll mod = 1000000007;
//ll mod = 998244353;

int main() {
	int n, m;
	cin >> n >> m;
	cout << n * m << endl;
}


Measured memory_bytes: 3096
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

import java.io.BufferedReader;



public class Main{

    public static void main(String[] args) throws IOException {

        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int plus = a+b;
        int minus = a-b;
        int prod = a*b;
        
        out.print(Math.max(prod,Math.max(plus,minus)));

        out.flush();

    }

}



class Scanner {
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream system) {
        br = new BufferedReader(new InputStreamReader(system));
    }

    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public char nextChar() throws IOException {
        return next().charAt(0);
    }

    public Long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public boolean ready() throws IOException {
        return br.ready();
    }

    public void waitForInput() throws InterruptedException {
        Thread.sleep(3000);
    }


}



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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    string N = '0' + input<string>();
    
    auto dp = make_vector(N.size(), 2, 0);
    dp[0][1] = 1;
    range(i, 1, N.size()) {
        int r = N[i] - '0';
        int d = 9 - r + (i + 1 == N.size());

        dp[i][0] = min(dp[i - 1][0] + r, dp[i - 1][1] + 9 - r + 1);
        dp[i][1] = min(dp[i - 1][1] + 9 - r, dp[i - 1][0] + r + 1);
    }

    cout << dp.back()[0] << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 55964
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> vec(N, 0);
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    vec[x-1]+= 1;
    vec[y-1]+=1;
  }
  for(int i=0;i<N;i++){
    cout << vec[i] <<endl;
  }
}

Measured memory_bytes: 256
# (o) recursionはダメ
# (o) 素因数はO(sqrt(N))で求められる
# (x) 具体的な計算

"""
Memo:
- A=[a1,...,an]の最大公約数をDとする
- sum(A)=MもDで割り切れる，よってDはMの約数 (Mも割れる)

2条件
- DがMの約数であって，M >= N * Dであるとき
    - a1=...=an-1=D, an = M - (N - 1) * D は全てDで割り切れる (最大公約数)
- Mの約数かつM // N以下の整数で最大
"""

N, M = map(int, input().split())


# 約数を求める
factors = []
i = 1
while i * i <= M + 1:
    if M % i == 0:
        factors.append(i)
        if M // i != i:
            factors.append(M // i)
    i += 1

factors.sort(reverse=True)
# Mの約数でM // N以下の最大
for f in factors:
    if M // f >= N:
        print(f)
        exit()

# ans = 1
# for factor in factors:
#     if factor <= M // N:
#         ans = factor
# print(ans)

Measured memory_bytes: 38768
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    Map<Integer, Integer> occurs = new HashMap<>();
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      occurs.put(a, occurs.getOrDefault(a, 0) + 1);
    }

    int numOfEvens = 0;
    for (int key : occurs.keySet()) {
      if (occurs.get(key) % 2 == 0) numOfEvens++;
    }
    int ans = occurs.size() - (numOfEvens % 2);
    os.println(ans);
  }

  private static class Scanner {

    private final InputStream is;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    Scanner(InputStream is) {
      this.is = is;
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = is.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) {
        return buffer[ptr++];
      } else {
        return -1;
      }
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
        ptr++;
      }
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
        throw new NumberFormatException();
      }
      return (int) nl;
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}


Measured memory_bytes: 30996
import sys
n,u,v=map(int,input().split())
sys.setrecursionlimit(10**9)
tree=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
a=[None]*n
t=[None]*n
t[u-1]=0
a[v-1]=0
def dfsA(x,c):
  for i in tree[x]:
    if a[i]==None:
      a[i]=c
      dfsA(i,c+1)
dfsA(v-1,1)
k=a[u-1]
def dfsT(x,c):
  global k
  for i in tree[x]:
    if t[i]==None and c<a[i]:
      t[i]=c
      if k<a[i]:
        k=a[i]
      dfsT(i,c+1)
dfsT(u-1,1)
print(k-1)

Measured memory_bytes: 98340
#include "bits/stdc++.h"
using namespace std;

#define ASC(a) a.begin(), a.end()		// 昇順ソート 例：sort(ASC(a));
#define DESC(a) a.rbegin(), a.rend()	// 降順ソート 例:sort(DESC(a));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(a) rep(i, n) cin>>a[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;
#define only_unique(vec) vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────

int main() {
	int power[] = { 6000 ,4000,3000,2000 };
	int ans[4];

	rep(i, 4) {
		int t, n; cin >> t >> n;
		ans[i] = power[t - 1] * n;
	}
	rep(i, 4) {
		ANS(ans[i]);
	}
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#define rep(i, j, k) for (long long (i) = (j); (i) < (k); ++(i))
#define repr(i, j, k) for (long long (i) = (j); (i) <= (k); ++(i))

using namespace std;

int solve() {
	long long l, r;
	cin >> l >> r;
	if (r/2019 != l/2019 || l % 2019 == 0) {
		return 0;
	}
	
	long long min_num = 2019;
	repr(i, l, r-1) {
		repr(j, i+1, r) {
			min_num = min(min_num, i*j%2019);
		}
	}
	return min_num;
}

int main()
{
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] hArr = new int[n];
        for (int i = 0; i < n; i++) {
            hArr[i] = sc.nextInt();
        }

        int[] dp = new int[n + 10];
        dp[0] = 0;
        dp[1] = Math.abs(hArr[1] - hArr[0]);
        for (int i = 0; i < n - 2; i++) {
            dp[i + 2] = Math.min(dp[i] + Math.abs(hArr[i] - hArr[i + 2]), dp[i + 1] + Math.abs(hArr[i + 1] - hArr[i + 2]));
        }
        //debug(dp);
        System.out.println(dp[n - 1]);
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 51460
#include<bits/stdc++.h>
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

template<typename T> class mylist
{
 private:
    struct Node{
        T val;
        Node *next,*prev;
    };
    Node *head,*tail;
 public:
    mylist(){
        head=new Node; tail=new Node;       
        head->next=tail; tail->prev=head;
    }
    void insert(int val){
        Node *node=new Node;
        node->val=val;
        node->next=head->next; 
        node->next->prev=node;
        node->prev=head;
        node->prev->next=node;
    }
    void print(){
        bool flag=false;
        for(Node *p=head->next;p!=tail;p=p->next){
            if(!flag) cout<<p->val,flag=true;
            else cout<<' '<<p->val;
        }
        cout<<endl;
    }
    Node* search(int val){
        for(Node* p=head->next;p!=tail;p=p->next){
            if(p->val==val) return p;
        }
        return tail;
    }
    void deletenode(Node* node){
        node->prev->next=node->next;
        node->next->prev=node->prev;
        delete node;
    }
    void delete_by_key(int val){
        Node* node=search(val);
        if(node!=tail) deletenode(node);
    }
    void deleteFirst(){
        if(head->next!=tail) deletenode(head->next);
    }
    void deleteLast(){
        if(tail->prev!=head) deletenode(tail->prev);
    }
};

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

    int Q; cin>>Q;
    mylist<int> list;
    while(Q--){
        string s; cin>>s;
        if(s=="insert"){
            int x; cin>>x;
            list.insert(x);
        }else if(s=="delete"){
            int x; cin>>x;
            list.delete_by_key(x);
        }else if(s=="deleteFirst"){
            list.deleteFirst();
        }else{
            list.deleteLast();
        }
        // list.print();
    }
    list.print();
    return 0;
}


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

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long res = 0;
            //     long[] kn = s2iarray(Console.ReadLine().Split(' '));
            //   long[] an = s2iarray(Console.ReadLine().Split(' '));
            string s = Console.ReadLine();
            if(s.IndexOf("AB") >=0 || s.IndexOf("BA")>=0) 
            RESULT("Yes");
            else RESULT("No");


        }
      
      
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 13280
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
c = Counter(a).most_common()

if len(c) == 3 and c[0][1] == c[1][1] == c[2][1]:
    x = c[0][0]
    y = c[1][0]
    z = c[2][0]
    if x^y == z and y^z == x and z^x == y:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 2 and c[0][1] == 2*c[1][1]:
    x = c[0][0]
    y = c[1][0]
    if x^x == y and x^y == x:
        ans = "Yes"
    else:
        ans = "No"
elif len(c) == 1 and c[0][0] == 0:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Measured memory_bytes: 22244
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int N;

void solve(){
    for(int i = 1; i <= N; ++i){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> N;

    solve();
}


Measured memory_bytes: 3160
from itertools import accumulate, combinations

N, *L = map(int, open(0).read().split())

A = [0] * (2 * 10 ** 3 + 7)
for l in L:
    A[l] += 1

S = list(accumulate(A))

ans = 0
for b, c in combinations(L, 2):
    l, r = abs(b - c), b + c
    ans += S[r - 1] - S[l] - (l < b < r) - (l < c < r)

print(ans // 3)


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

int main()
{
  	int w,a,b;
  	cin>>w>>a>>b;
  	if(a>b)
  	swap(a,b);
  	int w_a=a+w;
  	int w_b=b+w;
	int ans=min(w_b-a,b-(a+w));
  	cout<<(ans<0?0:ans)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include<unordered_map>
#include<unordered_set>

using namespace std;
#define IO                 \
	ios::sync_with_stdio(0); \
cin.tie(0);              \
cout.tie(0);
#define forn(i, n) for (int i = 0; i < n; i++)
#define forse(i, s, e) for (int i = s; i < e; i++)
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mp make_pair
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define getcurrtime() \
	cerr << "Time = " << ((double)clock() / CLOCKS_PER_SEC) << endl

#define watch(x) cerr << (#x) << " is " << (x) << endl;

#ifndef LOCAL
#define cerr if(false)cerr
#endif
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll P=1e9+7;
double PI=3.141592653589793;
const int arrn = 2e5 + 1;

int n;
int a[arrn],ans[arrn];
vector<int> proc;
vector<int> adj[arrn];

void dfs(int u,int par){
	auto it=lower_bound(all(proc),a[u]);
	int rem;
	if(it==proc.end()){
		rem=-1;
		proc.pb(a[u]);
	}else{
		rem=*it;
		*it=a[u];
	}
	ans[u]=proc.size();
	for(auto i:adj[u]){
		if(i==par) continue;
		dfs(i,u);
	}
	if(rem==-1) proc.rb();
	else{
		it=lower_bound(all(proc),a[u]);
		*it=rem;
	}
}

void solve(){
	cin >> n;
	forn(i,n) cin >> a[i];
	forn(i,n-1){
		int u,v;
		cin >> u >> v;
		u--;v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(0,-1);
	forn(i,n) cout << ans[i] << '\n';
}

int main() {
	IO;
	int T=1;
//	cin >> T;
	forn(c,T){
		solve();
	}
}



Measured memory_bytes: 30384