akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;
using vd = vector<ld>;

template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class TIn, class TOut = null_type>
using order_tree = tree<TIn, TOut, less<TIn>, rb_tree_tag,
	tree_order_statistics_node_update>;
// .find_by_order(int r) and .order_of_key(TIn v)

constexpr int INF = 2000000010;
constexpr ll LLINF = 9000000000000000010LL;
constexpr ld PI = acos(-1);

ll nckmod2(ll n, ll k) {
	assert(n >= k);
	return ((n&k) == k) ? 1LL : 0LL;
}

void solve() {
	int N;
	cin >> N;
	vi a(N);
	{
		string S;
		cin >> S;
		for (int i = 0; i < N; ++i) a[i] = int(S[i]-'1');
	}

	// is there no 1?
	bool no1 = true;
	for (ll x : a) no1 = no1 && (x != 1);

	if (no1) {
		ll ans = 0LL;
		for (int i = 0; i < (int)a.size(); ++i) {
			ans = (ans + (a[i]/2)*nckmod2(ll(a.size())-1, ll(i))) % 2;
		}
		cout << (ans*2) << endl;
	} else {
		ll ans = 0LL;
		for (int i = 0; i < (int)a.size(); ++i) {
			ans = (ans + (a[i]%2)*nckmod2(ll(a.size())-1, ll(i))) % 2;
		}
		cout << ans << endl;
	}
}

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


Measured memory_bytes: 9756
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)			
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}	
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=4005,mod=998244353;
char s[maxn];
int n;
int f[maxn][maxn],binom[maxn][maxn];
int sum[maxn];
int add(int x,int y){
	return x+y>=mod?x+y-mod:x+y;
}
int main(){
	rep(i,0,maxn-5)rep(j,0,i)binom[i][j]=!j?1:add(binom[i-1][j-1],binom[i-1][j]);
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n)sum[i]=sum[i-1]+(s[i]-'0');
	f[0][0]=1;
	rep(i,1,n)rep(j,0,min(sum[i-1],i-1))if(f[i-1][j]){
		if(i-j<=2*i-sum[i])f[i][j]=add(f[i][j],f[i-1][j]);
		if(j+1<=sum[i])f[i][j+1]=add(f[i][j+1],f[i-1][j]);
	}
	int res=0;
	rep(j,0,min(sum[n],n))res=add(res,1ll*f[n][j]*binom[n][sum[n]-j]%mod);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 93056
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int count = 1;
    for(int i = 1;i < n;i++)
    {
      if(s.at(i-1) != s.at(i)) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 512
// 約数作るだけでは

package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	divs := enumDiv(N)
	ans := int(1e10)
	for _, a := range divs {
		b := N / a
		ans = min(ans, max(keta(a), keta(b)))
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

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

func keta(x int) int {
	ret := 0
	for x > 0 {
		ret += 1
		x /= 10
	}
	return ret
}

func enumDiv(x int) (ret []int) {
	ret = []int{}
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			ret = append(ret, i)
			if i != 1 && i*i != x {
				ret = append(ret, x/i)
			}
		}
	}
	return
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	IOS;
	int n, u, v;
	cin >> n >> u >> v;
	u--;
	v--;
	vector<int> a(n - 1), b(n - 1);
	REP(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	vector<vector<int>> path(n);
	REP(i, n - 1) {
		path[a[i]].push_back(b[i]);
		path[b[i]].push_back(a[i]);
	}
	int res = 0;
	queue<int> qa, qb;
	vector<int> dv(n, -1);
	dv[v] = 0;
	qa.push(v);
	vector<int> du(n, -1);
	du[u] = 0;
	qb.push(u);
	int tmp = -1;
	while (!qa.empty()) {
		int pa = qa.front();
		qa.pop();
		REP(i, path[pa].size()) {
			if (dv[path[pa][i]] < 0) {
				dv[path[pa][i]] = dv[pa] + 1;
				qa.push(path[pa][i]);
			}
		}
	}
	while (!qb.empty()) {
		int pb = qb.front();
		qb.pop();
		REP(i, path[pb].size()) {
			if (du[path[pb][i]] < 0) {
				du[path[pb][i]] = du[pb] + 1;
				if (dv[path[pb][i]] == du[path[pb][i]]) {
					if (tmp < 0) {
						tmp = dv[path[pb][i]];
					}
				}
				qb.push(path[pb][i]);
			}
		}
	}
	chmax(res, tmp);

	REP(i, n) {
		if (dv[i] > du[i]) {
			int t1 = 0;
			REP(j, path[i].size()) {
				chmax(t1, dv[path[i][j]]);
			}
			int t2 = (t1 - du[i]) / 2 * 2 + du[i];
			chmax(res, min(t2,dv[i]));
		}
	}
	put(res);
	
	return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <limits>
#include <cmath>

using namespace std;

int N;
int F[100];
int P[100][11];
int match[100][1024];

int main() {
	cin >> N;
	for(int i=0; i<N; i++) {
		int d = 1;
		for(int j=0; j<10; j++) {
			int n;
			cin >> n;
			F[i] += d * n;
			d *= 2;
		}
	}
	for(int i=0; i<N; i++) {
			for(int j=0; j<11; j++) {
				cin >> P[i][j];
			}
	}

	for(int i=1; i<1024; ++i) {
		for(int j=0; j<N; ++j) {
			int b = i & F[j];
			while(b) {
				match[j][i] += b & 1;
				b >>= 1;
			}
		}
	}
	int pmax = numeric_limits<int>::min();
	for(int i = 1; i<1024; i++) {
		int cnt = 0;
		for(int j=0; j<N; j++) {
			cnt += P[j][match[j][i]];
		}
		pmax = max(pmax, cnt);
	}
	cout << pmax << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int a,b,c,d;
	int s1,s2;
	cin>>a>>b>>c>>d;
	s1=a+b;
	s2=c+d;
	if(s1>s2)cout<<"Left"<<endl;
	else
	if(s1<s2)cout<<"Right"<<endl;
	else if(s1==s2)cout<<"Balanced"<<endl;
		
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<string,int> P;
int main(){
   int N;
   cin>>N;
   vector<string> S(N);
   vector<int> T(N),ans(N);
   vector<P> Q,judge; 
   for(int i=0;i<N;i++){
       cin>>S.at(i)>>T.at(i);
        Q.push_back(P(S.at(i),T.at(i)*-1));
        judge.push_back(P(S.at(i),T.at(i)*-1));
   }
   sort(Q.begin(),Q.end());
   string check1;
   int  check2;
   int k=0;
for(int i=0;i<N;i++){
    check1=judge.at(i).first;
    check2=judge.at(i).second;
    for(int j=0;j<N;j++){
        if(check1==Q.at(j).first&&check2==Q.at(j).second){
            ans.at(j)=i+1;
            k++;
        }
    }
}
for(int i=0;i<N;i++){
    cout<<ans.at(i)<<endl;
}
}

Measured memory_bytes: 256
import io.StdIn._
 
object Main extends App {
  val n = readInt
  val Seq(t, a) = readLine().split(" ").map(_.toInt).toList
  val hList = readLine().split(" ").map(_.toInt).toList
  val result = hList.zipWithIndex.map { case (h, i) =>
    val temperature = t - h * 0.006
    ((temperature - a).abs, i + 1)
  }.min
  println(result._2)
}

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

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
bool check(int a, int b, int c, int d) {
  if (a < b) return false;
  if (d < b) return false;
  if (c >= b) return true;

  int g = gcd(b, d);

  int mx = b + a % g - g;
  if (mx > c) return false;
  return true;
}

signed main() {
  int T;
  cin >> T;

  while (T--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (check(a, b, c, d)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  for(int i=1;i<3501;i++) {
    for(int j=1;j<3501;j++) {
      if(4*i*j-i*n-j*n>0&&i*j*n%(4*i*j-i*n-j*n)==0) {
        cout << i << " " << j << " " << i*j*n/(4*i*j-i*n-j*n) << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
r,g,b,n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  res = n - r * i
  for j in range(res // g + 1): 
    res2 = res - g * j
    if not (res2 % b):
      ans += 1
print(ans)


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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, K;
    cin >> N >> K;
    vector<vector<int>> B(10);
    for (int i = 0; i < N; i++) {
        int s, k;
        cin >> s >> k;
        k--;
        B[k].push_back(s);
    }
    for (int c = 0; c < 10; c++) {
        sort(all(B[c]), greater<int>());
    }

    vector<vector<int>> acc(10);
    for(int c = 0; c < 10; c++) {
        int sum = 0;
        for(int i = 0; i < B[c].size(); i++) {
            acc[c].push_back(sum);
            sum += B[c][i];
            sum += i * 2;
        }
        acc[c].push_back(sum);
    }

    vector<int> dp(K + 1, -1);
    dp[0] = 0;
    for(int c = 0; c < 10; c++) {
        for(int i = K; i >= 0; i--) {
            if (dp[i] == -1) continue;
            for(int j = 0; j < acc[c].size(); j++) {
                if (i + j <= K) dp[i + j] = max(dp[i + j], dp[i] + acc[c][j]);
            }    
        }
    }
    cout << dp[K] << endl;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)

void solve(){
   string s;
   cin >> s;
   for(char &c : s){
      if(c == '?')c = 'D';
   }
   cout << s << "\n";
}

int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int t = 1;
//   cin >> t;
   while(t--){
      solve();
   }
}

Measured memory_bytes: 3784
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

ans = []

if n == 1:
    print(a1[0] + a2[0])
else:
    for i in range(1, n + 1):
        ans.append(sum(a1[0:-i]) + sum(a2[len(a2)-i-1:]))
    print(max(ans))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    string S;
    cin >> S;
    if (S.size() < 4) {
        cout << "No" << endl;
        return 0;
    }
    
    if (S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
// Problem : L - Deque
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_l
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 3005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int n;
int a[maxn],dp[maxn][maxn][2];
void fun(int l,int r,int f)
{
	//cout <<l <<" " << r <<" "<<f <<"\n";
	if(dp[l][r][f]!=-1)
		return;
	if(l == r)
	{
		dp[l][r][f]=a[l];
		dp[l][r][1-f]=0;
		return;
	}
	fun(l,r-1,1-f);
	fun(l+1,r,1-f);
	dp[l][r][f] = max(a[l]+dp[l+1][r][f],a[r]+dp[l][r-1][f]);
	if(dp[l][r][f] == a[l]+dp[l+1][r][f])
		dp[l][r][1-f] = dp[l+1][r][1-f];
	else dp[l][r][1-f]=dp[l][r-1][1-f];
}
void solve()
{
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	memset(dp,-1,sizeof(dp));
	fun(0,n-1,1);
	cout << dp[0][n-1][1]-dp[0][n-1][0];
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 145068
s=str(input())

lis=[0]*3

lis[0]=s.count("a")
lis[1]=s.count("b")
lis[2]=s.count("c")

n=len(s)//3

ans="YES"

for i in lis:
  if n<=i<=n+1:
    continue
  else:
    ans="NO"
    
print(ans)

Measured memory_bytes: 9200
# -*- coding: utf-8 -*-
import itertools
import sys
import math
from functools import lru_cache

# 1整数
# n = int(input())

# 空白区切り2変数
from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

# input = sys.stdin.readline

# N個整数
# a, b, c = list(map(int, input().split()))

# 1整数
# n = int(input())

# 空白区切りリスト整数
# b = list(map(int, input().split()))

# 空白区切り文字列
# t, d = input().split()
ll = []

for i in range(5):
    ll.append(int(input()))
k = int(input())

if ll[4] - ll[0] > k:
    print(':(')
else:
    print('Yay!')


Measured memory_bytes: 4572
// 27
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef LOCAL
#define debug(e) cerr << "\033[48;5;196m\033[38;5;15m" << e << "\033[0m";
#else
#define debug(e)
#endif
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << " " << p.se << ")";
}
// 8
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, (int)v.size()) o << setw(7) << left << v[i];
  return o << endl;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 3
void _main(int tc) {
  string s;
  cin >> s;
  int groupcnt = 0;
  for (int i = 0; i < len(s); i++) {
    while (i + 1 < len(s) && s[i] == s[i + 1])
      i++;  // checking if the next one is same as current
    groupcnt++;
  }
  cout << groupcnt - 1 << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
using namespace std;
 
int main(){
    
    string S;
    int max,x;
    max = 0;
    x=0;

    cin >> S;

    for(int i=0;i<=10;i++){
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
            x+=1;
        }else{
            if(max<x){
                max=x;
            }
            x=0;
        }
    }

    cout << max;

    return 0;

}

Measured memory_bytes: 256
import heapq as hp
import numpy as np

h, w = map(int, input().split())
s = np.array([list(input()) for _ in range(h)])
s = np.pad(s, 1, 'constant')
visited = np.zeros_like(s, dtype=np.bool)

judge = np.inf

q = []
hp.heappush(q, (0, 1, 1))

while q:
    cnt, y, x = hp.heappop(q)
    if y == h and x == w:
        judge = cnt
        break
    for dy, dx in [[0, 1], [1, 0], [-1, 0], [0, -1]]:
        ny, nx = y + dy, x + dx
        if s[ny, nx] == '.' and not visited[ny, nx]:
            visited[ny, nx] = True
            hp.heappush(q, (cnt + 1, ny, nx))

if judge == np.inf:
    print(-1)
else:
    print((s == '.').sum() - judge - 1)

Measured memory_bytes: 27304
#include<iostream>

using namespace std;

int main(){
	
	int n,s=100000;
	cin>>n;
	for(int i=1;i<=n;i++){
		s+=s*0.05;
	if(s%1000!=0)
		s=s-s%1000+1000;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


int keta(int x) {
	int ans = 1;
	for (; 10 <= x; x /= 10)ans++;
	return ans;
}

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

	int N;
	cin >> N;

	int ans = intmax;
	for (int i = 1; i*i <= N; i++)if (N%i == 0) {
		int A = i, B = N / i;
		ans = min(ans, max(keta(A), keta(B)));
	}

	cout << ans << endl;




	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if((a*b)%2 == 0)cout <<"No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define mod 1000000007
using namespace std;
typedef long long int LL;

int main() {
    int n;
    cin >> n;
    vector<vector<int> > a(2, vector<int>(n));

    rep(i, 2) {
        rep(j, n) {
            cin >> a[i][j];
        }
    }

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

    for (int i = 1; i < n; i++) {
        dp[1][i] = a[1][i] + max(dp[0][i], dp[1][i - 1]);
    }
    // rep(i, 2) {
    //     rep(j, n) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[1][n - 1] << endl;
    return 0;
}


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

using namespace std;
int main(void) {
	int a, b, c;
	cin >> a >> b >> c;

	if (a == b && a == c && b == c)
		cout << "Yes";
	else
		cout << "No";
	

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

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

        int dmtr[][][]= new int[4][3][10]; //b f r

        for(int i = 0;i < 4;i++){
            for(int j = 0;j<3;j++){
                for(int k = 0; k < 10;k++){
                    dmtr[i][j][k]=0;
                }
            }
        }
        int n = 100;
        for(int i = 0;i < n;i++){
            if(i ==0){
                String line = new String();
                line = scanner.next();
                n = Integer.parseInt(line);

            }
            String x = scanner.next();
            int b = Integer.parseInt(x);
            String y = scanner.next();
            int f = Integer.parseInt(y);
            String z = scanner.next();
            int r = Integer.parseInt(z);
            String w = scanner.next();
            int v = Integer.parseInt(w); 

            dmtr[b-1][f-1][r-1] += v;
        }
        

        for(int i = 0;i < 4;i++){
            for(int j = 0;j<3;j++){
                for(int k = 0; k < 10;k++){
                    System.out.print(" "+dmtr[i][j][k]);
                    if(k == 9){
                        System.out.print("\n");
                    }
                }
            }
            if(i != 3){
            System.out.println("####################");
            }
        }

        }
    }



Measured memory_bytes: 28796
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a), i##_end = (b); i < i##_end; ++i)
#define per(i, a, b) for (int i = (a), i##_end = (b); i >= i##_end; --i)

using namespace std;

typedef long long ll;

const int N = 1e5 + 2, MOD = 1e9 + 7;

ll fpm(ll x, ll n)
{
	ll y = 1;
	for (; n; (x *= x) %= MOD, n >>= 1)
		if (n & 1)
			(y *= x) %= MOD;
	return y;
}

ll fac[N], ifac[N];
int pos[N];

inline ll C(int n, int k)
{
	if (k > n) return 0;
	return fac[n] * ifac[k] % MOD * ifac[n-k] % MOD;
}

int main()
{
	int n;
	scanf("%d", &n);
	++n;
	fac[0] = 1;
	rep (i, 1, n+1) fac[i] = fac[i-1] * i % MOD;
	ifac[n] = fpm(fac[n], MOD-2);
	per (i, n, 1) ifac[i-1] = ifac[i] * i % MOD;
	int m, x;
	rep (i, 1, n+1)
	{
		scanf("%d", &x);
		if (pos[x])
		{
			m = n - (i - pos[x] + 1);
			break;
		}
		pos[x] = i;
	}
	rep (i, 1, n+1)
		printf("%lld\n", (C(n, i) - C(m, i-1) + MOD) % MOD);
	return 0;
}


Measured memory_bytes: 3200
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        vi a;
        rep(i,n)
        {
            vp(a,x);
        }
        for(i=n-1;i>=0;i-=2)
        {
            cout<<a[i]<<" ";
        }
        if(n%2==0)
        {
            for(i=0;i<n;i+=2)
            {
                cout<<a[i]<<" ";
            }
        }
        else
        {
            for(i=1;i<n;i+=2)
            {
                cout<<a[i]<<" ";
            }
        }
        cout<<en;
    }
}




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

using namespace std;

class Alloc
{
public:
  int n, k;
  int w[100000];
  int solve();
  int maxcnt( int p );
};

int Alloc::solve()
{

  cin >> n >> k;

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

  int a = 0;
  int b = 1000000000;

  while ( a + 1 != b )
    {
      int c = (a + b) / 2;
      
      if ( maxcnt( c ) == n )
        b = c;
      else
        a = c;
    }

  cout << b << endl;
      
  return 0;
}

int Alloc::maxcnt( int p )
{
  int s = 0;
  int j = 0;
  
  for ( int i = 0; i < k; i++ )
    {
      while ( s + w[j] <= p  && j < n )
        {
          s += w[j];
          j++;
        }

      if ( j == n ) return n;
      
      s = 0;
    }
  
  return j;
}

int main( void )
{
  
  Alloc al;

  al.solve();

  return 0;
}

Measured memory_bytes: 1548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        CF_Reader in = new CF_Reader();

        int n = in.Int();
        long[] nums = new long[n];
        Map<Long, Long> counts = new HashMap<>();
        for (int i = 0; i < n; i++) {
            nums[i] = in.Long();
            counts.merge(nums[i], (long) 1, Long::sum);
        }
        long total = 0;
        Map<Long, Long> totalCount = new HashMap<>();
        for (long cnt: counts.values()) {
            long totalVal = (cnt * (cnt - 1)) / 2;
            long totalValMinusOne = ((cnt - 1) * (cnt - 2)) / 2;
            total += totalVal;
            totalCount.put(cnt, totalVal);
            totalCount.put(cnt-1, totalValMinusOne);
        }
        for (long num: nums) {
            long cnt = counts.get(num);

            out.println(total - totalCount.get(cnt) + totalCount.get(cnt-1));
        }


        out.close();
    }


    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long Long() throws IOException {
            return Long.parseLong(next());
        }

        int Int() throws IOException {
            return Integer.parseInt(next());
        }

        double Double() throws IOException {
            return Double.parseDouble(next());
        }

        char Char() throws IOException {
            return next().charAt(0);
        }

        String Line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 76752
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int N;
int PP;
int main()
{
	cin>>N>>PP;
	int cnt=0;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		a=a%2;
		if(a==1)cnt++;
	}
	if(cnt>0)N--;
	if(PP==0){
		ll ans=(ll)1;
		for(int i=0;i<N;i++){
		ans=ans*(ll)2;
		}
		cout<<ans<<endl;
	}else{
		if(cnt==0)cout<<0<<endl;
		else{
			ll ans=(ll)1;
			for(int i=0;i<N;i++){
				ans=ans*(ll)2;
			}
			cout<<ans<<endl;
		}
	}
}

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

int main() {
	int a,b;
	bool f=true;
	string s;
	cin>>a>>b>>s;
	if(s.substr(a,1)=="-"){
		for(int i=0;i<a;i++){
			if(s.substr(i,1)=="-"){
				f=false;
			}
		}
		for(int i=a+1;i<s.size();i++){
			if(s.substr(i,1)=="-"){
				f=false;
			}
		}
	}else{
		f=false;
	}
	if(f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1000000000
#define MOD 1000000007

int main(){

    ll n;
    cin >> n;

    ll n1 = n/500;
    n = n%500;

    ll n2 = n/5;
    n = n%5;

    cout << 1000*n1 + 5*n2 << endl;

}







Measured memory_bytes: 256
/*
 * Author: Anmol Choudhary
 */
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
// using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
void solve()
{
    int k;
    cin>>k;
    int an=0;
    rep1(i,k)rep1(j,k)rep1(k1,k){
        int gc=__gcd(i,__gcd(j,k1));
        an+=gc;
    }
    pr(an);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3652
#imos法で更新を繰り返す
#log回で終わる
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(k):
    b=[0]*n
    for i in range(n):
        b[max(0,i-a[i])]+=1
        if i+a[i]+1<n:
            b[i+a[i]+1]-=1
    a=list(accumulate(b))
    if a==[n]*n:
        break
    #print(a)
print(" ".join(map(str,a)))

Measured memory_bytes: 179736
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;


void main() {
    int n, q;
    scan(n, q);

    auto sd = SqrtDecomp(n);

    foreach (time ; 0 .. q) {
        auto line = readln.split.to!(int[]);
        if (line[0] == 0) {
            sd.update(line[1], line[2] + 1, line[3], time);
        }
        else {
            writeln(sd.get(line[1]));
        }
    }
}

struct SqrtDecomp {
    private {
        enum rt = 512;
        int N, K;
        int[] bucket;
        int[] data;
        int[] bt;
        int[] dt;
    }

    this(int n) {
        N = n;
        K = (N + rt - 1) / rt;
        bucket = new int[](K);
        data = new int[](K * rt);
        bucket[] = -1;
        data[] = int.max;

        bt = new int[](K);
        dt = new int[](K * rt);
        bt[] = -1;
        dt[] = -1;
    }

    void update(int l, int r, int x, int time) {
        foreach (k ; 0 .. K) {
            int bl = k * rt, br = (k + 1) * rt;
            if (r <= bl || br <= l) continue;
            if (l <= bl && br <= r) {
                bucket[k] = x;
                bt[k] = time;
            }
            else {
                foreach (i ; max(l, bl) .. min(r, br)) {
                    data[i] = x;
                    dt[i] = time;
                }
            }
        }
    }

    int get(int idx) {
        int k = idx / rt;

        foreach (i ; k * rt .. (k + 1) * rt) {
            if (bt[k] > dt[i]) data[i] = bucket[k];
        }

        return data[idx];
    }
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}



Measured memory_bytes: 3968
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


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


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


template <class T>
inline bool get_bit(T mask, int bit) {
    assert(0 <= bit && bit < numeric_limits<T>::digits);
    return mask & ((T)(1) << bit);
}


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
  auto h = next<int>(in);
  auto w = next<int>(in);
  auto k = next<int>(in);
  vec<string> f(h);
  FOR(i, h) {
    f[i] = next<string>(in);
  }

  auto getCnt = [&] (int mh, int mw) -> int {
    int res = 0;
    FOR(i, h) {
      if (!get_bit(mh, i)) {
        FOR(j, w) {
          if (!get_bit(mw, j)) {
            if (f[i][j] == '#') {
              ++res;
            }
          }
        }
      }
    }
    return res;
  };

  int res = 0;
  FOR(mh, 1 << h) {
    FOR(mw, 1 << w) {
      auto cnt = getCnt(mh, mw);
      if (cnt == k) {
        ++res;
      }
    }
  }
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y){
    if(y == 0) return x;
    return gcd(y,x%y);
}

ll lcm(ll x, ll y){
    ll g = gcd(x,y);
    return x / g * y;
}

int main(int argc, char const *argv[])
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll c_div, d_div, cd_div, cd_lcm;
    cd_lcm = lcm(c, d);
    c_div = b/c - a/c;
    d_div = b/d - a/d;
    cd_div = b/cd_lcm - a/cd_lcm;
    if (a%c==0) c_div++;
    if (a%d==0) d_div++;
    if (a%(cd_lcm)==0) cd_div++;
    cout << b - a + 1 - (c_div + d_div - cd_div) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N, M;
    cin >> N >> M;
    if (N % 2) {
        for (int i = 1; i <= M; ++i) { cout << i << " " << N - i << endl; }
    } else {
        for (int i = 1; i <= M; ++i) {
            cout << i << " " << N - i - (4 * i >= N) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

bool vis[105][105];

int main(){
    int N,K;
    scanf("%d%d",&N,&K);
    int Max=(N-1)*(N-2)/2;
    if(K>Max){
        printf("-1");
        return 0;
    }
    printf("%d\n",N-1+(Max-K));
    for(int i=1;i<=N-1;i++)
        printf("%d %d\n",i,N);
    K=Max-K;
    for(int i=1;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(!K)
                break;
            if(!vis[i][j]){
                vis[i][j]=vis[j][i]=1;
                printf("%d %d\n",i,j);
                K--;
            }
        }
        if(!K)
            break;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int M[N][N], n, color[N], d[N], f[N], tt, nt[N];
int next(int u){;
    for(int v = nt[u]; v < n; v++){
        nt[u] = v + 1;
        if(M[u][v])return v;
    }
    return -1;
}

void dfs_visit(int r){
    for(int i = 0; i < n; i++)nt[i] = 0;
    
    stack<int> S;
    S.push(r);
    color[r] = GRAY;
    d[r] = ++tt;
    while(!S.empty()){
        int u = S.top();
        int v = next(u);
        if(v != -1){
            if(color[v] == WHITE){
                color[v] = GRAY;
                d[v] = ++tt;
                S.push(v);
            }
        }else{
            S.pop();
            color[u] = BLACK;
            f[u] = ++tt;
        }
    }
}

void dfs(){
    for(int i = 0; i < n; i++){
        color[i] = WHITE; 
        nt[i] = 0;
    }
    tt = 0;
    for(int u = 0; u < n; u++)if(color[u] == WHITE)dfs_visit(u);
    for(int i = 0; i < n; i++)cout << i + 1 << " " << d[i] << " " << f[i] << endl;
}

int main(){
    int u,k,v;
    cin >>n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++)M[i][j] = 0;
    }
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        for(int j = 0; j < k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    dfs();
    return 0;
}





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

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


Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

int main(){
    ll n,ans=0;
    cin >> n;
    ll ni_rui[n+1];
    ll a[n+1];
    ni_rui[0]=1;
    for (ll i=0;i<n+1;i++)cin >> a[i];
    if (n==0 and a[0]==1){
        cout << 1 << endl;
        return 0;
    }
    if (a[0]!=0){
        cout << -1 << endl;
        return 0;
    }
    
    for (ll i=1;i<=n;i++){
        if (ni_rui[i-1]==INF)ni_rui[i]=INF;
        else ni_rui[i]=min(ni_rui[i-1]*2-a[i],INF);
        if (ni_rui[i]<0){
            cout << -1 << endl;
            return 0;
        }
    }
    ll x=a[n];
    ans=x;
    for (ll i=0;i<n;i++){
        x=min(ni_rui[n-i-1],x);
        x+=a[n-i-1];
        ans+=x;
    }
    cout << ans << endl;
    return 0;
}
 
 



Measured memory_bytes: 5204
# UnionTreeクラス：グループ分けを木構造で管理する
class UnionFind():
    def __init__(self, N):
        self.par = [i for i in range(N)]
        self.size = [1] * N
        self.N = N

    # xのrootを返す
    def root(self, x):
        if self.par[x] == x:
            return x
        else: 
            self.par[x] = self.root(self.par[x])
            return self.root(self.par[x])

    # x, yが同じrootの場合true
    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    # x,yのrootが違った場合、併合
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if self.size[rx] < self.size[ry]:
            self.par[rx] = ry
            self.size[ry] += self.size[rx]
        else:
            self.par[ry] = rx
            self.size[rx] += self.size[ry]
            
import sys
input = sys.stdin.readline

n, m = (int(i) for i in input().split())
xyz = [[int(i)-1 for i in input().split()] for i in range(m)]

uf = UnionFind(n)
for x,y,z in xyz:
    if not uf.same(x,y):
        uf.unite(x,y)

dic = {}
for i in range(n):
    dic[uf.root(i)] = 1

print(len(dic))

Measured memory_bytes: 95580
n, m = gets.split(' ').map(&:to_i)
left = []
right = []

m.times do
  l, r = gets.split(' ').map(&:to_i)
  left << l
  right << r
end

left_max = [left.max,1].max
right_min = [right.min,n].min

if left_max > right_min
  puts 0
else
  puts right_min - left_max + 1
end


Measured memory_bytes: 3464