akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAX 1000005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007LL
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vll vector<ll>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
ll gcd(ll n1,ll n2){
	if(n2==0)
		return n1;
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	if(exponent<0) exponent+=MOD-1;
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll fact[MAX],ifact[MAX];
int main()
{
	fact[0]=1;
	ifact[0]=1;
	for(int i=1;i<MAX;i++)
	{
		fact[i]=(i*1LL*fact[i-1])%MOD;
		ifact[i]=powmod(fact[i],-1);
	}
	ll ans=0;
	int n;
	cin>>n;
	ll prev=0;
	for(int i=1;i<n;i++)
	{
		if(i-1>=n-i-1)
		{
			ll temp=fact[i-1]*ifact[n-i-1];
			temp%=MOD;
			temp*=ifact[i-1-n+i+1];
			temp%=MOD;
			temp*=fact[i];
			temp%=MOD;
			temp*=fact[n-i-1];
			temp%=MOD;
			ans+=MOD-prev;
			prev=temp;
			//cout<<i<<" "<<temp<<endl;
			ans%=MOD;
		}
		ans+=fact[n-1];
     	ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll n; cin >> n;
	ll MAX = 100000;
	ll m = 12;

	ll C[12] = { 1,6,9,36,81,216,729,1296,6561,7776,46656,59049 };
	//ll C[12] = { 59049 ,46656,7776,6561,1296,729,216,81,36 ,9 ,6,1 };
	ll T[100001] = {};

	for (int i = 0; i <= n; i++) T[i] = 1 << 29;
	T[0] = 0;
	rep(i, 0, m) {
		for (int j = 0; j + C[i] <= n; j++) {
			T[j + C[i]] = min(T[j + C[i]], T[j] + 1);
		}
	}
	cout << T[n] << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; 
#define loop for(int i=0;i<n;i++)
const int N=100020;
vector<int> adj[N];
int visited[N];
int n;
vector<int> ans[N];
int32_t  main()
{
	int w,s;
	cin>>s>>w;
	if(w>=s)
	cout<<"unsafe";
	else
	cout<<"safe";
}


		
			
		
		
		

		
		


	


Measured memory_bytes: 8280
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int a[1000];
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    
    for (int i=1; i<=n; i++) {
        sort(a, a+i);
        for (int k=0; k<n-1; k++) {
            cout<<a[k]<<" ";
        }
        cout<<a[n-1]<<endl;
    }
}

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

const unsigned MAX_SIZE = 100005;

struct Process{
	string name;
	unsigned time;
};

Process processes[MAX_SIZE];

int head = 0, tail = 0;

bool emptyOrNot() {
	return head == tail;
}

bool is_full() {
	return (tail + 1) % MAX_SIZE == head;
}

void initialize() {
	head = tail = 0;
}

void enqueue(Process p) {
	processes[tail] = p;
	tail = (tail + 1) % MAX_SIZE;
}

Process dequeue() {
	Process x = processes[head];
	head = (head + 1) % MAX_SIZE;
	return x;
}

// const int &min(const int &a, const int &b) {return a < b ? a : b;}
int min(int a, int b) {return a < b ? a : b;}

int main () {
	int numberOfProcesses, quantum, elapsTime = 0;
	cin >> numberOfProcesses >> quantum;

	Process u;

	for(int i = 0; i < numberOfProcesses; ++i) {
		cin >> u.name >> u.time;
		enqueue(u);
	}

	while(!emptyOrNot()) {
		u = dequeue();
		int lessTime = min(quantum, u.time);
		u.time -= lessTime;
		elapsTime += lessTime;
		if (u.time > 0) enqueue(u);
		else
			cout << u.name << " " << elapsTime << endl;
	}

	return 0;
}



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

const int N = 1e5+5;

int sum[N],add[N];

int pen[N];

void update(int ind,int add) {
   while(ind<N) {
      pen[ind] += add;
      ind += ind&(-ind);
   }
}
int query(int ind) {
   int ret= 0;
   while(ind>0) {
      ret += pen[ind];
      ind = ind&(ind-1);
   }
   return ret;
}

vector<pair<pair<int,int>,int> > input[N];

void solve() {
   int n,m;
   scanf("%d%d",&n,&m);
   for(int i=0;i<n;++i) {
      int l,r;
      scanf("%d%d",&l,&r);
      int len = r-l+1;
      sum[1] += 1;
      sum[len+1] -= 1;
      if(len+1<=r) {
         input[len+1].push_back(make_pair(make_pair(l,r),1));
         input[r+1].push_back(make_pair(make_pair(l,r),-1));
      }
   }
   int d,i,l,r,pos,ret;
   for(d=1;d<=m;++d) {
      sum[d] = sum[d-1] + sum[d];
      for(i=0;i<input[d].size();++i) {
         l = input[d][i].first.first;
         r = input[d][i].first.second;
         pos = input[d][i].second;
         update(l,pos);
         update(r+1,-pos);
      }
      ret = sum[d];
      for(i = d;i<=m;i+=d) {
         ret += query(i);
      }
      printf("%d\n", ret);
   }
}
int main() {
   //freopen("input.txt","r",stdin);
   solve();
}

Measured memory_bytes: 14976
#include <stdio.h>

int main (void){
    char str[100];
    int num;
    int i;
    int cnt = 0;

    scanf("%d\n",&num);
    scanf("%s",str);
    for(cnt = 0;str[cnt]!='\0';cnt++);
    if(num >= cnt){
        printf("%s",str);
    }else{
        str[num] = '.';
        str[num+1] = '.';
        str[num+2] = '.';
        str[num+3] = '\0';
        for(i = num+3;i < cnt;i++)str[i] = '\0';
        printf("%s",str);
    }

    return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

void dfs_ignore(int u, int p, vector<vector<int>>& G, vector<int>& a, vector<bool>& ignore) {
	ignore[u] = a[u];
	for (int v: G[u]) if (v != p) {
		dfs_ignore(v, u, G, a, ignore);
		if (!ignore[v]) ignore[u] = false;
	}
}

int maji = INT_MIN / 10;

void dfs_ma(int u, int p, vector<vector<int>>& G, vector<int>& a, vector<bool>& ignore, vector<int>& dp) {
	vector<int> unko = {0, 0};
	for (int v: G[u]) if (v != p && !ignore[v]) {
		dfs_ma(v, u, G, a, ignore, dp);
		unko.pb(dp[v]);
	}
	sort(unko.rbegin(), unko.rend());
	int x = a[u] ? 0 : 2;
	maji = max(maji, x + unko[0] + unko[1] + 1);
	dp[u] = x + unko[0];
}

int main() {
	int N; cin >> N;
	vector<vector<int>> G(N);
	rep(i, N - 1) {
		int u, v; scanf("%d%d", &u, &v), u--, v--;
		G[u].pb(v), G[v].pb(u);
	}
	string s; cin >> s;
	vector<int> a(N);
	rep(u, N) a[u] = (s[u] == 'B');
	int r = -1;
	rep(u, N) if (!a[u]) r = u;
	if (r == -1) {
		cout << 0 << endl;
		return 0;
	}
	vector<bool> ignore(N);
	dfs_ignore(r, -1, G, a, ignore);
	int ans = -1;
	rep(u, N) if (!ignore[u]) {
		ans += 2;
		int deg = 0;
		for (int v: G[u]) if (!ignore[v]) deg++;
		a[u] ^= deg % 2;
		ans += !a[u];
	}
	if (ans == 2) {
		cout << 1 << endl;
		return 0;
	}
	int ma = 1;
	vector<int> dp(N);
	dfs_ma(r, -1, G, a, ignore, dp);
	ma = max(ma, maji);
	cout << ans - ma << endl;
}


Measured memory_bytes: 25344
from collections import deque
import heapq
import bisect

n,m = map(int,input().split())
L = []
for i in range(n):
    a,b = map(int,input().split())
    L.append([a, -b])
L.sort()
T = deque(L)
K = []
ans = 0
for i in range(m):
    while len(T) != 0:
        a = T.popleft()
        if a[0] == i+1:
            heapq.heappush(K, a[1])
        else:
            T.appendleft(a)
            break
    if len(K) != 0:
        t = heapq.heappop(K)
        ans += t
print(-ans)


Measured memory_bytes: 22260
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <queue>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() { 
  int N, X, Y;
  std::cin >> N >> X >> Y;
  --X; --Y;
  std::vector<std::vector<int>> graph(N);
  for (int i: range(1, N)) {
    graph[i - 1].push_back(i);
    graph[i].push_back(i - 1);
  }
  graph[X].push_back(Y);
  graph[Y].push_back(X);
  std::vector<int> ans(N);
  for (int u: range(0, N)) {
    std::vector<int> dist(N, N);
    dist[u] = 0;
    std::queue<int> que;
    que.push(u);
    while (!que.empty()) {
      int v = que.front();
      que.pop();
      for (int t: graph[v]) {
        if (chmin(dist[t], dist[v] + 1)) {
          que.push(t);
        }
      }
    }
    for (int i: range(0, N)) {
      ++ans[dist[i]];
    }
  }
  for (int i: range(1, N)) {
    std::cout << ans[i] / 2 << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int paper = 0;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'p')paper++;
	}
	cout<<s.size() / 2 - paper<<endl;
	return 0;
}


Measured memory_bytes: 640
//AtCoder ABC081 A - Placing Marbles
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string S;
    cin>>S;
    ll ans=0;
    for(const auto& s:S){
        if(s=='1') ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

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

    int main() {
        
        long long n;
        cin >> n;
        
        string s = "";
        
        while(n--){
            
            int b = n%26;
            char c = 'a' + char(b);
            s+=c;
            n/=26;
            
            }
        
        reverse(s.begin(),s.end());
        cout << s;
        return 0;
        }

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

using ll = long long;

void dfs(vector<vector<int>> &G, int x, int p, ll keep, vector<ll> &counter) {
  counter[x] += keep;
  for (int i = 0; i < G[x].size(); i++) {
    if (G[x][i] == p) continue;
    dfs(G, G[x][i], x, counter[x], counter);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  
  vector<vector<int>> G(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  vector<ll> counter(n, 0);
  
  for (int i = 0; i < q; i++) {
    ll p, x;
    cin >> p >> x;
    p--;
    counter[p] += x;
  }
  
  dfs(G, 0, -1, 0, counter);
  
  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << counter[i];
  }
  cout << '\n';
}

Measured memory_bytes: 30592
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<set>
#include<map>

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n)cin >> a[i];

	int MIN, ans = 0, b;
	while(1){
		REP(i, n){
			if(i == 0) MIN = a[0];
			if(MIN > a[i] && a[i] != 0) MIN = a[i];

			if(a[i] == 0 || i == n-1){
				ans += MIN;
				b = i;
				if(i == n-1) b = n;
				REP(j, b){
					if(a[j] != 0) a[j] -= MIN;
				}
				break;
			}
		}

		REP(i, n){			
			if(a[i] > 0 || i == n-1){
				a.erase(a.begin(), a.begin() + i);
				n -= i;
				break;
			}
		}
		if(a[0] <= 0){
			a.erase(a.begin());
			n--;
		}

		if(n == 0) {
			cout << ans << endl;
			return 0;
		}
	}		
}


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

int main()
{

	int n; cin >> n;

	vector<vector<long long>> f(n, vector<long long>(10));
	for (int i = 0; i < n; i++) for (int j = 0; j < 10; j++) cin >> f[i][j];
		
	vector<vector<long long>> p(n, vector<long long>(11));
	for (int i = 0; i < n; i++) for (int j = 0; j < 11; j++) cin >> p[i][j];
		
	int profit = -2147483648;
	for (int bit = 1; bit < (1<<10); bit++) {

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

			int tmp_cnt = 0;
			for (int j = 0; j < 10; j++) {
				if ((bit & (1 << j)) && f[i][j] == 1) tmp_cnt++;
			}
			tmp_profit += p[i][tmp_cnt];
		
		}
		profit = max(profit, tmp_profit);

	}

	cout << profit << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
ll mod = 1000000007;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int x[100000], y[100000];
int ans[100000];
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	printf((a + b >= c) ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <omp.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

int main()
{
	int n, q;
	cin >> n >> q;
	fenwick_tree<long long> fw(n);
	for (int i = 0; i < n; ++i) {
		long long tmp;
		cin >> tmp;
		fw.add(i, tmp);
	}
	vector<long long> t(q), u(q), v(q);
	for (int i = 0; i < q; ++i) {
		cin >> t.at(i) >> u.at(i) >> v.at(i);
	}
	for (int i = 0; i < q; ++i) {
		if (t.at(i) == 0) {
			fw.add(u.at(i), v.at(i));
		} else {
			cout << fw.sum(u.at(i), v.at(i)) << endl;
		}
	}
}

Measured memory_bytes: 19980
/*
ID: leezhen
TASK: practice
LANG: C++11
*/
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef unsigned long long ull;
#define mp make_pair
#define pb push_back
#define inf 1e9
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

// struct

// data
int n;
int x[10];
int y[10];

double dist(int i, int j) {
  return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}

void solve() {
  int order[10];
  REP(i, 0, n) order[i] = i;
  double sum = 0;
  int cnt = 0;
  do {
    REP(i, 1, n) { sum += dist(order[i - 1], order[i]); }
    cnt++;
  } while (next_permutation(order, order + n));
  printf("%.10f\n", sum / cnt);
}

int main() {
  int k, kase = 0;
  // scanf("%d", &k);
  k = 1;
  while (k--) {
    scanf("%d", &n);
    REP(i, 0, n) scanf("%d%d", &x[i], &y[i]);
    solve();
  }

  return 0;
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  string ans="";
  for(int i=0;i<s.size();i++){
    ans+=char((s.at(i)+n-65)%26+65);
//    cout << (s.at(i)+n-65)%26+65 << '/';
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define MP make_pair
#define FF first
#define SS second

using LL = long long;
using PII = pair<LL,LL>;

const LL INF = 1e15;

int N, M, R, Q;
LL dist[10][100020];
void dijk(vector<vector<PII>>& G, int r){
  priority_queue<PII, vector<PII>, greater<PII>> pq;
  pq.push(MP(0,N+1+r));

  while(!pq.empty()){
	PII p = pq.top();
	pq.pop();
	if(p.FF > dist[r][p.SS])
	  continue;
	  
	for(auto&& e: G[p.SS]){
	  if(p.FF + e.SS < dist[r][e.FF]){
		dist[r][e.FF] = p.FF + e.SS;
		pq.push(MP(dist[r][e.FF], e.FF));
	  }
	}
  }
}

int main(){
  cin >> N >> M >> R >> Q;

  vector<vector<PII>> G(N+11);
  for(int i=0;i<M;++i){
	LL a, b, c;
	cin >> a >> b >> c;
	G[b].push_back(MP(a,c));
  }
  for(int i=0;i<=N;++i)
	G[N+1+i%R].push_back(MP(i,0));

  fill((LL*)dist, (LL*)dist+10*100020, INF);
  for(int r=0;r<R;++r)
	dijk(G, r);

  LL ans = 0;
  for(int q=0;q<Q;++q){
	LL x, y, z;
	cin >> x >> y >> z;
	LL tmp = min(dist[x%R][y], dist[y%R][x]);
	for(int r=0;r<R;++r)
	  tmp = min(tmp, dist[r][x] + dist[r][y]);

	ans += max(0ll, z-tmp);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 19452
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}

int a[3][105];
int dp[3][105];

signed main()
{
    int N;
    cin >> N;
    rep(i, 1, N+1) cin >> a[1][i];
    rep(i, 1, N+1) cin >> a[2][i];

    for (int i = 1; i <= N; ++i) {
        dp[1][i] = dp[1][i-1] + a[1][i];
    }
    for (int i = 1; i <= N; ++i) {
        chmax(dp[2][i], dp[1][i] + a[2][i]);
        chmax(dp[2][i], dp[2][i-1] + a[2][i]);
    }

    cout << dp[2][N] << endl;

    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    h,w = LI()
    a = [LI() for _ in range(h)]
    r = []
    for i in range(h):
        for j in range(w-1):
            if a[i][j] % 2 == 1:
                r.append(' '.join(map(lambda x: str(x+1), [i,j,i,j+1])))
                a[i][j] -= 1
                a[i][j+1] += 1
    for i in range(h-1):
        j = w - 1
        if a[i][j] % 2 == 1:
            r.append(' '.join(map(lambda x: str(x+1), [i,j,i+1,j])))
            a[i][j] -= 1
            a[i+1][j] += 1

    return '{}\n{}'.format(len(r), '\n'.join(r))


print(main())


Measured memory_bytes: 20696
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

H,W  = map(int,input().split())
S = [input() for i in range(H)]

dirc = [(0,1),(1,0),(0,-1),(-1,0)]
visited = [[False]*W for _ in range(H)]

def bfs(i,j):
    b,w = 0,0
    visited[i][j] = True
    que = deque([(i,j)])

    while que:
        ci,cj = que.popleft()
        if S[ci][cj] =="#":
            b += 1
        else:
            w += 1

        for di,dj in dirc:
            ni,nj = ci+di,cj+dj
            if not(0<=ni<H and 0<=nj<W) or visited[ni][nj]:
                continue
            if S[ci][cj] != S[ni][nj]:
                visited[ni][nj] = True
                que.append((ni,nj))
    return b*w

res = 0
for i in range(H):
        for j in range(W):
            if visited[i][j]:
                continue
            res += bfs(i,j)
print(res)

Measured memory_bytes: 48476
def main():
    mod=2019
    S=input()[::-1]
    l=[0]
    m=1
    for i in range(len(S)):
        l.append((l[-1]+m*int(S[i]))%mod)
        m=m*10%mod
    ll=[0]*2019
    for i in l:
        ll[i]+=1
    ans=0
    for i in range(2019):
        ans+=ll[i]*(ll[i]-1)//2
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 16460
#include <bits/stdc++.h>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define repdown(i, j, k) for(int (i)=(j);(i)>=(j);(i)--)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using ll = long long;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using namespace std;

const int Mod = 1e9 + 7;
const int max_n = 3 * 1e5 + 1;
const int max_m = 83 * 1e5 + 1;
const ll INF = 10241024;
long double INFD = 100100100;

//_________template______________
inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

//_____________________array calc____________________________________//
/*
vvi mul(vvi &A, vvi &B){
  vvi C(A.size(), vi(B.size()))
  rep(i,A.size()){
    rep(j,B.size()){
      rep(k,B[0].size()){
        C[i][j] = (C[i][j] A[i][k] + B[k][j]) % Mod;
      }
    }
  }

  return C;
}

vvi pow(vvi A, ll n){
  vvi B(A.size(), vi(A.size()));
  rep(i=0;i<A.size();i++){
    B[i][i] = 1;
  }

  while (n >0){
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n = n >> 1;
  }
  return B;
}
*/
//_____________________Bynary Indexed Tree __________________________//
/*
const max_st = (1 << 15) - 1;
int bit[max_st];
int sum (int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x){
  while(i <= n){
    bit[i] += x;
    i += i & -i;
  }
}
*/
//_____________________　following sorce code_________________________//
int n,q;
vvi dist;
vi vnum(2 * 1e5+2, 0);

void input(){
  IN(n,q);
  dist.resize(n);
  rep(i,n-1){
    int a,b;IN(a,b);a--;b--;
    dist[a].push_back(b);
    dist[b].push_back(a);
  }
  rep(i,q){
    int a,b;IN(a,b);a--;
    vnum[a] += b;
  }
}

void dfs(int v, int num, int c = -1){
  if(c >= 0)
  {
    vnum[v] += vnum[c];
  }
  for(int i=0;i<dist[v].size();i++){
    int u = dist[v][i];
    if(u == c)continue;
    dfs(u, vnum[u], v);
  }
}

void solve(){
  input();
  dfs(0, vnum[0]);
  rep(i,n){
    OUT(vnum[i]);
  }
}

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





Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int X, N, p[105];

int check[105];

int main(void) {

	cin >> X >> N;

	for (int i = 1; i <= N; i++) {
		cin >> p[i];
		check[p[i]] = 1;
	}

	int ans = 0;

	for (int x = 0; x <= 102; x++) {
		if (check[x] != 0) { continue; }
		if (abs(X - ans) > abs(X - x)) { ans = x; }
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
    int n, in;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        cin >> in;
        v.push_back(in);
    }
    int position = 1;
    for(int i = 1; i < n; i++){
        position = v[position - 1];
        if(position == 2){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 892
/**
*    author:  y_takano
*    created: 18.06.2020 17:19:04
**/

#include <bits/stdc++.h>

using namespace std;

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

  double i;
  cin >> i;

  cout << fixed << setprecision(6) << M_PI * i * i << " " << M_PI * 2 * i << endl;

  return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll N;
	cin>>N;
	ll ans=N-1;
	for(int i=1;i<=1000010;i++)
	{
		if(N%i==0)
			ans = min(ans, i + N / i - 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n, z, w = map(int, input().split())
list_a = list(map(int, input().split()))
if n == 1:
  print(abs(list_a[0] - w))
else:
  # 手番渡してカウンター喰らうなら、手番渡す価値がない
  result_all = abs(list_a[-1] - w)
  result_before = abs(list_a[-2] - list_a[-1])
  print(max(result_all, result_before))


Measured memory_bytes: 3188
n = int(input())

infos = [[0,0,0]]
for i in range(n):
    infos.append(list(map(int,input().split())))

for i in range(n):
    t = infos[i+1][0]-infos[i][0]
    abs_x = abs(infos[i][1]-infos[i+1][1])
    abs_y = abs(infos[i][2]-infos[i+1][2])
    d = abs_x + abs_y
    if t < d or t%2!=d%2:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 27132
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, ll> pll;
 
#define pb push_back
#define f first
#define s second
#define fr(i, n) for(ll i = 0; i < n; i++)
#define frr(i, n) for(ll i = 1; i<= n; i++)
#define MOD 1000000007
const ll MAX = 112345;
ll x, y, a, b, c;
ll q[MAX], r[MAX], p[MAX];
vector<ll> aux;
ll ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> x >> y >> a >> b >> c;
	fr(i, a){
		cin >> p[i];
		p[i] = -p[i];
	}
	fr(i, b){
		cin >> q[i];
		q[i] = -q[i];
	}
	fr(i, c){
		cin >> r[i];
		/*r[i] = -r[i];*/
	}
	sort(p, p+a);
	sort(q, q+b);
	sort(r, r+c);
	fr(i, x){
		aux.push_back(-p[i]);
	}
	fr(i, y){
		aux.push_back(-q[i]);
	}

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

	ll i, j;
	j = c-1;
	for(i = 0; i < aux.size(); i++){
		if(j >= 0 && r[j] > aux[i]){
			ans += r[j];
			j--;
		}
		else{
			ans += aux[i];
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 4852
//============================================================================
// Name        : aoj0075.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	double num, wei, hei;
	while(cin >> num){
		cin.get();
		cin >> wei;
		cin.get();
		cin >> hei;
		if(wei / (hei * hei) >= 25.0){
			cout << num << endl;
		}
	}
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll S[1000005];
ll N;
ll D[25];
ll E[25];

string solve()
{
    ll M = pow(2, N);
    sort(S, S + M, [](ll a, ll b) { return a > b; });
    ll n = 0;
    bool f = true;
    memset(E, 0, sizeof(E));
    E[N] = 1;
    REP(i, M)
    {
        n++;
        if (i < M - 1 && S[i] == S[i + 1])
            continue;
        if (f)
        {
            f = false;
            if (n > 1)
                return "No";
            n = 0;
            continue;
        }
        //cout << n << endl;
        memset(D, 0, sizeof(D));
        for (int j = N; j > 0; --j)
        {
            ll m = std::min(E[j], n);
            E[j] -= m;
            //! 今回生成したやつ
            D[j - 1] += m;
            //! 前回のが降りてきたやつ
            E[j - 1] += m;
            n -= m;
        }
        REP(j, N + 1)
        {
            E[j] += D[j];
        }
        // REP(j, N + 1)
        // {
        //     cout << E[j] << " ";
        // }
        // cout << endl;

        if (n > 0)
            return "No";
    }
    FOR(i, N + 1, 1)
    {
        if (E[i] > 0)
            return "No";
    }
    return "Yes";
}

int main()
{
    cin >> N;
    ll M = pow(2, N);
    REP(i, M)
    {
        cin >> S[i];
    }
    cout << solve() << endl;
    return 0;
}

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

namespace AtTest.OtherPractice
{
    class AtTemplate
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1]);
            long x = long.Parse(input[2]);

            long min = (a - 1) / x;
            if (a == 0)
            {
                min = -1;
            }
            long max = b / x;

            long cnt = max - min;
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int M,D,ans=0;
  cin>>M>>D;
  for(int i=1;i<=M;i++){
    for(int j=22;j<=D;j++){
      int k=j/10,l=j%10;
      if(k>1 && l>1 && k*l==i)
        ans++;
    }
  }
  cout<<ans<<endl;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in(),M=in();
	out((1900*M+100*(N-M))*(1<<M));

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, i, NG;
    int A[1000];
    scanf("%d", &a);
    for(i = 0; i < a; i++){
        scanf("%d", &A[i]);
    }
    NG = 1;
    for(i = 0; i < a; i++){
        if(A[i]%2 == 0){
            if(!(A[i]%3 == 0 || A[i]%5 == 0)){
                NG = NG - 1;
            }
        }
    }    
    if(NG <= 0){
        printf("DENIED");
    }else{
        printf("APPROVED");
    }
}


Measured memory_bytes: 1692
from itertools import combinations

N, K = map(int, input().split())


def cmb(x):
    return x * (x - 1) // 2


if K > cmb(N - 1):
    print(-1)
else:
    m = cmb(N - 1) - K
    print(N - 1 + m)

    for i, j in list(combinations(range(1, N + 1), 2))[:N - 1 + m]:
        print(i, j)

Measured memory_bytes: 3992
#include<stdio.h>

int main(void)
{
	int a;
	char ch;

	while(1)
	{
		scanf("%c",&ch);

		if(ch >= 65 && ch <= 90)
		{
			ch = ch + 32;
		}
		else if(ch >= 97 && ch <= 122)
		{
			ch = ch - 32;
		}
		else
		{
		}

		printf("%c",ch);
		if(ch == '\n')
		{
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(LL i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const int mod = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	map<int , int> cnt;
	for(int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}
	if(n % 3)
	{
		if(SZ(cnt) > 1 || cnt.begin()->X)
		{
			cout << "No";
		}
		else
		{
			cout << "Yes";
		}
		return 0;
	}
	int suma = 0;
	for(auto x : cnt)
	{
		
		
		if(x.Y % (n / 3))
		{
			cout << "No";
			return 0;
		}
		for(int i = 0; i < x.Y / (n / 3); i++)
		{
			suma ^= x.X;
		}
	}
	
	cout << (suma == 0 ? "Yes" :"No") << endl;
	//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

int main() {
    int N, K; cin >> N >> K;
    vector<int> C(N);
    for(int i=0; i < N; i++) {
        cin >> C[i];
    }

    int ans = 100000000000;
    for(int i=0; i+K-1 < N; i++) {
        ans = min(ans, (abs(C[i]) + abs(C[i+K-1] - C[i])));
        ans = min(ans, (abs(C[i+K-1]) + abs(C[i+K-1] - C[i])));
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#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 dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> s[i][j];

  int max_d = 0;
  rep(i, h) rep(j, w) {
    if (s[i][j] == '#') continue;
    queue<P> Q;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    Q.push(make_pair(i, j));
    dist[i][j] = 0;
    int cur_d = 0;
    while (Q.size()) {
      P p = Q.front();
      Q.pop();
      int x = p.first;
      int y = p.second;
      rep(i, 4) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if (s[nx][ny] == '#' || dist[nx][ny] != -1) continue;
        Q.push(make_pair(nx, ny));
        dist[nx][ny] = dist[x][y] + 1;
        cur_d = dist[nx][ny];
      }
    }
    max_d = max(max_d, cur_d);
  }
  cout << max_d << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int h = sc.nextInt(), w = sc.nextInt();
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (sc.next().equals("snuke")) {
					String c = (char) (j + 'A') + "";
					String r = String.valueOf(i + 1);
					System.out.println(c + r);
					return;
				}
			}
		}
	}
}

Measured memory_bytes: 25172
#include<stdio.h>

int main(void){
    int r, d, x[11];

    scanf("%d %d %d", &r, &d, &x[0]);
    for(int i=0; i<10; i++){
        x[i+1] = r * x[i] - d;
        printf("%d\n", x[i+1]);
    }
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    h1, m1, h2, m2, k = IL(int)
    all_time = (h2 * 60 + m2) - (h1 * 60 + m1)
    print(all_time - k)


solve()


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

int main()
{
	int A,B,x,y,z;
	cin >>A>>B;
	x= A+B;
	y=A-B;
	z=A*B;
    if (x>=y && x>=z)
		cout << x;
	else if (y>=x && y>=z)
		cout << y;
	else 
		cout << z;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        final int N = Integer.parseInt(sc.next());
        long[] a = new long[N];
        int lap = 0;
        for (int i = 0; i < N; i++) {
            a[i] = Long.parseLong(sc.next());
        }
        
        Outer:
        while (true) {
            for (int i = 0; i < N; i++) {
                if (a[i] % 2 != 0) break Outer; 
            }
            for (int i = 0; i < N; i++) {
                a[i] /= 2;
            }
            lap++;
        }
        
        out.println(lap);
        
        out.flush();
    }
}

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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if((A==5&&B==7&&C==5)||(A==7&&B==5&&C==5)||(A==5&&B==5&&C==7)){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int, pair<int,int>> ppi;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int h, w;
int sr, sc, dr, dc;
string grid[1010];
int dist[1010][1010];
bool vis[1010][1010];

bool valid(int i, int j) {
    return 0 <= i && i < h && 0 <= j && j < w && grid[i][j] != '#';
}

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> h >> w;
    cin >> sr >> sc >> dr >> dc;
    --sr; --sc; --dr; --dc;
    for (int i = 0; i < h; i++) {
        cin >> grid[i];
    }
    deque<pi> q;
    memset(dist, 0x3f, sizeof dist);
    dist[sr][sc] = 0;
    q.emplace_back(sr, sc);
    while (!q.empty()) {
        auto pos = q.front();
        q.pop_front();
        if (vis[pos.first][pos.second]) continue;
        vis[pos.first][pos.second] = true;
        if (pos == pi(dr, dc)) break;
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int nr = pos.first + i;
                int nc = pos.second + j;
                if (valid(nr, nc) && pi(nr, nc) != pos) {
                    int w = abs(i) + abs(j) == 1 ? 0 : 1;
                    if (dist[pos.first][pos.second] + w < dist[nr][nc]) {
                        dist[nr][nc] = dist[pos.first][pos.second] + w;
                        if (w) q.emplace_back(nr, nc);
                        else q.emplace_front(nr, nc);
                    }
                }
            }
        }

    }

    cout << (dist[dr][dc] < INF ? dist[dr][dc] : -1);
}

Measured memory_bytes: 9736
# AtCoder
N, M = map(int, input().split())
nlst = [list(map(int, input().split())) for i in range(N)]
mlst = [list(map(int, input().split())) for i in range(M)]

for i in range(N):
    mn = []
    x1 = nlst[i][0]
    y1 = nlst[i][1]
    for j in range(M):
        x2 = mlst[j][0]
        y2 = mlst[j][1]

        dis = abs(x1-x2) + abs(y1-y2)
        mn.append(dis)
    minn = min(mn)
    print(mn.index(minn)+1)


Measured memory_bytes: 3064
n,d = [int(x) for x in input().split()]
counts = 0

for i in range(n):
      x,y = [int(x) for x in input().split()]
      if d**2 >= x**2 + y**2:
            counts += 1

print(counts)

# 原点Oと入力された座標(x,y)間の距離とx,yの値の間で三平方の定理が成り立てばいいので、
# math.sqrt()を作らずともd**2 >= x**2 + y**2を条件式にすればいい

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

int main()
{
int N;
int Y;
int A;
int B;
int C;

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

	cin >> N;
	cin >> Y;

	Y /= 1000;

	A = 0;
	while( true )
	{
		B = Y - N - 9 * A;
		C = 5 * N - Y + 5 * A;

		if( B < 0 ) break;
		if( B % 4 == 0 && C >= 0 )
		{
			B /= 4;
			C /= 4;
			cout << A << " " << B << " " << C << endl;

			return 0;
		}

		A++;
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}



Measured memory_bytes: 256
while True:
    try:
        l = list(map(int, input().split(',')))
    except:
        break
    d, v1, v2 = sum(l[:10]), l[10], l[11]
    t = 0
    m = 0
    for i, x in enumerate(l[:10]):
        t = x / v1
        m += t * v2
        if m + sum(l[:i+1]) >= d:
            print(i+1)
            break

Measured memory_bytes: 7596
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 10000000000000007
#define eps 1e-8
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.12lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
int a[200004],b[210004];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int l=100041;int r=l+1;
    b[l]=a[1];
    l--;
    if(n==1){cout<<a[1]<<endl;return 0;}
    for(int i=2;i<=n;i++)
    {
        if(i%2==0)
        {
            b[r]=a[i];
            r++;
            if(i==n)
            {
                                for(int i=r-1;i>l;i--)cout<<b[i]<<" ";
                cout<<endl;

            }
        }
        else
        {
            b[l]=a[i];
            l--;
            if(i==n)
            {
                                for(int i=l+1;i<r;i++)cout<<b[i]<<" ";
                cout<<endl;

            }

        }

    }






}




Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define lim (int) (1e5+5)
using namespace std;
typedef pair<int,int> ii;
typedef string string;
typedef long long int lli;
string s;
int ans;
int main()
{
	cin>>s;
	int len=s.length();
	int a=0,b=len-1;
	while(a!=b && a<b)
	{
		if(s[a]==s[b])
		{
			a++;
			b--;
			continue;
		}
		else if(s[a]=='x' && s[b]!='x')
		{
			a++;
			ans++;
			continue;
		}
		else if(s[a]!='x' && s[b]=='x')
		{
			b--;
			ans++;
			continue;
		}
		else
		{
			printf("-1");
			return 0;
		}
	}
	printf("%d",ans);
}



Measured memory_bytes: 512
#入力
S = str(input())

N = int(len(S))
kaibun1 = int((N-1)/2)
kaibun2 = int((N+2)/2)


#普通の回文判定

#print(S[0:kaibun1],S[kaibun2:N])

if S[0:kaibun1] == S[kaibun2:N]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

      int N = in.nextInt();
      int A = 1;
      int ANS = 0;

      while(A * A <= N) {
          ANS = A * A;
          A++;
      }

      System.out.println(ANS);


    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 10;
const ll oo = 0x3f3f3f3f3f3f3f3f;
class Point{
public:
	ll x;
	int v;
};
Point p[maxn];
int n;
ll C;
ll ans = 0;
bool cmp(Point p1 , Point p2){
	return p1.x < p2.x;
}

ll sum[maxn];
void solve(){
	sort(p + 1 , p + n + 1 , cmp);
	sum[0] = 0;
	ll cur = 0 , mx = 0;
	for(int i = 1 ; i <= n ; ++ i){
		cur += p[i].v - (p[i].x - p[i - 1].x);
		if(cur > mx) mx = cur;
		sum[i] = mx;
	}
	ans = max(ans , sum[n]);
	ll now = 0;
	for(int i = n ; i >= 1 ; -- i){
		now += p[i].v;
		ans = max(ans , sum[i - 1] - 2 * (C - p[i].x) + now);
	} 
}
int main(){
	ios::sync_with_stdio(0);
	cin >> n >> C;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> p[i].x >> p[i].v;
	solve();
	for(int i = 1 ; i <= n ; ++ i)
		p[i].x = C - p[i].x;
	solve();
	cout << ans << endl;
	return 0;
}


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

public class Main {
	static boolean reverse(int n) {
		int k = n; 
		int rev = 0; 
		while(n != 0) {
			rev = rev * 10 + n%10; 
			n /= 10; 
		}
		return (k == rev) ? true:false;
	}
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);	
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0; 
		for(int i = a; i<= b; i++) {
			if(reverse(i)) ans++; 
		}
		System.out.println(ans); 
	}
	
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using mat = vector<vector<ll> >;
const ll mod = 1e9+7;

mat mul(mat &A,mat &B){
    mat C(A.size(), vector<ll>(B[0].size()));
    rep(i,A.size()){
        rep(k,B.size()){
            rep(j,B[0].size()){
                C[i][j] = (C[i][j] + ((A[i][k] * B[k][j]) % mod))% mod;
            }
        }
    }
    return C;
}

mat pow(mat A,ll n){
    mat B(A.size(), vector<ll>(A.size()));
    rep(i,A.size()){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B,A);
        A = mul(A,A);
        n = n >> 1;
    }
    return B;
}

int main(){
    int n;
    ll k;
    cin >> n >> k;
    mat A(n,vector<ll>(n));
    rep(i,n){
        rep(j,n){
            cin >> A[i][j];
        }
    }
    A = pow(A,k);
    ll ans = 0;
    rep(i,n){
        rep(j,n){
            ans = (ans + A[i][j]) % mod;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3712
from sys import stdin
from collections import defaultdict
N,K,Q = [int(x) for x in stdin.readline().rstrip().split()]
cntdic = defaultdict()
for i in range(1,N+1):
    cntdic[i] = 0
for _ in range(Q):
    q = int(input())
    cntdic[q] += 1

for j in cntdic.values():
    if (K - Q + j) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15468
#include <cstdio>
#include <cassert>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef unsigned char byte;
typedef unsigned int uint;
typedef unsigned long long int ulli;

int a[101010];

inline int absi(int x) {
    return x > 0 ? x : -x;
}

int main() {
    int n;
    scanf("%d", &n);
    int i;
    lli s = 0;
    for (i=1; i<=n; ++i) {
        scanf("%d", a+i);
    }
    n += 1;
    for (i=1; i<=n; ++i) {
        s += absi(a[i] - a[i-1]);
    }
    for (i=1; i<n; ++i) {
        printf("%lld\n", s - absi(a[i] - a[i-1]) - absi(a[i+1] - a[i]) + absi(a[i+1] - a[i-1]));
    }
    return 0;
}


Measured memory_bytes: 1536