akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int Q;
  cin>>Q;
  ll query, a, b;
  vector<ll> ansarr;
  vector<ll> ansarr1;
  ll add=0, sub=0;
  multiset<ll> st1, st2;
  ll bash=big;
  auto tmp1=st1.begin(), tmp2=st2.begin(); // st1: ちっちゃいほう, st2: おっきいほう
  ll ans = 0;
  for(int i=0;i<Q;++i) {
    cin>>query;
    if(query==1) {
      cin>>a>>b;
      ans += b;
      if(st1.empty() && bash==big) {
        bash = a;
        continue;
      }
      if(bash==big) {
        if(st1.empty()) {
          bash = a;
        }
        else {
          tmp1 = st1.end();
          tmp1--;
          tmp2 = st2.begin();
          if(*tmp1<=a && a<=*tmp2) bash = a;
          else if(a<*tmp1) {
            bash = *tmp1;
            sub -= *tmp1;
            st1.erase(st1.find(*tmp1));
            sub += a;
            st1.insert(a);
          }
          else {
            bash = *tmp2;
            add -= *tmp2;
            st2.erase(st2.find(*tmp2));
            add += a;
            st2.insert(a);
          }
        }
      }
      else {
        if(bash<=a) {
          add += a;
          sub += bash;
          st1.insert(bash);
          st2.insert(a);
        }
        else {
          add += bash;
          sub += a;
          st1.insert(a);
          st2.insert(bash);
        }
        bash = big;
      }
    }
    else {
      if(bash==big) {
        tmp1 = st1.end();
        tmp1--;
        ansarr1.push_back(*tmp1);
      }
      else ansarr1.push_back(bash);
      ansarr.push_back(add-sub+ans);
    }
  }
  for(int i=0;i<ansarr.size();++i) cout<<ansarr1[i]<<" "<<ansarr[i]<<endl;
}



Measured memory_bytes: 12884
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int i = 0; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int W, H;
    while(cin >> W >> H, W != 0){

        vector<vector<int>> mp(H, vector<int>(W));
        rep(h, H) rep(w, W) cin >> mp[h][w];

        const int dy[8] = {1,1,-1,-1,1,-1,0,0};
        const int dx[8] = {1,0,-1,1,-1,0,-1,1};
        vector<vector<bool>> visited(H, vector<bool>(W, false));

        auto dfs = [&](auto&& dfs_, int y, int x) -> void {
            visited[y][x] = true;

            for(int i = 0; i < 8; i++){
                int ny = y + dy[i];
                int nx = x + dx[i];

                if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
                if(visited[ny][nx] || mp[ny][nx] == 0) continue;

                dfs_(dfs_, ny, nx);
            }
        };

        int ans = 0;
        rep(h, H) rep(w, W){
            if(mp[h][w] == 1 && visited[h][w] == false){
                ans++;
                dfs(dfs, h, w);
            }
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 2e5 + 10;
int n, a[N];
long long sum[N], tot;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum[a[i]]++;
	for (int i = 1; i <= n; i++) {
		tot += sum[i] * (sum[i] - 1) / 2;
	}
	for (int i = 1; i <= n; i++) {
		printf("%lld\n", tot - (sum[a[i]] - 1));
	}
	return 0;
}

Measured memory_bytes: 3968
N,M=map(int,input().split())

AB=[]
#B=[]

#print(N,M)

#AB[i][0]→A
#AB[i][1]→B

for i in range(N):
    a,b=map(int,input().split())
    AB.append([a,b])

"""
for i in range(N):
    print(AB[i][0],AB[i][1])
"""

AB.sort()
"""
for i in range(N):
    print(AB[i][0],AB[i][1])
"""    
ySum=0
dSum=0
for i in range(N):
    cnt=0
    while(cnt<AB[i][1]):
        if(dSum==M):
            break
        ySum=ySum+AB[i][0]
        cnt+=1
        dSum+=1
            
print(ySum)


Measured memory_bytes: 20064
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{	
	ll N = 0;
	string tmp = "";
	ll ret = 0;

	cin >> N;

	map<char, ll> S;

	Rep(i, N) {
		cin >> tmp;
		S[tmp[0]]++;
	}

	// calc all combination
	// "MARCH"
	// 5C3 = 5x4x3 / 6 = 10
	ret += S['M'] * S['A'] * S['R'];	// "MAR"
	ret += S['M'] * S['A'] * S['C'];	// "MAC"
	ret += S['M'] * S['A'] * S['H'];	// "MAH"
	ret += S['M'] * S['R'] * S['C'];	// "MRC"
	ret += S['M'] * S['R'] * S['H'];	// "MRH"
	ret += S['M'] * S['C'] * S['H'];	// "MCH"
	ret += S['A'] * S['R'] * S['C'];	// "ARC"
	ret += S['A'] * S['R'] * S['H'];	// "ARH"
	ret += S['A'] * S['C'] * S['H'];	// "ACH"
	ret += S['R'] * S['C'] * S['H'];	// "RCH"

	cout << ret << endl;

	return 0;
}





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

namespace dijkstra_n {
template<class W>
struct Edge {
	using type = Edge<W>;
	int to;
	W w;
	template<class... Args> Edge(int t, Args... args) : to(t), w(args...) {}
	inline bool operator<(const Edge& rhs) const { return w < rhs.w; }
	inline bool operator>(const type& rhs) const { return rhs < *this; }
	inline bool operator>=(const type& rhs) const { return !(*this < rhs); }
	inline bool operator<=(const type& rhs) const { return !(rhs < *this); }
	inline bool operator==(const type& rhs) const { return !(*this < rhs) && !(rhs < *this); }
	inline bool operator!=(const type& rhs) const { return (*this < rhs) || (rhs < *this); }
};
template<class W>
struct Edges : private vector<vector<Edge<W>>> {
	using type = vector<vector<Edge<W>>>;
	template<class... Args> Edges(Args... args) : type(args...) {}
	template<class... Args> void add_edge(int u, int v, Args... args) {
		(*this)[u].emplace_back(v, args...);
	}
	using type::begin; using type::end; using type::rbegin; using type::rend;
	using type::cbegin; using type::cend; using type::crbegin; using type::crend;
	using type::size; using type::operator[]; using type::at; using type::back; using type::front;
	using type::reserve; using type::resize; using type::assign; using type::shrink_to_fit;
	using type::clear; using type::erase; using type::insert; using type::swap; 
	using type::push_back; using type::pop_back; using type::emplace_back; using type::empty;
};
template<class W>
struct Graph {
	const int sz;
	Edges<W> e;
	Graph(int n) : sz(n), e(sz) {}
	template<class... Args> void add_edge(int u, int v, Args... args) {
		e.add_edge(u, v, args...);
	}
	int size() {
		return sz;
	}
};
template<class W, class T = W>
struct Graph_D : public Graph<W> {
	vector<T> dist;
	Graph_D(int n) : Graph<W>(n), dist(n) {}
};
template<class W, class T>
void Dijkstra(Graph_D<W, T>& g, int start, T INF_COST) {
	auto& dist = g.dist;
	auto& e = g.e;
	for (auto& ww : dist) ww = INF_COST;
	using Q_T = pair<T, int>;
	priority_queue<Q_T, vector<Q_T>, greater<>> q;
	q.emplace(0, start);
	while (!q.empty()) {
		auto a = q.top();
		q.pop();
		if (a.first >= dist[a.second]) continue;
		dist[a.second] = a.first;
	for (auto& p : e[a.second]) {
			if (p.w == INF_COST) continue;
			if (a.first + p.w < dist[p.to]) q.emplace(a.first + p.w, p.to);
		}
	}
}
}
using dijkstra_n::Dijkstra;
template<class T, class U = T> using graph = dijkstra_n::Graph_D<T, U>;

int main() {
    int n; cin >> n;
    graph<int> g(n);
    for (int i = 0; i < n; i++) {
        int v, k; cin >> v >> k;
        while (k--) {
            int u, c; cin >> u >> c;
            g.add_edge(v, u, c);
        }
    }
    Dijkstra(g, 0, INT_MAX);
    for (int i = 0; i < n; i++) {
        cout << i << " " << g.dist[i] << endl;
    }
}


Measured memory_bytes: 3156
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

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

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag, 
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = 
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
const ld PI = 3.1415926535897932384626;
const ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
const ll MAX = 2e5 + 5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    boost
    string s, ss;
    ll q;
    cin >> s >> q;
    ll flag = 1;
    while(q--) {
        ll t, f;
        char c;
        cin >> t;
        if(t == 1) flag = 1-flag;
        else {
            cin >> f >> c;
            if((f==1 && flag) || (f==2 && flag==0)) ss.pb(c);
            else s.pb(c);
        }
    }
    reverse(all(ss));
    s = ss+s;
    if(flag==0) reverse(all(s));
    cout << s << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;

ll dp[2001];

int main() {
  int n;
  cin >> n;

  for (int i = 3; i <= n; i++) {
    dp[i] = (dp[i] + 1) % MOD;
    for (int j = i + 3; j <= n; j++) {
      dp[j] = (dp[j] + dp[i]) % MOD;
    }
  }

  cout << dp[n] << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    int N;
    cin>>N;
    int P[SIZE]={};
    for(int i=0;i<N-1;i++){
        int a;
        cin>>a;
        P[a]++;
    }
    for(int i=1;i<=N;i++)
        cout<<P[i]<<endl;

    return 0;
}


Measured memory_bytes: 4376
def myAnswer(N:int,K:int) -> int:
   ans = 0
   for n in range(1,N+1):
      total = n
      counter = 0
      while total < K:
         total *= 2
         counter += 1
      ans += 1/N * (1/2)**counter
   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   print(myAnswer(N,K))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 2003
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int k;
int dist[MAX];
vector<int> Graph[MAX];
vector<pair<int,int> > Edges;
int bfsNode(int root,int n,int d)
{
    int i,ans=n;
    for(i=1;i<=n;i++)
    {
        dist[i]=MAX*3;
    }
    queue<int> Nodes;
    int node=root;
    dist[node]=0;
    Nodes.push(node);
    while(!Nodes.empty())
    {
        node=Nodes.front();
        ans--;
        Nodes.pop();
        for(i=0;i<Graph[node].size();i++)
        {
            if(dist[node]+1>d) break;
            if(dist[Graph[node][i]]>dist[node]+1)
            {
                dist[Graph[node][i]]=dist[node]+1;
                Nodes.push(Graph[node][i]);
            }
        }
    }
    return ans;
}
int bfsEdge(pair<int,int> roots,int n,int d)
{
    int i,ans=n;
    for(i=1;i<=n;i++)
    {
        dist[i]=MAX*3;
    }
    queue<int> Nodes;
    int node=roots.first;
    dist[node]=0;
    Nodes.push(node);
    node=roots.second;
    dist[node]=0;
    Nodes.push(node);
    while(!Nodes.empty())
    {
        node=Nodes.front();
        ans--;
        Nodes.pop();
        for(i=0;i<Graph[node].size();i++)
        {
            if(dist[node]+1>d) break;
            if(dist[Graph[node][i]]>dist[node]+1)
            {
                dist[Graph[node][i]]=dist[node]+1;
                Nodes.push(Graph[node][i]);
            }
        }
    }
    return ans;
}
int main()
{
    int n;
    scanf("%d %d",&n,&k);
    int u,v,i;
    for(i=1;i<n;i++)
    {
        scanf("%d %d",&u,&v);
        Graph[u].push_back(v);
        Graph[v].push_back(u);
        Edges.push_back(make_pair(u,v));
    }
    int ans=n;
    if(k%2)
    {
        for(i=0;i<n-1;i++)
        {
            ans=min(ans,bfsEdge(Edges[i],n,k/2));
        }
    }
    else
    {
        for(i=1;i<=n;i++)
        {
            ans=min(ans,bfsNode(i,n,k/2));
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3912
#include <iostream>
using namespace std;
typedef long long ll;
int main(void) {
  ll n, m;
  cin >> n >> m;
  if (n >= m / 2) {
    cout << m / 2 << endl;
  } else {
    cout << n + (m - 2 * n) / 4 << endl;;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace AOJ
{
    class Program
    {

        
        private static string solve(int n)
        {
            string[,] cnvTbl = new string[,]{
                {"7","9"}
                ,{"6","8"}
                ,{"5","7"}
                ,{"4","5"}
            };

            string str8 = Convert.ToString(n, 8);
            
            for (int i = 0; i < cnvTbl.GetLength(0);i++ )
            {
                str8 = str8.Replace(cnvTbl[i, 0], cnvTbl[i, 1]);
            }
            return str8;
        }
        
        static void Main(string[] args)
        {

            while (true) {
                int n  = int.Parse(Console.ReadLine());
                if (n == 0) break;
                Console.WriteLine(solve(n));
            }
        }
    }
}

Measured memory_bytes: 19928
use std::io::*;

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    unsafe { String::from_utf8_unchecked(buf) }
  };
  let mut lines = input.split('\n');

  let n = lines.next().unwrap().parse().unwrap();
  let mut m = lines.next().unwrap().parse().unwrap();

  let mut max = m;

  for line in lines.take(n) {
    let mut iter = line.split(' ').map(|s| s.parse().unwrap());
    let (i, o) = (iter.next().unwrap(), iter.next().unwrap());

    let (s, err) = usize::overflowing_sub(m + i, o);
    if err {
      max = 0;
      break;
    }
    m = s;
    if max < s { max = s; }
  }

  println!("{}", max);
}



Measured memory_bytes: 5024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int a = sc.nextInt();
     	int b = sc.nextInt();
        int c = sc.nextInt();
        
        if(a - b == b - c){
          System.out.println("YES");
        }else{
          System.out.println("NO");
        }

    }
}

Measured memory_bytes: 35508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  string day[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
  int m, d;
  for(;;) {
    int ans = 0;
    cin >> m >> d;
    if(m == 0 || d == 0) break;
    for(int i=1; i<m; ++i) ans += month[i];
    ans += d;
    cout << day[ans % 7] << endl;
  }
}




Measured memory_bytes: 3108
// Problem : Divide them all
// Contest : CodeChef - Code Invicta
// URL : https://www.codechef.com/GHC32020/problems/MOON
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
 
 
 
 
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
 
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define mod 998244353
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}


int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n;
   cin >> n;
   int ans = 0;
   ans+=1000*(n/500);
   n %= 500;
   ans += 5 * (n / 5);
   cout << ans;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<deque>
#include<algorithm>
using namespace std;
char a[1005][1005];
int dis[1005][1005],h,w,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
deque<pair<int,int> > d;
void bfs(int x,int y){
	int i,j;
	for(i=1;i<=h;i++){
		for(j=1;j<=w;j++){
			dis[i][j]=2147483647;
		}
	}
	dis[x][y]=0;
	d.push_front(make_pair(x,y));
	while(!d.empty()){
		pair<int,int> f=d.front();
		d.pop_front();
		for(i=0;i<4;i++){
		    if(f.first+dx[i]>0&&f.first+dx[i]<=h&&f.second+dy[i]>0&&f.second+dy[i]<=w&&dis[f.first+dx[i]][f.second+dy[i]]>dis[f.first][f.second]&&a[f.first+dx[i]][f.second+dy[i]]=='.'){
		    	dis[f.first+dx[i]][f.second+dy[i]]=dis[f.first][f.second];
		    	d.push_front(make_pair(f.first+dx[i],f.second+dy[i]));
			}
		}
		for(i=max(f.first-2,1);i<=min(f.first+2,h);i++){
			for(j=max(f.second-2,1);j<=min(f.second+2,w);j++){
				if(dis[i][j]>dis[f.first][f.second]+1&&a[i][j]=='.'){
					dis[i][j]=dis[f.first][f.second]+1;
		    	    d.push_back(make_pair(i,j));
				} 
			}
		}
	}
}
int main(){
	int c1,c2,d1,d2,i;
	scanf("%d%d",&h,&w);
	scanf("%d%d",&c1,&c2);
	scanf("%d%d",&d1,&d2);
	for(i=1;i<=h;i++){
		scanf("%s",a[i]+1);
	}
	bfs(c1,c2);
	printf("%d",dis[d1][d2]==2147483647?-1:dis[d1][d2]);
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main()
{	   


string a;
cin >> a ;
string b;
cin >> b ;
if(a==b||(b.size()!=(a.size()+1)))
{
	cout << "No" ;
}
else
{
	long long int  count=0;
for(unsigned long long int  i=0; i<a.size(); i++)
{
	if(a[i]!=b[i])
	{
		cout << "No" ;
		count=1;
      break;
	}
}
if(count==0)
{
cout << "Yes" ;
}
}
}


Measured memory_bytes: 3600
def gcd(a, b):
    if a < b:
        a, b = b, a
    return b if (a % b == 0) else gcd(b, a % b)

def solve(n, a):
    l = [0] * n
    l[0] = a[0]
    for i in range(1, n):
        l[i] = gcd(l[i-1], a[i])
    r = [0] * n
    r[n-1] = a[n-1]
    for i in range(n-2, -1, -1):
        r[i] = gcd(r[i+1], a[i])
    b = []
    for i in range(n):
        if i == 0:
            b.append(r[i+1])
        elif i == n-1:
            b.append(l[i-1])
        else:
            b.append(gcd(l[i-1], r[i+1]))
    return max(b)

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

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

int main(){
    int N;
    cin >> N;
    if(N == 1) {
        cout << "Hello"<< " " <<"World" << endl;
    }
    else {
        int A,B;
        cin >> A >> B;
        cout << A+B << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
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;
}
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    ll candy=0;
    rep(i,n-1){
        if(a[i]+a[i+1]>x){
            candy += a[i]+a[i+1]-x;
            if(a[i+1]<a[i]+a[i+1]-x) a[i+1]=0;
            else a[i+1] -= a[i]+a[i+1]-x;

        }
    }
    cout<<candy<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll n;
ll a[6];

int main()
{
    ll ans = 0;
    scanf("%lld",&n);
    for(int i = 1;i <= 5;i++)
        scanf("%lld",&a[i]);
    ll temp = a[1];
    int cou = 1;
    for(int i = 2;i <= 5;i++)
        if(a[i] < temp)
        {
           cou = i;
           temp = a[i];
        }
    if(n > temp)
    {
        ans = n / temp;
        if(n % temp != 0)
        ans++;
    }
    else
        ans = 1;
    ans += (cou - 1) + (5 - cou);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

int k[31], a[31][31];
map<int, int> mp;

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

  int n, m;
  string s;

  cin >> n >> m;
  REP(i, n){
    cin >> k[i];
    REP(j, k[i]){
      int tmp;
      cin >> tmp;
      mp[tmp]++;
    }
  }
  int cnt = 0;
  for(auto itr = mp.begin(); itr!=mp.end(); itr++){
    if(itr->second == n) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *args[])
{

	int m,f,r;
	int sum;
	unsigned char seiseki;

	while(1) {

		scanf("%d %d %d", &m, &f, &r);

		if( m == -1 && f == -1 && r == -1 ) {
			break;
		}

		sum = m + f;

		if( m == -1 || f == -1 ) {
			seiseki = 'F';
		}
		else if( sum >= 80 ) {
			seiseki = 'A';
		}
		else if( 65 <= sum && sum < 80 ) {
			seiseki = 'B';
		}
		else if( 50 <= sum && sum < 65 ) {
			seiseki = 'C';
		}
		else if( 30 <= sum && sum < 50 ) {
			if( r >= 50 ) {
				seiseki = 'C';
			}
			else {
				seiseki = 'D';
			}
		}
		else if( sum < 30 ) {
			seiseki = 'F';
		}

		printf("%c\n", seiseki);

	}
	

	return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  cout << fixed << setprecision(10);
  double t;
  if (x > a * a * b / 2) {
    t = 1.0 * 2 * b / a - 2.0 * x / (a * a * a);
  } else {
    t = 1.0 * a * b * b / (2 * x);
  }
  cout << atan(t) * 180 / acos(-1) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long a,b,c;
  cin >> a >> b >> c;
  
  long d = a/(b+c);
  long e = a%(b+c);
  
  if(e>=b) cout << d*b+b;
  else cout << d*b+e;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
Node root;
void insert(Node);
void inorder(Node);
void preorder(Node);
Node search(Node,int);

int main()
{
  int n,i,x;
  char m[10];
  Node A,t;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s%d",m,&x);
    if(m[0]=='i'){
      A = (Node)malloc(sizeof(struct node));
      A->right = NIL;
      A->left = NIL;
      A->parent = NIL;
      A->key = x;
      insert(A);
    }
    else if(m[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(m[0]=='f'){
      t = search(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}

void insert(Node A)
{
  Node y,x;

  y = NIL;
  x = root;
  
  while(x!=NIL){
    y = x;
    if(A->key < x->key) x = x->left;
    else x = x->right;
  }
  A->parent = y;

  if(y==NIL) root = A;
  else if(A->key < y->key) y->left = A;
  else y->right = A;
}

void inorder(Node A)
{
  if(A==NIL) return;
  inorder(A->left);
  printf(" %d",A->key);
  inorder(A->right);
}

void preorder(Node A)
{
  if(A==NIL) return;
  printf(" %d",A->key);
  preorder(A->left);
  preorder(A->right);
}

Node search(Node r,int x)
{
  int f;
  
  while(r!=NIL && x!=r->key){
    if(x<r->key) r = r->left;
    else r = r->right;
  }
  return r;
}

  
  
  
  
  



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

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}
int num[10000024];
signed main(void){
	int n = read(),ans = 0;
	for(re int i=1;i<=n;++i){
		for(re int j=1;1;++j){
			int p = i*j;
			if(p>n)break;
			num[p]++;
		}
	}
	for(re int i=1;i<=n;++i){
		//cout<<num[i]<<' ';
		ans+=i*num[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 81824
a, b, k = map(int, input().split())

res = set()

for i in range(a, a+k):
    if i <= b:
        res.add(i)

for i in range(b-k+1, b+1):
    if a <= i:
        res.add(i)

# print(res)

for i in sorted(list(res)):
    print(i)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    int ans=0;
    rep(i,n){
        int x; cin>>x;
        ans+=min(k-x,x);
    }
    ans*=2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	map<ll,ll>q;
	ll n;
	cin>>n;
	ll a[200010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	q[1+a[0]]++;
	ll ans=0;
	for(ll i=1;i<n;i++){
		ll now=i+1-a[i];
		ans+=q[now];
		q[i+1+a[i]]++;
	}
	cout <<ans;
	// your code goes here
	return 0;
}


Measured memory_bytes: 27872
# 1秒で着想したけど実装が一度ドハマリして死亡 死亡ってか殺意
# 考え直して、すべての状態をboolで管理することにした

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
rsp = [True for _ in range(n)]
ans = r if t[0] == "s" else s if t[0] == "p" else p

for i in range(1, n):
    if i + 1 <= k:
        ans += r if t[i] == "s" else s if t[i] == "p" else p
    else:
        if t[i - k] == t[i]:
            if rsp[i - k] == True:
                rsp[i] = False
            else:
                ans += r if t[i] == "s" else s if t[i] == "p" else p
                rsp[i] = True
        else:
            ans += r if t[i] == "s" else s if t[i] == "p" else p
print(ans)


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

using namespace std;

int main()
{
    string s,t;
    cin>>s>>t;
    int c=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i])
        {
            c++;
        }
    }
    cout<<c;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


vector <ll> as;
vector <ll> fs;
ll k;
ll n;

bool judge(ll cost){
    ll _k = k;
    REP(i, n){
        ll bunsi = (-1 * cost);
        ll bunbo = fs[i];
       _k -=  max(ll(0), (bunsi / bunbo) + as[n-i-1]);
    }
    if (_k < 0){
        return false;
    } else {
        return true;
    }
}

int main(void){
    cin >> n;
    cin >> k;
    REP(i, n){
        ll a; cin >> a;
        as.push_back(a);
    }
    sort(as.begin(), as.end());
    REP(i, n){
        ll f; cin >> f;
        fs.push_back(f);
    }
    sort(fs.begin(), fs.end());
    ll ng = -1;
    ll ok = 1e12;
    ll mid;
    while (ok - ng > 1){
        mid = (ok + ng) / 2;
        if (judge(mid)){
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 4848
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int cal[10005];

int main() {
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++) {
		cin >> cal[i];
	}

	sort(cal, cal + n);
	double sumcal=c,sumdol=a;
	double cado = sumcal / sumdol;

	for (int i = n-1; i>-1; i--) {
		sumcal += cal[i];
		sumdol += b;
		double d = sumcal / sumdol;
		if (d >= cado) { cado = d; }
		else {break;}
	}
	cado = floor(cado);
	int ca = cado;
	cout << ca << endl;
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
    int n,m,s,t; cin>>n>>m>>s>>t; s--; t--;
    vector<pair<int,int>> tonariy[100010],tonaris[100010];
    int u,v,a,b;
    for (int i = 0; i < m; ++i) {
        cin>>u>>v>>a>>b; u--; v--;
        tonariy[u].push_back({a,v});
        tonaris[u].push_back({b,v});
        tonariy[v].push_back({a,u});
        tonaris[v].push_back({b,u});
    }
    //出発地から各都市への円コスト
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<>> pq;

    vector<ll> dist(n,1e18);
    vector<bool> det(n,false);

    dist[s]=0ll;

    pq.push({0ll,s});

    while(!pq.empty()){
        ll d=pq.top().first; ll node=pq.top().second;
        pq.pop();
        if(det[node]) continue;
        det[node]=true;
        for(auto tsugi:tonariy[node]){
            //dist[tsugi.second]=min(dist[tsugi.second],dist[node]+tsugi.first);
            if(chmin(dist[tsugi.second],dist[node]+tsugi.first)) pq.push({dist[tsugi.second],tsugi.second});
        }
    }

    vector<ll> dists(n,1e18);
    vector<bool> dets(n,false);

    dists[t]=0ll;

    pq.push({0ll,t});

    while(!pq.empty()){
        ll d=pq.top().first; ll node=pq.top().second;
        pq.pop();
        if(dets[node]) continue;
        dets[node]=true;
        for(auto tsugi:tonaris[node]){
            //dists[tsugi.second]=min(dists[tsugi.second],dists[node]+tsugi.first);
            if(chmin(dists[tsugi.second],dists[node]+tsugi.first)) pq.push({dists[tsugi.second],tsugi.second});
        }
    }

    vector<ll> anses(n);

    priority_queue<ll> cost;
    for(int i=n-1;i>=0;--i){
        cost.push(1e15-dist[i]-dists[i]);
        anses[i]=cost.top();
    }

    for(auto ans: anses) cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 17652
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  string s;
  cin>>s;
  int n=s.size();

  if(n==1){
    cout<<0<<endl;
    return 0;
  }
  int dist[26];
  int point;
  for(char i='a'; i<='z'; ++i){
    dist[i-'a']=-1;
    point=-1;
    REP(j, n){
      if(s[j] == i){
        dist[i-'a'] = max(dist[i-'a'], j-point-1);
        point = j;
      }
    }

    if(point!=-1) dist[i-'a'] = max(dist[i-'a'], n-point-1);
  }
  int ans=101;
  REP(i, 26) {
    if(dist[i]>=0) ans=min(ans, dist[i]);
    //ECHO(dist[i]);
  }
  ECHO(ans);
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
int main() {
  RL(line);
  std::vector<i8t> rem(2019u, 0), rem2;
  rem[0]++;
  i8t current = 0;
  i8t count = 0;
  for(int i = 0;i<line.size();i++){
    current = (current * 10 + (line[i] - '0')) % 2019;
    count += rem[current];

    // udpate rem
    rem[current]++;
    rem2.clear();
    rem2.resize(2019u, 0);
    for(int j=0;j<2019;j++){
      rem2[j*10%2019]+=rem[j];
    }
    rem.swap(rem2);
  }
  P(count);
  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll h;
  cin >> h;

  ll v = 1;
  ll ans = 0;
  while (h > 0) {
    h /= 2;
    ans += v;
    v *= 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, K: int):

    n = N // K
    print(min(abs(n*K-N), abs((n+1)*K-N)))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
 
int main(){
  ll a, b, k; cin >> a >> b >> k;
  ll ans_a, ans_b;
  if(a >= k){
      ans_a = a - k;
      ans_b = b;
  }else if(a + b <= k){
      ans_a = 0;
      ans_b = 0;
  }else{
      ans_a = 0;
      ans_b = b - k + a;
  }
  cout << ans_a << " " << ans_b << endl;
  return 0;
}

Measured memory_bytes: 256
#B - 文字列大好きいろはちゃんイージー

#input N L
N,L = map(int,input().split())

#input S1 ~ SN as list S
S = [input() for _ in range(N)]

#辞書順にソート
S.sort()

#文字列を結合
str = ''.join(S)

print(str)

Measured memory_bytes: 3060
N, M = map(int, input().split())
L_ans = 1
R_ans = N

for _ in range(M):
    L, R = map(int, input().split())
    L_ans = max(L, L_ans) # Lの中で一番大きいもの抽出
    R_ans = min(R, R_ans) # Rは最小

    if L_ans > R_ans:
        print(0)
        exit()

print(R_ans - L_ans + 1)


Measured memory_bytes: 3060
import java.util.*;
 
public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0 ; i < N; i++){
            a[i] = sc.nextInt();
            if(map.containsKey(a[i]))
                map.put(a[i], map.get(a[i])+1);
            else
                map.put(a[i], 1);
        }
        sc.close();

        int count = 0;

        for(Integer key: map.keySet()){
            if(key > map.get(key))
                count += map.get(key);
            else
                count += map.get(key) - key;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 63168
#include <iostream>
using namespace std;
int main(void){
    int bingo[3][3];
    int k[3][3];
    int a,b,n;
    int flag=0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>a;
            k[i][j]=0;
            bingo[i][j]=a;
        }
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        for(int j=0;j<3;j++){
            for(int l=0;l<3;l++){
                if(bingo[j][l]==a)k[j][l]=1;
            }
        }
    }
    for(int j=0;j<3;j++){
        if(k[j][0]==1 && k[j][1]==1 && k[j][2]==1)flag=1;
        if(k[0][j]==1 && k[1][j]==1 && k[2][j]==1)flag=1;
    }
        if(k[0][0]==1 && k[1][1]==1 && k[2][2]==1)flag=1;
        if(k[2][0]==1 && k[1][1]==1 && k[0][2]==1)flag=1;
    
    if(flag==1)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
n = int(input())
s = 0
for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        s+=i
print(s)

Measured memory_bytes: 65360
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

vi ans;
int N,Q;
vvi ed;
vector<int> p;

int dfs(int x, int v){
  dump(x);
  ans[x] = v;
  each(c, ed[x]){
    dump(c);
    if (ans[c]==-1) dfs(c, v+p[c]);
  }

  return 0;
}

int solve(){
  cin>>N>>Q;
  ed.resize(N);

  rep(i, N-1){
    int a,b;cin>>a>>b;
    a--;b--;
    ed[a].pb(b);
    ed[b].pb(a);
  }
  dump("hello");

  p.resize(N);
  rep(q, Q){
    int i, x;
    cin>>i>>x;
    i--;
    p[i] += x;
  }

  dump(p);

  ans = vi(N, -1);
  dfs(0LL, p[0]);
  dump(ans);

  rep(i, sz(ans)) cout << ans[i] << (i!=sz(ans)-1 ? " " : "\n");

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 22784
s=list(input())
mod=10**9+7
n=len(s)
for i in range(n):
    if s[i]!="?":
        s[i]=int(s[i])
dp=[[0]*13 for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    if s[i]=="?":
        for k in range(10):
            for j in range(13):
                p=(k+10*j)%13
                dp[i+1][p]+=dp[i][j]
                dp[i+1][p]%=mod

    else:
        for j in range(13):
            p=(s[i]+10*j)%13
            dp[i+1][p]+=dp[i][j]
            dp[i+1][p]%=mod
print(dp[n][5])


Measured memory_bytes: 70392
#include<stdio.h>

int main(void){

  int num[10];
  int i, j, temp;

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

  for(i=0;i<10;i++){
    for(j=9;j>0;j--){
      if(num[j] < num[j-1]){
	temp = num[j];
	num[j] = num[j-1];
	num[j-1] = temp;
      }
    }
  }

  for(i=9;i>6;i--){
    printf("%d\n", num[i]);
  }

  return 0;
}



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


int main() {

    int a, b, x;
    cin >> a >> b >> x;
    if (a <= x && x <= a+b-1) cout << "YES" << endl;
    else cout << "NO" << endl;    
    return 0;
}

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

int FIND_MIN(int basis,int n);
int MIN(int a,int b);
int main(void){
   
   int N;
   
   scanf("%d",&N);
   
   int i;
   int ans = INT_MAX;
   
   for(i = 0;i <= N;i++){
      ans = MIN(ans,FIND_MIN(6,i) + FIND_MIN(9,N - i));
   }

   printf("%d\n",ans);
  
   return 0;
}

int MIN(int a,int b){
   if(a > b){
      return b;
   }
   else {
      return a;
   }
}

int FIND_MIN(int basis,int n){
   
   int count = 0;
   
   while(n > 0){
      count = count + n%basis;
      n = n/basis;
   }
   
   return count;
   
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
double a[101];
int main(){
	cin>>N;
	double s=0;
	REP(i,N){
		cin>>a[i];
		s+=a[i];
	}
	s/=N;
	LL now=0;
	REP(i,N){
		if(abs(s-a[now])>abs(s-a[i])){
			now=i;
		}
	}
	cout<<now<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[1000010];
vector<int> v;
bool flag[1000010];
map<int,bool> mp;
int main(){
	cin>>n;
	flag[0]=1;
	flag[1]=1;
	for(int i=2;i<=1000000;i++){
		if(!flag[i]){
			v.push_back(i);
			for(int j=i+i;j<=1000000;j+=i){
				flag[j]=1;
			}
		}
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int gcd=a[0];
	for(int i=1;i<n;i++){
		gcd=__gcd(gcd,a[i]);
	}
	if(gcd!=1){
		cout<<"not coprime"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		int x=0;
		while(a[i]>1){
			if(!flag[a[i]]){
				if(mp[a[i]]){
					cout<<"setwise coprime"<<endl;
					return 0;
				}
				mp[a[i]]=1;
				break;
			}
			while(x<v.size()&&a[i]%v[x]!=0){
				x++;
			}
			if(mp[v[x]]){
				cout<<"setwise coprime"<<endl;
				return 0;
			}
			mp[v[x]]=1;
			while(a[i]%v[x]==0){
				a[i]/=v[x];
			}
		}
	}
	cout<<"pairwise coprime"<<endl;
	return 0;
}

Measured memory_bytes: 8572