akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())

    d = 0
    for i in range(1, n + 1, 2):
        c = 2
        for j in range(3, i // 2 + 1):
            if i % j == 0:
                c += 1
            if c > 8:
                break

        if c == 8:
            d += 1

    print(d)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
s = input()
l = len(s)

for i in range(2 ** (l - 1)):
    line = s[0]
    for j in range(l - 1):
        if (i>>j)&1:
            line += '+'
        else:
            line += '-'
        line += s[j + 1]
    if eval(line) == 7:
        print('{}=7'.format(line))
        exit()


Measured memory_bytes: 38384
import java.util.*;
class Main{
	public static void main(String[] args){
	    Scanner x=new Scanner(System.in);
	    int s = x.nextInt();
	    List<Integer> list = new ArrayList<Integer>();
	    for(int i=0;i<s;i++){
		    int a = x.nextInt();
            if(a==0){
	    		list.add(x.nextInt());
	    	}else if(a==2){
	    		list.remove(list.size()-1);
	    	}else if(a==1){
	    		System.out.println(list.get(x.nextInt()));
	    	}
	    }
	}
}	   


Measured memory_bytes: 131800
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>
#include <sstream>
#include <unistd.h>

#define ll long long
#define Int int
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define rep(n) for(int x = 0; x < n; x++)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define EPS 0.0000000001
#define MOD 1000000007

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

#define MAX_H 1000
#define INFTY (MAX_H*MAX_H)

Int H, W;
char c_;
vector<bool> M(MAX_H * MAX_H, false);
vector<Int> dist(MAX_H * MAX_H, INFTY);
vector<Vector2> starts;

void input() {
  cin >> H >> W;
  loop(h,0,H) {
    loop(w,0,W) {
      cin >> c_;
      if (c_ == '#') {
        M[h*W+w] = true;
        starts.push_back(Vector2(w, h));
      }
    }
  }
  M.resize(H * W);
  dist.resize(H * W);
}

Int bfs() {
  Int counter = starts.size();
  if (counter >= H*W) return 0;

  queue<Vector2> Q;
  for (auto s: starts) {
    Q.push(s);
    dist[s.y*W+s.x] = 0;
  }

  while (Q.size()) {
    Vector2 u = Q.front(); Q.pop();
    loop(dx,-1,2) {
      loop(dy,-1,2) {
        if (dx != 0 && dy != 0) continue;
        Vector2 next = u + Vector2(dx, dy);
        if (next.x < 0 || next.x >= W || next.y < 0 || next.y >= H) continue;
        if (dist.at(next.y*W+next.x) < INFTY) continue;
        dist[next.y*W+next.x] = dist[u.y*W+u.x] + 1;
        counter++;
        if (counter >= H*W) {
          return dist[next.y*W+next.x];
        }
        Q.push(next);
      }
    }
  }

  return -1;
}

void solve() {
  cout << bfs() << endl;
}

int main(void) {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 24548
# ABC138D - Ki
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


def dfs(v: int, p: int) -> None:
    x = cnt[v]
    for u in T[v]:
        if u != p:  # p: parent -> skip
            cnt[u] += x  # cumulative sum
            dfs(u, v)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    global T, cnt
    N, Q = tuple(map(int, input().split()))  # vertices and queues
    E = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # tree, N+1: 1-idx
    for a, b in E:
        T[a] += [b]
        T[b] += [a]
    cnt = [0] * (N + 1)
    for p, x in P:
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 265772
#include <iostream>

using namespace std;

int main()
{
   int S;
   cin >> S;
   int h, m, s;
   h=S/3600;
   m=(S%3600)/60;
   s=(S%3600)-m*60;
   cout << h << ":" << m << ":" << s << endl;


    return 0;
}



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

vector < int > v[502];

int cal( int a, int b){

    int sum=0,i,x,y;
    for(i=a; i<=b; i++){
        x=lower_bound(v[i].begin(),v[i].end(),a)-v[i].begin();
        y=upper_bound(v[i].begin(),v[i].end(),b)-v[i].begin();
        sum+=(y-x);
    }
    return sum;
}

int main(){

    int a,b, n, m, q, i,j,sum;
    cin>>n>>m>>q;
    for(i=1; i<=m; i++){
        cin>>a>>b;
        v[a].push_back(b);
    }
    for(i=1; i<=n; i++)
        sort(v[i].begin(),v[i].end());
    while(q--){
        cin>>a>>b;
        sum=cal(a,b);
        cout<<sum<<endl;
    }

    return 0;
}


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

main() {
  string S;
  cin >> S;
  int sz;
  sz = S.size();
  vector<int> keta(sz);
  for (int i=0; i < sz; i++) {
    keta.at(i) = S.at(i) - '0';
  }
  ll ans = 0;
  for (int i=0; i < (1 << (sz - 1)); i++) {
    bitset<10> D(i);
    int cons = 0;
    for (int j=0; j < sz; j++) {
      ans += keta.at(sz - j - 1) * pow(10, cons);
      if (!D.test(j)) {
        cons++;
      }
      else  cons = 0;
    }
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 384
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
long long ans[55];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    cin>>n;
    int i;
    for (i=0;i<n;i++)
    {
        cin>>ans[i];
    }
    long long anses=0;
    for (;;)
    {
        long long t=0;
        long long sum=0;
        for (i=0;i<n;i++)
        {
            t=ans[i]/n;
            ans[i]%=n;
            ans[i]-=t;
            sum+=t;
        }
        if (sum==0) break;
        for (i=0;i<n;i++)
        {
            ans[i]+=sum;
        }
        anses+=sum;
    }
    cout<<anses<<endl;
    return 0;
} 


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <map>
#include <stdlib.h>
#include <stdint.h>

using namespace std;

typedef long long	    ll;
typedef  intmax_t     intt;
typedef uintmax_t    uintt;
#define MAXX INTMAX_MAX

#define PI M_PI

//デバッグ、数値確認用
#define DBG(X) cout<< X <<endl

//繰り返し構文
#define REP(i, n)		for(intt i = 0;i < (n);i++)
#define FORL(i,m,a,n)	for(intt i = m;i <= (n);i+=a)	//CMDのfor/l
//#define FORL(i,m,a,n)	for(intt i = m;i <  (n);i+=a)	//CMDのfor/l
#define FORRL(i,m,a,n)	for(intt i = m;i >= (n);i+=a)
//#define FORRL(i,m,a,n)	for(intt i = m;i <  (n);i+=a)
#define ITEFOR(i,list)    for (auto i = list.begin();i != list.end();i++)

#define IN(a,n,b) ((a)<=(n)&&(n)<=(b))



int main()
{
    intt n;
    //uintt ;
    string ans = "YES";
    map<intt, intt> a;

    cin >> n;
    REP(i, n) {
        intt tmp;
        cin >> tmp;
        if (a[tmp] == 1) {
            ans = "NO";
            break;
        } else {
            a[tmp]++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	int i=0;
	vector<ll> b;
	while(i<n){
		if(i+1>=n) break;
		if(a.at(i)==a.at(i+1)){
			b.pb(a.at(i));
			i+=2;
		}
		else i++;
	}
	if(b.size()>=2) cout << b.at(b.size()-1)*b.at(b.size()-2) << endl;
	else cout << 0 << endl;
}

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

int main(){
  while(1){
    int h,w;
    scanf(" %d %d",&h,&w);
    if(h==0 && w==0)break;

    char mp[102][102];
    int flag[102][102]={0};
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)scanf(" %c",&mp[i][j]);
    }

    int nh=0,nw=0;
    while(mp[nh][nw]!='.' && flag[nh][nw]==0){
      flag[nh][nw]=1;
      if(mp[nh][nw]=='>')nw++;
      if(mp[nh][nw]=='<')nw--;
      if(mp[nh][nw]=='^')nh--;
      if(mp[nh][nw]=='v')nh++;
      
    }

    if(flag[nh][nw])printf("LOOP\n");
    else printf("%d %d\n",nw,nh);

  }
  return(0);
}

Measured memory_bytes: 1252
n = int(input())
s = input()

cnt = s.count('E')
res = n
tmp = ''
for i in range(n):
    if s[i] == 'E':
        cnt -= 1
    if tmp == 'W':
        cnt += 1
    res = min(res, cnt)
    tmp = s[i]

print(res)

Measured memory_bytes: 3672
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    ret = [0] * N
    for a in A:
        ret[a - 1] += 1
    print(*ret, sep="\n")


if __name__ == '__main__':
    main()


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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)

  if n!=1:
    l.append(n)
  
  return l

def main():
  n,p=LI()

  if n==1:
    print(p)
    exit()
  
  l=getPrimeList(p)
  
  if len(l)==0:
    print(1)
    exit()

  a=l[0]
  c=1
  sm=1
  for x in l[1:]:
    if a==x:
      c+=1
    else:
      c=1
      a=x

    if c==n:
      sm*=a
      c=0

  return sm

print(main())


Measured memory_bytes: 5336
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	string s, t;
	cin>>s>>t;
	int n=s.size();
	vector<int> c[26];
	for(int i=0; i<n; i++){
		c[s[i]-'a'].push_back(i);
	}
	int ct[26]={};
	for(int i=0; i<26; i++){
		if(c[i].size()==0) continue;
		ct[t[c[i][0]]-'a']++;
		for(int j=0; j<c[i].size()-1; j++){
			if(t[c[i][j]]!=t[c[i][j+1]]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	for(int i=0; i<26; i++){
		if(ct[i]>=2){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    int i,cr,max;
    cr=0;
    max=-100000;
    while(n--){
      cin>>i;
      cr +=i;
      if(cr>max) max=cr;
      if(cr<0) cr=0;
    }
    cout<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
 using namespace std;
int main(){
  int x=0;
  long int y=0;
  cin >> x;
	
  for(int i=1;i<=x;i++){
   if(i%3==0||i%5==0);
else y+=i;

  }
  printf("%ld",y);
 return 0; 
}

Measured memory_bytes: 3756
s = input()
if len(s)%2!=0:
    print("No")
    exit()
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != "h":
            print("No")
            exit()
    else:
        if s[i] != "i":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(),, greater<int>())
#define pb push_back
#define ll long long

int fact(int n) 
{ 
    int res = 1; 
    for (int i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
}
int nCr(int n, int r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
}
int cel(int a,int b){return((a-1)/b+1);} 
int gcd(int a, int b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a,int b){
    return (a*b)/gcd(a,b);
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t, n;
    cin>>n;
    cout<<8-(n-400)/200;
    return 0;
}

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

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);

    rep(i, N) {
        cin >> A.at(i) >> B.at(i);
    }

    int maxv = 0;
    int maxi;
    for (int i=0; i < N; i++) {
        if (maxv < A.at(i)) {
            maxv = A.at(i);
            maxi = i;
        }
    }
    cout << maxv + B.at(maxi) << endl;
}

Measured memory_bytes: 1024
n=int(input())
if n<4:
  print(2,5,63)
  exit()
a,b=[],[]
i=j=k=0
while i<n:
  if not b or a and a[-1]>b[-1]:
    b+=3*-~k,
    k+=1
    i+=1
  else:
    t=2*-~j
    if t%3:
      a+=t,
      i+=1
    j+=1
c=sum(a+b)
if c%6:
  if c%2:
    b[-1]+=3
    c+=3
  while c%6:
    a[-1]+=2
    c+=2
    if a[-1]%3<1and a[-1]==b[-1]:
      a[-1]+=2
      c+=2
print(*a+b)

Measured memory_bytes: 4792
//#define ONLINE_JUDGE
#define rush()        \
    int MYTESTNUM;    \
    cin >> MYTESTNUM; \
    while (MYTESTNUM--)
#define FOR(i, s, t) for (int i = (s); i <= (t); ++i)
#define mem(a, b) memset(a, b, sizeof(a))
#define pi acos(-1)
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1 << 30;
const double eps = 1e-8;
ll n;
vector<ll> ans;
void divisor(ll n)
{
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans.push_back(i);
            if (i != n / i) {
                ans.push_back(n / i);
            }
        }
    }
}
int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    divisor(n);
    ll tot = 0;
    for (auto& i : ans) {
        ll x = n / i, m = (n - x) / x;
        if (m > 0 && n % m == n / m) {
            tot += m;
        }
    }
    cout << tot;
}

Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [n, a, b] <- getIntList
  if a > b
    then print 0
    else do
      if n == 1
        then if a == b
          then print 1
          else print 0
      else print $ (b-a) * (n-2) + 1


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順(昇順)
//g++ code.cpp   ./a.out 
int main(){
  int a,b;
  cin >> a >> b;
  if(a>9 || b>9) cout << -1 << endl;
  else cout << a*b << endl;
}


Measured memory_bytes: 256
(N, M) = map(int, input().split())
X = list(map(int, input().split()))

X.sort()

d = []
for i in range(1, len(X)):
    d.append(X[i] - X[i-1])
    
d.sort()

k = 0
if M-N > 0:
    k = M-N

print(sum(d[0:k]))




Measured memory_bytes: 13960
#include <bits/stdc++.h>
#define ll long long
#define pb push_back;
using namespace std;
ll cnt,mini=1e9,maxi=-1;
ll n,m,k,x;
ll mini1=1e9,maxi1=-1,cnt1,cnt2,cnt3,ans,sum;
int main(){
ios_base::sync_with_stdio(0);
	// freopen (" .txt", "r", stdin);
	// freopen (" .txt", "w", stdout);
	string a,s;
	cin>>a;
	for(int i=0; i<a.size(); i++){
		cout<<"x";
	}
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *


Measured memory_bytes: 256
#include <iostream>

std::string s;

int main(void){
    std::cin >> s;

    std::string text = std::string(10, '\0');
    int i = 0;
    for(auto it=s.begin(), _END = s.end(); it != _END; ++it){
        if(*it == 'B'){
            if(--i<0) i=0;
        }else{
            text[i++] = *it;
        }
    }
    std::cout << text.substr(0,i) << std::endl;
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N,ans=0;
  cin>>N;
  rep(i,1,N+1){
    ll ten=1, k=0; //ten = 10^k
    while(i >= ten){
      ten *= 10;
      k++;
    }
    if (k%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
using namespace std;
const int N=1e3+10;
int h,w,ch,cw,dh,dw,head[N*N],cnt,dis[N*N],done[N*N];
char s[N][N];
int num(int x,int y){return (x-1)*w+y;}
struct Node{int nxt,to,w;}edges[N*N*25];
void addedge(int u,int v,int w){edges[++cnt]=Node{head[u],v,w},head[u]=cnt;}
int main()
{
	memset(head,-1,sizeof(head));
	scanf("%d%d%d%d%d%d",&h,&w,&ch,&cw,&dh,&dw);
	for(int i=1;i<=h;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)
	{
		if(s[i][j]=='#')continue;
		if(s[i][j+1]=='.')addedge(num(i,j),num(i,j+1),0);
		if(s[i][j-1]=='.')addedge(num(i,j),num(i,j-1),0);
		if(s[i+1][j]=='.')addedge(num(i,j),num(i+1,j),0);
		if(s[i-1][j]=='.')addedge(num(i,j),num(i-1,j),0);
		for(int x=max(1,i-2);x<=min(i+2,h);x++)
		for(int y=max(1,j-2);y<=min(j+2,w);y++)
		if(s[x][y]=='.'&&abs(x-i)+abs(y-j)>1)addedge(num(i,j),num(x,y),1);
	}
	int st=num(ch,cw),ed=num(dh,dw);
	memset(dis,0x3f,sizeof(dis));
	priority_queue<pii,vector<pii>,greater<pii>>q;
	q.push(mp(0,st)),dis[st]=0;
	while(!q.empty())
	{
		int u=q.top().se;q.pop();
		if(done[u])continue;done[u]=1;
		for(int i=head[u];~i;i=edges[i].nxt)
		{
			int v=edges[i].to;
			if(dis[v]>dis[u]+edges[i].w)dis[v]=dis[u]+edges[i].w,q.push(mp(dis[v],v));
		}
	}
	printf("%d\n",dis[ed]==0x3f3f3f3f?-1:dis[ed]);
	return 0;
}


Measured memory_bytes: 86720
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;

#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)


ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a /gcd(a, b) *b;
}
typedef pair<int,int> pii;
const int mod = 1e9+7;

ll xorr(ll n){

    if(n%4==0)
        return n;

    else if(n%4==1)
        return 1;

    else if(n%4==2)
        return n+1;

    else
        return 0;



}

int main() {

   int arr[5];
   int sum = 0;
   int j=0;
   fo(i,5){
       int x;
       cin>>x;
       sum+=x;

       arr[j++] = 10 - (!(x%10)?10:x%10);


   }
  sort(arr,arr+5);
   sum+= arr[0]+arr[1]+arr[2]+arr[3];

   cout<<sum;




























    return 0;

      }


Measured memory_bytes: 256
//dragon->emperor
#include <bits/stdc++.h>

using namespace std;

/*************************************************/

#define mod 1000000007
#define mod2 998244353
const double pi = acos(-1);
#define inf (1ll<<61)-1

#define ll long long
#define ld  long double
#define floop(i,a,n) for(ll i=a;i<n;i++)
#define loopf(i,a,n) for(ll i=n-1;i>=a;i--)
#define space " "
#define TEST(t) ll t; cin>>t; while(t--)
#define r(n) ll n; cin>>n;
#define r1(a,n) ll a[n]; for(ll i=0;i<n;i++) cin>>a[i];
#define p1(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endll;
#define p2(n) cout<<n<<" ";
#define p(n) cout<<n<<endll;

#define endll "\n"
#define pb push_back
#define mp make_pair
#define dec(n) fixed<<setprecision(n)
#define F first
#define S second

#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define reverseall(x) reverse(all(x))

typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef map<ll,ll> mll;

bitset<200000>vis(0);
vector<bool> prime;

void primes(ll n)
{
    prime.resize(n+1);
    prime.assign(n+1,true);
    prime[0]=0;
    prime[1]=0;
    for(ll i=2; i*i<=n; i++)
    {
        if(prime[i])
        {
            for(ll j=(i*i); j<n; j=j+i) prime[j]=false;
        }
    }
}

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

ll powM(ll x, ll y, ll m)
{
    ll ans=1, r=1;
    x=x%m;
    while(r>0 && r<=y)
    {
        if(r & y)
        {
            ans=ans*x;
            ans=ans%m;
        }
        r=r<<1;
        x=x*x;
        x=x%m;
    }
    return ans;
}

ll powN(ll a,ll n)
{
    if(n==0) return 1;
    if(n==1) return a;
    ll u=powN(a,n/2);
    u=u*u;
    if(n%2) u=u*a;
    return u;
}

ll modinv(ll a,ll m)
{
    return powM(a,m-2,m);
}

ll ncr(ll n, ll r, ll m)
{
    if(n<r) return 0;
    if(n==r || r==0) return 1;
    if(r==1) return n;
    if(n-r<r) return ncr(n,n-r,m);
    ll a=n;
    ll b=r;
    for(ll i=1; i<r; i++)
    {
        a=(a*(n-i))%m;
        b=(b*(r-i))%m;
    }
    b=modinv(b,m);
    a=(a*b)%m;
    return a;
}

ll countbits(ll n)
{
    ll cot=0;
    while(n)
    {
        cot++;
        n >>= 1;
    }
    return cot;
}

ll check_prime(ll n)
{
    ll ans=1;
    for(ll i=2; i*i<=n; i++)
    {
        if(n%i==0) { ans=0; break;}
    }
    return ans;
}

ll SOD(ll n)
{
    ll sum=0;
    while(n>0)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}

ll countsubstring(const string &s, ll n)
{
    ll count=0;
    string ttt="";
    for(ll i=0;i<=n;i++)
    {
        if(s.substr(i,ttt.size())==ttt) count++;
    }
    return count;
}

/*************************************************/
int main()
{    
    fast();
    ll t=1; 
    // cin>> t;
    while(t--)
    {
        ll n,w; cin>>n>>w;
        vector<ll> dp(w+1,0);
        floop(tt,0,n)
        {
            ll we,val; cin>>we>>val;
            loopf(i,0,w-we+1)
            {
                dp[i+we]=max(dp[i+we],dp[i]+val);
            }
        }
        ll ans=0;
        floop(i,0,w+1)
        {
            ans=max(ans,dp[i]);
        }
        cout<<ans<<endll;
    }
    return 0;
}

Measured memory_bytes: 3972
#include <iostream>

using namespace std;


int main(){
  int N, a;
  cin >> N;

  int count = 0, next = 1;
  for(int i = 0; i < N; i++) {
    cin >> a;
    if(a == next) {
      ++next;
    } else {
      ++count;
    }
  }

  if(count == N) {
    count = -1;
  }
  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main()
{
  int n;
  long long C;
  scanf("%d%lld", &n, &C);
  long long x[100002];
  long long v[100002];
  *x = *v = 0;
  x[n + 1] = C;
  long long oneway[100001];
  long long round[100001];
  *oneway = *round = 0;
  long long onewaymax[100001];
  long long roundmax[100001];
  *onewaymax = *roundmax = 0;
  for (int i = 1; i <= n; ++i)
  {
    scanf("%lld%lld", x + i, v + i);
    oneway[i] = oneway[i - 1] + v[i] - (x[i] - x[i - 1]);
    round[i] = round[i - 1] + v[i] - 2 * (x[i] - x[i - 1]);
    onewaymax[i] = std::max(onewaymax[i - 1], oneway[i]);
    roundmax[i] = std::max(roundmax[i - 1], round[i]);
  }

  long long ans = std::max(onewaymax[n], roundmax[n]);
  long long ow = 0;
  long long rd = 0;
  for (int i = n; i >= 1; --i)
  {
    ow += v[i] - (x[i + 1] - x[i]);
    rd += v[i] - 2 * (x[i + 1] - x[i]);
    ans = std::max(ans, std::max(ow + roundmax[i - 1], rd + onewaymax[i - 1]));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<vector>
using namespace std;
//O(√n)で nを素因数分解したものをvectorに記録して返す
typedef pair<long long int, int> P;
vector<P> PF(long long int n){
	vector<P> vec;
	long long int np=n,count;
	for(long long int i=2;i<=np/i;i++){
		if(n%i!=0)continue;
		count=0;
		while(n%i==0){n/=i;count++;}
		vec.push_back(P(i,count));
	}
	if(n>1)vec.push_back(P(n,1));
	return vec;
}
int main(){
	int N,m=0,j=0;
	bool pairwise=true;
	bool setwise=true;
	vector<P> vec;
	
	cin>>N;
	int A[N];
	for(int i=0;i<N;i++){
		cin>>A[i];
		m=max(m,A[i]);
	}
	
	bool pair[m+1]={0};
	int setw[m+1]={0};
	
	for(int i=0;i<N;i++){
		vec = PF(A[i]);
		for(P p:vec){
			setw[p.first]++;
			if(pair[p.first]){
				pairwise=false;
			}else pair[p.first]=true;
		}
		if(!pairwise){
			j=i+1;
			break;
		}
	}
	if(pairwise){
		cout<<"pairwise coprime";
		return 0;
	}
	
	vector<int> so[N+1];
	for(int i=2;i<=m;i++){
		if(setw[i]==j)so[j].push_back(i);
	}
	
	for(int i=j;i<N;i++){
		for(int p:so[i]){
			if(A[i]%p==0)so[i+1].push_back(p);
		}
		if(so[i+1].size()==0)break;
		else if(i==N-1)setwise=false;
	}
	if(pairwise)cout<<"pairwise coprime";
	else if(setwise)cout<<"setwise coprime";
	else cout<<"not coprime";
	return 0;
}

Measured memory_bytes: 67116
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, T, A; cin >> N >> T >> A;
    vector<long long>H(N);
    vector<long long>b(N);
    rep(i, N) {
        cin >> H[i];
        b[i] = abs(A * 500 - (T * 500 - H[i] * 3));
    }
    sort(b.begin(), b.end());
    rep(i, N) {
        if (b[0] == abs(A * 500 - (T * 500 - H[i] * 3))) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    if(a<=9&&b<=9)
    {
        cout<<(a*b)<<endl;
    }
    else
    {
        cout<<"-1"<<endl;
    }
    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum=0;
    ll mod=1000000007;
    rep(i,n){
        ll c;
        cin >> c;
        a[i]=c;
        sum+=c;
    }
    vector<ll> b(n);
    rep(i,n){
        sum-=a[i];
        b[i]=sum;
        b[i]=b[i]%mod;
    }
    ll ans=0;
    rep(i,n){
        ans+=((a[i]*b[i])%mod);
        ans=ans%mod;
    }
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 6360
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007 //(10^9 +7)
#define INF 1000000000000000000 //(10^18)
using namespace std;
typedef long long  ll;
typedef long double ld;
const ll N=100005;
const ll inf=1e18;
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1){
            res=res*a;
        }
        a=a*a;
        b>>=1;
    }
    return res;
}
int main(){
    fastIO;
    ll n;
    cin>>n;
    vector< vector<ll> > vect(n,vector<ll>(3,0));
    ll i=0,j=0;
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            cin>>vect[i][j];
        }
    }
    vector<ll> dp(3,INF);
    dp[0]=vect[0][0];
    dp[1]=vect[0][1];
    dp[2]=vect[0][2];
    for(i=1;i<n;i++){
        ll temp1=max(dp[1],dp[2])+vect[i][0];
        ll temp2=max(dp[0],dp[2])+vect[i][1];
        ll temp3=max(dp[1],dp[0])+vect[i][2];
        dp[0]=temp1;
        dp[1]=temp2;
        dp[2]=temp3;
        /*cout<<i<< " ";
        cout<<dp[0]<< " "<< dp[1]<< " "<< dp[2]<< "\n";*/
    }
    ll ans=max(dp[0],dp[1]);
    ans=max(ans,dp[2]);
    cout<<ans;
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100

int main(void){
  int i=0,num[N],x;
  char str[N];

  while(scanf("%s",str)!=EOF){
    if(str[0]=='+'){
      num[i-2]+=num[i-1];
      i--;
    }else if(str[0]=='-'){
      num[i-2]-=num[i-1];
      i--;
    }else if(str[0]=='*'){
      num[i-2]*=num[i-1];
      i--;
    }else{
      x=atoi(str);
      num[i]=x;
      i++;
    }
  }
  printf("%d\n",num[0]);
  return 0;
}

Measured memory_bytes: 548
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll maxn=1e5+10;
ll mm,m,n,a[60];
ll f[60];
ll ans;
inline void read(ll &x)
{
	ll f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
void dfs(ll x,ll n,ll sum){
    if(x==n/2+1){
        if(sum==m){
           	ll now=a[1]>=0?(9-a[1]):(9+a[1]);
            for(register ll i=2;i<x;i++)
				now*=(a[i]>=0?(10-a[i]):(10+a[i]));
            ans+=n&1?now*10:now;
        }
        return ;
    }
    if(sum+10ll*(f[n-x]-f[x-1])<m||sum-10ll*(f[n-x]-f[x-1])>m)
		return ;
    for(register ll i=-9;i<10;i++){
        a[x]=i;
        dfs(x+1,n,sum+1ll*a[x]*(f[n-x]-f[x-1]));
    }
}
int main(){
    read(m);
	mm=m;f[0]=1;
    while(mm) n++,mm/=10;
    for(register ll i=1;i<=18;i++) f[i]=f[i-1]*10;
    for(register ll i=n;i<=18;i++) dfs(1,i,0);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  string N = input<string>();
  for(int i=0;i<N.size();i++){
    if(N[i] == '7'){
      output("Yes");
      return 0;
    }
  }

  output("No");

  return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M; 
	unordered_map<int, bool> IsAC;
	unordered_map<int ,int> WANum;
	for (int i = 0; i < M; i++) {
		int p;
		string S;
		cin >> p >> S;
		if (S == "AC") IsAC[p-1] = true;
		else if (!IsAC[p-1]) WANum[p-1]++;
	}
	int ACSum = 0, WASum = 0;
	for (auto AC : IsAC) ACSum += AC.second;
	for (auto WA : WANum) if (IsAC[WA.first]) WASum += WA.second;
	cout << ACSum << " " << WASum << endl;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

int main() 
{
    fastio();

    int x,y,z;
    cin>>x>>y>>z;

    cout<<z<<" "<<x<<" "<<y,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 INF = 1e18 + 7;
const i64 MOD = 1e9 + 7;

signed main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();

    vector<vector<i64>> dp(n + 1, vector<i64>(m + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j <= m; ++j){
            if(!dp[i][j])
                continue;
            if(j != m && s[i] == t[j])
                dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
        }
    }
    cout << dp.back().back() << endl;
}



Measured memory_bytes: 10720
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#define F first
#define S second
using namespace std;
typedef pair<int,int> Pos;
typedef pair<Pos,string> P;
vector<P> era;
bool cmp(const P &p,const P &q){
  if(p.F.F != q.F.F)return p.F.F > q.F.F;
  return p.F.S > q.F.S;
}

bool Search(int year){
  for(int i=0;i<era.size();i++){
     if(era[i].F.F < year)break;
    if(era[i].F.S < year && year <= era[i].F.F){
      cout << era[i].S << " " << year-era[i].F.S << endl;
      return true;
    }
  }
  return false;
}

int main(){
  int N,Q,que;
  string s;
  P p;

  while(cin >> N >> Q && N && Q){
    era.clear();
    for(int i=0;i<N;i++){
      cin >> p.S >> p.F.S >> p.F.F;
      p.F.S = p.F.F-p.F.S;
      era.push_back(p);
    }
    sort(era.begin(),era.end(),cmp);


    for(int i=0;i<Q;i++){
      cin >> que;
      if(!Search(que))cout << "Unknown" << endl;
    }


  }
  return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<< #x" " << x << endl;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    int a;
    ll ans=0;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a,ans+=(a-1);
    cout<< ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,n;
vector<int> g[100005];
int distance_Fennec[100005]; //ふぇねえええええええええええええええええええええええええええええっく
int distance_Sunuke[100005];

void calc_distance(int r, int f, int d, int dist[]) {
	dist[r] = d;
	for(int x = 0; x < g[r].size(); x++)
		if (g[r][x] != f) calc_distance(g[r][x], r, d + 1, dist);
			
}
int main()
{
	cin>>n;
	for(int i = 0; i < n - 1; i++) {
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	calc_distance(0  ,-1,0,distance_Fennec);
	calc_distance(n-1,-1,0,distance_Sunuke);
	int ans = 0;
	for(int i = 0;i < n; i++){
		if(distance_Fennec[i] <= distance_Sunuke[i]) ans++;
		else ans--;
	}
	printf("%s\n",(ans > 0) ? "Fennec" : "Snuke");
}

Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <tuple>


using namespace std;

typedef long long ll;

const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}



int main(void){
	int n, m;

	cin >> n >> m;

	int largestL = 0;
	int smallestR = 1e9;
	for (int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		largestL = max(largestL, l);
		smallestR = min(smallestR, r);
	}

	if (largestL <= smallestR){
		cout << smallestR - largestL + 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 256
n = int(input())
d = list(map(int,input().split()))
m = 998244353
import collections
c = collections.Counter(d)
if c[0] == 1 and d[0] == 0:
    ans = 1
else:
    ans = 0
d = sorted(d)
for i in range(1,n):
    ans *= c[d[i]-1]
    ans %= m
print(ans)

Measured memory_bytes: 24184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cassert>

#define DBG(x) cerr << #x << ": " << x << endl
using namespace std;

double eval(int64_t n) {
  double sum = 0;
  int64_t x = n;
  while (x > 0) {
    sum += x%10;
    x /= 10;
  }
  return n / (double) sum;
}

vector<int64_t> solve(int K) {
  vector<int64_t> v;
  int64_t x = 1;
  int64_t inc = 1;
  v.push_back(x);
  for (int i=0; i<K; i++) {
    if (eval(x+inc) > eval(x+10*inc))
      inc *= 10;
    x += inc;
    v.push_back(x);
  }

  for (auto n : v) {
    cerr << n << " " << eval(n) << endl;
  }

  assert(v.size() >= K);
  //K = min(K, (int)v.size());

  return vector<int64_t>(v.begin(), v.begin()+K);
}

int main() {
  int K;
  cin >> K;
  auto ret = solve(K);
  for (const auto& x : ret)
    cout << x << endl;
}


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

using namespace std;

int main(){
  int h,w;
  while(true){
    cin >> h >> w;
    if(h == 0 && w == 0)
      break;
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;


using namespace std;

int main()
{
   FAST/**/
   
   //ll n;
   //cin>>n;
   
   ll n,w;
   cin>>n>>w;
   
   pair<ll,ll> arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i].first>>arr[i].second;
           
   ll dp[n][100001];
   
   for(ll i=0;i<n;i++)  
        for(ll j=0;j<100001;j++)
            dp[i][j] = w+1;
   dp[0][0] = 0;            
   dp[0][arr[0].second] = min(w+1,arr[0].first);
   
   for(ll i=1;i<n;i++)
   {
       for(ll j=0;j<100001;j++)
       {
           dp[i][j] = dp[i-1][j];
           if(j>=arr[i].second)
                dp[i][j] = min(dp[i][j], dp[i-1][j-arr[i].second] + arr[i].first);        
       }
   }
   
   /*for(ll j=0;j<n;j++){
   for(ll i=0;i<18;i++)
   {
       cout<<dp[j][i]<<" ";
   }
   cout<<"\n";
   }*/
   
   for(ll i=100000;i>-1;i--)
   {
       if(dp[n-1][i]<=w)
       {
            cout<<i;
            return 0;
       }
   }        
   
   
   return 0;
}

Measured memory_bytes: 78464
from collections import Counter

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

is_p=[1]*(10**6+1)
for i in set(a):
  if is_p[i]:
    for j in range(i+i,10**6+1,i):
      is_p[j]=0

c=Counter(a)

cnt=0
for i in a:
  if is_p[i] and c[i]==1:
    cnt+=1

print(cnt)

Measured memory_bytes: 159400
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint t;
    cin >> t;
    vector<lint> ret(t);
    for (int z = 0; z < t; ++z) {
        lint n;
        cin >> n;
        vector<lint> k(n), l(n), r(n);
        vector<array<lint, 4>> le, ri;
        for (lint i = 0; i < n; ++i) {
            cin >> k[i] >> l[i] >> r[i];
            k[i]--;
            if (k[i] == n - 1)
                r[i] = l[i];
            if (l[i] > r[i]) {
                le.push_back({l[i] - r[i], -k[i], l[i], r[i]});
            } else {
                ri.push_back({r[i] - l[i], k[i], l[i], r[i]});
            }
        }
        sort(le.begin(), le.end(), greater<>());
        sort(ri.begin(), ri.end(), greater<>());
        lint nl        = le.size();
        set<lint> used = {-1, n};
        for (int i = 0; i < n; ++i) {
            used.insert(i);
        }
        lint res = 0;
        for (auto &l : le) {
            lint edge = min(nl - 1, -l[1]);
            lint idx  = *prev(used.upper_bound(edge));
            if (idx != -1) {
                res += l[2];
                used.erase(idx);
            } else {
                lint jdx = *prev(used.upper_bound(nl - 1));
                assert(jdx != -1);
                res += l[3];
                used.erase(jdx);
            }
        }
        for (auto &r : ri) {
            lint edge = max(nl, r[1] + 1);
            lint idx  = *used.lower_bound(edge);
            if (idx != n) {
                res += r[3];
                used.erase(idx);
            } else {
                lint jdx = *used.lower_bound(nl);
                assert(jdx != n);
                res += r[2];
                used.erase(jdx);
            }
        }
        ret[z] = res;
    }

    for (auto &r : ret) {
        cout << r << "\n";
    }

    return 0;
}

Measured memory_bytes: 23484
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <memory>

//#define int long long

//#define ENABLE_TRACE
#ifdef ENABLE_TRACE
#define TRACE cout << __func__ << "()" << endl;
#define TRACE1(a) cout << __func__ << "(" << a << ")" << endl;
#define TRACE2(a, b) cout << __func__ << "(" << a << ", " << b << ")" << endl;
#else
#define TRACE
#define TRACE1(a)
#define TRACE2(a, b)
#endif  // #ifdef ENABLE_TRACE

using namespace std;

// Greatest Common Divisor
int Gcd(int a, int b) {
	TRACE2(a, b);
	if (a % b == 0) return b;
	return Gcd(b, a % b);
}

void Main()
{
	string s;
	cin >> s;

	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}

int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args>
void dbg(Args&&... args) {
  using expander = int[];
  (void)expander {0,(static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {exit(0);}

int n, m;
map<int, int> v;

void input() {
  scanf("%d %d", &n, &m);
  forn(i, 0, n) v[i] = n + 1;
  forn(i, 0, m) {
    int a, b;
    scanf(" %d %d", &a, &b);
    int x = min(a, b);
    int y = max(a, b);
    v[x] = min(v[x], y);
  }
}

void solve() {
  int ans = 0;
  int current = n + 1;
  forn(i, 1, n + 1) {
    if (i >= current) {
      ans++;
      current = n + 1;
    }
    current = min(current, v[i]);
  }
  printf("%d\n", ans);
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
  //  gen();
#endif
  input();
  solve();
  return 0;
}


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

vector<ll> v(3);

int main() {
  cin >> v[0] >> v[1] >> v[2];
  if ((v[0]%2)*(v[1]%2)*(v[2]%2) == 0) {
    cout << 0 << endl;
  } else {
    sort(v.begin(), v.end());
    cout << v[0]*v[1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    string s;
    in>>s;
    puts(s[2]==s[3]&&s[4]==s[5]?"Yes":"No");
}

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

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string a, b, c;
	cin >> a >> b >> c;
	puts(a.back() == b.front() && b.back() == c.front() ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

int main() {
  uint32_t N, K;
  cin >> N >> K;
  vector<uint32_t> h(N);
  ArrayInput(h);
  uint64_t res = 0;
  for (uint32_t i = 0; i < N; ++i) {
    if (h[i] >= K) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640