akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x){
	while( x->left!=NIL ) x=x->left;
	return x;
}
Node treeSearch(Node u, int k){
  if( u==NIL || k==u->key ) return u;
  if( k<u->key ) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}
Node treeSuccessor(Node x){
	if( x->right!=NIL ) return treeMinimum(x->right);
	Node y=x->parent;
	while( y!=NIL && x==y->right ){
		x=y;
		y=y->parent;
	}
	return y;
}
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if( z->left==NIL || z->right==NIL ) y=z;
  else y=treeSuccessor(z);

  if( y->left!=NIL ) x=y->left;
  else x=y->right;

  if( x!=NIL ) x->parent=y->parent;

  if( y->parent==NIL ) root=x;
  else if( y==y->parent->left ) y->parent->left=x;
  else y->parent->right=x;

  if( y!=z ) z->key=y->key;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while( x!=NIL ){
	  y=x;
	  if( z->key < x->key ) x=x->left;
	  else x=x->right;
  }
  z->parent=y;
  if( y==NIL ) root=z;
  else if( z->key < y->key ) y->left=z;
  else y->right=z;
}
void inorder(Node u){
	if( u->left!=NIL ) inorder(u->left);
	printf(" %d", u->key);
	if( u->right!=NIL ) inorder(u->right);
}
void preorder(Node u){
	printf(" %d", u->key);
	if( u->left!=NIL ) preorder(u->left);
	if( u->right!=NIL ) preorder(u->right);
}
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
ls = []
for i in range(n):
    x, l = MAP()
    ls.append([x-l, x+l])

ls = sorted(ls, key=itemgetter(1))
ans = n
for i in range(1, n):
    if ls[i][0] < ls[i-1][1]:
        ls[i][1] = ls[i-1][1]
        ans -= 1
print(ans)

Measured memory_bytes: 27440
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifndef ONLINE_JUDGE
#define debug(a) cout<<#a<<" --> "<<(a)<<"\n";
#define debug2(a) cout<<#a<<" --> "<<(a)<<" ";
#define HERE cout<<"here - "<<__LINE__<<"\n";
#else
#define debug(a)
#define debug2(a)
#define HERE
#endif
const ll mod = 1e9+7;
const int N = 1e5+5;
typedef pair<int,int> pii;


void TEST_CASES(int cas)
{
    int n;
    cin>>n;
    map<string, int>mp;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",mp["AC"],mp["WA"],mp["TLE"],mp["RE"]);


}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3736
class uf_tree:
    def __init__(self, n):
        self.sizes = [0] * n
        self.par = list(range(n))

    def find(self, x):
        if x == self.par[x]:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.sizes[x] < self.sizes[y]:
            x, y = y, x
        self.par[y] = x
        self.sizes[x] += self.sizes[y]

    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
a, b = [0] * M, [0] * M

for i in range(M):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1; b[i] -= 1
ans = 0
for i in range(M):
    uf = uf_tree(N+1)
    for j in range(M):
        if i == j:
            continue
        uf.unite(a[j], b[j])

    bridge = False
    for i in range(N):
        if not uf.same(0, i):
            bridge = True
    if bridge:
        ans += 1

print(ans)


Measured memory_bytes: 3064
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans=0
for i in range(N-2):
    for j in range(i+1,N):
        ng=N
        ok=j
        while abs(ok-ng)!=1:
            med =(ok+ng)//2
            if L[med]<L[i]+L[j]:
                ok=med
            else:
                ng=med
        ans+=ok-j
print(ans)

Measured memory_bytes: 43452
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;

int main(){

  int n,y;
  cin>>n>>y;
  int a=-1,b=-1,c=-1;
  int k;
 
  
  for(int i=0;i<=n;i++){
   // cout<<i<<" ";
    if(i*10000>y)break;
    for(int j=0;j<=n-i;j++){
     // for(int k=n-j-i;k>=0;k--){
       k=n-j-i;
          if(i*10000+j*5000+k*1000==y){
            cout<<i<<" "<<j<<" "<<k<<endl;
            return 0;
          }
     // }
    }
  }
  cout<<a<<" "<<b<<" "<<c<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
string s,t;
cin >> s >> t;
int n=s.size();
int cnt=0;
rep(i,n){
   if(s.at(i)!=t.at(i))cnt++;
}
cout << cnt << endl;
}
    

Measured memory_bytes: 3920
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	static unordered_map<ll, ll> memo;

	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	if (memo.find(b) == memo.end()) {
		ll k = 1;
		FOR(i, 2, b + 1) {
			k *= i;
			k %= MOD;
		}
		memo[b] = pow(k, MOD - 2);
	}
	c *= memo[b];
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}
/*
-- bit --
REP(i, (1 << n)) {
	REP(j, n) {
		cout << (1 & (i >> j));
	}
	cout << endl;
}
*/

int main() {
	string s;
	ll k;
	cin >> s >> k;
	ll cnt = 0;
	REPC(c, s) {
		if (c == '1') {
			++cnt;
		} else {
			break;
		}
	}
	cout << ((k > cnt) ? s[cnt]-'0' : 1) << endl;
}

Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 +10 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

ans='Possible'
n=I()
a=LI()
M=max(a)
m=min(a)
c=[0]*(M+1)
for i in range(n):
    c[a[i]]+=1
    
if all([c[i]>=2 for i in range(m+1,M+1)]):
    0
else:
    ans='Impossible'

if c[m]!=1+M%2:
    ans='Impossible'
    
print(ans)

Measured memory_bytes: 38640
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  ll a, b;

  cin >> a >> b;

  cout << (a - 1) * (b - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
k,n = gets.split.map(&:to_i)
a=gets.chomp.split.map(&:to_i)
i = 0
for num in 0..n-2 do
    if i<=a[num+1]-a[num]
        i = a[num+1]-a[num]
    end
end
if k-a[n-1]+a[0]>i
    puts k-(k-a[n-1]+a[0])
else
    puts k-i
end

Measured memory_bytes: 18692
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e6;
ll inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll a[200001];

int main()
{
    fast_io;
    ll n, k, i;
    cin >> n >> k;
    for (i = 1; i <= n; i++) cin >> a[i];
    for (i = k + 1; i <= n; i++) cout << (a[i] > a[i - k] ? "Yes" : "No") << '\n';
    return 0;
}

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

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  vector<vector<int>> data(h+1, vector<int>(w+1));
  
  vector<int> x(n);
  vector<int> y(n);
  vector<int> a(n);
  
  for(int i=0; i<n; i++){
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  
  int W_right = w;
  int W_left = 0;
  int H_top = h;
  int H_bottom = 0;
  
  for(int i=0; i<n; i++){
    if(a.at(i) == 1){
      if(W_left < x.at(i)){
        W_left = x.at(i);
      }
    }else if(a.at(i) == 2){
      if(W_right > x.at(i)){
        W_right = x.at(i);
      }
    }else if(a.at(i) == 3){
      if(H_bottom < y.at(i)){
        H_bottom = y.at(i);
      }
    }else{
      if(H_top > y.at(i)){
        H_top = y.at(i);
      }
    }
  }
  
  if(W_right - W_left < 0){
    W_right = W_left;
  }
  
  if(H_top - H_bottom < 0){
    H_top = H_bottom;
  }
  
  cout << (W_right - W_left) * (H_top - H_bottom) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,z,ans=0;
vector<int> graph[55];
bool vis[55];
void dfs(int a,int b,int x)
{
	++z;
	vis[x]=true;
	for(int i=0;i<graph[x].size();i++)
		if(!vis[graph[x][i]]&&!(x==a&&graph[x][i]==b)&&!(x==b&&graph[x][i]==a))
			dfs(a,b,graph[x][i]);
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		--x,--y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<graph[i].size();j++)
		{
			z=0;
			memset(vis,false,sizeof(vis));
			dfs(i,graph[i][j],1);
			if(z!=n)
				++ans;
		}
	ans/=2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> v(M, 0);
    for(int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for(int j = 0; j < K; j++) {
            int a;
            cin >> a;
            v[--a]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++) {
        if(v[i] == N) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import numpy as np

    N, K = map(int, input().split())
    H = np.array(list(map(int, input().split())) + [0] * (K + 2), dtype = np.int32) 

    INF = 10 ** 9
    cost = np.array([INF] * (N + K + 2), dtype = np.int32)
    cost[0] = 0

    n_minimum = np.minimum
    n_abs = np.abs

    for i in range(N):
        cost[i + 1: i + K + 1] = n_minimum(cost[i + 1: i + K + 1], cost[i] + n_abs(H[i + 1: i + K + 1] - H[i]))


    # print (cost)
    print (cost[N - 1])
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 22756
import queue

A = queue.Queue()
n, q = map(int, input().split())
for i in range(n):
    name, time = input().split()
    A.put([name, int(time)])
t = 0

while  not A.empty():
    L = A.get()
    if L[1] > q:
        L[1] -= q
        A.put(L)
        t += q
    else:
        t += L[1]
        print(L[0], t)


Measured memory_bytes: 14404
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
long long binpow(long long a,long long b)
{
    if (b == 1) return a;
    long long res = binpow(a, b/2)%MOD;
    if (b % 2) return (res*((res*a)%MOD))%MOD;
    else return (res * res)%MOD;
}

long long int fact(long long int a)
{
    if(a==0||a==1)
        return 1;
    long long int ans = 1;
    for(int i=a;i>=1;i--)
        ans = (ans * i)% MOD;
    return ans;
}

long long int ivmod(long long int a)
{
    return binpow(a,MOD-2);
}
 
long long int summ[1000005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n,m;
    cin>>n>>m;
    int x[100],y[100],xc[1000],yc[1000];
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>xc[i]>>yc[i];
    }
    for(int i=0;i<n;i++)
    {
        long long int minn = 9999999999;
        int ans = -1;
        for(int j=0;j<m;j++)
        {
            int temp = abs(x[i]-xc[j])+abs(y[i]-yc[j]);
            if(temp<minn)
            {
                minn=temp;
                ans = j+1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

const int inf = 1e7;
const long long mod = 1e9 + 7;
int main() {
        string s;
        cin >> s;
        int n = (int) s.size();
        bool unko = true;
        rep(i, n - 1) unko = unko && s[i] != s[i + 1];
        if (unko) {
                cout << 1 << endl;
                return 0;
        }
        vector<int> acc(n + 1);
        rep(i, n) {
                int a = (s[i] == 'a' ? 1 : 2);
                acc[i + 1] = (acc[i] + a) % 3;
        }
        vector<vector<int>> app(n + 2, vector<int> (3));
        rep(i, 3) app[n + 1][i] = inf;
        for (int i = n; i >= 0; i --) {
                rep(j, 3) {
                        app[i][j] = (acc[i] == j ? i : app[i + 1][j]);
                }
        }
        long long ans = 0;
        vector<int> add(n + 1);
        add[0] = 1;
        rep(i, n + 1) {
                if (acc[n] == acc[i]) (ans += add[i]) %= mod; // cut last part (sum == 0 (mod 3))
                for (int put = 1; put <= 2; put ++) {
                        int pos = app[i + 1][(put + acc[i]) % 3];
                        if (pos != inf) (add[pos] += add[i]) %= mod;
                }
        }
        if (acc[0] == acc[n]) (ans += mod - 1) %= mod; // no operation
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 6656
import java.util.Scanner;

public class Main {
  private static int height, width;
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    while (true) {
      height = stdIn.nextInt();
      width = stdIn.nextInt();
      if (height == 0 && width == 0) {
        break;
      }
      for (int i = 0;i < height; i++) {
        for (int j =0;j < width; j++) {
          if (i == 0 || i == height - 1) {
            System.out.print("#");
          } else {
            if (j == 0 || j == width - 1) {
              System.out.print("#");
            } else {
              System.out.print(".");
            }
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
}

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

int main()
{
   int N; cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++) cin>>a[i];

   int cur=0;
   for(int i=0;i<N;i++){
      if(a[i]==cur+1) cur++;
   }
   cout<<(cur==0? -1:N-cur)<<endl;
   return 0;
}


Measured memory_bytes: 1024
// ex3_4
//TKC001
#include<stdio.h>
 
int main(void){
    int num;
    //yn=1ならYes,0ならNo
    int yn = 0;
 
    scanf("%d", &num);
 
    for (int i = 9; i > 0; i--)
    {
        if(num/i<=9 && num/i>=1 && num%i==0){
            yn = 1;
            break;
        }
    }
 
    if(yn==1){
        printf("Yes");
    }else{
        printf("No");
    }
 
    return 0;
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll x){ cout << x << " "; }
void od(ld x){ cout << fixed << setprecision(10) << x << " "; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

int main(){
    string S;
    is(S);

    if(S[2]==S[3]&&S[4]==S[5]){
        ose("Yes");
    }else{
        ose("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=300005;
const int MOD=998244353;
int n;
char s[N];
int a[N];
int cnt[7];
void add(int &x,int &y)
{
	if(x>=1) x--,y++;
	return;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n*3;i++)
		if(s[i]=='R') a[i]=1;
		else if(s[i]=='G') a[i]=2;
		else if(s[i]=='B') a[i]=3;
	long long ans=1;
	for(int i=1;i<=n*3;i++)
	{
		if(cnt[7-a[i]]>=1) ans=ans*cnt[7-a[i]]%MOD,cnt[7-a[i]]--;
		else if(a[i]==1&&cnt[2]+cnt[3]>=1) ans=ans*(cnt[2]+cnt[3])%MOD,add(cnt[2],cnt[4]),add(cnt[3],cnt[5]);
		else if(a[i]==2&&cnt[1]+cnt[3]>=1) ans=ans*(cnt[1]+cnt[3])%MOD,add(cnt[1],cnt[4]),add(cnt[3],cnt[6]);
		else if(a[i]==3&&cnt[1]+cnt[2]>=1) ans=ans*(cnt[1]+cnt[2])%MOD,add(cnt[1],cnt[5]),add(cnt[2],cnt[6]);
		else cnt[a[i]]++;
		//R G B RG RB GB
	}
	for(int i=1;i<=n;i++)
		ans=ans*i%MOD;
	printf("%lld",ans);
	return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100000
#define LEN 10
i64 N;
string S[MAX_N];
unordered_map<string, i64> dict;

void solve() {
  i64 cnt = 0;

  i64 c;
  REP(i, N) {
    if (dict.count(S[i]) == 0) {
      dict[S[i]] = 1;
    } else {
      cnt += dict[S[i]];
      dict[S[i]]++;
    }
  }

  cout << cnt << endl;
}

int main() {
  cin >> N;
  REP(i, N) {
    cin >> S[i];
    sort(S[i].begin(), S[i].end());
  }

  solve();

  return 0;
}

Measured memory_bytes: 16036
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    long long int n,x;cin >> n >> x;

    long long int ans=0;
    long long int pre;cin >> pre;
    for(int i=0;i<n-1;i++){
        long long int now;cin >> now;
        if(pre+now>x){
            long long int dx = (pre+now) - x;
            ans += dx;                
            if(pre<=x){
                now -= dx;
            } else {
                now = 0;
            }
        }
        pre = now;        
    }    
    p(ans)
}

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

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
P Q2[LEN+1];

int head=0, tail=0, n;

void enqueue(P x){
  Q[tail]=x;
  if((tail+1)==LEN)
    tail = 0;
  else tail++;
}

P dequeue(){
  P x;
  x = Q[head];
  if((head+1)==LEN)
    head = 0;
  else head++;
  return x;
}


int main(){
  int elaps = 0, c=0;
  int i=1, q, time=0;
  P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n+1;

  while(1){
    u = dequeue();
    if(u.t>q){
      u.t -= q;
      enqueue(u);
      time += q;
    }
    else {
      time += u.t;
      printf("%s %d\n", u.name, time);
      c++; 
    }
    i++;
    if(c==n) break;
  }
  
  return 0;
}

Measured memory_bytes: 10828
from collections import defaultdict

k, s = map(int, input().split())

cnt = defaultdict(int)
for x in range(k+1):
    for y in range(k+1):
        cnt[x+y] += 1

ans = 0
for key, value in cnt.items():
    if 0 <= s - key <= k:
        ans += value

print(ans)


Measured memory_bytes: 9620
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_tuple();
    if a % 2 == 0 {
        if (b - a + 1) % 4 == 0 {
            println!("0");
        } else if (b - a + 1) % 4 == 2 {
            println!("1");
        } else if (b - a + 1) % 4 == 1 {
            println!("{}", b);
        } else {
            println!("{}", (b-2)^(b-1)^b);
        }
    } else {
        if (b - a) % 4 == 0 {
            println!("{}", a);
        } else if (b - a) % 4 == 2 {
            println!("{}", a ^ 1);
        } else if (b - a) % 4 == 1 {
            println!("{}", a^0^b);
        } else {
            println!("{}", a^0^(b-2)^(b-1)^b);
        }
    }
    // let mut tmp = 0;
    // for i in a..(b+1) {
    //     tmp = tmp ^ i;
    // }
    // println!("{}", tmp);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
namespace Computational_Geometry
{
	const long double eps=1e-8;
	struct Vector2
	{
		long double x,y;
		Vector2(long double X=0.0,long double Y=0.0):x(X),y(Y) {}
		Vector2 *read() {scanf("%Lf%Lf",&x,&y); return this;}
		void print() {printf("%.10Lf %.10Lf",x,y); return;}
		inline Vector2 operator - () const{return Vector2(-x,-y);}
		inline Vector2 operator + (const Vector2 &A) const{return Vector2(x+A.x,y+A.y);}
		inline Vector2 operator - (const Vector2 &A) const{return Vector2(x-A.x,y-A.y);}
		inline Vector2 operator * (const long double &k) const{return Vector2(x*k,y*k);}
		inline Vector2 operator / (const long double &k) const{return Vector2(x/k,y/k);}
		inline long double operator * (const Vector2 &A) const{return x*A.x+y*A.y;}
		inline long double operator ^ (const Vector2 &A) const{return x*A.y-y*A.x;}
		inline long double norm2() const{return x*x+y*y;}
		inline long double norm() const{return sqrtl(x*x+y*y);}
		inline bool operator < (const Vector2 &A) const{return (x<A.x-eps)||(x<=A.x+eps)&&(y<A.y-eps);}
		inline bool operator == (const Vector2 &A) const{return fabsl(x-A.x)<=eps&&fabsl(y-A.y)<=eps;}
		inline bool operator << (const Vector2 &A) const{return (y<-eps)^(A.y<-eps)?A.y<-eps:((*this^A)>eps)||((*this^A)>=-eps)&&(x>=-eps)&&(A.x<-eps);}
		inline Vector2 trans(long double a_11,long double a_12,long double a_21,long double a_22) const{return Vector2(x*a_11+y*a_12,x*a_21+y*a_22);}
	};
	#define Point Vector2
	Point Projection(Point P,Point P1,Point P2)
	{
		long double k1=(P2-P1)*(P-P1),k2=(P2-P1).norm2();
		return P1+((P2-P1)*(k1/k2));
	}
	Point Reflection(Point P,Point P1,Point P2)
	{
		long double k1=(P2-P1)*(P-P1),k2=(P2-P1).norm2();
		Point mid=P1+(P2-P1)*(k1/k2);
		return mid*2-P;
	}
};
using namespace Computational_Geometry;
Point P1,P2,P;
int Q;
int main()
{
	P1.read(),P2.read();
	scanf("%d",&Q);
	while(Q--)
	{
		P.read();
		Reflection(P,P1,P2).print();
		puts("");
	}
	return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <cmath>

#include <stdio.h>

using namespace std;

int main(){

   int n;
   cin >> n;

   int x[n], y[n];

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

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

   double d = 0;

   for(int i = 0; i < n; i++){
      d += abs(x[i] - y[i]);
   }

   printf("%.8lf\n", d);

   d = 0;

   for(int i = 0; i < n; i++){
      d += (x[i] - y[i]) * (x[i] - y[i]);
   }

   printf("%.8lf\n", sqrt(d));

   d = 0;

   for(int i = 0; i < n; i++){
      d += abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
   }

   printf("%.8lf\n", cbrt(d));

   d = 0;

   for(int i = 0; i < n; i++){
      if(d < abs(x[i] - y[i])){
         d = abs(x[i] - y[i]);
      }
   }

   printf("%.8lf\n", d);

   return 0;
}


Measured memory_bytes: 3344
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<climits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int n, k;
	cin >> n >> k;
	k--;
	string s;
	cin >> s;
	transform(s.begin() + k, s.begin() + k + 1, s.begin() + k, ::tolower);
	cout << s << endl;
}

Measured memory_bytes: 256
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def count_unique_pairs(n):
    return n * (n - 1) // 2

def main():
    GI()
    arr = LGIS()

    d = {}
    for x in arr:
        d[x] = d.get(x, 0) + 1

    tot = sum(count_unique_pairs(v) for v in d.values())
    
    for x in arr:
        print(tot - count_unique_pairs(d[x]) + count_unique_pairs(d[x]-1))

def main():
    GI()
    arr = LGIS()

    d = {}
    for x in arr:
        d[x] = d.get(x, 0) + 1

    tot = sum(count_unique_pairs(v) for v in d.values())
    
    for x in arr:
        print(tot - d[x] + 1)

main()


Measured memory_bytes: 87756
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin >> n >> k;
	int p[n];
	for(int i=0;i<n;i++)
		cin >> p[i];
	sort(p,p+n);
	int sum = 0;
	for(int i=0;i<k;i++)
		sum += p[i];
	cout << sum << "\n";
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  string s, t;
  ll dp[3030][3030];

  void init() {
    cin >> s >> t;
  }

  void solve() {
    rep(i, s.size()) rep(j, t.size()) {
      if(s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
      else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
    }
    string ans = "";
    ll i = (ll)s.size(), j = (ll)t.size();
    while(i>0&&j>0) {
      if(dp[i][j] == dp[i-1][j]) i--;
      else if(dp[i][j] == dp[i][j-1]) j--;
      else {
        ans += s[i-1];
        i--;
        j--;
      }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 71936
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int a[100],n,c;
  for(;;){
    cin>>n;
    if(n==0)
      break;
    for(i=0;i<n;i++)
      cin>>a[i];
    c=0;
    do{
      h=0;
      for(i=1;i<n;i++){
	if(a[i-1]>a[i]){
	  swap(a[i-1],a[i]);
	  h=1;
	  c++;
	}
      }
    }while(h);
    cout<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

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

	int len = s.length();

	REP(i, len - 2) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		else if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	if (s[len - 2] == s[len - 1]) {
		cout << len - 1 << " " << len << endl;
		return 0;
	}

	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
score_table = list(map(lambda x: [x[0]-1, x[1]-1, x[2], x[3]], [list(map(int, input().split())) for x in range(Q)]))
result = 0

for A in combinations_with_replacement(range(1,M+1), N):
    score = 0
    for i in range(Q):
        if A[score_table[i][1]] - A[score_table[i][0]] == score_table[i][2]:
            score += score_table[i][3]
            
    result = max(result, score)
    
print(result)

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,fx[100000];
  cin >> a;
  fx[0] = a;
  for(int i = 1;i<100000;i++){
    if(a%2==0) a/=2;
    else a = 3*a+1;
    for(int j = i-1;j>=0;j--){
      if(fx[j]==a){
        cout << i+1;
        return 0;
      }
      fx[i] = a;
    }
  }
}


Measured memory_bytes: 3584
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    lint n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    cout<<(n-1)/min({a,b,c,d,e})+5<<endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, m := readInt(), readInt()
	xm := make(map[int]map[int]bool, n)
	for i := 0; i < m; i++ {
		a, b := readInt(), readInt()
		if _, ok := xm[a]; !ok {
			xm[a] = make(map[int]bool)
		}
		xm[a][b] = true
	}

	for t := range xm[1] {
		for t2 := range xm[t] {
			if t2 == n {
				fmt.Println("POSSIBLE")
				return
			}
		}
	}
	fmt.Println("IMPOSSIBLE")
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, m; std::cin >> n >> m;
  vi h(n); rep(i, n) std::cin >> h[i];
  vvi to(n);
  rep(i, m) {
    int a, b; std::cin >> a >> b;
    --a, --b;
    to[a].pb(b), to[b].pb(a);
  }
  int ans = 0;
  rep(i, n) {
    int ma = 0;
    for (auto &v : to[i]) {
      chmax(ma, h[v]);
    }
    if (h[i] > ma) ans++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 8744
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for(int& l: L) cin >> l;

    sort(L.begin(), L.end());
    int ans = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            auto itr = lower_bound(L.begin(), L.end(), L[i]+L[j]);
            int k = distance(L.begin(), itr);
            ans += max(k-j-1, 0);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int N;

int main(){
  ios_base::sync_with_stdio(false); 
  int X;
  cin >> X;
  long long p = 0;
  int i; 
  for(i=1; p < X; ++i){
    p += i;
  }
  --i;
  cout << i << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vvll vecror<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
 
 


void solve()
{
    ll n,m,sum=0;
    cin>>n>>m;
    ll a[n];
    for(ll i=0;i<n;i++)
    {	cin>>a[i];
    	sum+=a[i];
    }
    sort(a,a+n);
    ll t;
    
    t=ceil1(sum,4*m)-1;
    ll ans=0;
    // cout<<sum;
    for(ll i=n-1;i>=0;i--)
    {
    	if(a[i]>t)
    	{
    		ans++;
    	}
    	
    }
    // cout<<ans;
    if(ans>=m)
    	cout<<"Yes";
    else
    	cout<<"No";
    return;
}

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


Measured memory_bytes: 256