akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
	int n,a[3000],i,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		s+=a[i];
	}
	printf("%d\n",s-n);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

# print([i for i in range(N-1) if A[i]+1 == A[i+1]])
# print(C)
print(sum(B)+sum([C[A[i]-1] for i in range(N-1) if A[i]+1 == A[i+1]]))

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

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

struct Edge {
    int src, dst;
    int capacity, flow;
    Edge* rev;
    Edge(int src, int dst, int capacity): src(src), dst(dst), capacity(capacity), flow(0), rev(nullptr) {}
};
using Vertex = deque<Edge>;
using Graph = vector<Vertex>;

inline int residue(const Edge& edge) { return edge.capacity - edge.flow; }

int edmonds_karp(Graph& graph, int source, int sink) {
    Edge dummy(-1, -1, -1);
    int total = 0;
    for (;;) {
        // find path
        queue<int> Q; Q.push(source);
        vector<Edge*> prev(graph.size()); prev[source] = &dummy;
        while (!Q.empty() && prev[sink] == nullptr) {
            int u = Q.front(); Q.pop();
            for (auto& e : graph[u]) {
                if (prev[e.dst] == nullptr && residue(e) > 0) {
                    prev[e.dst] = &e;
                    Q.push(e.dst);
                }
            }
        }
        if (prev[sink] == nullptr) return total;

        // augment flow
        int flow = INT_MAX;
        for (int u = sink; prev[u] != &dummy; u = prev[u]->src)
            flow = min(flow, residue(*prev[u]));
        for (int u = sink; prev[u] != &dummy; u = prev[u]->src) {
            prev[u]->flow += flow;
            prev[u]->rev->flow -= flow;
        }
        total += flow;
    }
}

void add_edge(Graph& graph, int src, int dst, int capacity) {
    graph[src].emplace_back(src, dst, capacity);
    graph[dst].emplace_back(dst, src, 0);
    graph[src].back().rev = &graph[dst].back();
    graph[dst].back().rev = &graph[src].back();
}

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a%b); }

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

    int m, n;
    while (cin>>m>>n, m|n) {
        vector<int> blue(m), red(n);
        REP(i, m) cin >> blue[i];
        REP(i, n) cin >> red[i];

        Graph graph(m+n+2);
        REP(i, m) REP(j, n) {
            if (gcd(blue[i], red[j]) > 1)
                add_edge(graph, i, m+j, 1);
        }
        REP(i, m) add_edge(graph, m+n, i, 1);
        REP(j, n) add_edge(graph, m+j, m+n+1, 1);

        cout << edmonds_karp(graph, m+n, m+n+1) << '\n';
    }
}

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    cout << (e - a <= k ? "Yay!" : ":(") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int cnt[3000];
int main() {
	rep(i,3000)cnt[i] = 0;

	ll L,R;
	cin>>L>>R;
	map<int, int> map;
	vector<int> v;
	for (int i = L; i <= R; ++i){
		if(cnt[i%2019]){
			cnt[i%2019]++;
			continue;
		}
		cnt[i%2019]++;
		v.push_back(i%2019);
		if(int(v.size()) == 2019)break;
	}
	int ans = INF;
/*	for(auto x:map){
		int a = x.first;
		for(auto y:map){
			if(x.first == y.first&&x.second<2)continue;
			ans = min(ans, (x.first*y.first)%2019);
		}
	}*/
	rep(i,v.size()){
		rep(j,v.size()){
			if(v[i] == v[j]){
				if(cnt[v[i]]<2)continue;
			}
			ans = min(ans, (v[i]*v[j])%2019);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=[]
for i in range(m):
    ks=list(map(int,input().split()))
    s.append(ks[1:])
p=list(map(int,input().split()))
ans=0
for i in range(1<<n):

    for j in range(m):
        cnt=0
        for k in s[j]:
            if i&1<<(k-1):
                cnt+=1
        if cnt%2!=p[j]:
            break
    else:
        ans+=1

print(ans)


Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int main(){
int a,b;
  cin>>a>>b;
  if((a+b)%2==0) cout<<(a+b)/2;
  else cout<<"IMPOSSIBLE";
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int res=n;
  for(int i=0;i<=n;i++){
    int cc=0;
    int t=i;
    while(t>0)cc+=t%6,t/=6;
    t=n-i;
    while(t>0)cc+=t%9,t/=9;
    if(res>cc)res=cc;
  }
  cout<<res<<endl;
}
  

Measured memory_bytes: 256
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;

void show_all(vector<int> &d) {
  rep (i, d.size()) {
    cout << d[i] << ' ';
  }
  cout << endl;
}


bool convergence(vector<int> d) {
  int nonzero = 0;
  for (int _d : d) {
    if (_d != 0) nonzero++;
  }
  return nonzero == 1;
}

int main() {
  int n, p;

  while (cin >> n >> p && n && p) {
    int i = 0;

    vector<int> d(n+1);
    for (int j=0; j<n; j++) d[j] = 0;
    d[n] = p;

    while (true) {
      // cout << "wan: " << i << endl;
      // show_all(d);

      // ???????????´??°
      if (d[n] > 0) {
        d[n]--;
        d[i]++;
      } else if (d[n] == 0) {
        d[n] += d[i];
        d[i] = 0;
      }


      // ????????????
      if (convergence(d)) {
        cout << i << endl;
        // show_all(d);
        break;
      }

      // ???????????????????????´??°
      if (i == n-1) {
        i = 0;
      } else {
        i++;
      }
    }
  }
}

Measured memory_bytes: 3120
/*
Bubble Sort
ALDS1_2_A
*/

package main

import (
	"fmt"
	"strconv"
)

func array_data(data []int) string {
	s := ""
	for i := 0; i < len(data); i++ {
		s += strconv.Itoa(data[i])
		if i != len(data)-1 {
			s += " "
		}
	}

	return s
}

func bubble_sort(data []int, n int) ([]int, int) {
	flag := true
	sort_num := 0

	for flag {
		flag = false
		for j := n - 1; j >= 1; j-- {
			if data[j] < data[j-1] {
				data[j-1], data[j] = data[j], data[j-1]
				flag = true
				sort_num++
			}
		}
	}

	return data[:], sort_num
}

func main() {
	var n int
	var data [100]int

	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &data[i])
	}

	sorted, i := bubble_sort(data[:n], n)
	fmt.Println(array_data(sorted))
	fmt.Println(i)
}


Measured memory_bytes: 1212
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)
def cmb(n,r,mod):
  if n == r:
    return 1
  p,q = 1,1
  r = min(r,n-r)
  for i in range(r):
    p = p*(n - i)%mod
    q = q*(i + 1)%mod
    Y = pow(q,10**9+5,mod)
  return p*Y%mod
ans = ans - cmb(n,a,mod) - cmb(n,b,mod) - 1
print(ans%mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=2e5+5;
int lson[N],rson[N],wl[N],wr[N];
vector<pii> v[N];
void dfs(int u,int md){
	if(!lson[u]){
		v[u].pb(mp(0,0));return;
	}
	dfs(lson[u],md);dfs(rson[u],md);
	int pos=0,sz=(int)v[rson[u]].size();
	vector<pii> rv;rv.clear();
	for(auto x:v[lson[u]]){
		while(pos<sz&&x.se+v[rson[u]][pos].fi+wl[u]+wr[u]<=md){
			rv.pb(mp(x.fi+wl[u],v[rson[u]][pos].se+wr[u]));
			rv.pb(mp(v[rson[u]][pos].se+wr[u],x.fi+wl[u]));
			pos++;
		}
	}
	if(rv.size()){
		sort(rv.begin(),rv.end());
		v[u].pb(rv[0]);
		For(i,1,(int)rv.size()-1){
			if(rv[i].se>=rv[i-1].se) continue;
			v[u].pb(rv[i]);
		}
	}
}
bool check(int md){
	dfs(1,md);
	if(v[1].size()) return 1;
	return 0;
}
int main(){
	int n=read();
	For(i,2,n){
		int fa=read(),x=read();
		if(!lson[fa]) lson[fa]=i,wl[fa]=x;
		else rson[fa]=i,wr[fa]=x;
	}
	int l=0,r=1e9,mid,ans=-1;
	while(l<=r){
		For(i,1,n) v[i].clear();
		check(mid=l+r>>1)?r=(ans=mid)-1:l=mid+1;
	}
	cout<<ans;
}

Measured memory_bytes: 24548
#include <stdio.h>

int main() {
	int n;
	int val[20], cost[20];
	int x = 0, y = 0;
	int i = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++)	scanf("%d", &val[i]);
	for (i = 0; i < n; i++)	scanf("%d", &cost[i]);

	for (i = 0; i < n; i++) {
		if (val[i] > cost[i]) {
			x += val[i];
			y += cost[i];
		}
	}
	printf("%d", x - y);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	string ans="";
	vector<string>v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v.at(i);
	}
	sort(v.begin(),v.end());
		//cout<<v.at(0)<<endl;

	for(int i=0;i<n;i++)
	{
		ans+=v.at(i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll a, x[35];
    cin >> a;
    for (int i = 0; i < 35; i += 2) {
        ll vx = 1, vvx = 0;
        for (int j = 0; j < i; j += 2) {
            vvx += vx;
            vx *= 4;
        }
        x[i] = vvx;
    }
    for (int i = 1; i < 35; i += 2) {
        ll vx = -2, vvx = 0;
        for (int j = 1; j < i; j += 2) {
            vvx += vx;
            vx *= 4;
        }
        x[i] = vvx;
    }
    ll b = 0;
    for (; b < 35; b++) {
        if ((a > 0 && x[b] >= a) || (a < 0 && x[b] <= a)) break;
        if (a == 0) break;
    }
    if (b - 1 > 1) b -= 1;
    else b = 1;
    for (int i = b - 1; i >= 0; i--) {
        if (i % 2 == 0 && a > x[i]) {
            cout << 1;
            a -= pow(2, i);
        }
        else if (i % 2 == 1 && a < x[i]) {
            cout << 1;
            a += pow(2, i);
        }
        else cout << 0;
    }
    cout << endl;
}


Measured memory_bytes: 256
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound of 2
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <stdio.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
typedef long long ll;
typedef long double ld;
int A,B,Q;
ll As[100000+10];
ll Bs[100000+10];
ll INF=(ll)1000*1000*1000*1000;
ll min(ll a, ll b) {
  return a>b? b:a;
}
ll abs(ll a) {
  return a>0?a:-a;
}
ll* lower_bound(ll* a, ll* b, ll v){
  while(b>a+1) {
    ll* m=a+(b-a)/2;
    if(*m >= v) {
      b=m;
    } else {
      a=m;
    }
  }
  return b;
}
ll fastGet() {
  ll ret=0;
  char c=getchar_unlocked();
  // skipping
  while(c<'0' || c > '9') c=getchar_unlocked();
  do {
    ret = (ret<<3)+(ret<<1);
    ret += (c-'0');
    c = getchar_unlocked();
  } while(c>='0' && c<='9');
  return ret;
}
void fastPut(ll v) {
  char s[256];
  int p=0;
  do {
    s[p++]=(v%10)+'0';
    v/=10;
  } while(v>0);
  while(p--)
    putchar_unlocked(s[p]);
}
int main() {
  A=fastGet();
  B=fastGet();
  Q=fastGet();
  As[0]=-INF;
  Bs[0]=-INF;
  As[A+1]=INF;
  Bs[B+1]=INF;
  REP(i,A)
    As[i+1]=fastGet();
  REP(i,B)
    Bs[i+1]=fastGet();
  REP(i,Q) {
    ll x=fastGet();
    ll* ita=lower_bound(As, As+A, x);
    ll* itb=lower_bound(Bs, Bs+B, x);
    ll ans=INF;
    ll alis[2],blis[2];
    alis[0]=*ita;
    blis[0]=*itb;
    alis[1]=ita[-1];
    blis[1]=itb[-1];
    REP(j,2)
      REP(k,2){
        ll a=alis[j],b=blis[k];
        ans = min(ans,abs(a-x)+abs(b-a));
        ans = min(ans,abs(b-x)+abs(b-a));
      }
    fastPut(ans);
    putchar_unlocked('\n');
  }
  return 0;
}


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

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T>
auto make_vector(int n, int m, const T &value){
  return std::vector<std::vector<T>>(n, std::vector<T>(m, value));
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}



namespace solver{
  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }
  
  void solve(){
    std::string S, T; std::cin >> S >> T;
    int ans = INT_MAX;

    for(int i = 0; i <= (int)(S.size() - T.size()); ++i){
      auto s = S.substr(i, T.size());
      //dump(s, T, i);

      int c = 0;
      for(int j = 0; j < (int)T.size(); ++j) if(s[j] != T[j]) ++c;

      chmin(ans, c);
    }

    std::cout << ans << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3880
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//int K = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			string ans = "APPROVED";
			foreach (var i in a) {
				if (i % 2 == 0 && (i % 3 != 0 && i % 5 != 0)) {
					ans = "DENIED";
					break;
				}
			}
			Console.WriteLine(ans);


			//Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var tmp = input.split("\n");
  //var line0 = tmp[0].split(" ");
  //var line1 = tmp[1].split(" ");
  //var line2 = tmp[2].split(" ");
  //var line3 = tmp[3].split(" ");

  var N = Number(tmp[0]);
  //var A = Number(line0[1]);
  //var B = Number(line0[2]);
  
  var pos = 0;
  var pay = 0;
  for(var i=1; i<=N; i++){
    pay += 800;
    if(i%15 == 0) pay-=200;
  }
  
  console.log(pay);
  
  
  //入出力確認コード
  // A.forEach( function(value) console.log(value); );


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(void){
  string s;
  cin >> s;
  
  if(s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  }else if(s[1] == s[2] && s[2] == s[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define SORT(a) sort(a.begin(),a.end())
 
int main() {
	
	string ans="No";
	//vector<int> c(30,0);
	//cout << a << b << endl;
	
	
	//int ans=0;
	
	int a;
	
	cin >> a;// >> b;
	
	//vector<int> a(n);
	
	rep(i,10) rep(j,10) if(i*j==a) ans="Yes";
	
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#define N 10000
using namespace std;

list<int> l;
bool color[N]={false};
vector<int> adj[N];
int n;

void topo(int k){
	for(int i=0;i<adj[k].size();i++){
		if(!color[adj[k][i]])topo(adj[k][i]);
	}
	if(!color[k])l.push_front(k);
	color[k]=true;
}

int main(void){
	int u,v;
	int e;
	cin>>n>>e;
	for(int i=0;i<e;i++){
		cin>>u>>v;
		adj[u].push_back(v);	
	}
	for(int i=0;i<n;i++){
		if(!color[i])topo(i);
	}
	for(list<int>::iterator it=l.begin();it!=l.end();it++)cout<<*it<<endl;
	return 0;
}

Measured memory_bytes: 4064
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b<c||d<a) cout<<0;
	else{
		a=max(a,c);
		b=min(b,d);
		cout<<b-a;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
const int MOD = 1000002013;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n - 1)&n) + 1 : 0; }

const int N = 100001;
int i, j, k, m, n, l;
int a[N];

vector<int> v, w;

int main() {
	//freopen("x.in", "r", stdin);

	int x = 2 * 3 * 5;
	//cout << x << endl;

	F1(i, 30000) if (gcd(i, x) != 1) {
		w.push_back(i);
	}
	//cout << SZ(w) << endl;

	while (cin >> n) {
	//for (n = 3; n <= 20000; n++) {
		if (n == 3) {
			cout << "2 5 63" << endl;
			continue;
		}
		v.clear();
		int s = 0;
		F0(i, n - 2) {
			v.push_back(w[i]);
			s += v[i];
		}
		for (int i = n + 1; i < SZ(w); i++) if (SZ(v) != n) for (int j = i + 1; j < SZ(w); j++) if ((w[i] + w[j] + s) % x == 0) {
			v.push_back(w[i]);
			v.push_back(w[j]);
			break;
		}
		if (SZ(v) != n) {
			cout << n << " " << s << " " << s % x << endl;
			throw 12;
		}
		//cout << n;
		for (int x : v) cout << x << " ";
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    for i in range(n):
        Ball = map(int,input().split())
        l = r = 0
        for value in Ball:
            if value > r:
                r = value
            elif value > l:
                l = value
            else:
                print("NO")
                r = -777
                break
            if r < l:
                r,l = l,r
            
        if r == -777:
            continue
        else:
            print("YES")

if __name__ == '__main__':
    main()



Measured memory_bytes: 5592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while (!(line = br.readLine()).equals("0 0")) {
            int n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
            int r = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

            int[] card1, card2;
            card1 = new int[n];
            card2 = new int[n];
            for (int i = n - 1; i >= 0; i--) {
                card1[i] = n - i;
            }
            for (int i = 0; i < r; i++) {
                line = br.readLine();
                int p = Integer.parseInt(line.substring(0, line.indexOf(' ')));
                int c = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
                for (int j = 0; j < n; j++) {
                    if (j < p - 1) {
                        card2[c + j] = card1[j];
                    } else if (j < p - 1 + c) {
                        card2[j - p + 1] = card1[j];
                    } else {
                        card2[j] = card1[j];
                    }
                }
                for (int k = 0; k < n; k++) {
                    card1[k] = card2[k];
                }
            }
            System.out.println(card1[0]);
        }
    }
}

Measured memory_bytes: 22020
S = gets.chomp.split("").to_a
T = gets.chomp.split("").to_a
long = S.length
count = 0

(0..long-1).each do |i|
  if S[i] == T[i]
    count += 1
  end
end

if count == long
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14192
#include <iostream>
using namespace std;
int main(){
    int n, i, MAR_num, NUM, CARD[5][14]={};
    char MAR;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> MAR >> NUM;
        if(MAR == 'S') MAR_num=1;
        if(MAR == 'H') MAR_num=2;
        if(MAR == 'C') MAR_num=3;
        if(MAR == 'D') MAR_num=4;
        CARD[MAR_num][NUM]=1;
    }
    
    for(MAR_num=1; MAR_num<=4; MAR_num++){
        for(NUM=1; NUM<=13; NUM++){
            if(CARD[MAR_num][NUM] == 0){
                if(MAR_num == 1) cout << "S " << NUM << endl;
                if(MAR_num == 2) cout << "H " << NUM << endl;
                if(MAR_num == 3) cout << "C " << NUM << endl;
                if(MAR_num == 4) cout << "D " << NUM << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;

int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
	
	long long int n;
	cin >> n;
	string ans = "";
	int temp = 0;
	while(n>0){
		n-=1;
		int temp = n%26;
		ans = (char)(97+temp)+ans;
		n=n/26;
	}
	cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 3608
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O2")
// #pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pob pop_back
#define __bp __builtin_popcount
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pdd = pair<ld,ld>;
using vint = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
#define F first
#define S second
const int N = 2e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const ll INF = 1e18+7;
const int Mod = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(7) << fixed;
}

int n, k;

void solve()
{
	cin >> n;
	int ans = 0;
	for (int i = 1; i < n; ++i)
	{
		ans += (n - 1) / i;
	}
	cout << ans;
}

signed main()
{
	io();
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		// solve();
		solve();
//		cerr << '\n';

	}
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long[] hp = new long[n];
		for(int i = 0; i < n; i++) {
			hp[i] = sc.nextLong();
		}
		long Tmax = 1000000000;
		long Tmin = 0;
		long T = 0;
		int k = 0;
		while(Tmax - Tmin > 1) {
			T = Tmin + (Tmax-Tmin)/2;
			k = 0;
			for(int i = 0; i < n; i++) {
				if(hp[i] > b*T) {
					k += Math.ceil((double)(hp[i]-b*T) / (double)(a-b));
				}
			}
			if(k > T) {
				Tmin = T;
			} else {
				Tmax = T;
			}
		}
		System.out.println(Tmax);
	}
}

Measured memory_bytes: 50296
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;

int N, A, B;
ll v[50];
ll co[58][58];
int c[51];

void makeco(){
  for(int i = 0; i < 55; i++){
    co[i][0] = co[i][i] = 1;
    for(int j = 1; j < i; j++){
      co[i][j] = co[i-1][j] + co[i-1][j-1];
    }
  }
}


int main(){
  cin >> N >> A >> B;
  for(int i = 0; i < N; i++){
    cin >> v[i];
  }

  makeco();
  sort(v, v+N); reverse(v, v+N);

  fill(c, c+N+1, 0);
  c[0] = 1;
  int index = 0;
  for(int i = 1; i < N; i++){
    if(v[i-1] == v[i])  c[index]++;
    else c[++index]++;
  }

  ll sum = 0;
  for(int i = 0; i < A; i++){
    sum += v[i];
  }
  double ave = (double)sum / (double) A;

  int s = 0;
  sum = 0;
  for(int i = 0; c[i] != 0; i++){
    if(s+c[i] < A)  s += c[i];
    else{
      int m = (i==0) ? (min(B, s+c[i])) : A;
      for(int j = A; j <= m; j++){
        sum += co[c[i]][j-s];
      }
      break;
    }
  }

  printf("%.6f\n", ave);
  cout << sum << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
vector<int> g[100100];
int d[100100][3];
int N,M,S,T;
int main(){
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int u,v;
		cin >> u >> v;
		u--;v--;
		g[u].pb(v);
	}
	cin >> S >> T;
	S--;T--;
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++){
			d[i][j]=INF;
		}
	}
	d[S][0]=0;
	priority_queue<P,vector<P>,greater<P> > q;
	q.push(P(0,S*3));
	while(!q.empty()){
		P a = q.top();
		q.pop();
		int v = a.sec/3;
		int m = a.sec%3;
		int dis = a.fi;
		for(int i=0;i<g[v].size();i++){
			int u = g[v][i];
			if(d[u][(m+1)%3]>dis+1){
				d[u][(m+1)%3]=dis+1;
				q.push(P(d[u][(m+1)%3],u*3+(m+1)%3));
			}
		}
	}
	int ans = d[T][0];
	if(ans==INF)cout << -1 << endl;
	else cout << ans/3 << endl;
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

struct LzSegT{
  int sz;
  vector<int>v;
  vector<bool>lzF;
  LzSegT(vector<int>u){
    int n=u.size();
    sz=1;while(sz<n)sz*=2;
    v.resize(2*sz-1,0);
    lzF.resize(2*sz-1,false);
    for(int i=0;i<n;i++)v[sz-1+i]=u[i];
    for(int i=sz-2;i>=0;i--)v[i]=v[2*i+1]+v[2*i+2];
  }
  void eval(int k,int l,int r){
    if(lzF[k]){
      v[k]=(r-l)-v[k];
      if(2*k+1<2*sz-1){
        lzF[2*k+1]=lzF[2*k+1]^1;
        lzF[2*k+2]=lzF[2*k+2]^1;
      }
      lzF[k]=false;
    }
  }
  void add(int a,int b){
    add_(a,b,0,0,sz);
  }
  void add_(int a,int b,int k,int l,int r){
    eval(k,l,r);
    if(b<=l||r<=a)return;
    if(a<=l&&r<=b){
      lzF[k]=lzF[k]^1;
      eval(k,l,r);
    }
    else{
      add_(a,b,2*k+1,l,(l+r)/2);
      add_(a,b,2*k+2,(l+r)/2,r);
      v[k]=v[2*k+1]+v[2*k+2];
    }
  }
  int sum(int a,int b){
    return sum_(a,b,0,0,sz);
  }
  int sum_(int a,int b,int k,int l,int r){
    eval(k,l,r);
    if(b<=l||r<=a)return 0;
    if(a<=l&&r<=b)return v[k];
    int vl=sum_(a,b,2*k+1,l,(l+r)/2);
    int vr=sum_(a,b,2*k+2,(l+r)/2,r);
    return vl+vr;
  }
};

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

  int n,q;
  cin>>n>>q;
  vector<vector<int>>g(n);
  for(int i=0;i<n-1;i++){
    int p;
    cin>>p;
    p--;
    g[i+1].push_back(p);
    g[p].push_back(i+1);
  }
  vector<int>c(n);
  for(int i=0;i<n;i++){
    char C;
    cin>>C;
    if(C=='G')c[i]=1;
    if(C=='W')c[i]=0;
  }
  vector<int>ls(n),rs(n);
  vector<int>m(n);
  [&](auto f){return [=](auto...args){return f(f,args...);};}([&](auto f,int now,int par,int&idx)->void{
      m[now]=idx;
      ls[now]=idx++;
      for(auto it:g[now])if(it!=par)f(f,it,now,idx);
      rs[now]=idx;
  })(0,-1,0);
  vector<int>C(n);
  for(int i=0;i<n;i++)C[m[i]]=c[i];
  LzSegT seg(C);
  while(q--){
    int v;
    cin>>v;
    v--;
    int l=ls[v];
    int r=rs[v];
    seg.add(l,r);
    if(seg.sum(0,n)>n/2)cout<<"broccoli"<<endl;
    else cout<<"cauliflower"<<endl;
  }
  return 0;
}



Measured memory_bytes: 16012
function Main(input){
  //パラメータ受け取り
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var N = Number.parseInt(inputStr[0]);
  var K = Number.parseInt(inputStr[1]);
  inputStr = input[1].split(" ");
  var H_arr = inputStr.map( inputStr => parseInt(inputStr));
  
  //解法としてDPを用いる
  var i = 0;	//今たっている場所
  var ans = []; //回答格納用配列
  //ansの配列要素Nの確定と初期化
  for(var i=0 ; i<N ; i++){
    ans.push(0);
  }
  
  //階段の0段目のコストをメモ。値は0
  ans[0] = 0;
  //階段の1段目に進んだ時のコストをメモ
  ans[1] = Math.abs(H_arr[1]-H_arr[0]); 
  //階段の3段目以降のコストをforループで処理
  for( var i=2 ; i<N ; i++){
    var last = 1000000000;
    for(var j=1 ; j<=K ; j++){
      if( i >= j){
        //自分のところ(i段目)にj段前から来た場合の値を格納
        var tmp = ans[i-j]+Math.abs(H_arr[i]-H_arr[i-j]);
        last = Math.min(tmp,last);
      }
    }
    //より小さい値(最小コスト)を回答配列の自分の段に格納
    ans[i] = last;
  }
  //結果表示
  console.log(ans[N-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int K,A,B;
  cin >>K>>A>>B;
  if(A%K==0 || (A>K && B>=A+K-A%K) || (A<=K && K<=B))cout<<"OK"<<endl;
  else cout<<"NG"<<endl;

  }


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int count = 0;
    //500円玉を0枚→1枚→2枚→...→A枚or(X/500の切り下げ)枚と増やしていく
    for(int i = 0; i <= X / 500 && i <= A; i++){
        //100円玉を同様に増やしていく、残った値は50円玉で
        for(int j = 0; j <= (X - i * 500) / 100 && j <= B; j++){
            if((X - i * 500 - j * 100) / 50 <= C)count ++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6;
int n,i,l,r,mid,ans,sum[N],c[N],x;
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&x),++sum[++c[x]];
	for (i=1;i<=n;i++) sum[i]+=sum[i-1];
	for (i=1;i<=n;i++){
		l=1,r=n,ans=0;
		while (l<=r){
			mid=l+r>>1;
			if (1ll*mid*i<=sum[mid]) ans=mid,l=mid+1;
			else r=mid-1;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 6144
#import<bits/stdc++.h>
using namespace std;priority_queue<long long> q,l;long long N,d[5<<16],a[5<<16],i,m;main(){cin>>N;for(;i<N*3;++i)cin>>a[i];for(i=0;i<N*2;d[++i]=m){q.push(-a[i]);m+=a[i];(i/N^1)?0:(m+=q.top(),q.pop(),0);}m=0;for(i=N*3;--i>=N;d[i]-=m){l.push(a[i]);m+=a[i];(i/N^1)?0:(m-=l.top(),l.pop(),0);}cout<<*max_element(d+N,d+N+N+1);}

Measured memory_bytes: 7156
X,K,D = list(map(int,input().split()))

r = X % D

maxMoveLength = K * D

plusMin = r
minusMin = r - D

countForPlusMin = abs(X - plusMin) // D
countForMinusMin = abs(X - minusMin) // D

goal = 0
if K >= countForPlusMin and K % 2 == countForPlusMin % 2:
    goal = plusMin
elif K >= countForMinusMin and K % 2 == countForMinusMin % 2:
    goal = minusMin
elif K < countForMinusMin or K < countForPlusMin:
    if X < 0:
        goal = X + D * K
    else:
        goal = X - D * K

print(abs(goal))

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

int main() {
  int n; cin>>n;
  vector<ll> l(n+1);
  l[0]=2; l[1]=1;
  for(int i=2; i<=n; i++) {
    l[i] = l[i-1] + l[i-2];
  }
  cout<<l[n];
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    char a[1000];
    int i,sum;
    while(1)
    {
        scanf("%s",&a);
        if(a[0]=='0')
        {
            return 0;
        }
        sum = 0;
        for(i=0;a[i]!='\0';i++)
        {
            sum+=a[i]-'0';
        }
        printf("%d\n",sum);
}
return 0;
    }



Measured memory_bytes: 2052
import java.util.Scanner;
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 && c==a) System.out.println("1");
		else if (a==b || b==c || c==a) System.out.println("2");
		else System.out.println("3");
	}
}


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

using namespace std;

int main() {

	int n;
	string s;
	cin >> n >> s;

	vector<int> black(n);
	for (int i = 0; i < n; i++) black[i] = s[i] == '#';
	for (int i = 1; i < n; i++) black[i] += black[i - 1];

	vector<int> white(n);
	for (int i = n - 1; i >= 0; i--) white[i] = s[i] == '.';
	for (int i = n - 2; i >= 0; i--) white[i] += white[i + 1];

	int ans = INT_MAX;
	for (int i = 0; i < n; i++) {
		// #.
		// ↓
		// .#

		int bChangeCnt = black[i];
		int wChangeCnt = (i == n - 1) ? 0 : white[i + 1];
		int cost = bChangeCnt + wChangeCnt;

		ans = min(ans, cost);
	}


	// #.
	// ↓
	// ##
	int allBlackCnt = 0;
	for (auto v : s) {
		allBlackCnt += v == '.';
	}

	ans = min(ans, allBlackCnt);

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


Measured memory_bytes: 2180
import math
N = int(input())
count = 0
ans = 0
for i in range(N+1):
    money = 0
    money = math.floor(i*1.08)
    if money == N:
        count += 1
        ans = i
        break
if count == 0:
    print(":(")
else:
    print(ans)

Measured memory_bytes: 38640
def e_coprime():
    from math import gcd
    from functools import reduce
    N = int(input())
    A = [int(i) for i in input().split()]

    def sieve(n):
        ret = list(range(n + 1))
        for j in range(2, int(n**0.5) + 1):
            for k in range(j, n + 1, j):
                if k == ret[k]:
                    ret[k] = j
        return ret

    d = sieve(max(A))
    prime_factor = set()
    for a in A:
        t = set()
        while a > 1:
            t.add(d[a])
            a //= d[a]
        if prime_factor & t:
            break
        prime_factor |= t
    else:
        return 'pairwise coprime'

    if reduce(lambda x, y: gcd(x, y), A) == 1:
        return 'setwise coprime'
    return 'not coprime'

print(e_coprime())

Measured memory_bytes: 128148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    set<ll> S;
    rep(i, N)
    {
        cin >> A[i];
        S.insert(A[i]);
    }
    vector<ll> C(N + 1, 0);
    rep(i, N)
    {
        C[A[i]] += 1;
    }
    vector<ll> ANS(N, 0);
    vector<ll> ANSD(N, 0);
    for (auto x : S)
    {

        ANS[x] = C[x] * (C[x] - 1) / 2;
        if (C[x] >= 2)
        {
            ANSD[x] = (C[x] - 1) * (C[x] - 2) / 2;
        }
    }
    ll total = 0;
    for (auto x : S)
    {
        total += ANS[x];
    }
    rep(i, N)
    {
        cout << total - ANS[A[i]] + ANSD[A[i]] << endl;
    }
}

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

int main()
{
    int n, ans = 0;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        mp[i + 1] = a;
        if (mp[a] == i + 1)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#shotoyooさんのコードをお借りしてテスト

import numpy as np
from numba import njit, b1, i4, i8, f8
from heapq import heappop as hpp, heappush as hp

@njit((b1[:, :],i8,i8,i8,i8), cache=True)
def main(ss,ch,cw,dh,dw):
    inf = 1<<30
    h,w = ss.shape
    start = ch*w+cw
    goal = dh*w+dw
    n = h*w
    seen = np.full(n, inf, np.int64)
    seen[start] = 0
    q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
    while q:
        pnum,pu = hpp(q)
        ux,uy = divmod(pu,w)
        if pu==goal:
            break
        for xx in range(-2, 3):
            for yy in range(-2, 3):
                if xx==yy==0:
                    continue
                if abs(xx)+abs(yy)<=1:
                    vv = 0
                else:
                    vv = 1
                x,y = ux+xx, uy+yy
                u = x*w + y
                num = pnum+vv
                if x<0 or y<0 or x>=h or y>=w or ss[x][y]:
                    continue
        #         print(x,y)
                if seen[u]>num:
                    seen[u] = num
                    hp(q,(num, u))
                
    val = seen[goal]
    if val==inf:
        return -1
    else:
        return val
      

h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
ss = np.array([[c=="#" for c in input()] for _ in range(h)])

print(main(ss,ch,cw,dh,dw))



Measured memory_bytes: 120052
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,r,n,q,ans;
    string s;
    cin>>n>>q>>s;

    vector<ll>Till_I(n,0);
    ll cnt=0;
        for(i=1; i<s.size(); i++)
        {
            if(s[i-1]=='A'&&s[i]=='C')
             cnt++;
             Till_I[i]=cnt;
        }
    while(q--)
    {
        ans=0;
        cin>>l>>r;

        cout<<Till_I[r-1]-Till_I[l-1]<<endl;
    }



    return 0;
}





Measured memory_bytes: 4240
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n m
a1 b1
...
am bm

n m 50
 */

int n,m;
int v[50];

int main(){
  cin>>n>>m;
  REP(i,m){
    int a,b;
    cin>>a>>b;
    v[a-1]++;
    v[b-1]++;
  }

  REP(i,n){
    cout<<v[i]<<endl;
  }

  return 0;
}


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

using namespace std;

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

    vector<char> strVec;
    for (size_t i = 0; i < s.size(); i++)
    {
        strVec.push_back(s[i]);
    }

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

    if (strVec[0] == 'a' && strVec[1] == 'b' && strVec[2] == 'c')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
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(){
  ll A,B,V,W,T; cin >> A >> V >> B >> W >> T;
  if(V <= W) {
    cout << "NO" << endl;
    return 0;
  }
  if(abs(V-W)*T>=abs(A-B)){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3624
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let r: usize = itr.next().unwrap().parse().unwrap();
    let mut ans = r;
    if n < 10 {
        ans += 100 * (10 - n);
    }
    println!("{}", ans);
}

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

using namespace std;

const int MOD = 1e9 + 7;

const int N = 1e6 + 5;
vector<int> pf[N];
void sieve() {
    for (int i = 2 ;i < N ;i++)
        if (!pf[i].size())
            for (int j = i ;j < N ;j += i)
                pf[j].push_back(i);
}

int add (int a , int b) {
    a += b;
    while (a >= MOD) a -= MOD;
    while (a < 0) a += MOD;
    return a;
}

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    sieve();

    int n;
    cin >> n;

    map<int , int> mx;

    vector<int> a(n);
    for (int i = 0 ;i < n ;i++) {
        cin >> a[i];
        auto &v = pf[a[i]];
        for (int x : v) {
            int org = a[i] , cnt = 0;
            while (org % x == 0)
                org /= x , cnt++;

            mx[x] = max(mx[x] , cnt);
        }
    }

    int lcm = 1;
    for (auto &p : mx)
        lcm = mul(lcm , power(p.first , p.second));

    int ans = 0;
    for (int i = 0 ;i < n ;i++) {
        auto &v = pf[a[i]];
        int m = 1;
        for (int x : v) {
            int org = a[i] , cnt = 0;
            while (org % x == 0)
                org /= x , cnt++;
            m = mul(m , power(x , cnt));
        }
        ans = add(ans , mul(lcm , mod_inv(m)));
    }

    cout << ans;
}


Measured memory_bytes: 59512
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;


int32_t main(){
    FAST;

    int a, b, c;    cin >> a >> b >> c;
    if(c >= a and c <= b)
        cout << "Yes";
    else cout << "No";

    return 0;
}




Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        a: u8,
        b: u8,
        c: u8,
        d: u8,
    }

    let takahashi_times = (a + (d-1)) / d;
    let aoki_times = (c + (b-1)) / b;

    if takahashi_times < aoki_times {
        println!("No");
    } else {
        println!("Yes");
    }
    
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a>=13)cout << b;
  else if(a>=6)cout << b/2;
  else cout << 0;
  cout << endl;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
ll counter;
ll keta(ll i) {
	counter = 0;
	while (i > 10) {
		i /= 10;
		counter++;
	}
	return counter;
	
}
int main() {
	ll a = 0, b = 0, n = 0, counter=0,maxi=0;
	ll nums[100002];
	std::string str,str2;
	cin >> a;
	cout << a*(a - 1) / 2 << endl;
}


Measured memory_bytes: 256
import bisect
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[-int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect.bisect_left(A,b)
    c = bisect.bisect_left(C,-b)
    #print(a,c)
    ans += a*c
print(ans)

Measured memory_bytes: 104932
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
	    //String input1 = scanner.next();
	    String input2 = scanner.next();

	    //int h=Integer.parseInt(input1);
	    int n=Integer.parseInt(input2);
	    //int a[]=new int[n];
	    Set<String> sa=new HashSet<String>();
	    for(int i=0;i<n;i++) {
	    	sa.add(scanner.next());
	    }
	    scanner.close();
	    /*int sum=sa.stream()
	    		.mapToInt(s->Integer.parseInt(s))
	    		.sum();
	    	System.out.println("YES");*/
	    System.out.println(sa.size());
	}

}


Measured memory_bytes: 71512