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

int main() {
	int n;
	int mmm=0;
	cin>>n;
	vector<pair<double,double>> vec(n);
	vector<int> perm(n);
	for(int i=0;i<n;i++) cin>>vec[i].first>>vec[i].second;
	iota(perm.begin(),perm.end(),0);
	double dist=0;
	do{
		mmm++;
		for(int i=1;i<n;i++){
			dist+=sqrt(pow(vec[perm[i]].first-vec[perm[i-1]].first,2)+pow(vec[perm[i]].second-vec[perm[i-1]].second,2));
		}
	}while(next_permutation(perm.begin(),perm.end()));

	cout << fixed << setprecision(10);
	cout<<dist/mmm;
}


Measured memory_bytes: 3820
import itertools
"""
n = int(input())
m, a, r, c, h = [0] * 5
for i in range(n):
    s = input()
    if s[0] == "M": m += 1
    if s[0] == "A": a += 1
    if s[0] == "R": r += 1
    if s[0] == "C": c += 1
    if s[0] == "H": h += 1
x = [m, a, r, c, h]
y = ["M", "A", "R", "C", "H"]
ans = 0
for i in itertools.combinations(x, 3):
    ans += i[0] * i[1] * i[2]
print(ans)
"""

# n <= 10**5
n = int(input())
# vi <= 10**5
v = list(map(int, input().split()))
a = [[0] * 100010 for _ in range(2)]
for i in range(n):
    a[i % 2][v[i]] += 1

od, ev = [], []
for i in range(100010):
    od.append([a[1][i], i])
    ev.append([a[0][i], i])
od.sort()
od.reverse()
ev.sort()
ev.reverse()
if od[0][1] != ev[0][1]: print(n - od[0][0] - ev[0][0])
else: print(n - max(od[0][0] + ev[1][0], od[1][0] + ev[0][0]))

Measured memory_bytes: 33328
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>

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

using namespace std;

const int MAXN = 400000 + 10;

char S[MAXN];

void Work()
{
	scanf("%s", S);
	for (int i = 0; S[i]; i ++)
		if (S[i] == 'A' && S[i + 1] == 'C')
		{
			printf("Yes\n");
			return;
		}
	printf("No\n");
}

int main()
{
	Work();
	return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;
vector<int> a[mxn],vis(mxn);

void dfs(int u)
{
	vis[u] = 1;
	for(int i : a[u])
	{
		if(!vis[i])
		{
			dfs(i);
		}
	}
}
void solve(){
	int n,m;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int u,v; cin >> u >> v;
		a[u].pb(v);
		a[v].pb(u);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(!vis[i]){
			dfs(i);
			ans++;
		}
	}
	cout << ans - 1 << '\n' ;
}

int32_t main()
{
	FLASH
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 10588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    int ans1 = 0, ans2 = 0;
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0 ){
            if(s[i] == '0'){
                ans1++;
            }else{
                ans2++;
            }
        }else{
            if(s[i] == '1'){
                ans1++;
            }else{
                ans2++;
            }
        }
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n;
pii h[N];
int ans[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i].x,h[i].y=i;
	sort(h,h+n);
	for (int i=0;i<n-1;++i) ans[h[i].y]=h[n-1].x;
	ans[h[n-1].y]=h[n-2].x;
	for (int i=0;i<n;++i) cout<<ans[i]<<en;
}




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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 2e5+23;
int a[N];
int h[21];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  long long ans = 0;
  long long i = 0, j = 0, cnt = 0, prev = 0;
  bool good;
  for (; i < n; ++i) {
    good = true;
    ++cnt;
    for (int b = 0; b < 21; ++b) {
      if (a[i] & (1<<b)) ++h[b];
      if (h[b] > 1) good = false;
    }
    if (good) continue;
    ans += cnt*(cnt-1)/2;
    ans -= prev*(prev+1)/2;
    while (!good) {
      good = true;
      --cnt;
      for (int b = 0; b < 21; ++b) {
	if (a[j] & (1<<b)) --h[b];
	if (h[b] > 1) good = false;
      }
      ++j;
    }
    prev = cnt-1;
  }
  ans += (cnt+1)*cnt/2;
  ans -= prev*(prev+1)/2;
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4644
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

    // dp[i][j] := sをi番目まで, tをj番目まで見た時のlcsの長さ
    int dp[3003][3003] = {0};
    rep(i, s.size()){
        rep(j, t.size()){
            if (s[i]==t[j]){
                chmax(dp[i+1][j+1], dp[i][j]+1);
            }
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    // 復元
    string ans = "";
    int sn = s.size(), tn = t.size();
    while(sn>0 and tn>0){
        if (dp[sn][tn]==dp[sn-1][tn]) sn--;
        else if (dp[sn][tn]==dp[sn][tn-1]) tn--;
        else{
            ans = s[sn-1] + ans;
            sn--; tn--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s; cin >> s;
	vector<int> v(s.size()); for (int i = 0; i < s.size(); i++) v[i] = s[i] - '0';
	vector<vector<ll>> dp(s.size() + 1, vector<ll>(2, INF));
	dp[0][0] = 0;
	for (int i = 0; i < s.size(); i++) {
		chmin(dp[i + 1][0], dp[i][0] + v[i]);
		chmin(dp[i + 1][0], dp[i][0] + 1 + 10 - v[i]);
		chmin(dp[i + 1][1], dp[i][0] + 1 + 9 - v[i]);
		chmin(dp[i + 1][1], dp[i][1] + 9 - v[i]);
		chmin(dp[i + 1][0], dp[i][1] + 10 - v[i]);
	}
	cout << dp[s.size()][0] << endl;
	return 0;
}

Measured memory_bytes: 62812
S = input()
T = input()

LT = len(T)
minDiff = LT
for i in range(len(S) - len(T) + 1):
    U = S[i:i+LT]
    diff = 0
    for j in range(LT):
        if U[j] != T[j]:
            diff = diff + 1
    
    if diff <minDiff:
        minDiff = diff

print(minDiff)

Measured memory_bytes: 73300
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n,m;
  cin >> n >> m;
  vl cnt(n,0);
  rep(i,m){
    ll a,b;
    cin >> a >> b;
    cnt[a-1]++;
    cnt[b-1]++;
  }
  bool B=true;
  rep(i,n){
    if(cnt[i]%2!=0){
      B=false;
    }
  }
  if(B){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,t;
    cin>>a>>b>>t;
    cout<<b*(t/a)<<endl;
}

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

#define M 1046527
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[])
{
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++)
	{
		h= (h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if (strlen(H[h])==0)return 0;
	}
	return 0;
}

int insert(char str[])
{
	long long key,i,h;
	key =getKey(str);
	for(i=0;;i++)
	{
		h= (h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if (strlen(H[h])==0)
		{
			strcpy(H[h],str);
			return 0;
		}
	}
		return 0;
}

int main(void)
{
	int i,n,h;
	char str[L],com[9];
	for(i=0;i<M;i++)
	{
		H[i][0]='\0';
	}
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%s %s",com,str);
		if(com[0]=='i')
		{
			insert(str);
		}
		else
		{
			if(find(str))
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
	}
	return 0;
}



Measured memory_bytes: 16100
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll f(ll x) {
   return x * x * x * x * x;
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   ll x;
   cin >> x;
   rep(a, 0, 1000) {
      rep(b, -2000, 2000) {
         if (f(a) - f(b) == x) {
            printf("%d %d\n", a, b);
            return 0;
         }
      }
   }
   return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(void){
    int A,B;
    int K;
    cin>>A>>B>>K;
    for(int i=min(A,B);i>0;i--){
        if(A%i==0 & B%i==0){
            K--;
        }
        if(K==0){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=355;
typedef long long ll;
const ll mod=1e9+7;

int n;
ll k,a[N],ans;
struct at
{
	ll b,c;
	bool operator <(const at & x) const {return c<x.c;}
}tmp[N];


int num;
struct aa
{
	ll a[N],res;
	void print()
	{
		for (int i=1;i<=n;i++) printf("%lld ",a[i]);printf("  res : %lld\n",res);
	}
	bool operator <(const aa &b) 
	{
		for (int i=2;i<=n;i++) if (a[i]!=b.a[i]) return a[i]<b.a[i];
		return a[1]-res<b.a[1]-b.res;
	}
	bool operator ==(const aa &b) 
	{
		for (int i=2;i<=n;i++) if (a[i]!=b.a[i]) return false;
		return true;
	}
}t[N*70];



ll workmi(ll l,ll r) 
{
	int num=0;
	for (int i=60;i>=0;i--) 
	{
		if ( ( l&(1ll<<i) ) && ( r&(1ll<<i)) ) num++;
		else if ( r&(1ll<<i) ) return num+1;
	}
	return num;
}

void work()
{
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);

	ans=0;
	num=0;

	for (int kk=0;kk<=min( 60ll,k );kk++)  
	{
		for (int i=1;i<=n;i++) tmp[i].b=(a[i]>>kk),tmp[i].c=a[i]&( (1ll<<kk )-1 );
		
//		for (int i=1;i<=n;i++) printf("i=%d b=%d c=%d\n",i,tmp[i].b,tmp[i].c);
		
		sort(tmp+1,tmp+n+1);
		tmp[n+1].c=(1ll<<kk)-1;
			
		for (int i=1;i<=n+1;i++) 
		if (tmp[i].c!=tmp[i-1].c || i==1) 
		{
			int mi= i==1 ? 0: workmi(tmp[i-1].c,tmp[i].c);
			
			if (k-kk-mi<0) continue;
			
			++num;
			for (int j=1;j<=n;j++)  t[num].a[j]=tmp[j].b - (j<i) ;
//			,printf("tmp[%d].a[%d]=%lld\n",num,j,t[num].a[j]);
			
			sort(t[num].a+1,t[num].a+n+1);
			for (int j=n;j>=2;j--) t[num].a[j]-=t[num].a[j-1];
			
			t[num].res=min( k-kk-mi  ,t[num].a[1] );
//			printf("t[%d].res=%lld\n",num,t[num].res);
			
			
			if (t[num].a[1]<0) num--;
		}
//		puts("");
	}
	
	sort(t+1,t+num+1);
	for (int l=1,r;l<=num;) 
	{
		r=l;while (t[r+1]==t[l]&&r<num) ++r;
		
		ll tl=0,tr=-1;
		while (l<=r) 
		{
//			t[l].print();
			if (t[l].a[1]-t[l].res<=tr) tr=max( tr , t[l].a[1] );
			else 
			{
				ans=(ans+tr-tl+1)%mod;
				tl=t[l].a[1]-t[l].res,tr=t[l].a[1];
			}
		//	printf("ans=%lld tl=%lld tr=%lld\n",ans,tl,tr);
			l++;
		}
		ans=(ans+tr-tl+1)%mod;
//		puts("");
	}
	
	printf("%lld\n",ans);
}


int main()
{
	work();
	return 0;
}

/*
4
2 2
9 9
2 3
7 9
2 3
2 5
3 3
10 11 11
*/

Measured memory_bytes: 28800
#include <cstdio>

int main() {
    int n, x, t;
    std::scanf("%d %d %d", &n, &x, &t);

    int cnt = 0;
    while (n > 0) {
        n -= x;
        cnt += t;
    }

    std::printf("%d\n", cnt);

    return 0;
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

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

vector<int> v[2010];
int match[2010];
bool used[2010];

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

int two_matching_max(int l)
{
	int res = 0;
	memset(match,-1,sizeof(match));
	REP(v,l)
	{
		if(match[v] < 0)
		{
			memset(used,0,sizeof(used));
			if(matchdfs(v))res++;
		}
	}
	//cout << res << endl;
	return res;
}


int main()
{
	int n;cin >> n;
	vector<pair<int,int>> A;
	vector<pair<int,int>> B;
	
	REP(i,n)
	{
		int a,b;cin >> a >> b;
		A.PB(MP(a,b));
	}

	REP(i,n)
	{
		int a,b;cin >> a >> b;
		B.PB(MP(a,b));
	}
	
	REP(i,n)
	{
		REP(j,n)
		{
			if(A[i].FI < B[j].FI && A[i].SE < B[j].SE)
			{
				v[i].PB(n+j);
				v[n+j].PB(i);
			}
		}
	}
	
	cout << two_matching_max(2*n) << endl;
	
	return 0;
}

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

#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define mset(a,x) memset(a,x,sizeof(a))

char buf[114514];
int x, y;

bool dpx[8000][16010];
bool dpy[8000][16010];

int main() {
    mset(dpx, 0); mset(dpy, 0);
    scanf("%s", buf);
    scanf("%d%d", &x, &y);
    string s = buf;
    s += "T";

    vector<int> dx, dy;
    bool b = 0;
    int cnt = 0;
    for (auto&& c : s) {
        cnt += (c == 'F');
        if (c == 'T') {
            if (!b) dx.push_back(cnt);
            else dy.push_back(cnt);
            cnt = 0;
            b ^= 1;
        }
    }

    int n = dx.size(), m = dy.size();
    dpx[0][8000] = dpx[1][dx[0] + 8000] = 1;
    FOR(i, 1, n) rep(px, 16001) if (dpx[i][px]) {
        int j = px + dx[i];
        int k = px - dx[i];
        dpx[i + 1][j] = dpx[i + 1][k] = 1;
    }

    dpy[0][8000] = 1;
    rep(i, m) rep(py, 16001) if (dpy[i][py]) {
        int j = py + dy[i];
        int k = py - dy[i];
        dpy[i + 1][j] = dpy[i + 1][k] = 1;
    }

    cout << (dpx[n][x + 8000] && dpy[m][y + 8000] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 250496
X, Y, A, B, C = gets.split(' ').map(&:to_i)
P = gets.split(' ').map(&:to_i).sort.reverse[0..(X - 1)]
Q = gets.split(' ').map(&:to_i).sort.reverse[0..(Y - 1)]
R = gets.split(' ').map(&:to_i).sort.reverse[0..(X + Y)]
puts (P + Q + R).sort.reverse[0..(X + Y - 1)].inject(:+)

Measured memory_bytes: 32344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
#define MAX 500000
#define SENTINEL 2000000000
#define NIL -1
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
static const ll N =100;
int main(){
    ll Adj[N][N];
    ll n,u,k,v;
    cin >> n;
    REP(i,n)REP(j,n)Adj[i][j]=0;

    REP(i,n){
        cin >> u >> k;
        u--;
        REP(j,k){
            cin >> v;
            v--;
            Adj[u][v] =1;
        }
    }
    REP(i,n){
        REP(j,n){
        if(j)cout << " ";
        cout<<Adj[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

int N;
int * data;

void init() {
  // child: parent's index
  // root: -size
  data = array(N, int);

  rep(i, N) {
    // at first, all data is root and size is -1
    data[i] = -1;
  }
}

int find(int x) {
  if (data[x] < 0) {
    return x;
  }

  return data[x] = find(data[x]);
}

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

int unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) {
    return 0;
  }
  // becasue data has minus size, reverse the inequality sign
  if (data[x] > data[y]) {
    swap(int, x, y);
  }
  data[x] += data[y];
  data[y] = x;
  return 1;
}

int size(int x) {
  return -data[find(x)];
}

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

  init();

  rep(i, M) {
    int A, B;
    scanf("%d%d", &A, &B);
    A -= 1;
    B -= 1;
    unite(A, B);
  }

  int ans = 0;
  rep(i, N) {
    ans = max(ans, size(i));
  }

  printf("%d\n", ans);

  free(data);

  return 0;
}


Measured memory_bytes: 2248
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[200007];
long long ans=0LL;
int main()
{
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    if (k>n) k=n;
    for (int i=1;i<=n-k;i++)
        ans+=a[i];
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n;
	cin >> n;
	char s[15];
	rep(i, n) cin >> s[i];
	int k;
	cin >> k;
	rep(i, n) {
		if (s[k - 1] == s[i]) {
			cout << s[i];
		}
		else cout << '*';
	}
	cout << endl;

	return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            if (S == "SUN")
                Console.WriteLine(7);
            else if (S == "MON")
                Console.WriteLine(6);
            else if (S == "TUE")
                Console.WriteLine(5);
            else if (S == "WED")
                Console.WriteLine(4);
            else if (S == "THU")
                Console.WriteLine(3);
            else if (S == "FRI")
                Console.WriteLine(2);
            else
                Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int h, w, n;
    cin >> h >> w >> n;
    vector<ll> nums(n);
    for (int i = 0; i < n; i++)
    {
        cin >> nums[i];
    }
    vector<ll> k;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < nums[i]; j++)
        {
            k.emplace_back(i + 1);
        }
    }
  
    for (int i = 0; i < h; i++)
    {
        if(i % 2 == 0){
            for(int j = 0; j < w; j++)
            cout << k[i * w + j] << " ";
        }
        else{
            for(int j = w - 1; 0 <= j; j--){
                cout << k[i * w + j] << " ";
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 500005;
const int K = 20;
int ans[N], x[N], w[N], n, tt, l, t, nl, nx[N], nw[N], nt;
void solve(vector < int > a, int h = 0){
    int s = 0;
    int n = a.size();
    for (auto i: a) s += (i - 1);
    if (s % 2 == 1){
        if (h % 2 == 0){
            cout << "First";
        } else{
            cout << "Second";
        }
        exit(0);
    }
    int cnt = 0;
    int k = 0;
    for (auto i: a) if (i == 1) k++;
    for (auto i: a) if (i % 2) cnt++;
    if (cnt >= 2 || k > 0){
        if (h % 2 == 0){
            cout << "Second";
        } else{
            cout << "First";
        }
        exit(0);
    }
    for (int i = 0; i < n; i++){
        if (a[i] % 2) a[i] -= 1;
    }
    int g = a[0];
    for (int i = 1; i < n; i++) g = __gcd(g, a[i]);
    for (int i = 0; i < n; i++) a[i] /= g;
    solve(a, h + 1);
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    vector < int > a;
    int s = 0;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        s += x - 1;
        a.pb(x);
    }
    if (n == 1){
        if (s % 2){
            cout << "First";
        } else{
            cout << "Second";
        }
        return 0;
    }
    solve(a);
}


Measured memory_bytes: 19956
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]+1<<" ";nl
#define vinn(n,v) int n;cin>>n;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define vinm(n,m,v) int n,m;cin>>n>>m;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define debug(x) cerr<<#x<<" : "<<x<<endl;
mt19937 rd(time(0)); // i = rd%n
signed main() 
{
    fastio();

    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    int ans = 0;
    int cnt = 0;
    vector<int>fr,zr;
    for(int i = 0;i<n;i++)
    {
        if(cnt==k)break;
        if(s[i]=='o')
            fr.pb(i),i+=c,cnt++;
    }
    cnt = 0;
    for(int i = n-1;i>=0;i--)
    {
        if(cnt==k)break;
        if(s[i]=='o')
            zr.pb(i),i-=c,cnt++;
    }
    reverse(all(zr));
    for(int i = 0;i<k;i++)if(zr[i]==fr[i])cout<<fr[i]+1<<endl;



    return 0;
}


Measured memory_bytes: 5128
#include <iostream>
using namespace std;
 
int main(){
    int N;
    cin >> N;
 
    int A[N];
    int col[9] = {0};
    int buff = 0;
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        A[i] = A[i] / 400;
        if(A[i] >=8)A[i] = 8;
        col[A[i]]++;
    }
 
    for(int i = 0; i < 8; ++i){
        if(col[i]) buff++;
    }
    if(buff == 0 && col[8] > 0) cout << 1 << " " << col[8] << endl;
    else cout << buff << " " << buff + col[8] << endl;
    return 0;
        
        
 
}


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

int main(){
    int A,B;
    cin >> A >> B;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9){
        cout << A*B << endl;
        return 0;
    }
    cout << "-1" << endl;
}


Measured memory_bytes: 256
/*
 * atcoder/dp_2nd/l.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long
#define MOD 1000000007

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

// Nが奇数で最後1つ(j-i==1) dp[i][j] = +a_i
// Nが偶数で最後1つ(j-i==1) dp[i][j] = -a_i
// Nが奇数で最後2つ(j-i==2) dp[i][j] = - min(dp[i+1][j] - a_i, dp[i][j-1] - a_j)
// Nが偶数で最後2つ(j-i==2) dp[i][j] = + max(dp[i+1][j] + a_i, dp[i][j-1] + a_j)
// Nが奇数で最後3つ(j-i==3) dp[i][j] = + max(dp[i+1][j] + a_i, dp[i][j-1] + a_j)
// Nが偶数で最後3つ(j-i==3) dp[i][j] = - min(dp[i+1][j] - a_i, dp[i][j-1] - a_j)
// Nが奇数で最後Nつ(j-i==N) dp[0][N] = ...同上...
// Nが偶数で最後Nつ(j-i==N) dp[0][N] = ...同上...

const int MAX = 3100;
ll N;
vector<ll> A;
ll dp[MAX][MAX];

void input() {
  cin >> N;
  ll a;
  loop(n,0,N) {
    cin >> a;
    A.push_back(a);
  }
}

ll minmax(ll a, ll b, int sign) {
  if (sign > 0) return max(a, b);
  return min(a, b);
}

void solve() {
  for (int len=1; len <=N; len++) {
    for (int l=0; l+len <=N; l++) {
      int sign = ((N + len)%2 == 0) ? 1 : -1;
      if (len == 1) { dp[l][l+1] = sign * A[l]; continue; }
      int r = l + len;
      dp[l][r] = minmax(dp[l+1][r] + sign * A[l], dp[l][r-1] + sign * A[r-1], sign);
    }
  }
  cout << dp[0][N] << endl;
}

void dump() {
  for (int len=1; len <=N; len++) {
    for (int l=0; l+len <=N; l++) {
      int sign = ((N + len)%2 == 0) ? 1 : -1;
      cout << "[" << l << ": " << (l+len-1) << "] dp = " << dp[l][l+len] << " sign = " << sign << endl;
    }
  }
}

int main() {
  // cout.precision(15);
  input();
  solve();
  // dump();
  return 0;
}


Measured memory_bytes: 73984
#include <iostream>
#include <vector>
#include <cmath>

long long gcd(long long a, long long b){
    long long num = std::max(a, b), denom = a + b - num, buf;
    while(0 != denom){
        buf = denom;
        denom = num % denom;
        num = buf;
    }

    return num;
}

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

    std::vector<int> x = {val};
    for(int i = 0; i < n; ++i){
        std::cin >> val;
        x.push_back(val);
    }

    std::sort(x.begin(), x.end());

    std::vector<int> spans(n);
    int ans;
    if(2 == x.size()){
        ans = x.at(1) - x.at(0);
    }else{
        ans = gcd(x.at(1) - x.at(0), x.at(2) - x.at(1));
        for(int i = 2; i < n; ++i){
            ans = gcd(ans, x.at(i + 1) - x.at(i));
        }
    }

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

    return 0;
}

Measured memory_bytes: 1144
package main

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

type Menu struct {
  time int
}

type Menus []Menu

func (p Menus) Len() int {
  return len(p)
}

func (p Menus) Swap(i, j int) {
  p[i], p[j] = p[j], p[i]
}

func (p Menus) Less(i, j int) bool {
  return (p[i].time - 1) % 10 < (p[j].time - 1) % 10
}

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  var time Menus = []Menu{{0}, {0}, {0}, {0}, {0}}

  for i := 0; i < 5; i++ {
    sc.Scan()
    time[i].time, _ = strconv.Atoi(sc.Text())
  }

  sum := 0

  sort.Sort(time)

  for i := 1; i < 5; i++ {
    sum += (time[i].time + 9) / 10 * 10
  }

  fmt.Println(sum + time[0].time)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

static const int MAX=1400;
int dp[MAX][MAX],G[MAX][MAX];

int getLargestSquare(int H,int W){
    int maxwidth=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            dp[i][j]=(G[i][j]+1)%2;
            maxwidth|=dp[i][j];
        }
    }
    
    for(int i=1;i<H;i++){
        for(int j=1;j<W;j++){
            if(G[i][j]){
                dp[i][j]=0;
            }else{
                dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
                maxwidth=max(maxwidth,dp[i][j]);
            }
        }
    }
    return maxwidth*maxwidth;
}

int main(void){
    int H,W;
    scanf("%d %d",&H,&W);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            scanf("%d",&G[i][j]);
        }
    }
    
    printf("%d\n",getLargestSquare(H,W));
    
    return 0;
}



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

#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;

ll dp[3001][3001][4];

void solve()
{
ll r,c,k;
cin>>r>>c>>k;
vector<vector<ll>> v(r+1,vector<ll>(c+1,0));
while(k--){
		ll a,b;
		cin>>a>>b;
		ll x;
		cin>>x;
		v[a][b]=x;
}
	

dp[0][0][0]=0;
dp[1][1][0]=0;
for(ll i=1;i<=r;i++){
	dp[i][1][0]=0;
}
for(ll i=1;i<=r;i++){
	for(ll j=1;j<=c;j++)
		{
			for(ll k=1;k<=3;k++){
				dp[i][j][k]=max(dp[i-1][j][3],dp[i][j-1][k]);
			}
			
			for(ll k=1;k<=3;k++){
				dp[i][j][k]=max(dp[i][j][k],max(dp[i-1][j][3]+v[i][j],dp[i][j-1][k-1]+v[i][j]));
			}
			
		}
}

ll temp=0;
temp=dp[r][c][3];

cout<<temp;
}



int main(){
	ll t;
	//cin>>t;
	t=1;
	while(t--){
			solve();
	cout<<endl;
	}



}

Measured memory_bytes: 354992
/*
ID: alec3
LANG: C++14
PROG:
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

ifstream fin("input.txt");
ofstream fout("output.txt");

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

    cout << max({a * c, a * d, b * c, b *d}) << endl;

    return 0;
}


Measured memory_bytes: 3652
package main

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

type Shop struct {
	NumDrink int
	Value    int
}

type ByValue []Shop

func (s ByValue) Len() int           { return len(s) }
func (s ByValue) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s ByValue) Less(i, j int) bool { return s[i].Value < s[j].Value }

func main() {

	sc := bufio.NewScanner(os.Stdin)

	var N, M int
	var err error
	if sc.Scan() {
		s := splitWithSpace(sc.Text())
		if N, err = strconv.Atoi(s[0]); err != nil {
			panic(err)
		}
		if M, err = strconv.Atoi(s[1]); err != nil {
			panic(err)
		}
	}

	var shops []Shop
	for i := 0; i < N; i++ {
		if !sc.Scan() {
			panic(fmt.Errorf("cannot scan at row: %v", i))
		}
		s := splitWithSpace(sc.Text())
		var numDrink, value int
		if value, err = strconv.Atoi(s[0]); err != nil {
			panic(err)
		}
		if numDrink, err = strconv.Atoi(s[1]); err != nil {
			panic(err)
		}
		shops = append(shops, Shop{
			NumDrink: numDrink,
			Value:    value,
		})
	}

	// 昇順にソート: 1.6では使えない
	// sort.Slice(shops, func(i, j int) bool {
	// 	return shops[i].Value < shops[j].Value
	// })
	sort.Sort(ByValue(shops))

	paymentAmount, numDrink := 0, 0
	for i := 0; i < N; i++ {
		numToBuy := shops[i].NumDrink
		if numDrink+numToBuy > M {
			numToBuy = M - numDrink
		}

		paymentAmount += shops[i].Value * numToBuy
		numDrink += numToBuy

		if numDrink >= M {
			break
		}
	}

	fmt.Println(paymentAmount)
}

func splitWithSpace(str string) []string {
	return strings.Split(str, " ")
}

Measured memory_bytes: 9344
N = int(input())
S = input()
M = 10**9+7

cnt = {}
for i in S:
    if i in cnt.keys():
        cnt[i] += 1
    else:
        cnt[i] = 1

ans = 1
for l in cnt.values():
    ans *= l + 1

print((ans-1)%M)




Measured memory_bytes: 3188
#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;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  string S;
  cin >> S;
  string T = S;
  reverse(ALL(T));
  for(char &c: T) {
    if(c == 'b') c = 'd';
    else if(c == 'd') c = 'b';
    else if(c == 'p') c = 'q';
    else if(c == 'q') c = 'p';
  }
  cout << (S == T ? "Yes" : "No") << endl;
  return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    set<int>out;
    set<int>::iterator it;
    int a, b, k;
    cin>>a>>b>>k;
    int i;
    int rb = MIN2(a+k, b);
    FOR(i, a, rb)
    {
        out.insert(i);
    }
    int lb = MAX2(a, b-k+1);
    FORD(i, b, lb)
    {
        out.insert(i);
    }
    it = out.begin();
    while(it!=out.end())
    {
        cout<<*it<<endl;
        it++;
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e8 + 7;

int main(){
	
	while(true){
		int n, k;
		cin >> n >> k;
		if(n == 0){
			break;
		}
		int c[110];
		for(int i = 0; i < n; i++){
			cin >> c[i];
		}
		long long int S1 = 0, S2 = 0;
		for(int i = 0; i <= n - k; i++){
			long long int num = 1;
			for(int j = 0; j < k; j++){
				num *= c[i + j];
			}
			S1 = max(S1, num);
		}
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				swap(c[i], c[j]);
				
				for(int p = 0; p <= n - k; p++){
					long long int num = 1;
					for(int q = 0; q < k; q++){
						num *= c[p + q];
					}
					S2 = max(S2, num);
				}
				swap(c[i], c[j]);
			}
		}
		cout << S2 - S1 << endl;
	}
	return 0;
}



Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
char a[30005];
vector<int>b[12];
char c[5]={0};
map<string,int>ma;
int  find(int n,int m,int t)
{
   int l=0,r=b[t].size()-1;
  for(int i=0;i<=r;i++)
  {
     if(b[t][i]<m&&b[t][i]>n)
     {
    return 1;
     }
  }
  return 0;

}
int main()
{
int n,t,kk;
long long ans=0;
scanf("%d",&n);
getchar();
for(int i=0;i<n;i++)
{
 scanf("%c",&a[i]);
 b[a[i]-'0'].push_back(i);

}
for(int i=0;i<11;i++)
{

  if(b[i].size()<=0)
  continue;
  //printf("%d\n",b[i].size());
  for(int j=0;j<11;j++)
  {
     t=b[j].size();
     if(t>0)
     {
       if(b[j][t-1]-1>b[i][0])
       {
         for(int k=0;k<11;k++)
        {

             kk=find(b[i][0],b[j][t-1],k);
            // printf("%d\n",kk);
            if(kk==1)
             {

             c[0]=i+'0';
             c[1]=k+'0';
             c[2]=j+'0';
             if(ma[c]==0)
             {
                       ma[c]=1;
             ans++;
             }
             }

        }

       }
     }

  }
}

printf("%lld\n",ans);
}




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

int main()
{
	int h,m,s,r1,r3;
	while(scanf("%d %d %d",&h,&m,&s), h!=-1&&m!=-1&&s!=-1)
	{
		r1 = 120*60 - (((h*60)+m)*60+s);
		r3 = r1*3;

		printf("%02d:%02d:%02d\n",r1/3600,(r1/60)%60,r1%60);
		printf("%02d:%02d:%02d\n",r3/3600,(r3/60)%60,r3%60);
	}
}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}
func parseInt(s string) (n int) {
	n, _ = strconv.Atoi(s)
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := getInt(), getInt()
	//a := make([]int, n)

	for i := 0; i < n; i++ {
		getInt()
	}
	//fmt.Println(math.Ceil(float64(1 + (float64(n-k) / 2))))

	fmt.Println(math.Ceil(float64(n-1) / float64(k-1)))
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }


int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];

    long long ans = 0;
    long long mx = 0;
    REP(i, N){
        if(A[i] >= mx + 2){
            long long cnt = (A[i]-1)/(mx+1);
            ans += cnt;
            A[i] -= cnt * (mx+1);
            if(mx == 0) mx = 1;
        }else{
            mx = max(mx, A[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

void merge(int *,int ,int ,int);
void mergeSort(int *,int,int);

int count=0;

int main(){

  int n,i;
  int S[500000];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,0,n);
  
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i==n-1)printf("\n");
    else printf(" ");
  }
  
  printf("%d\n",count);
  
  return 0;
}

void mergeSort(int *s,int l,int r){

  int m;

  if(l+1<r){
    m=(l+r)/2;
    mergeSort(s,l,m);
    mergeSort(s,m,r);
    merge(s,l,m,r);
  }
}

void merge(int *s,int l,int m,int r){

  int n1,n2,i,j,k;

  n1=m-l;
  n2=r-m;

  int L[n1+1],R[n2+1];

  for(i=0;i<=n1-1;i++) L[i]=s[l+i];
  for(i=0;i<=n2-1;i++) R[i]=s[m+i];

  L[n1]=1000000000;
  R[n2]=1000000000;

  i=0;
  k=0;

  for(j=l;j<=r-1;j++){
    count++;

    if(L[i]<=R[k]){
      s[j]=L[i];
      i=i+1;
    }
    else{
      s[j]=R[k];
      k=k+1;
    }
  }
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
#define PI 3.1415926535

int main()
{
    int n,arr[2000000],a;
    cin>>n;
    for(int i=0;i<n;i++)
        arr[i]=0;
    for(int i=0;i<n-1;i++)
    {
        cin>>a;
        arr[a-1]++;
    }
    for(int i=0;i<n;i++)
        cout<<arr[i]<<"\n";
}


Measured memory_bytes: 4408
import bisect

N = int(input())
li = list(map(int, input().split()))
li = sorted(li)

ans = 0

for i in range(N):
    for j in range(i+1, N):
        cnt = bisect.bisect_left(li, li[i]+li[j])
        ans += cnt - j - 1

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
using namespace std;
int main () {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int unhappy_inside = 0, unhappy_end = (s.at(0) == 'L') + (s.at(n-1) == 'R');
  
  for (int i = 0; i < n-1; ++i) {
    if (s.at(i) == 'R' and s.at(i+1) == 'L') unhappy_inside += 2;
  }
  int happy = n - unhappy_end - unhappy_inside;
  if (unhappy_inside / 2 >= k) {
    happy += 2 * k;
  } else if (unhappy_end > 0 ) {
    happy += unhappy_inside;
    if (unhappy_end == 2) happy += 1;
  } else {
    happy += unhappy_inside - 1;
  }
  cout << happy << endl;
  return 0;
}



Measured memory_bytes: 512
/// In the name of ALLAH
/// I'm THEOVE46
#include<bits/stdc++.h>
using namespace std;

#define gap             " "
#define nn              "\n"
#define pi              2*acos(0.0)
#define db              double
#define ft              float
#define ll              long long int
#define ull             unsigned long long int
#define pf              printf
#define sf              scanf
#define ff              first
#define ss              second
#define sfi(n)          sf("%d",&n)
#define sfi2(n, m)      sf("%d%d",&n,&m)
#define sfl(n)          sf("%lld",&n)
#define sfl2(n, m)      sf("%lld%lld",&n,&m)
#define sff(n)          sf("%f",&n)
#define sfd(n)          sf("%lf",&n)
#define pfi(n)          pf("%d",n)
#define pfl(n)          pf("%lld",n)
#define pff(n)          pf("%f",f)
#define pfd(n)          pf("%lf",f)
#define bfi             cin.ignore()
#define bfs             cin.get()
#define bfc             getchar()
#define gl(s)           getline(cin, s)
#define loop(a,n)       for(i=a; i<n; i++)
#define mloop(i,a,n)    for(i=a; i<n; i++)
#define rloop(i,a,n)    for(i=a; i>=n; i--)
#define tloop(test)     for(ll tl=1; tl<=test; tl++)
#define case1(z)        cout<<"Case "<<z<<": "
#define case2(z)        printf("Case %d: ",z)
#define vi              vector<int>
#define vl              vector<ll>
#define vld(vc,rw)      vector<vector<ll> >vc(rw)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define pis             pair<int,string>
#define psi             pair<string,int>
#define mls             map <ll,string>
#define msl             map <string,ll>
#define mll             map <ll,ll>
#define mp              make_pair
#define pb              push_back
#define itr             vector<int> :: iterator
#define atl(i, v)       for(auto i: v)
#define sz(s)           s.size()
#define sl(s)           s.length()
#define Sort(s)         sort(s.begin(), s.end())
#define SortR(s)        sort(s.rbegin(), s.rend())
#define all(x)          x.begin(),x.end()
#define rall(x)         x.end(), x.begin()
#define MEM(ar,val)     memset(ar, (val), sizeof(ar))
#define IN(A,B,C)       assert(B<=A && A<=C)
#define MOD             1000000007
#define EPS             1e-9
#define Max             1e9
#define Min             -1e9
#define bug1            "**1**"
#define bug2            "****2****"
#define artri(b,h)      0.5*b*h
#define artrap(b1,b2,h) (b1+b2)/2*h
#define arcrl(r)        pi*r*r
#define vlsyl(r,h)      pi*r*r*h
#define vlcone(r,h)     pi*r*r*(h/3)
#define vlsph(r)        (4/3)*pi*r*r*r
#define flush           fflush(stdout)
#define pcn(dg,val)     fixed << setprecision(dg) << val
#define ggl             pf("Case #%lld: ", tl)
#define FastIO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define showsort(n, a)  for(int i=0; i<n; i++) cout << a[i] << gap; cout << endl;

///THEOVE46

int main()
{
    //FastIO;
    ll n;
    cin >> n;
    cout << ceil(n*1.0/1000)*1000 - n << endl;
    return 0;
}

///   check for integer overflow, array bounds
///   check for n=1
///   - - - The Ove 46



Measured memory_bytes: 3780
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int a=0, b=0;
    for(int i=0; i<s.length(); i++) {
        if(i%2) {
            if(s[i]=='0') a++;
            else if(s[i]=='1') b++;
        } else {
            if(s[i]=='1') a++;
            else if(s[i]=='0') b++;
        }
    }
    cout << min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 512