akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int res = 0;
	for(int i=1;i<=n;i++)
	{
		int m = i;
		int cnt = 0;
		while(m)
		{
			++cnt;
			m/=10;
		}
		if(cnt&1)++res;
	}	
	cout<<res<<endl;
	return 0;
}

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

#include <climits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int zero = count(s.begin(), s.end(), '0');
	int one = count(s.begin(), s.end(), '1');

	int result = min(zero, one) * 2;
	cout << result << endl;
	return 0;
}


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

using namespace std;

int solve(int s, int d) {
	int ret = 0;
	while (s != d) {
		if (s % 2 != 0) {
			s++;
			ret++;
		}
		if (d % 2 != 0) {
			d--;
			ret++;
		}
		s /= 2;
		d /= 2;
	}
	return ret;
}

int main() {
	int n;
	int s, d;

	cin >> n;
	vector<int> ans(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> s >> d;
		ans[i] = solve(s, d);
	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

const ll mx=1e18;

void solve(){
 ll n;
 cin >> n;

 map<ll,ll> mp;
 for(ll i=2;i*i<=n;i++){
  if(n%i) continue;
  while(n%i==0){ 
   mp[i]++;
   n/=i;
  }
 }
 if(n!=1) mp[n]++;
  
 ll ans=0;
 for(auto p:mp){
  ll cnt=1;
  while(p.se>=cnt){
    p.se-=cnt;
    ++ans;
    ++cnt;
  }
 }
  cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3648
n, a, b = list(map(int, input().split()))

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    if a > b:
        print(0)
    else:
        mins = (n-1)*a + b
        maxs = a + (n-1)*b
        print(maxs - mins + 1)

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll n;
cin>>n;
if(n%2){
    cout<<0<<endl;
    return 0;
}
ll x=n;
ll five=0,two=0;
x/=2;
while(x){
    five+=(x/5);
    x/=5;
}
x=n;
while(x){
    two+=(x/2);
    x/=2;
}
cout<<min(two,five)<<endl;
}


Measured memory_bytes: 256
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e6;

int main()
{
  FastIO();
  int tc, ca = 0;
  int n;
  cin >> n;
  string s;
  int ac = 0;
  int wa = 0;
  int tle = 0;
  int re = 0;
  for (int i = 0;i < n;i++){
    cin >> s;
    if (s == "AC")ac++;
    if (s == "WA")wa++;
    if (s == "TLE")tle++;
    if (s == "RE")re++;
  }
  cout << "AC x " << ac << '\n';
  cout << "WA x " << wa << '\n';
  cout << "TLE x " << tle << '\n';
  cout << "RE x " << re << '\n';
  return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c;
  int maxv;
  scanf("%d %d %d",&a,&b,&c);
  maxv=max(a,b);
  maxv=max(maxv,c);
  printf("%d\n",a+b+c-maxv);
  return 0;
}


Measured memory_bytes: 128
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

int main(){	
	ll N;
	cin >> N;
	vector<ll> A(15);
	vector<vector<ll>> x(15, vector<ll>(15));
	vector<vector<ll>> y(15, vector<ll>(15));
	rep(i, N) {
		cin >> A[i];
		rep(j, A[i]) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}

	ll res = 0;
	rep(i, 1<<N) {
		ll now = 0;
		rep(j, N) {
			if ((i&(1<<j)) > 0) {
				now++;
			}
		}
		bool flg = true;
		rep(j, N) {
			if ((i&(1<<j)) == 0) continue;
			rep(k, A[j]) {
				if ( ((i&(1<<x[j][k])) > 0 && y[j][k] == 0) || ((i&(1<<x[j][k])) == 0 && y[j][k] == 1)) {
					flg = false;
					// if (i == 3) {
					// 	cout << i << " " << j << " " << k << endl;
					// 	cout << x[j][k] << " " << y[j][k] << " " << (i&(1<<x[j][k])) << endl;
					// }
				}
			}
		}
		if (flg) res = max(res, now);
	}
	cout << res << endl;
}


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

int main()
{
    int n, k;
    std::cin >> n >> k;

    std::string s;
    std::cin >> s;

    std::vector<int> pos;
    pos.push_back(0);
    for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] != s[i + 1]) {
            pos.push_back(i + 1);
        }
    }
    pos.push_back(n);

    int ans = 0;
    for (int i = 0; i < pos.size() - 1; i++) {
        int end_pos_idx;
        if (s[pos[i]] == '1') {
            end_pos_idx = i + 2 * k + 1;
        } else {
            end_pos_idx = i + 2 * k;
        }

        if (end_pos_idx >= pos.size()) {
            end_pos_idx = pos.size() - 1;
        }

        ans = std::max(ans, pos[end_pos_idx] - pos[i]);
    }

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


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int n,a[100005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		a[x]++;
	}
	int sum=0;
	for(int i=0;i<=100000;i++)
		sum=max(sum,a[i]+a[i+1]+a[i+2]);
	cout<<sum;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <string>

int main(){
  std::ios_base::sync_with_stdio(false);

  std::set<std::string> dic;

  unsigned n;
  std::cin >> n;

  std::string buf;
  for(unsigned i = 0; i < n; i++){
    std::cin >> buf;
    if(buf == "insert"){
      std::cin >> buf;
      dic.insert(buf);
    }
    if(buf == "find"){
      std::cin >> buf;
      std::cout << ((dic.find(buf) == dic.end())?"no":"yes") << '\n';
    }
  }
}

Measured memory_bytes: 28168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 1000000


int main() {

	int x, n, arr[200], ans = 0, dist = 0, pos = -1;
	cin>>x>>n;

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

	if(n == 0) {
		cout<<x<<endl;
		return 0;
	}

	sort(arr, arr+n);
	int flag = 0;

	for(int i = 0 ; i < n ; i++) {
		if(arr[i] == x) {
			flag = 1;
			break;
		}
	}

	if(flag == 0) {
		cout<<x<<endl;
		return 0;
	}


	for(int i = x-1; ;i--) {

		int flag = 0;

		for(int j = 0 ; j < n && arr[j] <= i; j++) {
		//	cout<<arr[j]<<endl;
			if(arr[j] == i) {
				flag = 1;
				break;
			}
		}

		if(!flag) {

			dist =abs(abs(x)-abs(i));
			ans = i;
			break;
		}
	}

	// cout<<ans<<endl;
	// cout<<dist<<endl;

	for(int i = x+1; ;i++) {

		int flag = 0;

		for(int j = 0 ; j < n && arr[j] <=i; j++) {
			if(arr[j] == i) {
				flag = 1;
				break;
			}
		}

		if(!flag) {

			if(abs((abs(i)-abs(x))) < dist) {
				dist = abs(abs(x)-abs(i));
				ans = i;
			}
			
			break;
		}
	}

	cout<<ans<<endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<int> freqs(N + 1, 0);
  for (int i = 0; i < M; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    ++freqs[a];
    ++freqs[b];
  }
  for (int i = 1; i <= N; ++i) {
    printf("%d\n", freqs[i]);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int N;
 cin >> N ;
vector<string> S(100000);
 vector<long long> march(5);
march.at(0)=0;
march.at(1)=0;
march.at(2)=0;
march.at(3)=0;
march.at(4)=0;
 for(int n=0;n<N;n++){
 	cin >> S.at(n);
 	switch(S.at(n).at(0)){
 		case 'M':march.at(0)++;break;
 		case 'A':march.at(1)++;break;
 		case 'R':march.at(2)++;break;
 		case 'C':march.at(3)++;break;
 		case 'H':march.at(4)++;break;
 	}
 }
 int a=0;
 for(int n=0;n<5;n++){
 	if(march.at(n)>0){
 	   a++;
 	}
 }
 if(a>=3){
 	long long ans=0ll;
   for(int d=0;d<5;d++){
       for(int e=d+1;e<5;e++){
         for(int f=e+1;f<5;f++){
     ans+=march.at(d)*march.at(e)*march.at(f);
 }
}
}
cout << ans <<endl;
 }else{
 cout << '0' <<endl;
 }
}

Measured memory_bytes: 6144
use std::io;

fn input() -> (i32, i32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    (a, b)
}

fn main() {
    loop {
        let (x, y) = input();
        if x == 0 && y == 0 {
            break;
        }

        if x < y {
            println!("{} {}", x, y);
        } else {
            println!("{} {}", y, x);
        }
    }
}


Measured memory_bytes: 5024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    vector<int> c(N, -1);
    for(int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        s--;
        if(c[s] == -1 || c[s] == t) {
            c[s] = t;
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }

    if(N == 1 && c[0] == 0){
        cout << 0 << endl;
    }
    else if(N == 1 && c[0] == -1) {
        cout << 0 << endl;
    }
    else {
        if(c[0] == 0) {
            cout << -1 << endl;
        } else {
            bool p = false;
            for(int i = 0; i < N; i++) {
                if(c[i] != -1) {
                    cout << c[i];
                    p = true;
                }
                else {
                    if(p) cout << 0;
                    else {
                        cout << 1;
                        p = true;
                    }
                }
            }

            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
public class Main{
  public static void main(String agrs[])
  {
    Scanner in = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    int n = in.nextInt();
    long[] arr = new long[n];
    long max = (long) Math.pow(10,18);
    boolean zero = false;
    long counter = 1;
    for(int i = 0; i < n; i++)
    {
      arr[i] = in.nextLong();
      if(arr[i] == 0)
      {
        zero = true;
      }
    }
    if(zero)
    {
      out.println(0);
    }
    else
    {
      for(int i = 0; i < n; i++)
      {
        if(arr[i] > max / counter)
        {
          zero = true;
          break;
        }
        counter *= arr[i];
      }
      if(zero)
      {
        out.println(-1);
      }
      else
      {
        out.println(counter);
      }
    }
    out.close();
  }
}

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

int main() {
  int n, L;
  cin >> n >> L;
  vector<string> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  rep(i,n) cout << a[i];
  cout << endl;
}

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

using namespace std;

int hrpe[100005];

int main() {
	int n;
	cin >> n;
	for (int i=0;i<n;i++) cin >> hrpe[i];
	sort (hrpe, hrpe+n);
	int zadnji = -1;
	for (int i=0;i<n;i++) {
		int b = hrpe[i]-1;
		int u = n-i-1;
		if ((b+u) % 2 == 0) {
			if (u <= (b+u)/2) {
				if (zadnji == -1) {
					cout << "Second";
					break;
				}
				else if (hrpe[i-1] != hrpe[i]) {
					cout << "Second";
					break;
				}
				else if (!zadnji) {
					cout << "Second";
					break;
				}
			}
		}
		else {
			if (u <= (b+u)/2+1) {
				if (zadnji == -1) {
					cout << "First";
					break;
				}
				else if (hrpe[i-1] != hrpe[i]) {
					cout << "First";
					break;
				}
				else if (zadnji) {
					cout << "First";
					break;
				}
			}
		}
		if (i != 0) {
			if (hrpe[i-1] != hrpe[i]) {
				zadnji = (b+u)%2;
			}
		}
		else {
			zadnji = (b+u) % 2;
		}
	}
	return 0;
}

Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * 2834.cc: Dimension travel
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_E2 = 1 << 18; // = 262144
const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;

template <typename T, const int MAX_E2>
struct SegTreeMin {
  int n, e2;
  T inf, nodes[MAX_E2];
  SegTreeMin() {}

  void init(int _n, T _inf) {
    n = _n; inf = _inf;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(nodes, nodes + MAX_E2, inf);
  }

  T get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;

    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = min(nodes[j * 2 + 1], nodes[j * 2 + 2]);
    }
  }

  T min_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return inf;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = min_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = min_range(r0, r1, k * 2 + 2, im, i1);

    return min(v0, v1);
  }
  T min_range(int r0, int r1) { return min_range(r0, r1, 0, 0, e2); }
};

/* global variables */

int ds[MAX_N];
pii es[MAX_N];
SegTreeMin<int,MAX_E2> stm;

/* subroutines */

/* main */

int main() {
  int n, m, s, t;
  scanf("%d%d%d%d", &n, &m, &s, &t);
  s--, t--;

  for (int i = 0; i < n; i++) scanf("%d", ds + i);

  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    es[i] = pii(a, b);
  }
  sort(es, es + m);

  stm.init(n, INF);
  stm.set(s, 0);

  for (int i = 0; i < m; i++) {
    int &a = es[i].first, &b = es[i].second;

    int da = stm.min_range(a, n);
    int db = stm.min_range(b, n);
    int vd = da + ds[b];
    if (db > vd) stm.set(b, vd);
  }

  printf("%d\n", stm.min_range(t, n));
  return 0;
}



Measured memory_bytes: 5448
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;

ll per[100100];
ll mn[100100];
map<ll,ll>rep;
map<ll,ll>::iterator it;
ll pr(ll x){
    if(x == per[x])return x;
    return per[x] = pr(per[x]);
}

void merg(int x,int y){
    x = pr(x);
    y = pr(y);
    per[x] = y;
    mn[y] = min(mn[y],mn[x]);
}

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

    for(int i=0 ;i < n; i++){
        per[i]= i;
        scanf("%d",&mn[i]);
        rep[mn[i]]++;
    }
    int x,y;
    for(int i=0 ;i <m ;i ++){
        scanf("%d%d",&x,&y);
        merg(x,y);
    }
    set<int>st;
    set<int>::iterator it1;
    for(int i=0 ;i <n ;i ++){
       //     cout<<pr(i)<<" ";
        st.insert(pr(i));
    }
  /*  cout<<endl;
    cout<<endl;*/
    ll res = 0;
    m = st.size()-1;
    m *= 2;
    if(st.size() == 1){
        cout<<"0\n";
        return 0;
    }
    for(it1 = st.begin() ; it1 != st.end() ; it1++){
        res += mn[*it1];
        rep[mn[*it1]]--;
        m--;
    }
    for(it = rep.begin() ; it != rep.end() ; it++){
        if(!m)break;
        if(it->sc <=m){
            m -= it->sc;
            res += it->fr *it->sc;
        }
        else{
            res += it->fr*m;
            m = 0;
            break;
        }
    }
    if(m){
        cout<<"Impossible\n";
        return 0;
    }
    cout<<res<<endl;
    return 0;
}


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

int main()
{
  string s;int k;
  cin>>k>>s;
  int n = s.length();
  if(n<=k)
    cout<<s<<"\n";
  else
  {
    string str = s.substr(0,k);
    str +="...";
    cout<<str<<"\n";
  }
 return 0; 
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(100001);
  int64_t sum = 0;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    vec.at(a)++;
    sum = sum + a;
  }
  
  int Q;
  cin >> Q;
  
  for(int i = 0; i < Q; i++){
    int b, c;
    cin >> b >> c;
    if(vec.at(b)!=0){
      vec.at(c) += vec.at(b);
      sum += (c-b)*vec.at(b);
      vec.at(b)=0;
    }
    cout << sum << endl;;
  }
      
      
}



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

int min(int x, int y)
{
	return ((x < y) ? x : y);
}

int main()
{
	int n;
	int a[100] = { 0 }, b[100] = { 0 };

	cin >> n;
	for (int i = 0; i < (n - 1); i++) {
		cin >> b[i];
	}

	a[0] = b[0];
	a[n - 1] = b[n - 2];
	for (int i = 1; i < (n - 1); i++) {
		a[i] = min(b[i - 1], b[i]);
	}

	int m = 0;
	for (int i = 0; i < n; i++) {
		m += a[i];
	}

	cout << m << endl;

	return 0;
}

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

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

  std::sort(a, a+N, std::greater<int>());
  int alice = 0;
  int bob = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( i % 2 == 0 ) alice += a[i];
    else bob += a[i];
  }
  std::cout << alice - bob << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,k,n) for(int i = k; i < n; i++)  
#define repp(i,k,n) for(int i = k; i <= n; i++) 
#define per(i,k,n) for(int i = k; i >= n; i--)

#define int long long
#define all(a) a.begin(),a.end()       

#define pb push_back
typedef long long ll; 
typedef pair<int, int> ii;
typedef pair<int,ii > iii; 
typedef vector<ii> vii;
typedef vector<char> vchar;
typedef vector<int> vi;
#define ff first
#define ss second

#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));

#define INF 1000000000
//#define mod 998244353
#define mod 1000000007
#define endl "\n"


   //=\/=\/=\/=\/=\/=\/=\/=\/=\/=\        Jai Hind Dosto        /=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\
  //=\/=\/=\/=\                    ̿̿ ̿̿ ̿̿ ̿'̿'\̵͇̿̿\з= ( ▀ ͜͞ʖ▀) =ε/̵͇̿̿/’̿’̿ ̿ ̿̿ ̿̿ ̿̿                             /=\/=\/=\/=\\
 //=\/=\/=\/=\                                                                               /=\/=\/=\/=\\
//=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\/=\\



int modPow(int a, int b);           

                
void solve(){
    int n[5] ;
    int ans;
    rep(i,0,5){cin >> n[i]; if(n[i]==0)ans = i+1;}
    cout << ans <<endl;
}






signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed;
    //cout <<setprecision(6);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
   // int test=1; cin >> test; while(test--)
    solve();
}

int modPow(int a, int b){
    if(b==0)return 1;
    if(b%2==0){
        int x = a*a;
        x%=mod;
        return modPow(x,b/2);
    }
    return (a*modPow(a,b-1))%mod;
}




Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
const int mod = 1e9 + 7;

void solve() {
	ll N;
	cin >> N;


	vector<vector<ll>> dp(63, vector<ll>(3, 0));
	dp[62][0] = 1;

	for(ll i = 61; i >= 0; i--) {
		for (ll j = 0; j < 2; j++) {
			if (!dp[i + 1][j]) continue;
			ll j_ = min(2LL, (N >> i) - (((((N >> (i + 1)) - j) << (i + 1)) + (1LL << (i + 1)) ) >> i));
			if (j_ >= 0) {
				dp[i][j_] += dp[i + 1][j];
				dp[i][j_] %= mod;
			}

			ll j__ = min(2LL, (N >> i) - (((((N >> (i + 1)) - j) << (i + 1)) + (1LL << i)) >> i));
			if (j__ >= 0) {
				dp[i][j__] += dp[i + 1][j];
				dp[i][j__] %= mod;
			}  

			ll j___ = min(2LL, (N >> i) - (((((N >> (i + 1)) - j) << (i + 1))) >> i ));
			if (j___ >= 0) {
				dp[i][j___] += dp[i + 1][j];
				dp[i][j___] %= mod;
			}
		}
		dp[i][2] += 3 * dp[i + 1][2];
		dp[i][2] %= mod;
	}

	cout << (dp[0][0] + dp[0][1] + dp[0][2]) % mod << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<list>
#include<cstring>
#include<cctype>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<ctime>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n);++i)

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

    vector<vector<int>> v(n+1);
    int a[m],b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }

    vector<int> c(n+1,0);

    queue<int>que;
    que.push(0);
  	vector<bool> g(n+1,false);  
  
    while(!que.empty()){
        int p = que.front();
        que.pop();

        for(auto u : v[p]){
            if(g[u] == true)continue;
          	c[u] = p + 1;
            que.push(u);
          	g[u] = true;
        }
    }
  	
  	cout << "Yes" << endl;
   	for(int i = 1;i < n;i++)cout << c[i] << endl;
}


Measured memory_bytes: 11540
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for (int i=1; i<n; i++)
using namespace std;
using f=float; using ll=long long; using ld=long double;
using ull=unsigned long long; using vi=vector<int>; using pii=pair<int, int>;

int main() {
    int n, flag_n = 0;
    cin >> n;
    string s = to_string(n);
    rep(i, s.size()) {
        if ( s.at(i) == '7') {
            flag_n = 1;
        }
    }
    if (flag_n) cout << "Yes" << endl;
    else cout << "No" << endl;
//    cout << s << endl;
    return 0;
}

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

int main(){
	ll N;
	string S;
	cin >> N >> S;
	bool black_exists(false);
	ll b_num(0),w_num(0);
	for(ll i(0);i<N;++i){
		if(S[i] == '#') ++b_num;
		else ++w_num;
	}
	vector<ll> cnt{b_num, w_num};
	ll b_cnt(0), w_cnt(0);
	for(ll i(0);i<N;++i){
		if(S[i] == '#'){
			cnt.push_back(b_cnt + w_num - w_cnt);
			b_cnt++;
		}else{
			cnt.push_back(b_cnt + w_num - w_cnt);
			w_cnt++;
		}
	}
	sort(cnt.begin(),cnt.end());
	cout << cnt[0] << endl;
	return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
long long modpow(long long a, long long n)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a)
{
    return modpow(a, mod - 2);
}
vec fact(300001);    //fact[i]=(i!)
vec factinv(300001); //factinv[i]=(i!)^-1
void COMinit()
{
    long long now = 1;
    fact[0] = 1;
    factinv[0] = modinv(0);
    Loop(i, 1, 300001)
    {
        now *= i;
        now %= mod;
        fact[i] = now;
        factinv[i] = modinv(now);
    }
}
long long COM(long long n, long long r)
{
    if (n < r)
        return 0;
    if (n < 0 || r < 0)
        return 0;
    if (n == r)
        return 1;
    if (r == 0)
        return 1;
    long long ans = fact[n];
    ans *= factinv[r];
    ans %= mod;
    ans *= factinv[n - r];
    ans %= mod;
    return ans;
}
int main()
{
    cout << fixed << setprecision(30);
    ll N, M, K;
    cin >> N >> M >> K;
    ll ans = 0;
    COMinit();
    loop(i, K + 1)
    {
        ll k = i;
        ans += (((M * COM(N - 1, k) % mod) * modpow(M - 1, N - 1 - k)) % mod);
        ans %= mod;
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 7876
// https://atcoder.jp/contests/abc072/tasks/abc072_d
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) {
        cin >> v[i];
        v[i]--;
    }
    int cnt = 0;
    REP(i, n - 1) {
        if (i == v[i]) {
            swap(v[i], v[i + 1]);
            cnt++;
        }
    }
    if (v[n - 1] == n - 1)
        cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;cin >> s;char pm[2] = {'+','-'};int a[4],i,j,k,sum;
  for(i=0;i<4;i++) a[i] = s[i]-'0';
  for(i=0;i<2;i++){
    for(j=0;j<2;j++){
      for(k=0;k<2;k++){
        sum = a[0];
        if(i) sum -= a[1];
        else sum += a[1];
        if(j) sum -= a[2];
        else sum += a[2];
        if(k) sum -= a[3];
        else sum += a[3];
        if(sum==7){
          cout << a[0] << pm[i] << a[1] << pm[j] << a[2] << pm[k] << a[3] << "=7" << endl;
          return 0;
        }
      }
    }
  }
}


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

int main(){	
	long long N, res = 0, s = 0;
	scanf("%lld",&N);
	// for (long long i=1; i*i<=N; i++) s = i;
	for (long long i=1; i*i<=N; i++) {
		if ((N - i) % i == 0 && (N - i) / i > i) res += (N - i) / i;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

vi v[N];
vi lis;
int c[N], a[N];
pii trash[N];
void dfs(int u, int e)
{
	int id = lower_bound(lis.begin(), lis.end(), a[u]) - lis.begin();
	if(id == lis.size())
	{
		lis.pb(a[u]);
		trash[u] = M(-1, -1);
	}
	else
	{
		trash[u] = M(id, lis[id]);
		lis[id] = a[u];
	}
	c[u] = lis.size();
	for(auto it : v[u])
		if(it != e)
			dfs(it, u);
	if(trash[u].F == -1)
		lis.pop_back();
	else
		lis[trash[u].F] = trash[u].S;
}

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	for(int i = 2; i <= n;i ++)
	{
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	
	dfs(1, 0);

	for(int i = 1; i <= n; i ++)
		cout << c[i] << '\n';

	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    ll N, D, A, X, H;
    cin >> N >> D >> A;
    priority_queue<vector<ll>> pq;
    rep(i, N) {
        cin >> X >> H;
        pq.push({-X, H});
    }
    ll ans = 0, bomb = 0;
    while (pq.size() > 0) {
        auto p = pq.top();
        pq.pop();
        //cout << "p[0]=" << p[0] << ", p[1]=" << p[1];
        if (p[1] > 0) {
            if (D == 0) {
                ans += (p[1] + A - 1) / A;
            } else if (p[1] > A * bomb) {
                ll add = (p[1] - A * bomb + A - 1) / A;
                ans += add;
                pq.push({p[0] - D - D, -add});
                bomb += add;
            }
        } else {
            bomb += p[1];
        }
        //cout << ", ans=" << ans << ", bomb=" << bomb << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12464
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n, m=1000000, cnt = 0;
    cin >> n;
    int p[n];
    REP(i, n){
        cin >> p[i];
        m = min(p[i], m);
        if(m == p[i]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int maxn = max(max(a, b), c);
	int minn = min(a, min(b, c));

	cout << minn << " " << maxn << endl;

	return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p==NIL) printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");

}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
  if(T[u].r!=NIL) calcDepth(T[u].r,p);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 3344
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int a, b, c, k;

    cin >> a >> b >> c >> k;

    if (a + b >= k) {
        cout << min(a, k) << endl;
    } else {
        k -= (a + b);
        cout << a - k << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define pi 3.14159265359
#define mp make_pair
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%lld",&a)
#define pf printf
#define sz(a) (ll)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()
#define sp(a) setprecision(a)
#define rz resize
#define ld long double

using namespace std;

vector<vector<ll> > dp;

bool cmp(const pair<int,pair<int,int> > &a,const pair<int,pair<int,int> > &b)
{
	return a.ff+a.ss.ff<b.ff+b.ss.ff;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<pair<int,pair<int,int> > > p(n);
	int val[n],w=0;
	f(i,0,n)
	{
		cin>>p[i].ff>>p[i].ss.ff>>p[i].ss.ss;
		w+=p[i].ff;
	}
	dp.rz(n+1,vector<ll> (20202));
	sort(all(p),cmp);
	f(i,1,n+1)
		dp[i][0]=0;
	f(i,1,20202)
		dp[0][i]=0;
	dp[0][0]=0;
	// f(i,0,n)
	// 	cout<<p[i].ff<<' '<<p[i].ss.ff<<' '<<p[i].ss.ss<<"\n";
	f(i,1,n+1)
	{
		f(j,p[i-1].ff,20202)
		{
			if(p[i-1].ss.ff>=j-p[i-1].ff)
				dp[i][j]=max(dp[i-1][j],p[i-1].ss.ss+dp[i-1][j-p[i-1].ff]);
			dp[i][j-p[i-1].ff]=max(dp[i][j-p[i-1].ff],dp[i-1][j-p[i-1].ff]);
		}
	}
	// cout<<dp[n][w]<<"\n";
	ll mx=-1;
	// f(i,0,n+1)
	// {
	// 	f(j,0,w+1)
	// 		cout<<dp[i][j]<<' ';
	// 	cout<<"\n";
	// }
	f(i,1,20202)
		mx=max(mx,dp[n][i]);
	cout<<mx<<"\n";
}

Measured memory_bytes: 160640
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d;
int main(){
  cin >> n;
  a = n / 1000, b = n / 100 % 10, c = n / 10 % 10, d = n % 10;
  if((a == b && b == c) || (b == c && c == d)) puts("Yes");
  else puts("No");
} 

Measured memory_bytes: 256
n,k = map(int,input().split())
def search(n,k):
    buf = [[],[]]
    for i in range(1,n+1):
        if i % k == 0:
            buf[0].append(i)
        elif k % 2 == 0 and i % k == k // 2:
            buf[1].append(i)
    return buf
def countans(l):
    length = len(l)
    if length == 1:
        return 1
    elif length == 2:
        return 2 + 2*1*3
    else:
        return length + length*(length-1)*3 + length*(length-1)*(length-2)
buf = search(n,k)
print(countans(buf[0])+countans(buf[1]))


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


int main() {
    int N, K, c = 0, ans = 0;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    while(c<N) {
        if(!ans) c+=K;
        else c+=K-1;
        ans++;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 640
import           Control.Exception (assert)
import           Data.Foldable     (for_)
import           Data.List         (sortOn)
import           Data.Ord          (Down (Down))

main :: IO ()
main = do
  [x, y, z, k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  bs <- map read . words <$> getLine
  cs <- map read . words <$> getLine
  assert (length as == x && length bs == y && length cs == z) $
    for_ (solve k as bs cs) print

solve :: Int -> [Int] -> [Int] -> [Int] -> [Int]
solve k as bs cs =
  let
    asbs = take k $ sortOn Down $ (+) <$> as <*> bs
  in
    take k $ sortOn Down $ (+) <$> asbs <*> cs


Measured memory_bytes: 631292
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    if(S.at(0) == S.at(1) && S.at(2) == S.at(3) && !(S.at(0) == S.at(3)) ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
while 1:
   H, W = map(int,raw_input().split())
 
   if H ==0 and W == 0:
      break
   for i in range(H):
      if i%2==0:
        if W%2==0:
           print "#."*(W/2)
        elif W%2==1:
           print "#."*(W/2)+"#"
      elif i%2==1:
         if W%2==0:
            print ".#"*(W/2)
         elif W%2==1:
            print ".#"*(W/2)+"."
   print ""

Measured memory_bytes: 6440
function Main(s) {
  var n = s.split("\n")[0]*1;
  var dp = new Array(100001).fill(100001);
  dp[0] = 0, dp[1] = 1;
  var sixs = [], nines = [];
  var six = 6, nine = 9;
  while(six <= 100000) sixs.push(six), six *= 6;
  while(nine <= 100000) nines.push(nine), nine *= 9;
  sixs.push(Infinity), nines.push(Infinity);
  for (var i = 2; i < 100001; i++) {
    if (i < 6) { 
      dp[i] = dp[i-1] + 1
    } else if (i < 9) {
      dp[i] = Math.min(dp[i-1]+1, dp[i-6] + 1);
    } else {
      for (var j = 0; sixs[j] <= i; j++) {
        dp[i] = Math.min(dp[i], dp[i-1]+1, dp[i-sixs[j]]+1);
      }
      for (var j = 0; nines[j] <= i; j++) {
        dp[i] = Math.min(dp[i], dp[i-1]+1, dp[i-nines[j]]+1);
      }
    }
  }
  console.log(dp[n]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9144
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);
  int e[n+1], w[n+1], ans = 300001;
  w[0] = 0; e[n] = 0;
  for (int i=1; i<n+1; i++) w[i] = (s[i-1] == 'W') ? w[i-1]+1 : w[i-1];
  for (int i=n-1; i>=0; i--) e[i] = (s[i] == 'E') ? e[i+1]+1 : e[i+1];
  for (int i=0; i<n; i++) {
    int cnt = w[i] + e[i+1];
    ans = (ans > cnt) ? cnt : ans;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N,C;
int main(){
    cin >> N >> C;
    vector<ll> x(N+1),v(N+1);
    //入力
    for(int i = 0; i < N; i++){
        cin >> x.at(i+1) >> v.at(i+1);
    }
    //v = calorie(kg)
    ll sum_v = 0;
    vector<ll> max_sum(N+1);
    ll mx = 0;
    //時計回り
    //mxは保存
    for(int i = 1; i <= N; i++){
        sum_v += v.at(i);
        mx = max(mx,(sum_v - x.at(i)));
        //愚直に時計回りで進んだ時のカロリー摂取最大値
        max_sum.at(i) = mx;
    }
    ll ans = max_sum.at(N);
    //初期化
    sum_v = 0;
    //反時計回りと時計回りの合成
    for(int i = N; i >= 1; i--){
        sum_v += v.at(i);
        ans = max(ans, (sum_v - (C - x.at(i)) *2 + max_sum.at(i-1)));
        //max_sum.at(i-1)はmax_sum.at(i-1)'まで'の最大値
    }
    vector<ll> max_sum2(N+1);
    sum_v = 0;
    mx = 0;
    //反時計回りのみ
    for(int i = N; i >= 1; i--){
        sum_v += v.at(i);
        mx = max(mx, (sum_v - (C - x.at(i))));
        max_sum2.at(i) = mx;
    }
    ans = max(ans, max_sum2.at(1));
    sum_v = 0;
    //反時計回りと時計回りの合成2
    for(int i = 1; i < N; i++){
        sum_v += v.at(i);
        ans = max(ans, (sum_v - x.at(i)*2 + max_sum2.at(i+1)));
    }
    cout << ans << endl;
}




Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=1; i<n-1; i++)
    {
        if((a[i-1]<a[i] && a[i]<a[i+1]) || (a[i-1]>a[i] && a[i]>a[i+1]))
            ans++;
    }
    cout<<ans<<endl;
}


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

#define INF 1e9
using namespace std;

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

    return gcd(b, a % b);
}

int main() {

    int N; cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    //累積GCD
    vector<int> left(N+1, 0); //初期値を設定
    for (int j = 0; j < N; ++j) {
        left[j+1] = gcd(left[j], A[j]);
    }

    vector<int> right(N+1, 0); //初期値を設定
    for (int k = N-1; k >= 0; --k) {
        right[k] = gcd(right[k+1], A[k]);
    }

    int ans = 0;
    for (int l = 0; l < N; ++l) {
        ans = max(ans, gcd(left[l], right[l+1]));
    }

    cout << ans << endl;
}

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

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

  string ans = "Yes";
  for ( int i = 1; i < n; i++ ) {
    for ( int j = i-1; j >= 0; j-- ) {
      if ( w[i] == w[j] ) { ans = "No"; }
    }
  }
  for ( int i = 1; i < n; i++ ) {
    if ( w[i][0] != w[i-1][w[i-1].length()-1] ) { ans = "No"; }
  }

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


Measured memory_bytes: 256
from math import sqrt
n,d = map(int,input().split())
points = []
for i in range(n):
    x = list(map(int,input().split()))
    points.append(x)
count = 0
for i in range(n):
    for j in range(i+1,n):
        total_distance_ij = 0
        for k in range(d):
            dis = (points[i][k] - points[j][k])**2
            total_distance_ij += dis
        squared = sqrt(total_distance_ij)
        if squared == int(squared):
            count += 1
print(count)

Measured memory_bytes: 3064
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

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

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll n,m,k;
  cin >> n >> m >> k;
  vl a(n);
  vl b(m);
  REP(i,n) cin >> a[i];
  REP(i,m) cin >> b[i];
  FOR(i,1,n) a[i] += a[i-1];
  FOR(i,1,m) b[i] += b[i-1];
  ll ans = 0;
  REP(i,m){
    if(b[i]<=k) ans = i+1;
    else break;
  }
  REP(i,n){
    ll remain = k-a[i];
    if(remain<0) break;
    // i+1 books
    ll ok,ng;
    ok = -1;
    ng = m;
    while(abs(ok-ng)>1){
      ll mm = (ok+ng)/2;
      if(b[mm]<=remain) ok = mm;
      else ng = mm;
    }
    //cout << "a:" << i+1 << ",b:" << ok+1 << endl;
    ans = max(ans,i+1+ok+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
ll n,A,fac[10000001],inv[10000001],_inv[10000001];
inline ll getC(ll n,ll m){
    if (n<m) return 0;
    return fac[n]*_inv[m]%ljc*_inv[n-m]%ljc;
}
inline ll query(ll i1,ll i2){
	if (i1<=0||i2<=0||i1>i2) return 0;
	return fac[i2]*_inv[i1-1]%ljc;
}
inline ll solve(ll i1,ll i2){
	if (n-A<i1) return 0; 
	return query(n-A-i1+1,n-A)*query(i1+i2,i2-n-A+1)%ljc*query(n-A+i1+i2+2,n)%ljc;
}
ll dp[5001][5001],sum[5001][5001];
inline void add(ll &a,ll b){a+=b;a%=ljc;}
signed main(){
    fac[0]=inv[0]=inv[1]=_inv[0]=1;
    for (ll i=1;i<=10000000;i++) fac[i]=fac[i-1]*i%ljc;
    for (ll i=2;i<=10000000;i++) inv[i]=(ljc-inv[ljc%i]*(ljc/i)%ljc)%ljc;
    for (ll i=1;i<=10000000;i++) _inv[i]=_inv[i-1]*inv[i]%ljc;
    n=read(),A=read(); 
//    for (int i1=0;i1<=A;i1++){
//    	for (int i2=0;i2+i1<=A;i2++){
//    		if (i1==0&&i2==0){
//    			dp[0][0]=1;continue;
//			}
//    		if (i2) add(dp[i1][i2],dp[i1][i2-1]);
//    		for (int j=1;j<i1;j++) add(dp[i1][i2],dp[i1-j-1][i2]*getC(i1+i2-1,j)%ljc);
//		}
//	}
//	ll _=0;
//	for (int i=2;i<=A+1;i++){
//		for (int i1=0;i1<i;i1++){
//			_=(_+solve(i1,i-1-i1)*dp[i1][i-1-i1]%ljc)%ljc;				
//		}
//	}
	ll _=0;
	for (int T=2;T<=A+1;T++) {
		int x=T-1,y=max(A-T,0ll),z=n-A;
		for (int i=0;i<T;i++){
			if (i&1) add(_,ljc-getC(x,i)*(x-i)%ljc*inv[x-i+z]%ljc*fac[x-i+y+z]%ljc);
			else add(_,getC(x,i)*(ll)(x-i)%ljc*inv[x-i+z]%ljc*fac[x-i+y+z]%ljc);
		} 
	}
	cout<<_;
}

Measured memory_bytes: 237972