akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<(a);i++)

const int MAX_V=210;
int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=1;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i], w=match[u];
    if(w<0 || !used[w] && dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
        res++;
      }
    }
  }
  return res;
}

int main(){
  cin>>V;
  int x[2][V],y[2][V];
  rep(i,2) rep(j,V) cin>>x[i][j]>>y[i][j];
  rep(i,V) rep(j,V){
    if(x[0][i]<x[1][j]&&y[0][i]<y[1][j]){
      add_edge(i,V+j);
    }
  }
  cout<<bipartite_matching()<<endl;
  return 0;
}

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

string S;

int arc062d() {
  int res = 0;
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0 && S[i] == 'p') {
      res--;
    }
    if (i % 2 == 1 && S[i] == 'g') {
      res++;
    }
  }
  return res;
}

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

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 100000;
int N, X[Nmax], Y[Nmax], T[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> T[i] >> X[i] >> Y[i];
	}

	for(int i=0; i<N; i++){
		int t = T[i];
		int x = X[i];
		int y = Y[i];
		if(i > 0){
			t -= T[i-1];
			x -= X[i-1];
			y -= Y[i-1];
		}
		t = abs(t);
		x = abs(x);
		y = abs(y);
		if(t < x+y || t%2!=(x+y)%2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
 
int main(){
  int a;
  cin>>a;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
  }
  int ans=10000000,p=0;
  for(int t=0;t<1000;t++){
    for(int i=0;i<a;i++){
      p+=pow(vec.at(i)-t,2);
    }
    ans=min(p,ans);
    p=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main () {
  int bi[21];
  bi[0] = 1;
  for (int i = 1; i <= 20; i ++) bi[i] = bi[i - 1] * 2;
  int N;
  cin >> N;
  int v[30];
  int c[30];
  for (int i = 0; i < N; i ++) cin >> v[i];
  for (int i = 0; i < N; i ++) cin >> c[i];
  int k[30];
  for (int i = 0; i < N; i ++) k[i] = v[i] - c[i];
  int ans = -1;
  for (int i_ = 0; i_ < bi[N]; i_ ++) {
    int ko = 0;
    int i = i_;
    for (int j = 0; j < N; j ++) {
      if (i % 2) ko += k[j];
      i /= 2;
    }
    if (ans < ko) ans = ko;
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
N,K = map(int,input().split())
S = list(input())
K -= 1

if S[K] == 'A':
    S[K] = 'a'
elif S[K] == 'B':
    S[K] = 'b'
elif S[K] =='C':
    S[K] = 'c'

ans = ''
for i in range(N):
    ans += S[i]

print(ans)

Measured memory_bytes: 38256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sum = 0
for i in range(N):
  sum += B[A[i] - 1]
  if i <= N-2:
    if A[i+1] == A[i] + 1:
      sum += C[A[i] - 1]
print(sum)

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            int output = 0;
            for (int i = 0; i < 6; i++)
            {
                if (read[i] == '1') output++;
            }
            Console.WriteLine(output);
        }
    }
}


Measured memory_bytes: 13140
m = 1000000000000001

n = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

ans = num2alpha(n)

print(ans.lower())

Measured memory_bytes: 61648
#include<stdio.h>
 
int main(){
  int a,b,c,d,e,f;
  float x,y;
  while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=-1){
    x = (float)(c*e-b*f)/(a*e-d*b);
    y = (float)(c*d-a*f)/(b*d-a*e);
    if(-0.0005<x && x<=0)
      x=0;
    if(-0.0005<y && y<=0)
      y=0;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}
 

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

long long x;

long long read() {
    long long x = 0, f = 1; char s;
    while((s = getchar()) < '0' || s > '9') if(s == '-') f = -1;
    while(s >= '0' && s <= '9') {x = (x << 1) + (x << 3) + (s ^ 48); s = getchar();}
    return x * f;
}

int main() {
    x = read();
    long long n = 100, ans = 0;
    while(n < x) n += n / 100, ++ ans;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

set<int>s[200005];
int mm[200005];

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

  #ifndef ONLINE_JUDGE
      if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout);
      }
  #endif  

  int n,k;
  cin>>n>>k;
  int a[n];
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    s[a[i]].insert(i);    
  }
  int cnt=1;
  int z=0;
  while (cnt<k && mm[z]==0)
  {
    mm[z]=cnt;
    auto j=s[a[z]].lower_bound(z+1);
    if(j==s[a[z]].end())
    {
      if(k==cnt)
        break;
      j=s[a[z]].lower_bound(0);
      z=*j+1;
      cnt++;
      if(z==n)
      {
        z=0;
        cnt++;        
      }
      if(cnt==k)
      {
        break;
      }
    }
    else
    {
      z=*j+1;
      if(z==n)
      {
        z=0;
        cnt++;
      }
    }    
  }

  if(cnt==k+1)
    return 0;
  if(mm[z]==0)
  {
    if(z==n)
      return 0;
    vector<int>res;
    for(int i=z;i<n;i++)
    {
      auto j=s[a[i]].lower_bound(i+1);
      if(j!=s[a[i]].end())
      {
        i=*j;
        continue;
      }
      else
      {
        res.push_back(a[i]);
      }
    }
    for(auto i:res)
      cout<<i<<" ";      
    return 0;
  }
  else
  {
    int per=cnt-mm[z];
    k-=mm[z];
    k%=per;
  }

  while (k>0)
  {
    auto j=s[a[z]].lower_bound(z+1);
    if(j==s[a[z]].end())
    {
      j=s[a[z]].lower_bound(0);
      z=*j+1;
      k--;
      if(z==n)
      {
        z=0;
        k--;
        if(k==-1)
          return 0;
      }
      if(k==0)
        break;
    }
    else
    {
      z=*j+1;
      if(z==n)
      {
        z=0;
        k--;
      }
    }    
  }

    if(z==n)
      return 0;
    vector<int>res;
    for(int i=z;i<n;i++)
    {
      auto j=s[a[i]].lower_bound(i+1);
      if(j!=s[a[i]].end())
      {
        i=*j;
        continue;
      }
      else
      {
        res.push_back(a[i]);
      }
    }
    for(auto i:res)
      cout<<i<<" ";      

}


Measured memory_bytes: 27076
#include<bits/stdc++.h>
using namespace std;
int res=0;
int main()
{
	int x,y;
	cin>>x>>y;
	for(int i=1;i<10000000;i++)
	{
		res+=i;
		if(res>x)
		{
			if(res-x==res+i+1-y)
			{
				cout<<res-x<<endl;
				return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;

#define show(x) cerr << #x << " = " << x << endl;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

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

char getLetter(int l){
  l--;
  return l + 'a';
}

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

  long long n;
  cin >> n;

  string nameDog = "";
  while(n!=0){
    long long mod = n%26;
    n = n/26;

    if(mod == 0){
      n--;
      mod = 26;
     nameDog += getLetter(mod);
   }else{
     nameDog += getLetter(mod);
   }

  }
  reverse(all(nameDog));
  cout << nameDog << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

    if ((a * b) % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
    return 0;
}

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

int main(){
  string S ;
  int counter,i ;

  cin >> S ;
  counter=0 ;

  for(i=0;i<=2;i++){
    if(S[i]=='o'){
      counter++ ;
    }
  }

  cout << 700+counter*100 << endl ;
  return 0;

}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> hs(n); cin >> hs;
    sort(hs.begin(), hs.end());
    int ans = M;
    for(int i = 0; i < n - k + 1; i++){
        ans = min(ans, hs[i + k - 1] - hs[i]);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N,x; cin >> N >> x;
	vector<ll> a(N);
	rep(i,N) cin >> a[i];
	ll ans = 0;
	if(a[0] > x){
		ans += a[0]-x;
		a[0] -= a[0]-x;
	}
	ll now = a[0];
	repr(i,1,N){
		now += a[i];
		if(now > x){
			ans += now-x;
			a[i] -= now-x;
			now -= now-x;
		}
		now -= a[i-1];
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
ll a,b,c;
ll arr[3];
cin>>arr[0]>>arr[1]>>arr[2];
sort(arr,arr+3);
cout<<arr[0]+arr[1]<<endl;
}



Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    W, H, N = map(int, input().split())
    X = Y = 0
    for i in range(N):
        x, y, a = map(int, input().split())
        if a == 1:
            X = max(X, x)
        elif a == 2:
            W = min(W, x)
        elif a == 3:
            Y = max(Y, y)
        else:
            H = min(H, y)
    print(max(W - X, 0) * max(H - Y, 0))


main()


Measured memory_bytes: 9104
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

struct edge {ll to, w;};

int main(){
    ll N; cin >> N;
    vector<edge> ed[N];
    REP(i, N-1){
        ll u, v, w; cin >> u >> v >> w; u--; v--;
        ed[u].pb({v,w}); ed[v].pb({u,w});
    }
    
    queue<PL> que;
    que.push({0,0});
    vl col(N, LINF); col[0] = 0;
    while(!que.empty()){
        auto tmp = que.front(); que.pop();
        ll now_p = tmp.ff, now_c = tmp.ss;
        for(auto e : ed[now_p]){
            if(col[e.to] != LINF) continue;
            if(e.w%2 == 0){
                col[e.to] = now_c;
                que.push({e.to, now_c});
            }
            else{
                col[e.to] = 1-now_c;
                que.push({e.to, 1-now_c});
            }
        }
    }
    REP(i, N) cout << col[i] << endstr;
    return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int ans=0, N;
	vector<int> V;
	scanf("%d", &N);
	for(int n=0; n<2*N; n++)
	{
		int L;
		scanf("%d", &L);
		V.push_back(L);
	}
	sort(V.begin(), V.end());
	for(int n=0; n<N; n++)
	{
		ans+=V[2*n];
	}
	printf("%d\n", ans);
}

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

int main(void){
    long long a, b, x;
    cin >> a >> b >> x;
    if(a > 0){
        cout << b / x - (a - 1) / x << endl;
    } else {
        cout << (b / x) + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, h, w);
  vector<string> vs(h);
  for (auto& e : vs) cin >> e;

  for (auto e : vs) {
    cout << e << endl;
    cout << e << endl;
  }

  return 0;
}

Measured memory_bytes: 256
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!();
    let k = get!();
    
    let mut ans = 0;
    for a in 1..n+1 {
    	let am = a % k;
        let xk = k - am;
        if (xk * 2) % k != 0 {
        	continue;
        }
        if n % k < xk {
        	let n = n - n % k - am;
            let p = (n + k - 1) / k;
            ans += p * p;
        } else {
        	let n = n - n % k + xk;
            let p = (n + k - 1) / k;
            ans += p * p;
        }
    }
    
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()
#define alln(a, n) a, a+n 

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	ini(n); ini(h); ini(w);
	outn((n-h+1)*(n-w+1));
		
	return 0;
}


Measured memory_bytes: 256
n, *a = map(int, open(0).read().split())
half_a = sum(a)//2
tmp = 0
for i in range(n):
    if tmp + a[i] >= half_a:
        ans1 = abs(tmp + a[i] - half_a) + abs(sum(a[i+1:]) - half_a)
        ans2 = abs(tmp - half_a) + abs(sum(a[i:]) - half_a)
        ans = min(ans1, ans2)
        break
    tmp += a[i]
print(ans)

Measured memory_bytes: 25212
while True:
    try:
        a,b,c,d,e,f = map(int, input().split())
    except EOFError:
        break
    x = c/a - (b/a) * (a*f-c*d) / (a*e-b*d)
    y = (f*a - c*d) / (e*a - b*d)
    print('{:.3f} {:.3f}'.format(x, y))

Measured memory_bytes: 7568
#include<stdio.h>
int main(void){
  int a,b,c,ans;
  scanf("%d %d %d",&a,&b,&c);
  a = a - b;
  ans = c - a;
  if (ans<=0){
      printf("0\n");
  }
  else{
      printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <limits.h>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    if (a > b) a = b;
    if (c > d) c = d;
    cout << a + c;
    return 0;
}

Measured memory_bytes: 256
from pprint import pprint
from collections import deque

h,w=map(int,input().split())
ch,cw=map(int,input().split())
ch-=1;cw-=1
dh,dw=map(int,input().split())
dh-=1;dw-=1

INF=float("inf")

maze=[input() for _ in range(h)]
dist=[[INF]*w for _ in range(h)]

q=deque()
p=[]
q.append((ch,cw))
dist[ch][cw]=0
cur=0

while q:
    while q:
        x,y=q.popleft()
        # (x,y)は到達訪問済み
        d=dist[x][y]
        for i in range(-2,3):
            for j in range(-2,3):
                # absの和が1、上下左右
                if abs(i)+abs(j)==1:
                    xx=x+i
                    yy=y+j
                    # 範囲内の時
                    if 0<=xx<=h-1 and 0<=yy<=w-1:
                        # 道のとき
                        if maze[xx][yy]==".":
                            # 未到達の時
                            # ※非ワープで未到達
                            if dist[xx][yy]>d:
                                # 移動前のdist[x][y]と同じコスト
                                dist[xx][yy]=d
                                q.append((xx,yy))
                # ワープ
                if abs(i)+abs(j)>=2:
                    xx=x+i
                    yy=y+j
                    # 範囲内の時
                    if 0<=xx<=h-1 and 0<=yy<=w-1:
                        # 道のとき
                        if maze[xx][yy]==".":
                            # 未到達の時
                            if dist[xx][yy]>d+1:
                                # ワープを使うと
                                # 移動前+1する
                                dist[xx][yy]=d+1
                                p.append((xx,yy))

    cur+=1
    q=deque(p)
    p=[]


ans=dist[dh][dw]
if ans==INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 99980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }

int main(){
    ll N;
    cin >> N;
    vector<ll> a;
    REP(i, N) {
        ll n;
        cin >> n;
        if (n%2==0) a.push_back(n);
    }
    ll sum = 0;
    REP(i, a.size()) {
        ll c = 0;
        ll n = a[i];
        while (n%2==0) {
            n /= 2;
            c++;
        }
        sum += c;
    }
    cout << sum << "\n";
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
int nowG=0;
int nowP=0;
int point=0;
string s;
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>s;
    for (int i = 0; i < s.length(); ++i) {
        if(s[i]=='g'){
            if(nowP<nowG){
                nowP++;
                point++;
            }else{
                nowG++;
            }
        }else{
            if(nowP<nowG) {
                nowP++;
            }else{
                nowG++;
                point--;
            }
        }
    }
    cout<<point<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define emb emplace_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define N  999999
#define f first 
#define em emplace
#define s second
#define lint long long int 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<lint> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

 
#define fori(n) for(int i=0; i<int(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) lint i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
#define z 1000000007 
 int arr[N];
 vector<int>v;
 
 
int  solve(int l,int r){

    
      if(arr[l]!=-1) return arr[l];
     else if(l==r-1) {arr[l]= abs(v[l]-v[r]);
        return arr[l];}
     else if(l==r) {arr[l]=0; return arr[l];}
     else if(l>r) return 100000;


 return arr[l]=min(

    abs(v[l]-v[l+1])+solve(l+1,r),

    abs(v[l+2]-v[l])+solve(l+2,r)

    );
  
 
}
   
   

 
 
int main()
{ 
  fast;
 /* #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("hex.txt","w",stdout);
  #endif*/
 
 memset(arr,-1,sizeof(arr));
 cini(n);
 fori(n){
    cini(a);
    v.pb(a);
 }  
 
  int min=solve(0,n-1);

cout<<min<<endl;

 }

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<int MOD> struct modnum {
    int v;
    modnum() : v(0) {}
    modnum(ll _v) : v(_v % MOD) { if (v < 0) v += MOD; }
    explicit operator int() const { return v; }
    friend ostream& operator << (ostream& o, const modnum& n) { return o << n.v; }
    friend istream& operator << (istream& i, modnum& n) { ll v; i >> v; n = modnum(v); return i; }

    friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
    friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

    modnum& operator += (const modnum& o) { v += o.v; if (v >= MOD) v -= MOD; return *this; }
    modnum& operator -= (const modnum& o) { v -= o.v; if (v < 0) v += MOD; return *this; }
    modnum& operator *= (const modnum& o) { v = int(ll(v) * ll(o.v) % MOD); return *this; }
    modnum operator - () { modnum res; if (v) res.v = MOD - v; return res; }
    friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
    friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
    friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }

    modnum pow(int e) const {
        if (e == 0) return 1;
        if (e & 1) return *this * this->pow(e-1);
        return (*this * *this).pow(e/2);
    }

    /* requires prime MOD */
    modnum& operator /= (const modnum& o) { return (*this) *= o.pow(MOD - 2); }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= modnum(b); }
};
using mn = modnum<1000000007>;

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

    int N;
    cin >> N;

    vi loc(N);
    int inx = 1;
    mn ans = 1;

    for (int i = 0; i < N; i++) {
        cin >> loc[i];
        while (loc[i] < inx) {
            ans *= (inx + 1) / 2;
            inx -= 2;
        }
        inx += 2;
    }

    inx -= 2;
    while (inx > 1) {
        ans *= (inx + 1) / 2;
        inx -= 2;
    }

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



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

int main() {
    int n, m; int ac = 0; int wa = 0;
    cin >> n >> m;
    vector<int> acmemo(n+1);
    vector<int> wamemo(n+1);
    int p; string s;

    for (int i = 0; i < m; i++) {
        cin >> p >> s;
        if (acmemo.at(p)) continue;
        if (s == "AC") {
            ac++;
            acmemo.at(p) = 1;
            wa += wamemo.at(p);
        } else wamemo.at(p)++;
    }
    cout << ac << " " << wa << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
   long long int i,num=0,n,m,a[100002];
    cin>>n;
    for(i=n-1; i>=0; i--)
        cin>>a[i];
    int flag=0,p=0;
    while(num+1<n)
    {
        if(a[num]<a[num+1])
            p+=(a[num+1]-a[num]);
        else if(a[num]>a[num+1])
            p=0;
        num++;
        if(p>=2)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<"No";
    else
        cout<<"Yes";
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define db double
struct point{
    db x,y;
    point(){}
    point(db x,db y):x(x),y(y){}
    point operator + (point B){ return point(x+B.x,y+B.y); }
    point operator - (point B){ return point(x-B.x,y-B.y); }
    point operator * (db k){ return point(k*x,k*y); }
    db operator * (point B){ return x*B.y-y*B.x; }
    db operator ^ (point B){ return x*B.x+y*B.y; }
    bool operator < (point B){ return (y>0)!=(B.y>0)?y>0:((*this)*B)>0; }
};
db dis2(point A,point B){ return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y); }
struct line{
    point A,B;
    line(){}
    line(point A,point B):A(A),B(B){}
};
point projection(line l,point P){
    point dir=l.B-l.A; P=P-l.A;
    return dir*((P^dir)/dis2(l.A,l.B))+l.A;
}
point reflection(line l,point P){
    return projection(l,P)*2-P;
}
int main(){
    db x1,y1,x2,y2; scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    line l(point(x1,y1),point(x2,y2));
    int q; scanf("%d",&q);
    while (q--){
        db x,y; scanf("%lf%lf",&x,&y);
        point refl=reflection(l,point(x,y));
        printf("%.9f %.9f\n",refl.x,refl.y);
    }
}



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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int N;
vector<vector<int>> E;

ll dp[100000][2];//dp[i][j]:= 頂点iにいるとき、色jである場合の数。　j := falseなら白　trueなら黒
void dfs_memo(int pos, int par) {

	dp[pos][0] = 1, dp[pos][1] = 1;
	for (int i = 0; i < E[pos].size(); i++) {
		int next = E[pos][i];
		if (next != par) {
			
			dfs_memo(next, pos);
			
			//白なら
			dp[pos][0] *= (dp[next][0] + dp[next][1]);
			dp[pos][0] %= MOD;
			//黒なら
			dp[pos][1] *= dp[next][0];
			dp[pos][1] %= MOD;
		}
	}
}

int main() {
	cin >> N;
	E.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		E[a].push_back(b), E[b].push_back(a);
	}
	dfs_memo(0, -1);//初期条件で頂点0から始めるけど、その時には親が存在しないので-1
	//親に戻らないように探索をすれば、木なので重複なく全域にいきわたることが可能

	cout << (dp[0][0] + dp[0][1]) % MOD << endl;

	return 0;
}

Measured memory_bytes: 14208
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a + b == 15){
        cout << '+' << endl;
    }else if(a * b == 15){
        cout << '*' << endl;    
    }else{
        cout << 'x' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	int N, M, X, i, j;
	scanf("%d %d %d", &N, &M, &X);

	int c1 = 0, c2 = 0;
	for (i = 1; i <= M; i++) {
		scanf("%d", &j);
		if (j < X) c1++;
		else c2++;
	}
	return !printf("%d\n", min(c1, c2));
}

Measured memory_bytes: 256
import re
A = ">'=+#=+~$"
B = ">\^(Q=)+~~$"
n = int(input())
for i in range(n):
    s = input()
    if re.match(A,s):
        a, b = re.match(A,s).group().split("#")
        print("A" if a.count("=") == b.count("=") else "NA")
    elif re.match(B,s):
        print("B")    
    else:
        print("NA")


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

int main() {

  int64_t n;
  cin>>n;

  vector<int64_t> A(n);
  for(int i=0;i<n;i++){
    cin>>A.at(i);
  }

  sort(A.begin(),A.end());

  cout<<A.back()-A.front()<<endl;

  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,n) for(int i = a; i < n; i++)
typedef long long ll;




/*
// s1の(i-1)文字目までの文字列に1文字追加する場合
dp[i][j] = dp[i-1][j] + 1;
//s1のj文字目を削除する場合
dp[i][j] = dp[i][j-1] + 1;
// s1のi文字目とs2のj文字目が同じ文字になるように置換する場合
dp[i][j] = dp[i-1][j-1] + cost;
// -> i文字目とj文字目が等しければコストはかからない
cost = (s[i-1] == t[j-1]) ? 0 : 1;
*/
// cost[0] : 追加
// coat[1] : 削除
// cost[2] : 置き換え
// cost[3] : 先頭から末尾へ

string s,t;

ll cost[4];
const ll INF = 1e16;
void solve(){

  ll n = s.size() ,m = t.size();
  ll dp[s.size()+1][t.size()+1];

  ll ans = INF;
  ll c;
  rep(k,n){ // k回 末尾移動操作をした
    /* dpテーブル初期化 */
    rep(i,n+1) rep(j,m+1) dp[i][j] = INF;
    dp[0][0] = 0;

    /* dpテーブル埋め(貰うDP) */
    rep(i, n+1) rep(j, m+1) {
      // 追加する場合
      if(j > 0) dp[i][j] = min(dp[i][j], dp[i][j-1] + cost[0]);

      // 削除する場合
      if(i > 0){
        c = (n-k < i) ? cost[3] : 0;
        dp[i][j] = min(dp[i][j], dp[i-1][j] + cost[1] - c);
      }

      // 置き換える場合
      if(i > 0 && j > 0){
        c = (s[i-1] == t[j-1]) ? 0 : cost[2];
        dp[i][j] = min(dp[i][j], dp[i-1][j-1] + c);
      }

    }

    ans = min(ans,dp[n][m] + cost[3] * k);
    // スワップ回数
    s += s[0];
    s.erase(s.begin());
  }
  cout << ans << endl;
}

int main(){

  while(true){
    cin >> s;
    if(s == "#") break;
    cin >> t;
    rep(i,4) cin >> cost[i];
    solve();
    s.clear();
    t.clear();
  }
  return 0;
}



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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    ll n;
    cin >> n;
    ll start = static_cast<ll>(ceil(sqrt(static_cast<double>(n))));
    for (ll i=start; i>=1; i--) {
        if (n%i == 0) {
            cout << i+(n/i)-2 << endl;
            break;
        }
    }
    return 0;
}




Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

x = onem()

po = [0,1]

for i in range(1,10**3+1):
    po.append((i+1)**5)

a,b = 0,0
for i in range(10**3+2):
    for j in range(10**3+2):
        if po[i] - po[j] == x:
            a = i
            b = j
            break
        elif po[i] + po[j] == x:
            a = i
            b = -j
            break
    else:
        continue
    break

print(a,b)

Measured memory_bytes: 67832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

vector<int> ki[100005];
int n;

vector<int> dist;
void dfs(int v, int d = 0, int p = -1) {
  dist[v] = d;
  for (int u : ki[v]) {
    if (u == p) continue;
    dfs(u, d + 1, v);
  }
}
vector<int> calcDist(int s) {
  dist = vector<int>(n);
  dfs(s);
  return dist;
}

int main() {
  int v, u;
  cin >> n >> v >> u;
  // vector<int> ki[n];
  v--;
  u--;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ki[a].push_back(b);
    ki[b].push_back(a);
  }
  vector<int> distV = calcDist(v);
  vector<int> distU = calcDist(u);

  int mx = 0;
  rep(i, n) {
    if (distV[i] < distU[i]) mx = max(mx, distU[i]);
  }
  cout << mx - 1 << endl;
  return 0;
}

Measured memory_bytes: 10744
def main():
    N = int(input())
    A = [input() for i in range(N)]
    M = int(input())
    B = [input() for i in range(M)]
    ans = 0
    from collections import Counter
    S = Counter(A)
    T = Counter(B)
    for k, v in S.items():
        ans = max(ans, v - T[k])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<stdio.h>
int main(){
   int n,m;
   scanf("%d%d",&n,&m);
   int count=0;
   if(n>1){
      count=n*(n-1)/2;
   }
   if(m>1){
      count=count+m*(m-1)/2;
   }
   printf("%d",count);
   return 0;
}


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

int main(void)
{
  int a;
  cin>>a;
  string c;
  if(a>=1000)
  {
    a+=1;
    c+="ABD";
  }
  else
  {
    c+="ABC";
  }
  cout<<c;

}


Measured memory_bytes: 256
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = 0

for i in range(n+1):
    for j in range(n+1):
        num = i + j
        if num > n or num > k: continue
        item = v[:i] + v[n-j:]
        item.sort()
        rem = k - num
        s = sum(item)
        for x in item:
            if x >= 0: break
            if rem:
                s -= x
                rem -= 1
            else: break
        ans = max(ans, s)

print(ans)


Measured memory_bytes: 3064
// from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};
#[allow(unused_imports)]
use std::mem::swap;

#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    let t = readl!(usize);
    if t == 1 {
        printfln!("Hello World");
    } else {
        let a = readl!(usize);
        let b = readl!(usize);
        printfln!("{}", a+b);
    }
}


Measured memory_bytes: 4352
x,y=map(int,input().split())
c=0
d=0
if x==1:
    c=300000
elif x==2:
    c=200000
elif x==3:
    c=100000
if y==1:
    d=300000
elif y==2:
    d=200000
elif y==3:
    d=100000
print(c+d if c+d!=600000 else 1000000)

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int k=Integer.parseInt(str[0]);
        int s=Integer.parseInt(str[1]);
        
        int result=0;
        
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        }
        
        System.out.println(result);
    }
}


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

#define fo(i,n)         for(int i=0;i<n;i++)
#define fo2(i,n)        for(int i=n-1;i>=0;i--)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll              long long
#define si(x)	        scanf("%d",&x)
#define sl(x)	        scanf("%lld",&x)
#define ss(s)	        scanf("%s",s)
#define pi(x)	        printf("%d\n",x)
#define pi2(x)          printf("%d ",x)
#define pl(x)	        printf("%lld\n",x)
#define pl2(x)          printf("%lld ",x)
#define ps(s)	        printf("%s\n",s)
#define pn              printf("\n")
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl
#define pb              push_back
#define F               first
#define S               second
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it, a)       for(auto it = a.begin(); it != a.end(); it++)
#define PI              3.1415926535897932384626

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vpl;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

/*int mpow(int base, int exp);
ll binpow(ll base , ll exp);
void ipgraph(int n, int m);
void dfs(int u);*/

const int mod = 1000000007;
const int N = 3e5+5, M = N;

//vi g[N];
//bool vis[N];

bool ok[1000005];


void solve()
{
    ll n, m, res=0;

    sl(n) ; sl(m);

    ll ar[n];

    fo(i,n) sl(ar[i]);

    sort(ar,ar+n);

    fo(i,m) res += ar[i];

    pl(res);

}


int main()
{
    int t = 1;

    //si(t);

    while(t--)
    {
        solve();
    }

    return 0;
}






















/*void dfs(int u) //DFS
{
    vis[u] = 1;

	for(int v:g[u])
    {
		if (!vis[v])
           dfs(v);
	}

	vis[u] = 0;
}

void ipgraph(int n, int m) //GRAPH INPUT
{
	int i, u, v;

	while(m--)
    {
		si(u); si(v);
		g[u].pb(v);
		g[v].pb(u);
	}
}



ll binpow(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp & 1)
            res = res * base;
        base = base * base;
        exp >>= 1;
    }
    return res;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
       if (exp & 1) result = ((ll)result * base) % mod;
       base = ((ll)base * base) % mod;
       exp >>= 1;
    }
    return result;
}
*/






//    #include <chrono>
//    using namespace std::chrono;
//    auto start = high_resolution_clock::now();
//    auto stop = high_resolution_clock::now();
//    auto duration = duration_cast<milliseconds>(stop - start);
//    cout << duration.count() << endl;
//#ifdef _DEBUG
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif




Measured memory_bytes: 3816
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            if len(phU) == 2 : break
            else :
                if isCLKWISE(phU) : break

    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            if len(phL) == 2 : break
            else :
                if isCLKWISE(phL) : break

                
                
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33748
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    vector<int> color{399,799,1199,1599,1999,2399,2799,3199,4800};
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int sum=0;
    int ans=0;
    rep(i,9){
        if(i!=8){
        if(sum<n&&a[sum]<=color[i])ans++;
        while(sum<n&&a[sum]<=color[i]){
            sum++;
        }
        }
        else {
            sum=n-sum;
        }
   }
        cout<<max(ans,1)<<" "<<sum+ans<<endl;
    return 0;
}




Measured memory_bytes: 256