akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
ll a[300005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, 3 * n) cin >> a[i];

  ll suml[300005];
  ll sumr[300005];

  // REP(i, 3 * n) {
  //   l += a[i];
  //   suml[i + 1] = l;
  //   r += a[3 * n - (i + 1)];
  //   sumr[i + 1] = r;
  // }

  priority_queue<ll, vector<ll>, greater<ll>> lque;
  priority_queue<ll> rque;

  ll l = 0, r = 0;
  REP(i, n) {
    l += a[i];
    lque.push(a[i]);
    r += a[3 * n - (i + 1)];
    rque.push(a[3 * n - (i + 1)]);
  }


  suml[0] = l; sumr[0] = r;
  REP(i, n) {
    l += a[n + i];
    lque.push(a[n + i]); l -= lque.top(); lque.pop();
    suml[i + 1] = l;
    r += a[2 * n - (i + 1)];
    rque.push(a[2 * n - (i + 1)]); r -= rque.top(); rque.pop();
    sumr[i + 1] = r;
  }

  ll ans = -LLINF;
  REP(i, n + 1) ans = max(suml[i] - sumr[n - i], ans);
  cout << ans << endl;
}


Measured memory_bytes: 9068
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = (1LL << 63);

int gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

int main() {
	llint n;
	cin >> n;
	hei(llint) a(n);
	hei(bool) s(1000000, false);
	bool pc = true;
	rep(i, 0, n) {
		cin >> a[i];
		llint x = a[i];
		for (llint j = 2; j * j <= x; j++) {
			if (x % j == 0) {
				if (s[j])pc = false;
				else s[j] = true;
				while (x % j == 0)x /= j;
			}
		}
		if (x != 1) {
			if (s[x])pc = false;
			else s[x] = true;
		}
	}
	if (pc)cout << "pairwise coprime" << endl;
	else {
		llint GCD = a[0];
		rep(i, 1, n) {
			GCD = gcd(GCD, a[i]);
		}
		if (GCD == 1)cout << "setwise coprime" << endl;
		else cout << "not coprime" << endl;
	}
	return 0;
}


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

using namespace std;

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

ll H, W, ans = 0, numH, numW;
int idx;
string M[MAXH];
vi vert[MAXW], hori[MAXH];

void preprocess(){

    rep(j, W){
        vert[j].push_back(0);

        rep(i, H){
            if(M[i][j]=='#') vert[j].push_back(i+1);
        }

        vert[j].push_back(H+1);

        // for(auto& v: vert[j])
        //     cout << v << " ";
        // cout << endl;
    }

    rep(i, H){
        hori[i].push_back(0);

        rep(j, W){
            if(M[i][j]=='#') hori[i].push_back(j+1);
        }

        hori[i].push_back(W+1);

        // for(auto& v: hori[i])
        //     cout << v << " ";
        // cout << endl;
    }
}

void solve(){
    preprocess();

    rep(i, H){
        rep(j, W){
            if(M[i][j]=='#') continue;
            
            // cout << i << ", " << j << endl;

            auto posH = lower_bound(hori[i].begin(), hori[i].end(), j+1);  
            idx = distance(hori[i].begin(), posH);
            // cout << j+1 << " is idx " << idx << endl;
            numH = hori[i][idx] - 1 - hori[i][idx-1];
            
            // cout << hori[i][idx] - 1<< " - " << hori[i][idx-1] << endl;

            auto posW = lower_bound(vert[j].begin(), vert[j].end(), i+1);  
            idx = distance(vert[j].begin(), posW);
            // cout << i+1 << " is idx " << idx << endl;
            numW = vert[j][idx] - 1 - vert[j][idx-1];

            // cout << vert[j][idx] - 1<< " - " << vert[j][idx-1] << endl;
            // cout << "(" << numH  << ", " << numW <<  ")" << endl;

            ans = max(ans, numH+numW-1);
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> H >> W;

    rep(i, H){
            cin >> M[i];
    }

    solve();
}


Measured memory_bytes: 36480
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class B
{
	public static void Main()	
	{
		int N = Int32.Parse(Console.ReadLine());
		int ans = 0;
		bool[] used = new bool[101];
		for(int i = 0; i < N; i++)
		{
			int d = Int32.Parse(Console.ReadLine());
			if(!used[d])
			{
				ans++;
				used[d] = true;
			}
		}

		Console.WriteLine(ans);
	}
}





Measured memory_bytes: 11092
/*
	* ernestvw
	* C++
	* May 2020
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define x first
#define y second
#define pb push_back
#define pii pair<int, int>
#define veci vector<int>
#define vecs vector<string>
#define amax(x, v) x = max(x, (v))
#define amin(x, v) x = min(x, (v))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define nl '\n'

using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

const int oo = 1e9; // INT_MAX
const long long OO = 1e18; // LLONG_MAX
const double eps = 1e-9;
const int p197 = 1000000007;
const int p998 = 998244353;
const int p103 = 1000003;

#define TEST_CASES 0

void solve(int test_case);

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

	int T = 1;
	if(TEST_CASES) cin >> T;
	for(int t = 1; t <= T; t++)
		solve(t);

	return 0;
}

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

int n, m;

void solve(int test_case) {
	cin >> n >> m;
	int i1 = 1, i2 = m + 1, i3 = m + 2, i4 = 2*m + 1;
	for(int i = 0; i < m; i++) {
		if(i % 2 == 0) cout << i1 << " " << i2 << nl, i1++, i2--;
		else cout << i3 << " " << i4 << nl, i3++, i4--;
	}
}




















































Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll dp[20005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
string s[2000005];
P p[2000005];
int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		sum += x[i];
	}
	ll h = (double)sum / n+0.5;
	
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll kai =  abs((x[i] - h) * (x[i] - h));
		
		ans += kai;
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 18688
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    set<string> st;
    bool ok = true;
    string tmp;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        if(st.find(s) != st.end()) ok = false;
        else st.insert(s);
        if(i > 0)
        {
            if(tmp.back() != s[0]) ok = false;
        }
        tmp = s;
    }
    cout << (ok ? "Yes" : "No") << endl;
	return 0;
}



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

int check(int x)
{
  int y=3;
  
  while(y<=sqrt(x)){
    if(x%y==0) return 0;
    
    y+=2;
  }
  return 1;
}

int main(){
  int num[10000], i, number, x;
  int M=0;

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

  for(i=0; i<number; i++){

    if(num[i]==2){
      M++;
      continue;
    }
    else if(num[i]<2||num[i]%2==0){
      continue;
    }
    x=check(num[i]);
    if(x==1) M++;
  }
  printf("%d\n", M);
  return 0;
}

Measured memory_bytes: 632
n = int(input())
a = list(map(int, input().split()))
calc = []
for i in range(n):
    calc.append(a[i] - (i + 1))

calc.sort()
b = calc[n // 2]
ans = 0
for i in range(n):
    ans += abs(a[i] - (b + i + 1))

print(ans)

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

int main() {
  int n;
  set<string> st;
  cin >> n;

  bool flg=true;
  for (int i=0; i<n; i++) {
    char t;
    string s;
    cin >> s;

    if (i>0 && s.front()!=t) flg=false;
    t=s.back();
    st.insert(s);
  }

  if (st.size()!=n) flg=false;

  if (flg) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;


const int MAX = 1000000;
bool is_prime[MAX + 10];

int memo[MAX + 10];
int key(int n)
{
	if (is_prime[n])
		return n;
	//else if (~memo[n])
	//	return memo[n];

	int sum = 0, last;
	for (int i = 2; i <= n; ++i)
	{
		if (is_prime[i] && n % i == 0)
		{
			sum += i, last = i;
			while (n % i == 0)
				n /= i;
		}
	}
	return memo[n] = 2*last - sum;
}
int main()
{
	fill_n(is_prime, MAX, true);
	for (int i = 2; i*i <= MAX; ++i)
		if (is_prime[i])
			for (int j = 2*i; j <= MAX; j += i)
				is_prime[j] = false;

	//fill_n(memo, MAX, -1);
	int a, b;
	while (scanf("%d%d", &a, &b), a | b)
		puts(key(a) > key(b) ? "a" : "b");
}

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

bool c, d, e;
int main() {
	char a[20];
	scanf("%s", a);
	int b = strlen(a);
	for (int i = 0; i < b; i++) {
		if (a[i] >= '0'&&a[i] <= '9')c = true;
		else if (a[i] >= 'a'&&a[i] <= 'z')d = true;
		else if (a[i] >= 'A'&&a[i] <= 'Z')e = true;
	}
	if (b >= 6 && c&&d&&e)puts("VALID");
	else puts("INVALID");
}

Measured memory_bytes: 3148
N, M = map(int, input().split())
swich = [set() for i in range(N)]
ans = 0
b = 0
for i in range(M):
  S = list(map(int, input().split()))
  for j in range(1, len(S)):
    swich[S[j] - 1].add(i)
P = list(map(int, input().split()))
for i in range(2**N):
  light = [0 for i in range(M)]
  for j in range(N):
    if i >> j & 1 == 1:
      for x in swich[j]:
        light[x] += 1
  if all(light[i] % 2 == P[i] for i in range(M)):
    ans += 1
print(ans)

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

int main() {
    vector<int> v(3);
    for(auto &i: v) cin >> i;
    sort(v.begin(), v.end());
    cout << v[0] << " " << v[1] << " " << v[2] << endl;

    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
struct Point{double x,y;};
double dis(Point a,Point b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
Point tri(Point a, Point b, Point c){
  double a1,a2,b1,b2,c1,c2;
  a1=2*(b.x-a.x);
  b1=2*(b.y-a.y);
  c1=a.x*a.x-b.x*b.x+a.y*a.y-b.y*b.y;
  a2=2*(c.x-a.x);
  b2=2*(c.y-a.y);
  c2=a.x*a.x-c.x*c.x+a.y*a.y-c.y*c.y;
  Point p;
  p.x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
  p.y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
  return p;
}
int main(){
  int n;
  cin >> n;
  int i;
  for(i=0;i<n;i++){
  Point a,b,c;
  cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
  Point x = tri(a,b,c);
  printf("%.3f %.3f %.3f\n",x.x,x.y,dis(x,a));
  }
  return 0;
}



Measured memory_bytes: 3208
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int W, H, N;
	cin >> W >> H >> N;

	bool Graph[102][102] = { false };

	int x[102], y[102], A[102];
	rep(i, N) {
		cin >> x[i] >> y[i] >> A[i];
		switch (A[i])
		{
		case 1:
			for (int a = 0; a < x[i]; a++) {
				for (int b = 0; b < H; b++) Graph[b][a] = true;
			}
			break;
		case 2:
			for (int a = x[i]; a < W; a++) {
				for (int b = 0; b < H; b++) Graph[b][a] = true;
			}
			break;
		case 3:
			for (int a = 0; a < W; a++) {
				for (int b = 0; b < y[i]; b++) Graph[b][a] = true;
			}
			break;
		case 4:
			for (int a = 0; a < W; a++) {
				for (int b = y[i]; b < H; b++) Graph[b][a] = true;
			}
			break;
		}
	}

	int ans = 0;
	rep(i, H) {
		rep(j, W) ans = Graph[i][j] ? ans : ans + 1;
	}

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


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int mex=2005;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
int main()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   int cnt=0;
   fo(i,0,n-2)
   {
       if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') cnt++;
   }
   cout<<cnt;
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define inf 1<<29

int check[100000];
vector<pii> g[100000];
int n;
int posi[100000];

bool bfs(int i){
  queue<int> q;
  q.push(i);
  check[i]=1;
  while(!q.empty()){
    int a = q.front();
    q.pop();
    int s = g[a].size();
    rep(j,s){
      if(check[g[a][j].first]==0){
	posi[g[a][j].first]=posi[a]+g[a][j].second;
	check[g[a][j].first]=1;
	q.push(g[a][j].first);
      }else{
	if(posi[g[a][j].first]!=posi[a]+g[a][j].second){
	  return false;
	}else continue;
      }
    }
  }
  return true;
}

main(){
  int m; cin >> n >> m;
  int l,r,d;

  rep(i,m){
    cin >> l >> r >> d;
    g[--l].pb(make_pair(--r,d));
    g[r].pb(make_pair(l,-1*d));
  }

  rep(i,n){
    if(check[i]==0)
      if(bfs(i)==false){
	cout << "No\n";
	return 0;
      }
  }

  cout << "Yes\n";
}


Measured memory_bytes: 10096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
void print(ll x){
	if(x<0)putchar('-'),x=-x;
	int y=x%10+'0';
	if(x>=10)print(x/10);
	putchar(y);
}
ll n,ans,a[100005][3],dp[100005][3];
int main(){
	n=read();
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			a[i][j]=read();
	for(int i=0;i<3;i++)
		dp[0][i]=a[0][i];
	for(int i=1;i<n;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(j!=k)dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
	for(int i=0;i<3;i++)
		ans=max(ans,dp[n-1][i]);
	print(ans);
	return 0;
}

Measured memory_bytes: 4992
N,T = map(int,input().split())

item=[list(map(int,input().split())) for _ in range(N)]
item = sorted(item,key=lambda x:x[0])

dp=[[0]*(T+3000) for _ in range(N+1)]

for i,(a,b) in  enumerate(item,1):
    for t in reversed(range(T)):
        dist=t+a
        dp[i][dist] = max(dp[i-1][t]+b,dp[i][dist])
        dp[i][t]=max(dp[i-1][t],dp[i-1][t])
ans=0
for l in dp:
    ans=max(ans,max(l))
print(ans)


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    string s;
    cin >> s;
    map<char,int>mp;
    set<char> se;
    for(char c:s){
        mp[c]++;
        se.insert(c);
    }
    set<string>st;
    set<char> stc;
    stc.insert(s[0]);
    mp[s[0]]--;
    if(mp[s[0]]==0)se.erase(s[0]);
    for(i=1;i<s.size();i++){
        mp[s[i]]--;
        if(mp[s[i]] == 0) se.erase(s[i]);
        for(char x:stc){
            for(char t:se){
                string f={};
                f += x;
                f+=s[i];
                f+=t;
                //cout << f << endl;
                st.insert(f);
            }
        }
        stc.insert(s[i]);
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

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

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    if (n % 2 == 1) {
      for (int i = 1; i <= m; i++) {
        pw.println(i + " " + (n - i));
      }
      return;
    } else {
      for (int i = 1; i <= m; i++) {
        if (i <= n / 4) {
          pw.println(i + " " + (n - i + 1));
        } else {
          pw.println(i + " " + (n - i));
        }
      }
      return;
    }
  }
}


Measured memory_bytes: 52960
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 2;

void solve(long long N, std::vector<long long> a){
  vector<ll> A(N);
  for(ll i=N;i>0;--i){
    if(i>N/2){
      A[i-1]=a[i-1];
    }else{
      ll sum=a[2*i-1],idx=i*3-1;
      while(idx<N){
        sum+=A[idx];
        sum%=2;
        idx+=2*i;
      }
      A[i-1]=(sum==a[i-1]?0:1);
    }
  }
  vector<ll> ans;
  REP(N){
    if(A[i]==1){
      ans.push_back(i);
    }
  }
  cout<<ans.size()<<endl;
  REP(ans.size()){
    cout<<ans[i]+1;
    if(i==ans.size()-1)cout<<endl;
    else cout<<" ";
  }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

int main() {
    string s;
    int n;
    cin >> n >> s;
    int res = 0, cur = 0;
    for (char c : s) {
        if (c == 'I') cur++;
        else cur--;
        res = max(res, cur);
    }
    cout << res << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m,a[1000];

  cin>>n>>m;


  for(int i=0;i<n;i++)cin>>a[i];


  bool used[1000]={};
  
  int p=0,ans=0;

  while(!used[p]){
    
    int mx=-1,mn=1e9,i=0;
    
    while(i<m){
      mn=min(a[(p+i)%n],mn);
      mx=max(a[(p+i)%n],mx);
      i++;
    }

    ans+=mx-mn;
    used[p]=1;
    p=(p+m)%n;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
const int mo = 1e9 + 7;
#define inv2 500000004ll
typedef long long LL;
const int MAXN = 3e3 + 10;
int a[MAXN], f[MAXN][MAXN];
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while(!isdigit(t)) t = getchar();
	while(isdigit(t))
	{
		x = x * 10 + t - '0';
		t = getchar();
	}
}
typedef long long ll;
inline ll fpm(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1) res = 1ll * res * a % mo;
		a = 1ll * a * a % mo;
		b >>= 1;
	}
	return res;
}
int n, q;
int main()
{
	_read(n), _read(q);
	for(int i = 1; i <= n; ++i) _read(a[i]);
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			f[i][j] = a[i] < a[j];
	for(int i = 1; i <= q; ++i)
	{
		int x, y;
		_read(x), _read(y);
		f[x][y] = f[y][x] = inv2 * (f[x][y] + f[y][x]) % mo;
		for(int j = 1; j <= n; ++j)
			if(j != x && j != y)
				f[j][x] = f[j][y] = inv2 * (f[j][x] + f[j][y]) % mo, f[x][j] = f[y][j] = inv2 * (f[x][j] + f[y][j]) % mo;
//		cout << "&*(@&*#)" << endl;
	}
	long long ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < i; ++j) ans += f[i][j];
//	cout << q << endl;
	printf("%lld\n", 1ll * ans % mo * fpm(2, q) % mo);
	return 0;
}

Measured memory_bytes: 35584
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint sum[2001][2001][2];
lint K;

lint calc(lint x1,lint x2,lint y1,lint y2,lint i){

    return sum[x2][y2][i]-sum[x1][y2][i]-sum[x2][y1][i]+sum[x1][y1][i];
}

int main(void){
    lint N;
    cin >> N >> K;
    lint X[N],Y[N];
    char C[N];
    rep(i,N) cin >> X[i] >> Y[i] >> C[i];
    rep(i,N) X[i]%=2*K,Y[i]%=2*K;
    lint cnt[2*K][2*K][2]={};
    rep(i,N){
        if(C[i]=='W') cnt[X[i]][Y[i]][0]++;
        else cnt[X[i]][Y[i]][1]++;
    }
    rep(i,2) rep(j,2*K) rep(k,2*K) sum[j+1][k+1][i]=cnt[j][k][i]+sum[j+1][k][i]+sum[j][k+1][i]-sum[j][k][i];
    lint ans=0;
    rep(x,2) rep(i,K) rep(j,K){
        lint cmp=0;
        lint n=(x+1)%2;
        cmp+=calc(0,i,0,j,x);
        cmp+=calc(i+K,2*K,0,j,x);
        cmp+=calc(0,i,j+K,2*K,x);
        cmp+=calc(i+K,2*K,j+K,2*K,x);
        cmp+=calc(i,i+K,j,j+K,x);
        cmp+=calc(i,i+K,0,j,n);
        cmp+=calc(i,i+K,j+K,2*K,n);
        cmp+=calc(0,i,j,j+K,n);
        cmp+=calc(i+K,2*K,j,j+K,n);
        ans=max(ans,cmp);
    }
    cout << ans << endl;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a,b,c;

  cin>>a>>b>>c;

  bool judge=0;

  if(a==1&&b==0&&c==0){
    judge=1;
  }

  else if(a==0&&b==1&&c==0){
    judge=1;
  }

  else if(a==1&&b==1&&c==0){
    judge=0;
  }

  else if(a==0&&b==0&&c==1){
    judge=0;
  }

  else if(a==0&&b==0&&c==0){
    judge=1;
  }
           
  if(judge){
    cout<<"Close"<<endl;
  }else{
    cout<<"Open"<<endl;
  }

  return 0;

}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N;
    cin>>N;
    vector<int> d(N);
    rep(i,N)cin>>d.at(i);
    sort(d.begin(),d.end());
    int b=d.at(N/2-1),r=d.at(N/2);
    cout<<r-b<<endl;
}

Measured memory_bytes: 640
const main = (input) => {
  input = input.split(' ');
  const n = parseInt(input[0], 10);
  const k = parseInt(input[1], 10);
  
  if(n%k==0){
    console.log(0);
  }else{
    console.log(1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>

#define equals ==

using namespace std;

int main()
{
    string weather;
    cin >> weather;
    if(weather equals "Sunny") {
        cout << "Cloudy";
    }
    else if(weather equals "Cloudy") {
        cout << "Rainy";
    }
    else if(weather equals "Rainy") {
        cout << "Sunny";
    }
}


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

using namespace std;

typedef long long int ll;

const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;

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

  ll n;
  cin >> n;
  vector < ll > a(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];

  vector < ll > b(n + 1, 1);
  for(int i = n; i >= 1; i--){
    ll cnt = 0;
    for(int j = i; j <= n; j += i){
      if(b[j]) cnt++;
    }
    if(cnt % 2 != a[i] % 2) b[i]--;
  }

  vector < ll > v;
  for(int i = 1; i <= n; i++){
    if(b[i]) v.push_back(i);
  }

  cout << v.size() << endl;
  for(auto i : v) cout << i << " ";
  cout << '\n';
}


Measured memory_bytes: 5108
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;


char S[100];

int i,j,K,X,N,Y,M,ans,A[2001]={0},r;

int main()
{
  cin>>N>>X>>Y;
  X--;
  Y--;
  for(i=0;i<N;i++)
  {
    for(j=i+1;j<N;j++)
    {
      if(i<=X)
      {
        if(j<=X)          
        {
          A[j-i]++;
        }
        else if(j<=Y)
        {
          r=X-i+min(j-X,Y-j+1);
          A[r]++;          
        }
        else
        {
          r=j-Y+1+X-i;
          A[r]++;
        }
      }
      else if(i<=Y)
      {
        if(j<=Y)
        {
          r=min(j-i,Y-j+1+i-X);
          A[r]++;
        }
        else
        {
          r=j-Y+min(Y-i,i-X+1);
          A[r]++;
        }
      }
      else
      {
        A[j-i]++;
      }
    }
  }
  
  for(i=1;i<N;i++)
  {
    cout <<A[i]<<endl;
  }
  
}

Measured memory_bytes: 256
#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>

using namespace std;
#define next __next
#define prev __prev
#define right __right
#define left __left
#define index __index

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<int, int> ipair;
#define szof(x) ((int)(x).size())
#define ff first
#define ss second
#define puba push_back
#define bend(x) (x).begin(), (x).end()

int const INF = 100 + (int) 1e9;
ll const INFL = 100 + (ll) 1e18;
ld const PI = 3.141592653589793238462643L;
mt19937 tw(960172);

bool is_prime(ll x) { for (ll y = 2; y * y <= x; ++y) if (x % y == 0) return 0; return x > 1; }
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }
ll sqr(int a) { return (ll) a * a; } template<class T> T sqr(T const& a) { return a * a; }
ll gcd(ll a, ll b) { while (b > 0) { ll t = a % b; a = b; b = t; } return a; }

int const N = 100100;

int cnt[N];

void solve() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    multiset<int> s;
    for (int i = 0; i < N; ++i)
        if (cnt[i] > 0)
            s.insert(cnt[i]);
    while (*s.rbegin() > 1) {
        int x = *s.rbegin();
        s.erase(s.find(x));
        if (x > 2) {
            s.insert(x - 2);
            continue;
        }
        int y = *s.rbegin();
        s.erase(s.find(y));
        if (y == 1) {
            s.insert(1);
        } else {
            if (s.empty()) {
                s.insert(1);
            } else {
                s.insert(1);
                s.insert(1);
            }
        }
    }
    cout << s.size() << '\n';
}

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    cout << setprecision(15) << fixed;
#ifdef LOCAL
    cerr << setprecision(6) << fixed;
#endif
    int tcnt = 1;
    for (int test = 1; test <= tcnt; ++test)
        solve();
#ifdef LOCAL
    cerr << "time: " << (ll) clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
}


Measured memory_bytes: 5376
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, k, q = map(int, input().strip().split())
  scores = numpy.zeros(n)
  for A in  [int(input()) for _ in range(q)]:
    scores[A-1] += 1
  for score in scores:
    if k - (q - score) > 0:
      print('Yes')
    else:
      print('No')

if __name__=='__main__':
  main()



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

using namespace std;

int main()
{
    long long int n,k;
    cin>>n>>k;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long int sum=0;
    for(int i=0;i<k;i++)
    {
        sum=sum+a[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
const ll INF=1e18;
vector<ll> v[200000];
ll dp[200000];
ll n,m;
ll dfs(ll n){
  if(dp[n]!=-1)
  return dp[n];
  ll y=0;
for(auto it:v[n]){
 dp[n]=max(1+dfs(it),dp[n]);
}
if(dp[n]==-1)
     dp[n]=0;
return dp[n];
}
 int main(){
   IOS;
   cin>>n>>m;
   ll a,b;
   for(ll i=1;i<=m;i++){
     cin>>a>>b;
     v[a].pb(b);
   }
  ll ans=0;
  memset(dp,-1,sizeof(dp));
   for(ll i=1;i<=n;i++)
   ans=max(ans,dfs(i));
   cout<<ans;
 }


Measured memory_bytes: 11008
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int mmin(int &a, int b) {
	a = min(a, b);
	return a;
}
int mmax(int &a, int b) {
	a = max(a, b);
	return a;
}
int nibu(vector<int> &v, int tan) {
	int up = v.size()-1;
	int lo = 0;
	if (tan <= v[0]) {
		return 0;
	}
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (tan <= v[mi]) {
			up = mi;
		}
		if (v[mi] < tan) {
			lo = mi;
		}
	}
	return up;
}
int main() {
	int n;
	cin >> n;
	vector<int> de(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		de[i] = (x + i) % 2;
	}
	vector<int> at(max(n,3), 0);
	int ba = de[0];
	int th = 0;
	int st = 0;
	for (int i = 1; i < n; i++) {
		if (ba != de[i]) {
			ba = de[i];
			at[th] = i - st;
			th++;
			st = i;
		}
	}
	at[th] = n - st;
	int ans = 0;
	for (int i = 0; i+2<max(n,3); i++) {
		mmax(ans, at[i] + at[i + 1] + at[i + 2]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3612
n = int(input())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))

ans = sum(blist)
for i in range(n-1):
    if alist[i + 1] - alist[i] == 1:
        ans += clist[alist[i]-1]
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(void){
    int i;
    int sum = 0;
    char W[11],T[1001];
    scanf("%s",W);
    for(i=0;W[i];++i){
        W[i]=tolower(W[i]);
    }
    while(1){
        scanf("%s",T);
        if(strcmp("END_OF_TEXT", T)==0){
            break;
        }
        for(i=0;T[i];++i){
            T[i] = tolower(T[i]);
        }
        if(strcmp(W,T)==0){
            ++sum;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,w,h,x,y,s,t,cnt,ans=0,k,l;
  int mp[210][210];
  while(1){
    cin>>n;
    if(n==0) break;
    for(int i=0;i<210;i++){
      for(int j=0;j<210;j++){
	mp[i][j]=0;
      }
    }
    ans=0;
    cin>>w>>h;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      mp[y-1][x-1]=1;
    }
    /* for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cout<<mp[i][j]<<" ";
      }
      cout<<endl;
    }*/
    cin>>s>>t;
    int ans = 0;
    for(int i=0;i+s-1<=w;i++){
      for(int j=0;j+t-1<=h;j++){
	int z=0;
	for(int k=i;k<s+i;k++){
	  for(int l=j;l<t+j;l++){
	    z+=mp[l][k];
	  }
	}
	ans=max(z,ans);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



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

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

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

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[55][55];
int dis[55][55];
int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%s", in[i] + 1);

	if (in[1][1] == '#' || in[N][M] == '#') return !printf("-1\n");

	memset(dis, 0x3f, sizeof(dis));
	dis[1][1] = 0;
	vector <pii> Vu;
	Vu.emplace_back(1, 1);
	for (i = 0; i < Vu.size(); i++) {
		for (j = 0; j < 4; j++) {
			int x = Vu[i].first + "1102"[j] - '1';
			int y = Vu[i].second + "0211"[j] - '1';
			if (x < 1 || x > N || y < 1 || y > M || in[x][y] == '#' || dis[x][y] != INF) continue;
			dis[x][y] = dis[Vu[i].first][Vu[i].second] + 1;
			Vu.emplace_back(x, y);
		}
	}
	if (dis[N][M] == INF) return !printf("-1\n");

	int ans = 0;
	for (i = 1; i <= N; i++) for (j = 1; j <= M; j++) if (in[i][j] == '.') ans++;
	ans -= dis[N][M] + 1;
	return !printf("%d\n", ans);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase

def solve():
    s = input()
    a = [x for x in s]

    if s == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
        return

    x = set(a)
    xd = []

    if len(s) == 26:
        while a[-2] > a[-1]:
            xd.append(a.pop())
        xd.append(a.pop())
        wtf = a.pop()
        xd.sort()
        for e in xd:
            if e > wtf:
                print(''.join(a) + e)
                return
    else:
        for e in string.ascii_lowercase:
            if e not in x:
                print(s + e)
                return
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


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

typedef struct pole{
	struct pole* next;
	int y;
} Pole;

Pole* table[5001];

int search(int x,int y)
{
	if(x < 0 || y < 0 || x > 5000 || y > 5000)return 0;
	if(table[x] != NULL)
	{
		Pole* pt = table[x];
		while(pt->next != NULL)
		{
			if(pt->y == y)
				return 1;
			pt = pt->next;
		}
		if(pt->y == y)
			return 1;
	}
	return 0;
}

int main()
{
	int** poleList;
	int n;
	int i,j,k,l,m,o;
	while(scanf("%d",&n),n)
	{
		for(i = 0;i <= 5000;i++)
		{
			table[i] = NULL;
		}
		poleList = (int**)malloc(sizeof(int*)*n);
		for(i = 0;i < n;i++)
		{
			int x,y;
			scanf("%d %d",&x,&y);
			poleList[i] = (int*)malloc(sizeof(int)*2);
			poleList[i][0] = x;
			poleList[i][1] = y;
			if(table[x] == NULL)
			{
				table[x] = (Pole*)malloc(sizeof(Pole));
				table[x]->next = NULL;
				table[x]->y = y;
			}
			else
			{
				Pole* tmp = table[x];
				table[x] = (Pole*)malloc(sizeof(Pole));
				table[x]->next = tmp;
				table[x]->y = y;
			}
		}
		int maxsq = 0;
		for(i = 0;i < n;i++)
		{
			for(j = (i+1);j < n;j++)
			{
				double posx[6] = {
					poleList[i][0]+poleList[i][1]-poleList[j][1],
					poleList[j][0]+poleList[i][1]-poleList[j][1],
					poleList[i][0]-poleList[i][1]+poleList[j][1],
					poleList[j][0]-poleList[i][1]+poleList[j][1],
					(poleList[i][0]+poleList[j][0]+poleList[i][1]-poleList[j][1])/2,
					(poleList[i][0]+poleList[j][0]-poleList[i][1]+poleList[j][1])/2
				};
				double posy[6] = {
					poleList[i][1]-poleList[i][0]+poleList[j][0],
					poleList[j][1]-poleList[i][0]+poleList[j][0],
					poleList[i][1]+poleList[i][0]-poleList[j][0],
					poleList[j][1]+poleList[i][0]-poleList[j][0],
					(poleList[i][1]+poleList[j][1]-poleList[i][0]+poleList[j][0])/2,
					(poleList[i][1]+poleList[j][1]+poleList[i][0]-poleList[j][0])/2
				};
				int sq = (poleList[i][0]-poleList[j][0])*(poleList[i][0]-poleList[j][0])
					+(poleList[i][1]-poleList[j][1])*(poleList[i][1]-poleList[j][1]);
				if(search(posx[0],posy[0]) && search(posx[1],posy[1]) || search(posx[2],posy[2]) && search(posx[3],posy[3]))
				{
					if(sq < maxsq)continue;
					else maxsq = sq;
				}
				else if(search(posx[4],posy[4]) && search(posx[5],posy[5]))
				{
					if(sq < maxsq*2)continue;
					else maxsq = sq/2;
				}
			}
		}
		printf("%d\n",maxsq);
	}
	return 0;
}

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


const ll mod=1e9+7;

const int maxn=1e5+7;
ll zx[maxn];


int main (){
    zx[0]=1;
    for(int i=1;i<maxn;i++) zx[i]=zx[i-1]*3ll%mod;
    string ss;cin>>ss;
    int sz=ss.size();
    ll ans=0,f2=1ll;
    for(int i=0;i<sz;i++){
        if(ss[i]=='1')  ans=(ans+f2*zx[sz-i-1]%mod)%mod,f2=f2*2%mod;
    }
    cout<<(ans+f2)%mod<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
string S;
bool V;

int main(void){
	//IO("test.in", "test.out");
	V = true;
	cin >> S;
	for(int i = 0; i < S.length() - 1; i++)
		for(int j = i + 1; j < S.length(); j++)
			if(S[i] == S[j]) V = false;
	if(V) printf("yes\n");
	else printf("no\n"); 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,a[N];

int main() {
	scanf("%d", &n);
	REP(i,1,2*n) cin>>a[i];
	sort(a+1,a+1+2*n);
	ll ans=0;
	REP(i,1,n) ans+=a[2*i-1];
	printf("%lld\n",ans);
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define SZ(x)        ((int)(x).size())
#define READ(x)      freopen(x,"r",stdin)
#define WRITE(x)     freopen(x,"w",stdout)
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef vector<int> VI;
const ll mod= 1e9+7,INF=1e18,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {

    Fast_Input

   // cin>>testCase;
    while(testCase--) {

        ll n; cin>>n;

        vector<ll> A(n),B(n);

        for(int i=0; i<n; i++){
            cin>>A[i];
            B[i]=A[i];
        }
        sort(all(B));

        for(int i=0; i<n; i++){

            int pos= lower_bound(all(B),A[i])-B.begin();

//            cout<<pos<<" "<<B[pos]<<endl;

            if(pos==0){
                pos= (n-1)/2;
                cout<<B[pos+1]<<endl;
            }else if(pos==n-1){

                pos= pos/2;
                cout<<B[pos]<<endl;
            }
            else{

                ll L=pos;
                ll R= n-pos-1;

                if(R>L){
                    //cout<<L<<" "<<R<<endl;
                    pos=(L+R)/2;

                    cout<<B[n-pos-1]<<endl;
                }else{

                    //cout<<L<<" "<<R<<endl;
                    pos=(L+R)/2;
                    cout<<B[pos]<<endl;

                }

            }


        }

    }
    return 0;
}

Measured memory_bytes: 5376
import sys
import math
input = sys.stdin.readline

s = input().strip()
n = len(s)
a = [ord(s[0]) - ord('0')]
for i in range(n - 1):
    if s[i] == s[i + 1]:
        a.append(0)
    else:
        a.append(1)
a.append(ord(s[n - 1]) - ord('0'))
ans = n
for i in range(len(a)):
    if a[i] == 1:
        ans = min(ans, max(n - i, i))
if sum(a) % 2 == 0:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 45936
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,b,a) for(int i=b;i>=a;--i)
#define efo(i,v,u) for(int i=BB[v],u=B[BB[v]][1];i;i=B[i][0],u=B[i][1])
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define cmax(x,y) ((x)<(y)?(x)=(y):(x))
#define cmin(x,y) ((x)>(y)?(x)=(y):(x))
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=2005,mo=1e9+7;
int n,m,k,f[N+N][N];
int main()
{
	n=read(),m=read(),k=read();
	swap(n,m);
	if(!n || !m) return puts("1"),0;
	f[0][0]=1;
	ll ans=0;
	fo(i,1,n+m)
		fo(j,0,min((k-1)*i,n)) if((k-1)*i-j<=m-1)
		{
			fo(l,max(0,j-k+1),j)
				f[i][j]=(f[i][j]+f[i-1][l])%mo;
			if((j%(k-1))==(n%(k-1)) && (((k-1)*i-j)%(k-1))==((m-1)%(k-1)))
				ans=(ans+f[i][j]-f[i-1][j]+mo)%mo;
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 30336
N=gets.to_i
A=gets.split.map &:to_i

def f(aa)
l=[[0,-1]]
u=[]
N.times{|i|
  a=aa[i]
  l.pop while l[-1][0]>a
  u<<i-l[-1][1]
  l<<[a,i]
}
u
end

B=f(A)
C=f(A.reverse).reverse
r=0
N.times{|i|
  r+=A[i]*B[i]*C[i]
}
p r


Measured memory_bytes: 36996
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
	Scanner scanner = new Scanner(System.in);

	String string = scanner.next();
	scanner.close();

	boolean result = false;

	boolean firstCondition = string.substring(2).startsWith(string.substring(3, 4));
	boolean secondCondition = string.substring(4).startsWith(string.substring(5, 6));

	result = firstCondition && secondCondition;

	System.out.println(result ? "Yes" : "No");
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    long long n,k; cin>>n>>k;
    long long a[n]; rep(i,n) cin>>a[i];
    long long cnt[40][2]={};
    long long sum=0;
    rep(i,n){
        sum+=a[i]^k;
        for(long long j=0;j<40;j++){
            cnt[j][a[i]>>j&1]++;
        }
    }
    for(long long i=39;i>=0;i--){
        if(!(k>>i&1)) continue;
        long long tmpsum=0;
        for(long long j=39;j>=0;j--){
            // kと同じ
            if(j>i){
                tmpsum+=cnt[j][!(k>>j&1)]*(1ll<<j);
            // ここから違うしここは0
            }else if(j==i){
                tmpsum+=cnt[j][1]*(1ll<<j);
            // 任意
            }else{
                tmpsum+=max(cnt[j][0],cnt[j][1])*(1ll<<j);
            }
        }
        sum=max(sum,tmpsum);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>

int main(void){
  int n, i;
  int a[n];
  int sum=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
  printf("%d\n",sum-n);
  
  return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int ans = 0;
  for (int i = 0; i < 3; ++i) if (S[i] == T[i]) ++ans;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256