akhauriyash/Code-Regression huggingface dataset:
/*
author : seryu
title : ABC171E_"Red Scarf"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	rep(i, n)
	{
		cin >> a[i];
		sum ^= a[i];
	}
	rep(i, n)
	{
		int ans = sum ^ a[i];
		cout << ans << " ";
	}
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 4660
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	
	int a;
	int maxa = 0, mina = pow(10,9);
	//std::cout << maxa << std::endl;
	//std::cout << mina << std::endl;
	for (int i = 0; i < n; i++) {
	    std::cin >> a;
	    maxa = max(maxa,a);
	    mina = min(mina,a);
	}
	
	std::cout << abs(maxa - mina) << std::endl;
	return 0;
}

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

using namespace std;

bool check(vector<int> vi,int m,int mid){
	int buf=0;
	int use=0;
	for(int i=0;i<vi.size();i++){
		if(buf+vi[i] > mid){
			if(buf == 0){
				return false;
			}
			use++;
			buf=0;
			i--;
			continue;
		}
		buf += vi[i];
	}
	if(buf != 0){
		use++;
	}
	if(use <= m){
		return true;
	}else{
		return false;
	}

}

int main(){
	while(true){
		int m,n;
		cin >> m >> n;
		if(m==0){
			break;
		}

		vector<int> vi;
		int l=INT_MAX,u=1500001;
		for(int i=0;i<n;i++){
			int buf;
			cin >> buf;
			l = min(l,buf);
			vi.push_back(buf);
		}

		for(int i=0;i<100;i++){
			int mid = (l+u)/2;
			if(check(vi,m,mid)){
				u = mid;
			}else{
				l = mid+1;
			}
		}
		cout << ((l+u)/2) << endl;
	}
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define DBG 0
#define BUFSIZE 40

static short h[6];

// return 0 : EOF
//        1 : read success
int getSimEq() {
  char buf[BUFSIZE] = {0};
  char *p;
  int i, j;
  if (NULL == fgets(buf, BUFSIZE, stdin)) {
    if (DBG) {
      fprintf (stderr, "EOF\n");
    }
    return 0;
  }
  buf[strlen(buf)-1] = 0;
  if (DBG) {
    fprintf(stderr, "input=%s\n", buf);
  }
  for (i=0, j=0, p = buf; j<6; j++, p = p+strlen(p)+1) {
    for (; buf[i] != ' ' && i<BUFSIZE; i++);
    buf[i] = 0;
    h[j] = atoi(p);
  }
  if (DBG) {
    fprintf(stderr, "h[*] =%d %d %d %d %d %d\n", h[0], h[1], h[2], h[3], h[4], h[5]);
  }
  return 1;
}

int main (void) {
  float x, y, detr;
  while (getSimEq()) {
    // (h[0], h[1]) (x) = (h[2])
    // (h[3], h[4]) (y)   (h[5])
    // (x) = 1/(h[0]*h[4]-h[1]*h[3]) (h[4], -h[1]) (h[2])
    // (y)                           (-h[3], h[0]) (h[5])
    // (x) = 1/(h[0]*h[4]-h[1]*h[3]) * ( h[4]*h[2] - h[1]*h[5])
    // (y) = 1/(h[0]*h[4]-h[1]*h[3]) * (-h[3]*h[2] + h[0]*h[5])
    detr = 1.0/(h[0]*h[4]-h[1]*h[3]);
    x = detr * ( h[4]*h[2] - h[1]*h[5]);
    y = detr * (-h[3]*h[2] + h[0]*h[5]);
    // for negative 0
    if (x == 0) x = 0;
    if (y == 0) y = 0;
    printf ("%.3f %.3f\n", x, y);
    if (DBG) {
      fprintf (stderr, "%f %f\n", x, y);
    }
  }
  return 0;
}

Measured memory_bytes: 580
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
class BIT
{
public:
	LL a[N];
	void add(int x, int val)
	{
		while (x < N)
		{
			a[x] += val;
			x += x & -x;
		}
	}
	LL sum(int x)
	{
		LL ret = 0;
		while (x)
		{
			ret += a[x];
			x -= x & -x;
		}
		return ret;
	}
} b1, b2;
vector<pair<int, int>> vp;
struct Node
{
	int op, a, b;
	void init()
	{
		scanf("%d", &op);
		if (op == 1) scanf("%d%d", &a, &b);
	}
}qr[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int q;
	scanf("%d", &q);
	for (int i = 1; i <= q; i++)
	{
		qr[i].init();
		if (qr[i].op == 1)
			vp.emplace_back(qr[i].a, i);
	}
	sort(vp.begin(), vp.end());
	LL sumb = 0;
	for (int i = 1; i <= q; i++)
	{
		if (qr[i].op == 1)
		{
			sumb += qr[i].b;
			int pos = lower_bound(vp.begin(), vp.end(), make_pair(qr[i].a, i)) - vp.begin() + 1;
			b1.add(pos, 1);
			b2.add(pos, qr[i].a);
		}
		else
		{
			int tot = b1.sum(N - 1);
			int key = (tot + 1) / 2;
			if (key == 0)
			{
				puts("0");
				continue;
			}
			int l = 1, r = N - 1;
			int pos = 0;
			while (l <= r)
			{
				int mid = (l + r) / 2;
				if (b1.sum(mid) >= key) pos = mid, r = mid - 1;
				else l = mid + 1;
			}
			LL ans = 0;
			if (tot % 2 == 0) ans = b2.sum(N - 1) - 2 * b2.sum(pos);
			else ans = b2.sum(N - 1) - b2.sum(pos - 1) - b2.sum(pos);
			printf("%d %lld\n", vp[pos - 1].first, ans + sumb);
		}
	}
	return 0;
}

Measured memory_bytes: 8436
package main

import  "fmt"

func min(x, y int) int{
    if x < y {
        return x
    } else {
        return y
    }
}

func abs(x, y int) int{
    if x < y {
        return y-x;
    } else {
        return x-y;
    }
}

func gcd(x, y int) int{
    for{
        if x == y {
            return x
        }
        z := abs(x, y)
        x = min(x, y)
        y = z
    }
}

func main(){
    var x, y int
    fmt.Scanln(&x, &y)
    fmt.Println(gcd(x,y))
}


Measured memory_bytes: 1156
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll K = 0;
	ll Y = 0;
	ll X = 0;
	ll m[100000] = {};
	ll p[100] = {};
	ll x[100] = {};
	//ll *x, *c, *d;
	string S;
	ll count = 0;
	ll sum = 0;
	ll min = 1000;
	ll i = 0;
	//char p;
	cin >> N;
	
	rep(i, 1, N+1) {
		cin >> m[i];
	}
	cin >> A;

	rep(j, 1, A+1) {
		cin >> p[j] >> x[j];
	}
	

	rep(k, 1, A+1) {
		rep(j, 1, N+1) {

			if (j == p[k]) {
				sum += x[k];
			}
			else {
				sum += m[j];
			}
			//cout << sum << endl;
		}
		cout << sum << endl;
		sum = 0;

	}
	return 0;

}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Lesen std::ios::sync_with_stdio(false);std::cin.tie(0);

int N, M, maxi = 0;
map <int, int> mp;

void solve(void){
	//Lesen;
	cin >> N;
	rep(N, i) {
		int d;
		scanf("%d\n", &d);
		mp[d] = mp[d-1]+1;
		maxi = max(maxi, mp[d]);
	}
	printf("%d\n", N - maxi);
}

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


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  string S;
  cin >> S;
  int N = S.length();
  if (S[N-1] != 's') cout << S + "s" << endl;
  else cout << S + "es" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	n++;
	vector<bool> s;
	while (n > 2) {
		if (n & 1) {
			s.pb(true);
			n--;
		}
		else {
			s.pb(false);
			n >>= 1;
		}
	}
	vector<int> l, r;
	int cnt = 1;
	r.pb(cnt);
	int k = s.size();
	for (int i = k - 1; i >= 0; i--) {
		cnt++;
		if (s[i]) l.pb(cnt);
		else r.pb(cnt);
	}
	cout << 2 * cnt << endl;
	rep(i, k + 1) cout << i + 1 << ' ';
	if (l.size()) for (int i = l.size() - 1; i >= 0; i--) cout << l[i] << ' ';
	rep(i, r.size()) cout << r[i] << ' ';
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323


void solve()
{
       ll n, k;
       cin>>n>>k;
       cout<<n-k+1<<endl;
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
     
    using namespace std;
     
    int main() {
    	long long n;
    	long long a, b, c, d, e;
    	cin >> n;
    	cin >> a >> b >> c >> d >> e;
    	cout << (n - 1) / min({ a,b,c,d,e }) + 5 << endl;
    }

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    string O, E;
    cin >> O >> E;
    REP(i, E.length()){
        cout << O[i] << E[i];
    }
    if(E.length()!=O.length()){
        cout << O[O.length()-1];
    }
    cout << el;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define INF 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int main(){
  int a,b,c,d,k;
  cin >> a >> b >> c >> d >> k;
  int A = a * 60 + b,B = c * 60 + d;
  B -= k;
  cout << max(0,B - A) << endl;
  return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
#define ALL(a)  (a).begin(),(a).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=c;
    ans=min(b/a,c);
    cout<<ans<<endl;
    
    
    
    return 0;
}


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

using namespace std;

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

  vector<string> s;
  int ans = 0;
  for(int i=0; i<n; i++){
    cin.ignore(); //改行を無視する
    string temp;
    cin >> temp;
    s.push_back(temp);
    for(int j=0; j<temp.size()-1; j++){
      if(temp.at(j) == 'A' && temp.at(j+1) == 'B') ans++;
    }
  }

  int b_a_count = 0;
  int b___count = 0;
  int __a_count = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i].front() == 'B' && s[i].back() == 'A') b_a_count++;
    if(s[i].front() == 'B' && s[i].back() != 'A') b___count++;
    if(s[i].front() != 'B' && s[i].back() == 'A') __a_count++;
  }

  if(b___count == __a_count && __a_count == 0){
    ans += ( b_a_count == 0 )? 0 : b_a_count - 1;
  }else{
    ans += ( b___count < __a_count )? b_a_count + b___count : b_a_count + __a_count;
  }

  cout << ans;


  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> R(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    R.at(a - 1)++;
    R.at(b - 1)++;
  }
  
  for (int i = 0; i < N; i++) {
    cout << R.at(i) << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
n,*a=map(int,open(0).read().split())
r=1
for k,v in Counter(a).items():
	if (n+k)%2 and v==2:
		r*=2
	elif n%2 and k==0 and v==1:
		pass
	else:
		r=0
		break
print(r%(10**9+7))

Measured memory_bytes: 14196
#include<iostream>
using namespace std;
//Minimum Cost Flow O(FE log V)
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<limits>
template<typename T>
struct MCF{
	struct edge{
		int to,rev,cap;
		T cost;
	};
	vector<vector<edge> >G;
	vector<T>h,d;
	vector<int>pv,pe;
	MCF(int n_=0):G(n_),h(n_,0),d(n_),pv(n_),pe(n_){}
	void add_edge(int from,int to,int cap,T cost)
	{
		G[from].push_back({to,(int)G[to].size(),cap,cost});
		G[to].push_back({from,(int)G[from].size()-1,0,-cost});
	}
	T min_cost_flow(int s,int t,int f)//ans or -1
	{
		T ret=0;
		while(f>0)
		{
			priority_queue<pair<T,int>,vector<pair<T,int> >,greater<pair<T,int> > >P;
			fill(d.begin(),d.end(),numeric_limits<T>::max());
			d[s]=0;
			P.push(make_pair(0,s));
			while(!P.empty())
			{
				pair<T,int>p=P.top();P.pop();
				if(d[p.second]<p.first)continue;
				for(int i=0;i<G[p.second].size();i++)
				{
					edge&e=G[p.second][i];
					if(e.cap>0&&d[e.to]>d[p.second]+e.cost+h[p.second]-h[e.to])
					{
						d[e.to]=d[p.second]+e.cost+h[p.second]-h[e.to];
						pv[e.to]=p.second;
						pe[e.to]=i;
						P.push(make_pair(d[e.to],e.to));
					}
				}
			}
			if(d[t]==numeric_limits<T>::max())return -1;
			for(int u=0;u<G.size();u++)h[u]+=d[u];
			int d=f;
			for(int u=t;u!=s;u=pv[u])d=min(d,G[pv[u]][pe[u]].cap);
			f-=d;
			ret+=d*h[t];
			for(int u=t;u!=s;u=pv[u])
			{
				G[pv[u]][pe[u]].cap-=d;
				G[u][G[pv[u]][pe[u]].rev].cap+=d;
			}
		}
		return ret;
	}
};
int N,K;
int A[50][50];
string S[50];
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>A[i][j];
	MCF<long>P(2*N+2);
	int s=2*N,t=2*N+1;
	const long inf=1e9;
	for(int i=0;i<N;i++)
	{
		P.add_edge(s,i,K,0);
		P.add_edge(i,t,K,inf);
	}
	for(int j=0;j<N;j++)P.add_edge(N+j,t,K,0);
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)
	{
		P.add_edge(i,N+j,1,inf-A[i][j]);
	}
	cout<<inf*N*K-P.min_cost_flow(s,t,N*K)<<endl;
	for(int i=0;i<N;i++)
	{
		S[i]=string(N,'.');
		for(int j=0;j<P.G[i].size();j++)
		{
			int v=P.G[i][j].to-N;
			if(0<=v&&v<N)
			{
				S[i][v]=P.G[i][j].cap==0?'X':'.';
			}
		}
		cout<<S[i]<<endl;
	}
}


Measured memory_bytes: 3852
#include <stdio.h>

int main(void)
{
  int h, a;
  scanf("%d %d", &h, &a);
  if (h % a != 0)
  {
    printf("%d", h / a + 1);
  }
  else
  {
    printf("%d", h / a);
  }
  return 0;
}


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

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<pii>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


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


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int val=__gcd(i,j);
                val=__gcd(val,k);
                ans+=val;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void){

    ll n;
    cin>>n;
    vector<string> s(n);
    ll count = 0;
    int a_end = 0;
    int b_start = 0;
    int co = 0;

    for(int i=0;i<n;i++){
        string x;
        cin>>x;
        s[i] = x;
        for(int j=0;j<s[i].size()-1;j++){
            if(x[j]=='A' && x[j+1] == 'B'){
                count++;
                //cout<<count<<endl;
            }
        }
        if(x[0] == 'B') b_start++;
        if(x[x.size()-1] == 'A') a_end++;
        if(x[0] == 'B' && x[x.size()-1] == 'A' ) co++;
    }

    if(a_end == 0 && b_start == 0 && count == 0 && co == 0){
        cout<<"0"<<endl;
        return 0;
    }else if(a_end!= 0 && a_end == b_start && a_end == co){
        cout<<co-1+count<<endl;
        return 0;
    }else{
        if(a_end > b_start){
            cout<<b_start+count<<endl;
        }else{
            cout<<a_end+count<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 768
//H->banyak darah
//A->darah berkurang
//berapa kali serang biar mati?

#include <stdio.h>

int main ()
{
	int H;
	int A;
	
	scanf("%d %d", &H, &A);
	
	H % A == 0? printf("%d\n", H/A) : printf("%d\n", H/A+1);
	
	return 0;
}

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

int main(){
  int array[5];
  for(int i = 0;i<3;i++){
    cin >> array[i];
  }
  sort(array,array+3);
    if(array[0] == array[1]){
      cout <<array[2]<<endl;
    }else{
      cout << array[0] <<endl;
    }
}

Measured memory_bytes: 256
#include<iostream> 
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main(){ 
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int N;
	cin>>N;
	vector<int> a(N);
	for(int i=0;i<N;i++){ 
		cin>>a[i]; 
	} 
	vector<ll> sum(N+1,0);
	for(int i=1;i<=N;i++){ 
		sum[i]=sum[i-1]+a[i-1]; 
	} 
	vector<vector<ll>>dp(N,vector<ll>(N,0));
	for(int i=1;i<N;i++){ 
		for(int j=0;j<N-i;j++){ 
			dp[j][j+i]=dp[j][j]+dp[j+1][j+i]+sum[j+1+i]-sum[j+1]+sum[j+1]-sum[j]; 
			for(int k=j+1;k<j+i;k++){ 
				dp[j][j+i]=min(dp[j][j+i],dp[j][k]+sum[k+1]-sum[j]+dp[k+1][j+i]+sum[j+i+1]-sum[k+1]);
			} 
		} 
	}
	cout<<dp[0][N-1]; 




	
	return 0;
} 



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr array<int, 4> dx = {1, 0, -1, 0};
constexpr array<int, 4> dy = {0, 1, 0, -1};
constexpr int MOD = 100000000 + 7;

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

    int a, b;
    cin >> a >> b;
    int ab = a * b;

    cout << (a < 10 && b < 10 ? ab : -1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,count=0;
    cin>>n;
    string str;
    cin>>str;
    for (i=0;i<n-2;i++)
    {
        for (j=i+1;j<n-1;j++)
        {
            if (str[i]=='A' && str[j]=='B' && str[j+1]=='C')
                count++;
            else
                break;   
            
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
MOD=10**9+7
class Fp(int):
    def __new__(self,x=0):return super().__new__(self,x%MOD)
    def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
    def __add__(self,value):return self.__class__(super().__add__(value))
    def __sub__(self,value):return self.__class__(super().__sub__(value))
    def __mul__(self,value):return self.__class__(super().__mul__(value))
    def __floordiv__(self,value):return self.__class__(self*self.__class__(value).inv())
    def __pow__(self,value):return self.__class__(super().__pow__(value%(MOD-1), MOD))
    __radd__=__add__
    __rmul__=__mul__
    def __rsub__(self,value):return self.__class__(-super().__sub__(value))
    def __rfloordiv__(self,value):return self.__class__(self.inv()*value)
    def __iadd__(self,value):self=self+value;return self
    def __isub__(self,value):self=self-value;return self
    def __imul__(self,value):self=self*value;return self
    def __ifloordiv__(self,value):self=self//value;return self
    def __ipow__(self,value):self=self**value;return self
    def __neg__(self):return self.__class__(super().__neg__())

import sys
sys.stdin.readline

def main():    
    n, m = map(int, input().split())
    X = list(map(int, input().split()))
    Y = list(map(int, input().split()))
    n = Fp(n)
    m = Fp(m)
    print(sum((n - i) * i * (X[i] - X[i-1]) for i in range(1, n)) * sum((m - i) * i * (Y[i] - Y[i-1]) for i in range(1, m)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 19580
#include <bits/stdc++.h>
#define i_love_u_Phuong ios_base::sync_with_stdio(0); cin.tie(0);

using ll = long long;
using namespace std;
using ld = long double;
int mod = 1e9+7;
const int MAXSUM = 40005;
int d[0][2*MAXSUM];




int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif // ONLINE_JUDGE
    i_love_u_Phuong;
    int n,k;
    cin >> n >> k;
    vector<ll> a(n+1);
    vector<ll> b(n+1);
    for(int i=1; i<=n; ++i)
        {
            cin >> a[i];
            b[i]=abs(a[i]);
        }
    int head=1;
    int tail=k;
    ll res=1e9+10;
    while (tail<=n)
    {
        ll ans = (a[head]*a[tail]<0)?(min(b[head],b[tail])*2 + max(b[head],b[tail])):(max(abs(a[head]),abs(a[tail])));
        res=min(res,ans);
        tail++;
        head++;
    }
    cout << res;
    return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 K, N;
	cin >> K >> N;
	vector<int64> A(N), D(N);
  int64 res = INF_LL;
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N-1) {
    res = min(res, K-abs(A[i+1]-A[i]));
  }
  res = min(res, K-abs(K+A[0]-A[N-1]));
  cout << res << endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



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

	if (n % 2 == 1) {
		REP(i, m) {
			cout << i + 1 << ' ' << m * 2 - i << endl;
		}
	}
	else {
		if (m % 2 == 0) {
			REP(i, m / 2) {
				cout << i + 1 << ' ' << m - i << endl;
			}
			REP(i, m / 2) {
				cout << m + 2 + i << ' ' << m * 2 + 2 - i << endl;
			}
		}
		else {
			REP(i, m / 2 + 1) {
				cout << i + 1 << ' ' << m + 1 - i << endl;
			}
			REP(i, m / 2) {
				cout << m + 3 + i << ' ' << m * 2 + 2 - i << endl;
			}

		}
	}
}


Measured memory_bytes: 3640
n,m = gets.split(" ").map(&:to_i)
matrix = n.times.map { gets.split(" ").map(&:to_i) }
vec = m.times.map { gets.to_i }

puts matrix.map {|m| m.zip(vec).inject(0) {|acc, x| acc + x[0] * x[1] } }

Measured memory_bytes: 8936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    N %= 1000;
    
    cout << (N==0?0:1000-N) << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void){
  long long int N,x;
  long long int a[100000]={};
  long long int count=0;
  scanf("%lld %lld", &N, &x);
  for(int i=0; i<N; i++)
    scanf("%lld",&a[i]);
  
  for(int i=0; i<N-1; i++){
    if(a[i]+a[i+1] > x){
      count += a[i] + a[i+1] - x;
      if(x >= a[i]){
        a[i+1] = x - a[i];
      }
      else{
        a[i+1] = 0;
        a[i] = x;
      }
      
    }
  }
  printf("%lld\n",count);
  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


/*
vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}
*/

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

	

int main(){
	ll n,m,a;
	priority_queue<ll> que;
	cin>>n>>m;
	rep(i,0,n)cin>>a,que.push(a);
	rep(i,0,m){
		ll tmp=que.top()/2;
		que.pop();
		que.push(tmp);
	}
	ll ans=0;
	rep(i,0,n){
		ans+=que.top();
		que.pop();
	}
	cout<<ans;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vvl = vector<vl>;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    int n; cin >> n;
    int ans = 0;
    rep(i,n) {
        int a; cin >> a;
        if (i % 2 == 0 and a % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    string T; cin >> T;
    rep(i,SZ(T)){
        if(T[i]=='?') T[i]='D';
    }
    cout << (string)T << endl;
}

Measured memory_bytes: 3736
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll npk(ll n, ll k) {
	ll ret = 1;
	if (n < k || n < 0)return 0;
	rep(i, 0, k) {
		ret *= (n - i);
		ret %= MOD;
	}
	if (ret < 0) ret = 0;
	return ret;
}

//E	
int main(void) {
	ll n, k;
	cin >> n >> k;
	vector<vector<ll>> graph = vector<vector<ll>>(n, vector<ll>());
	rep(i, 0, n - 1) {
		ll a, b;
		cin >> a >> b;
		--a;
		--b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	ll count = k;
	count *= npk(k - 1, graph[0].size());
  	count %= MOD;
	vector<ll> watched = vector<ll>(n, 0);
	watched[0] = 1;
	stack<ll> st = stack<ll>();
	rep(i, 0, graph[0].size()) {
		st.push(graph[0][i]);
		watched[graph[0][i]] = 1;
	}
	while (st.size() > 0) {
		ll v = st.top();
		st.pop();
		ll nVis = 0;
		rep(i, 0, graph[v].size()) {
			ll nbr = graph[v][i];
			if (watched[nbr] == 0) {
				nVis++;
				st.push(nbr);
				watched[nbr] = 1;
			}
		}
		count *= npk(k - 2, nVis);
		count %= MOD;
	}
	cout << count << endl;
}


Measured memory_bytes: 8052
/*
 * @author Dhruvit
 */
#include<cstring>
#include<math.h>
#include<stdlib.h>
#include <fstream>
#include<algorithm>
#include<vector>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
#define vi          vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define pb          push_back
#define pf          push_front
#define all(v)      v.begin(),v.end()
class CSlimes {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;
	    in>>n;
	    string s;
	    in>>s;
	    int len =1;
	    for(int i=1;i<n;i++){
	        if(s[i-1] !=s[i] ){
	            len++;
	        }
	    }
        out<<len;
	}
};


signed main() {
    fast;
	CSlimes solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<string>
using namespace std;
const int N=1000100;
struct node
{
    int l,r;
    double cost;
}p[N];
double  x[N],y[N];
int f[N];
int Find(int x)
{
    if(x==f[x])
        return x;
    else
    {
        f[x]=Find(f[x]);
        return f[x];
    }
}
int merg(int a,int b)
{
    int t1=Find(a);
    int t2=Find(b);
    if(t1!=t2)
    {
        f[t2]=t1;
        return 0;
    }
    return 1;
}
int cmp(node a,node b)
{
    return a.cost>b.cost;//?是从大到小排的
}
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        int i,j;
        for(i=1;i<=n;i++)
        {
            scanf("%lf%lf",&x[i],&y[i]);
        }
        double s=0;
        for(i=0;i<m;i++)
        {
            scanf("%d%d",&p[i].l,&p[i].r);
            int a=p[i].l,b=p[i].r;
            p[i].cost=sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
            s+=p[i].cost;
        }
        for(i=1;i<=n;i++)
        {
            f[i]=i;
        }
        sort(p,p+m,cmp);
        double sum=0;
        for(i=0;i<m;i++)
        {
            if(!merg(p[i].l,p[i].r))
                sum+=p[i].cost;
        }
        printf("%.3lf\n",s-sum);
    }
    return 0;
}

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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	string S, T;
	cin >>S>>T;
	cout << T <<S;
}

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(all(h));
  int ans = MOD;
  for(int i = k-1;i<n;i++){
    //cout << h[i] << "  " << h[i-k+1] << endl;
    ans = min(ans,h[i]-h[i-k+1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void){
  char str[21];
  int i;
  scanf("%20[a-zA-Z0-9]\n",str);
  i = strlen(str);
  while(i--){
    printf("%c", str[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=1000;

ll N,H,W,a[MAX_N],b[MAX_N];

int main(){
  cin>>N>>H>>W;
  ll ans=0;
  for(ll i=0;i<N;i++){
    cin>>a[i]>>b[i];
  }
  for(ll i=0;i<N;i++){
    if(H<=a[i]&&W<=b[i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    int n;
    cin >> n;
    auto a = vector<int>(n);
    for (auto& a_i : a)
        cin >> a_i;

    auto cnt = 0;
    for (auto i = 1; i <= n; ++i) {
        if (i % 2 == 1 && a[i - 1] % 2 == 1)
            cnt++;
    }

    cout << cnt << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int x = in.readInt();
		int y = in.readInt();
		String arr[] = new String[x]; 
		for(int i = 0; i<x ; i++) {
			arr[i] = in.readString();
		}
		for(int i = 0; i< y+2; i++) {
			System.out.print("#");
		}
		System.out.println(); 
		
		for(int i = 0; i<x; i++) {		
			System.out.println("#" + arr[i] + "#"); 
		} 
		for(int i = 0; i<y+2; i++) {
			System.out.print("#");
		}
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 23124
N = int(input())

roku = kyu = 1
h_list = [1]

while(roku<N):
    roku *= 6
    h_list.append(roku)

while(kyu<N):
    kyu *= 9
    h_list.append(kyu)

#print(h_list)

FIN = 10**7
dp = [FIN]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for j in range(len(h_list)):
        if h_list[j] <= i:
            dp[i] = min(dp[i], dp[i-h_list[j]]+1)
            #print(dp)

print(dp[N])

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    ll n,m;
    cin >> n >> m;


    ll res=min(n,m/2);
    n-=res;
    m-=2*res;

    res+=m/4;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#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, X;
  cin >> N >> X;
  int L[N];
  for(int i=0;i<N;i++) cin >> L[i];

  int ans = 1;
  int pos = 0;
  for(int i = 0; i < N; i++){
    pos = pos + L[i];
    if(pos <= X) ans++;
  }

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>   

int main()
{
int sum,i=0;
 char str[1000];

while(1){
        scanf("%s",&str); 
        if(str[0]=='0')
             break;
        sum=0;
        for(i=0;str[i]!='\0';i++){
         sum=sum+(str[i]-'0'); 
         }
         printf("%d\n",sum);
        }
 return 0;
}

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

int main() {
  int a,b;
  cin >>a >> b;
  if(a<6) {
    cout << 0 <<endl;
  }
  else if (a>12) {
    cout << b <<endl;
  }
  else {
    cout << b/2 <<endl;
  }
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    s = {1, 2, 4, 8, 16, 32, 64}
    ans = 0

    for i in range(1, N + 1):
        if i in s:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i, n)     for(int i = 0;      i < int(n); ++i)
#define rep3(i, a, b) for(int i = int(a); i < int(b); ++i)
#define all(x)        (x).begin(),(x).end()
#define sz(x)         int(x.size())
#define mp            make_pair
#define pb            push_back

typedef long long ll;

using namespace std;


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

  // input
  vector<vector<pair<int, int> > > P(N+1);
  rep(i, M){
    int p, y;
    cin >> p >> y;
    P[p].pb(mp(y,i));
  }

  // sorted
  vector<pair<int, int> > sorted(M);
  rep3(i, 1, N+1){
    sort(all(P[i]));
    rep(j, sz(P[i])){
      sorted[P[i][j].second] = mp(i, j+1);
    }
  }

  // output
  rep(i, M){
    cout << setfill('0') << right << setw(6) << sorted[i].first;
    cout << setfill('0') << right << setw(6) << sorted[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 7808
N, Y = map(int, input().split())
X = (Y - 1000*N)
# 9000x+4000y=Xなるx,yの組が存在するか判定すれば良い
# z=N-x-y

f = False

xm = X//9000 + 1
for i in range(xm):
  y = (X - 9000*i)//4000
  if (X - 9000*i)%4000 == 0 and (X - 9000*i)//4000 >= 0 and (N-i-y) >= 0:
    x = i
    f = True
    break

if f:
  print(x, y, N-x-y)
else:
  print(-1, -1, -1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

const int INF = 2000000000;
const double pi = 3.1415926;
const int base = 1000000007;

int n;
set <int> s;

int main()
{
    //ifstream cin ("input.txt");
    //ofstream cout ("output.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        s.insert(t);
    }
    if (s.size() == n) cout << "YES";
    else cout << "NO";
    return 0;
}


Measured memory_bytes: 9600
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, avg;
    cin >> n >> avg;
    vector <int> a(n);
    cin >> a;
    vector <vector <long long>> dp(n + 1, vector <long long> (2501));
    dp[0][0] = 1;
    forn (i, 0, n) {
        auto new_dp = dp;
        forn (j, 1, n + 1)
            forn (k, a[i], 2501)
                new_dp[j][k] += dp[j - 1][k - a[i]];
        dp = new_dp; 
    }
    long long ans = 0;
    forn (i, 1, n + 1)
        ans += dp[i][avg * i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 5308