akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
int main(){
	int n,set;
	vector<int> arr;
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>set;
		sum+=set;
		arr.push_back(set);
	}
	sort(arr.begin(),arr.end());
	int max = arr[n-1];
	vector<int> siv(max+1);
	

	for(int i=0;i<n;i++){
		for(int j=arr[i];j<=max;j+=arr[i])
			siv[j]++;
	}

	int ans=0;
	for(int i=0;i<n;i++)
		if(siv[arr[i]]==1)
			ans++;
	
	cout<<ans;	
    return 0;
}

Measured memory_bytes: 7864
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main()
{
  finp;
 ll a,b,x;
 cin>>a>>b>>x;
 ll low = (a/x)*x;
 if(low < a)low+=x;
 ll high = (b/x)*x;

 if(low<=high && low>=a && high<=b)cout<<(high - low)/x + 1;
 else cout<<0; 
return 0;
}

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    Int N, M;
    vector<vector<Int>> G;

    // vから出る辺を削除」
    double calc(Int v) {
        vector<double> dp(N);
        for (Int i = N - 2; i >= 0; --i) {
            double max_v = 0;
            double avg = 0;
            for (auto e : G[i]) {
                chmax(max_v, dp[e]);
                avg += dp[e];
            }
            if (i == v && G[i].size() > 1) {
                avg -= max_v;
                avg /= (G[i].size() - 1);
            } else {
                avg /= G[i].size();
            }

            dp[i] = avg + 1;
        }
        return dp[0];
    }

    void solve() {

        cin >> N >> M;
        G.resize(N);
        for (int i = 0; i < M; ++i) {
            int s, t;
            cin >> s >> t;
            s--, t--;
            G[s].push_back(t);
        }

        double ans = INFl;
        for (int i = 0; i < N; ++i) {
            double tmp = calc(i);
            chmin(ans, tmp);
        }
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 2560
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		String[] S = new String[N];
		for (int i = 0; i < N; i++) {
			S[i] = sc.next();
		}

		sc.close();

		HashMap<String, Integer> m = new HashMap<>();

		int max = 0;

		for (int i = 0; i < N; i++) {
			if (!m.containsKey(S[i])) {
				m.put(S[i], 1);
				max = Math.max(max, 1);
			} else {
				int x = m.get(S[i]);
				x++;
				max = Math.max(max, x);
				m.put(S[i], x);
			}
		}

		List<String> result = new ArrayList<>();

		for (Entry<String, Integer> e : m.entrySet()) {
			if (e.getValue() == max) {
				result.add(e.getKey());
			}
		}

		result.sort(Comparator.naturalOrder());

		for (String s : result) {
			out.println(s);
		}
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 81748
input = raw_input

N = int(input())
b = map(int,input().split(" "))

done = []
for i in range(N):
    idx = -1
    for j in range(len(b)-1,-1,-1):
        if b[j] == j+1:
            idx = j
            break
    if idx == -1:
        print(-1)
        exit()
    done.append(b.pop(j))

for i in range(len(done)-1,-1,-1):
    print(done[i])


Measured memory_bytes: 29036
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  ll n;
  cin>>n;
  cout<<n*(n-1)/2<<endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int culc = (n - 1) / 2;
		BigDecimal culc2 = BigDecimal.valueOf(culc).setScale(0, RoundingMode.UP);
		
		System.out.println(culc2);
		sc.close();
	}
}

Measured memory_bytes: 23892
#include<iomanip>
#include<cstdio>
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

typedef long double ll;
typedef pair<ll,ll> pll;
vector<pll> list;
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}

ll dist(pll a){
  return sqrt(a.first*a.first + a.second*a.second);
}

ll cal(pll a,pll b,pll c){
  ll ab = dist(a-b);
  ll bc = dist(b-c);
  ll ca = dist(c-a);
  ll z = (ab+bc+ca)/2;
  return sqrt(z*(z-ab)*(z-bc)*(z-ca));
}

ll solve(){
  ll ans=0;
  for(int i=2;i<list.size();i++){
    ans+=cal(list[0],list[i-1],list[i]);
  }
  return ans;
}
int main(){
  char c;
  ll x,y;
  while(cin>>x>>c>>y){
    list.push_back(pll(x,y));
  }
  cout<<solve()<<endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
ll i, j, k;
ll mk[20];

void calc(ll n,ll r){
    ll i;
    if(n==N){
        fornum(i,0,N){
            printf("%c", mk[i] + 'a');
        }
        printf("\n");
        return;
    }
    fornum(i,0,r){
        mk[n] = i;
        calc(n + 1, max(r, i + 2));
    }
}
int main(){
    scanf("%lld", &N);
    calc(0, 1);

    return 0;
}

Measured memory_bytes: 1536
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    let c = read::<usize>();
    let ans = b + std::cmp::min(a + b + 1, c);
    println!("{}", ans);
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    int D; cin >> D;
    D %= 10;
    cout << "Christmas";
    for (int i = 0; i < 5 - D; i++) {
        cout << ' ' << "Eve";
    }
    cout << endl;
    return 0;
}

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

int max(int, int);

int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);
  if((0 <= a)&&(a <= 1000000000)&&(0 <= b)&&(b <= 1000000000)&&(a != b))
  {
    int a_k_abs, b_k_abs, k = 0;
    for(int i = 1; i <= max(a, b); i++)
    {
      a_k_abs = abs(a - i);
      b_k_abs = abs(b - i);
      if(a_k_abs == b_k_abs) k = i;
    }
    if(k == 0) printf("IMPOSSIBLE");
    else printf("%d", k);
  }
  return 0;
}

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


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

using namespace std;

using times = pair<size_t, size_t>;

int main() {
  size_t N;
  cin >> N;

  vector<times> ts{};
  for (size_t i = 0; i < N; i++) {
    size_t a, b;
    cin >> a >> b;
    ts.emplace_back(a, b);
  }

  sort(ts.begin(), ts.end(), [](const times& a, const times& b) {
    return a.second < b.second;
  });

  size_t now = 0;
  for (size_t i = 0; i < N; i++) {
    now += ts[i].first;
    if (now > ts[i].second) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

int main(int argc, char const *argv[])
{
    vector<int> v;
    int p,q,r;cin>>p>>q>>r;
    v.push_back(p);
    v.push_back(q);
    v.push_back(r);
    sort(v.begin(),v.end());
    cout << v[0]+v[1]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,t,a;
  cin >> n >> t >> a;
  auto d = [&](int x){ return abs(1000*t-6*x-1000*a); };
  int ans, diff = 1e9;
  rep(i,n){
    double h;
    cin >> h;
    int x = d(h);
    if(x<diff) ans = i+1;
    diff = min(diff,x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	N := fsc.Next()
	values := make([]int, 4)
	for i, val := range N {
		valNum, _ := strconv.Atoi(string(val))
		values[i] = valNum
	}
	for bit := 0; bit < (1 << 3); bit++ {
		sum := values[0]
		tmpBit := bit
		i := 1
		for j := 0; j < 3; j++ {
			if tmpBit%2 == 0 {
				sum += values[i]
			} else {
				sum -= values[i]
			}
			tmpBit /= 2
			i++
		}
		if sum == 7 {
			sigs := make([]string, 3)
			for i := 0; i < 3; i++ {
				if bit%2 == 0 {
					sigs[i] = "+"
				} else {
					sigs[i] = "-"
				}
				bit >>= 1
			}
			fmt.Print(values[0])
			for i := 0; i < 3; i++ {
				fmt.Print(sigs[i])
				fmt.Print(values[i+1])
			}
			fmt.Println("=7")
			break
		}
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ template.cpp -o template.exe
//#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b)
{
    return (a.second < b.second);
}




int main()
{

unsigned long long int n,i;
long long int k=1;
cin>>n;
//unsigned long long int a[n];
long  double po,qo,a[n],sum=1;
for(i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
for(i=0;i<n;i++)
{

if(k==-1 || sum==0)
continue;




po=a[i];
qo=sum;

if(a[i]==0)
{
sum=0;
continue;
}

if((log10(a[i])+log10(sum))<=18)
{
sum=sum*a[i];
}
else
k=-1;

}
if(k==-1 || log10(sum)>18)
cout<<"-1"<<endl;
else
cout<<(unsigned long long int)sum;


return 0;
}



Measured memory_bytes: 5400
#include<stdio.h>
int n, p, a, i;
char odd;
long ans;
int main(){
  scanf("%d%d", &n, &p);
  for(i=0; i<n; i++){
    scanf("%d", &a);
    if(a&1){odd=1; break;}
  }
  if(odd){
    ans = (long)1<<n-1;
  }else{
    if(p){
      ans = 0;
    }else{
      ans = (long)1<<n;
    }
  }
  printf("%ld\n", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int n,W; cin >> n >> W;
  vl weight(n), value(n);
  rep(i,n) cin >> weight[i] >> value[i];

  vvl dp(n+1,vl(W+1));

  rep(i,n) rep(w,W+1) {
    dp[i+1][w] = dp[i][w];
    if(w >= weight[i]) chmax(dp[i+1][w], dp[i][w-weight[i]] + value[i]);
  }

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


Measured memory_bytes: 80256
#include <stdio.h>

int tree[100010];
//size, num

void add(int x){
    int n = tree[0];
    int now = n + 1;
    tree[n+1] = x;
    tree[0]++;
    while(now > 1){
        if(tree[now/2] > tree[now]){
            int a = tree[now/2];
            tree[now/2] = tree[now];
            tree[now] = a;
        }
        now = now / 2;
    }
}

int get_mini(){
    int res = tree[1];
    int n = tree[0];
    tree[0]--;
    tree[1] = tree[n];
    tree[n] = 0;
    
    int now = 1;
    while(now * 2 <= n){
        if(now * 2 == n){
            if(tree[now] > tree[now * 2]){
                int a = tree[now];
                tree[now] = tree[now * 2];
                tree[now * 2] = a;
                now *= 2;
            }else{
                now *= 2;
            }
        }else{
            if(tree[now * 2] < tree[now * 2 + 1]){
                if(tree[now * 2] < tree[now]){
                    int a = tree[now * 2];
                    tree[now * 2] = tree[now];
                    tree[now] = a;
                    now = now * 2;
                }else{
                    now = now * 2;
                }
            }else{
               if(tree[now * 2 + 1] < tree[now]){
                   int a = tree[now * 2 + 1];
                   tree[now * 2 + 1] = tree[now];
                   tree[now] = a;
                   now = now * 2 + 1;
               }else{
                   now = now * 2 + 1;
               }
            }
        }
    }
    return res;
}


int N, M;
int A[100010];
int main(void){
    scanf("%d", &N);
    scanf("%d", &M);
    for(int i = 0; i < N; i++){
        scanf("%d" ,&A[i]);
    }
    long long ans = 0;
    for(int i = 0; i < N; i++){
        add(-A[i]);
    }
    
    
    for(int i = 0; i < M; i++){
        int m = get_mini();
        m *= -1;
        m /= 2;
        add(-m);
    }
    for(int i = 0; i < N; i++){
        int m = get_mini();
        ans -= m;
    }
    printf("%lld", ans);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int H,W;
    cin >> H >> W;
    int h,w;
    cin >> h >> w;
    cout << H*W-h*W-w*H+h*w << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


bool is_Prime(ll n){
    for(ll i=2; i*i<=n; ++i){
        if(n%i == 0) return false;
    }

    return true;
}

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

    int N; cin >> N;
    ll id = 0, q = 1;
    vector<ll> ans(N);

    while(id<N){
        if(is_Prime(5*q+1)){
            ans[id++] = 5*q+1;
        }
        ++q;
    }

    for(int i=0; i<N; ++i){
        if(i) cout << ' ';
        cout << ans[i];
    }
    cout << endl;
    
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"regexp"
)

func main() {

	var S string
	fmt.Scan(&S)

	r := regexp.MustCompile(`^A[a-z][a-z]*C[a-z]*[a-z]$`)
	if r.MatchString(S) {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


Measured memory_bytes: 640
#pragma optimize("", off)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(i) (int)(i.size())
#define setto(n) cout << fixed << setprecision(n)
#define fi first
#define se second
#define ld long double
#define inf LONG_MAX
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int mod = 1e9 + 7;
using namespace std;

#ifndef ONLINE_JUDGE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}

//Check N size twiceeeeeeeeeeeeeeeeee, and verify it
const int N = 2*1e3 + 10;

int n, t, a;
int32_t main(){_
	
	cin>>n;
	cin>>t>>a;

	ld ma = 1e10;

	int pos = 1;
	for (int i = 1; i <= n; ++i)
	{
		ld h;
		cin>>h;
		ld tmp = t - 6*h/1000;
		if(abs(a-tmp) < ma){
			ma = abs(a-tmp);
			pos = i;
		}
	}

	cout<<pos;


	return 0;
}

Measured memory_bytes: 256
bingo = []
is_bingo = False
for i in range(3):
    bingo.append(list(map(int, input().split())))
for i in range(3):
    bingo.append([bingo[j][i] for j in range(3)])
bingo.append([bingo[i][i] for i in range(3)])
bingo.append([bingo[i][2-i] for i in range(3)])
n = int(input())
result = set()
for i in range(n):
    result.add(int(input()))
for i in bingo:
    if set(i).issubset(result):
        print('Yes')
        is_bingo = True
        break
if not is_bingo:
    print('No')

Measured memory_bytes: 3064
#include <cstdio>

void calc(int from, int now_sum, int deep);

int n, s;
int ans;

int main(void)
{
    while (1){
        ans = 0;
        scanf("%d %d", &n, &s);
        if (n == 0 && s == 0) break;
        for (int i = 0; i < 10; i++){
            calc(i, i, n - 1);
        }
        printf("%d\n", ans);
    }
    
}

void calc(int from, int now_sum, int deep)
{
    if (deep == 0){
        if (now_sum == s){
            ans++;
        }
        return;
    }
    
    for (int i = from + 1; i < 10; i++){
        calc(i,  now_sum + i, deep - 1);
    }
}

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

using namespace std;

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

	int n, x;
	int m[100];
	cin >> n >> x;
	for(int i = 0; i < n; i++)cin >> m[i];
	int ret = n, mi = 1000;
	for(int i = 0; i < n; i++)
	{
		x -= m[i];
		mi = min(mi, m[i]);
	}
	ret += x / mi;
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
from sys import exit, stdin

# import copy
# from collections import deque,Counter
# import numpy as np
input = stdin.readline

X, K, D = map(int, input().split())

if abs(X) >= K * D:
    print((abs(X) - K * D))
else:
    A1 = abs(X) % D
    A2 = abs(A1 - D)
    n = int((abs(X) - A1)/D)
    if (K - n) % 2 == 0:
        print(A1)
    else:
        print(A2)



Measured memory_bytes: 9084
#include<iostream>
#include<algorithm>
#include<vector>
#define LL long long
LL W, H;
LL SW[100010], SH[100010];
std::vector<LL> PW, PH;
LL ans;
int main() {
	std::cin >> W >> H;
	for (int i = 0; i < W; i++) {
		LL tmp;
		std::cin >> tmp;
		PW.emplace_back(tmp);
	}
	for (int i = 0; i < H; i++) {
		LL tmp;
		std::cin >> tmp;
		PH.push_back(tmp);
	}
	std::sort(PW.begin(), PW.end());
	std::sort(PH.begin(), PH.end());
	for (int i = 1; i <= W; i++) {
		SW[i] += SW[i - 1] + PW[i - 1];
	}
	for (int i = 1; i <= H; i++) {
		SH[i] += SH[i - 1] + PH[i - 1];
	}
	ans += SW[W] + SH[H];
	for (int i = 0; i < W; i++) {
		auto it = std::upper_bound(PH.begin(),PH.end(),PW[i]);
		LL K = it - PH.begin();
		ans += SH[K] + PW[i] * (H - K);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3444
N, M, K = [int(x) for x in input().split()]

def n_black(n, m):
    return (N - n) * m + (M - m) * n

ans = False
for i in range(N + 1):
    for j in range(M + 1):
        if n_black(i, j) == K:
            ans = True

print("Yes" if ans else "No")


Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<String>().chars().collect::<Vec<_>>();
    for i in 0..3 {
        if n[i] == n[i + 1] {
            println!("Bad");
            return;
        }
    }
    println!("Good");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2144
#include <iostream>
#include <string>
using namespace std;
int main()
{
  char station[2];
  scanf("%c""%c""%c", &station[0], &station[1], &station[2]);
  if (station[0] == station[1]){
      if (station[0] == station[2]){
          if (station[1] == station[2]){
              
              printf("No");
              }
              
              else{
          printf("Yes");
          }
          }
          else{
          printf("Yes");
          }
     
      }
      else{
          printf("Yes");
          }
  
  
  
  
  return 0;
}


Measured memory_bytes: 256
#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;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#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
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define GET_BIT(n, i) (((n) & (1LL << ((i)-1))) >> ((i)-1)) // i start from 1
#define SET_BIT(n, i) ((n) | (1LL << ((i)-1)))
#define CLR_BIT(n, i) ((n) & ~(1LL << ((i)-1)))
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;
void myInit();
const int MOD = 1000000007;
const int N = 3e5, M = N;
//=========TQR==============
vi g[N];

int main() {
	myInit();
	FIO;
	string s, t;
	int n, m, start, ans;
	cin >> s >> t;
	n = s.length(), m = t.length();
	ans = m;
	fo(start, n - m + 1) {
		int i, len = 0;
		fo(i, m) {
			// deb2(s[i], t[i]);
			if (s[i + start] != t[i])
				len++;
		}
		ans = min(ans, len);
	}
	cout << ans << endl;
	return 0;
}

void myInit() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


Measured memory_bytes: 10620
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var n = b - a - 1;
        var h = n * (n + 1) / 2;
        Console.WriteLine(h -a);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
int dis[20][100][100],p[20],wage[20][10011],dist[100][100];
int inf=1e+8;
int main(){
	while(true){
		int n,m,c,s,g;
		scanf("%d%d%d%d%d",&n,&m,&c,&s,&g);
		s--,g--;
		if(n==0) break;
		rep(i,c) rep(j,n) rep(k,n){
			if(j!=k) dis[i][j][k]=inf;
			else dis[i][j][k]=0;
		}
		rep(j,n) rep(k,n){
			if(j!=k) dist[j][k]=inf;
			else dist[j][k]=0;
		}
		rep(i,m){
			int x,y,d,c;
			scanf("%d%d%d%d",&x,&y,&d,&c);
			x--,y--,c--;
			dis[c][x][y]=min(dis[c][x][y],d);
			dis[c][y][x]=min(dis[c][x][y],d);
		}
		rep(i,c) scanf("%d",p+i);
		int q[50],r[50];
		rep(i,c){
			int now=0;
			rep(j,p[i]-1) scanf("%d",&q[j]);
			rep(j,p[i]) scanf("%d",&r[j]);
			rep(j,10010){
				wage[i][j+1]=wage[i][j]+r[now];
//				cout << wage[i][j+1] << " ";
				if(now<p[i]-1 && q[now]-1==j) now++;
			}
//			cout << endl;
		}
		rep(i,c){
			rep(j,n){
				rep(k,n){
					rep(l,n){
						dis[i][k][l]=min(dis[i][k][l],dis[i][k][j]+dis[i][j][l]);
					}
				}
			}
		}
		rep(i,c){
//			cout << "company " << i << endl;
			rep(j,n){
				rep(l,n){
					int d=dis[i][j][l];
//					if(d!=inf) cout << j << " " << l << " " << d << endl;
//					else cout << j << " " << l << " inf" << endl;
					if(d==inf) continue;
					if(d>=10000) dist[j][l]=min(dist[j][l],wage[i][10000]+(d-10000)*r[p[i]-1]);
					else dist[j][l]=min(dist[j][l],wage[i][d]);
				}
			}
		}
		rep(i,n) rep(j,n) rep(k,n) dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
		if(dist[s][g]==inf) dist[s][g]=-1;
		printf("%d\n",dist[s][g]);
	}
	return 0;
}

Measured memory_bytes: 2788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MAX = pow(10, 6) + 10;
// const ll mod = pow(10, 9) + 7;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a) {
        if((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a) {
        if((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if(!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if(t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    vector<int> nummap(MAX, 0);
    // vector<int> primes;
    nummap.at(0) = 1;
    nummap.at(1) = 1;
    for(int i = 2; i < MAX; i++) {
        if(nummap.at(i) != 0) {
            continue;
        }
        // primes.push_back(i);
        nummap.at(i) = i;
        for(int j = i * 2; j < MAX; j += i) {
            nummap.at(j) = i;
        }
    }

    vector<map<int, ll>> a_primes(A.size());
    for(int i = 0; i < A.size(); i++) {
        int a = A.at(i);
        while(a > 1) {
            int p = nummap.at(a);
            a /= p;
            a_primes.at(i)[p]++;
        }
    }

    map<int, ll> merged;
    for(map<int, ll> ps : a_primes) {
        // for(auto p, cnt : ps){
        for(auto p = ps.begin(); p != ps.end(); p++) {
            merged[p->first] = max(merged[p->first], p->second);
        }
    }
    mint x = 1;
    for(auto p = merged.begin(); p != merged.end(); p++) {
        x *= pow(p->first, p->second);
    }
    mint ans = 0;
    for(int i = 0; i < A.size(); i++) {
        ans += x / A.at(i);
        // cout << ans << endl;
    }
    cout << ans.x << endl;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC107C - Candles
  // x[i]～x[i+K-1]で順に探索する
  // x[i+K-1]より右側にろうそくと座標0があった場合は成り立たないが、最小値にはなり得ないので無視
  // x[i]より左側にろうそくと座標0があった場合も同様
  // x[i+K-1]が0以下のとき、ans=abs(x[i])
  // x[i]が0以上のとき、ans=x[i+K-1]
  // x[i]がマイナス、x[i+K-1]がプラスのとき
  // min(abs(x[i]), x[i+K-1])×2 + max(abs(X[i]), x[i+K-1])
  // 以上の条件でansの最小値を更新していく
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  REP(i, N){
    cin >> x.at(i);
  }
  int ans = 1000000007;
  for(int i = 0; i <= N - K; i++){
    if(x.at(i+K-1) <= 0){
      ans = min(ans, abs(x.at(i)));
    }else if(x.at(i) >= 0){
      ans = min(ans, x.at(i+K-1));
    }else if(x.at(i) < 0 && x.at(i+K-1) > 0){
      ans = min(ans, min(abs(x.at(i)), x.at(i+K-1))*2+max(abs(x.at(i)), x.at(i+K-1)));
    }
  }
  cout << ans << endl;
}

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

typedef long long int ll;

int main()
{
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
    }
    
    for(ll i = 0;i < n;i++){
        h -= a[i];
    }

    if(h <= 0){
        cout << "Yes";
    }
    else{
        cout << "No";
    }


    return 0;
}

Measured memory_bytes: 1024
import collections
h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]
group = [[-1 for _ in range(w)] for _ in range(h)]
group_positions = []
for h_i in range(h):
    for w_i in range(w):
      if maze[h_i][w_i] == ".":
        maze[h_i][w_i] = 0
      else:
        maze[h_i][w_i] = 1
      
def do_append(point, y_diff, x_diff):
  new_x = point[1] + x_diff
  new_y = point[0] + y_diff
  new_color = ((point[2]+1)%2)
  if new_x == -1 or new_x == w or new_y == -1 or new_y == h or new_color != maze[new_y][new_x]:
    return False, False
  elif group[new_y][new_x] != -1:
    return False, False
  else:
    return True, (new_y, new_x, new_color)

def wfs(pos, group_num):
  y_pos = pos[0]
  x_pos = pos[1]
  color = maze[y_pos][x_pos] # 0 white 1 black
  group_positions.append([(y_pos, x_pos, color)])
  
  que = collections.deque()
  que.append((y_pos, x_pos, color))
  group[y_pos][x_pos] = group_num
  while len(que) > 0:
    point = que.popleft()
    for dy in (-1, 0, 1):
      for dx in (-1, 0 , 1):
        if dx * dy != 0:
          continue
        result, new_point = do_append(point, dy, dx)
        if result:
          group[new_point[0]][new_point[1]] = group_num
          group_positions[group_num].append(new_point)
          que.append(new_point)
      
if __name__ == "__main__":
  count = 0
  group_num = 0
  for h_i in range(h):
    for w_i in range(w):
      if group[h_i][w_i] == -1:
        pos = (h_i, w_i)
        wfs(pos, group_num)
        group_num += 1
  
  for g in group_positions:
    black_num = 0
    white_num = 0
    for point in g:
      if point[2] == 0:
        white_num += 1
      else:
        black_num += 1
    count += white_num * black_num
  print(count)

Measured memory_bytes: 82012
#include<bits/stdc++.h>
using namespace std;
char s[10];
int main() {
    scanf("%s",s);
    if(strcmp(s,"SAT")==0) printf("1");
    if(strcmp(s,"FRI")==0) printf("2");
    if(strcmp(s,"THU")==0) printf("3");
    if(strcmp(s,"WED")==0) printf("4");
    if(strcmp(s,"TUE")==0) printf("5");
    if(strcmp(s,"MON")==0) printf("6");
    if(strcmp(s,"SUN")==0) printf("7");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPC2019_10
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int[] res = new int[n];
            for(int i = 0; i < n; i++)
            {
                if (i <= n / 2) res[i] = 0;
                else res[i] = m;

                Write(res[i]);
                if (i < n - 1) Write(' ');
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 15984
#include <iostream>
using namespace std;
int main(void){
    
    while(1){
        int h, w;
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i % 2 == 0){
                    if(j % 2 == 0) cout << "#";
                    else cout << ".";
                }
                else{
                    if(j % 2 == 0) cout << ".";
                    else cout << "#";                    
                }
            }cout << endl;
        }cout << endl;
    }
    
}



Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

string a[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
    string s;
    cin>>s;
    for(int i=0;i<7;i++){
        if(a[i]==s){
            cout<<7-i;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2001
#define INF 0x3f3f3f3f
using namespace std;
int n,k,ans=INF,tmp;
int cnt,head[N],nxt[N+N],to[N+N];
bool use[N+N];
void add(int u,int v)
{
	nxt[++cnt]=head[u];head[u]=cnt;to[cnt]=v;
}
void dfs(int u,int fa,int dep)
{
	if(dep>k/2)++tmp;
	for(int i=head[u],v;i;i=nxt[i])
		if(!use[i] && (v=to[i])!=fa)
			dfs(v,u,dep+1);
}
int f(int x)
{
	tmp=0;
	dfs(x,0,0);
	return tmp;
}
int main()
{
	scanf("%d",&n);
	scanf("%d",&k);
	for(int i=1,u,v;i<n;++i)
	{
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	if(k&1)
	{
		for(int i=1;i<=cnt;i+=2)	
		{
			use[i]=use[i+1]=1;
			ans=min(ans,f(to[i])+f(to[i+1]));
			use[i]=use[i+1]=0;
		}
	}
	else 
		for(int i=1;i<=n;++i)
			ans=min(ans,f(i));
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = (int)(1e9 + 1);
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, L; cin >> n >> m >> L;

    vector<vi> D(n, vi(n, inf));
    rep(i, n) D[i][i] = 0;
    rep(_, m){
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        D[a][b] = D[b][a] = c;
    }

    rep(k, n){
        rep(i, n){
            rep(j, n){
                chmin(D[i][j], D[i][k] + D[k][j]);
            }
        }
    }

    vector<vi> D2(n, vi(n, inf));
    rep(i, n){
        D2[i][i] = 0;
        rep(j, n){
            if(D[i][j] <= L){
                D2[i][j] = 1;
            }
        }
    }
    rep(k, n){
        rep(i, n){
            rep(j, n){
                chmin(D2[i][j], D2[i][k] + D2[k][j]);
            }
        }
    }

    int Q; cin >> Q;
    rep(_, Q){
        int a, b; cin >> a >> b;
        a--, b--;

        int val = D2[a][b];
        if(val == inf) val = -1;
        else val--;
        cout << val << endl;
    }

    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    
    set<int> water_set, sugar_set;

    //water
    for(int i=0;i<30;i++){
        for(int j=0;j<=30;j++){
            if(i==0&&j==0) continue;
            int w = 100*a*i+100*b*j;
            if(w<=f)water_set.insert(w);
        }
    }

    //sugar
    for(int i=0; i<=3000;i++){
        for(int j=0; j<=3000;j++){
            int s = c*i+d*j;
            if(s<=f)sugar_set.insert(s);
        }
    }
    
    double maxratio = -1.0;
    int sw=0,s=0;
    for(int x:water_set){
        for(int y:sugar_set){
            if(x+y>f)break;
            if((x/100)*e<y)break;
            double ratio = (double)y/(x+y);
            if(maxratio<ratio){
                maxratio = ratio;
                sw = (x+y);s = y;
            }
        }
    }
    cout << sw << " " << s << endl;
    return 0;
}  


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

#define MOD 1000000007
lli dp[205][210]={};

void add(lli& p,lli q){
	p = (p + q) % MOD;
}

int main(void){
	int n;
	scanf("%d",&n);
	dp[0][0]=1;
	int t=0;
	rep(i,n){
		char s[5];
		scanf("%s",s);
		if(s[0]=='-')continue;
		rep(j,n+5){
			//printf("%lld ",dp[t][j]);
			if(s[0]=='U'){
				add(dp[t+1][j+1],dp[t][j]);
				add(dp[t+1][j],dp[t][j] * j);
			}
			else{
				add(dp[t+1][j],dp[t][j] * j);
				if(j>0){
					add(dp[t+1][j-1],dp[t][j] * j * j);
				}
			}
		}
		//printf("\n");
		t++;
	}
	printf("%d\n",dp[t][0]);
	return 0;
}

Measured memory_bytes: 1512
A = input()

dic = {}
for i in range(len(A)):
    if A[i] in dic:
        dic[A[i]] += 1
    else:
        dic[A[i]] = 1

ans = len(A)*(len(A)-1)//2 + 1
for key in dic:
    ans -= dic[key]*(dic[key]-1)//2

print(ans)

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

int main(void)
{
    int N;
    cin >> N;

    vector<string> vec(N, "");

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

    int AC = 0, WA = 0, TLE = 0, RE = 0;

    for(int i = 0; i < N; i++){
        if(vec[i] == "AC"){
            AC++;
        }else if(vec[i] == "WA"){
            WA++;
        }else if(vec[i] == "TLE"){
            TLE++;
        }else if(vec[i] == "RE"){
            RE++;
        }
    }
     cout << "AC x " << AC << endl;
     cout << "WA x " << WA << endl;
     cout << "TLE x " << TLE << endl;
     cout << "RE x " << RE << endl;
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string a,b;
	cin>>a>>b;
	string ans;
	for(int i=0;i<n;i++)
	{
	ans+=a[i];
	ans+=b[i];
}
	cout<<ans<<endl;
}

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

int main() {
  string s,t;
  int max=0;
  int c=0,a,b;
  cin >> s >> t;
  
  a = s.size();
  b = t.size();
  for(int i=0 ;i < (a - b + 1); i++){
    c=0;
    for(int j=0;j < b;j++){
	  if(s.at(i+j)==t.at(j)){
        c++;
      }
      if(c>=max)
         max=c;
    }
  }
  cout << t.size() - max;
}


Measured memory_bytes: 3572
#include <iostream>
using namespace std;
char a,b;
 
int main(){
	cin>>a>>b;
  	if((int)a==(int)b){
		cout<<"="<<endl;
    }else if((int)a>(int)b){
		cout<<">"<<endl;
    }else{
		cout<<"<"<<endl;
    }
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
string z(int i){string s="";if(i>25){s+='a'+i/25;i%=25;}s+='a'+i;return s;}
int main(){
	string s;
	map<string,int>m;
	int i=0;
	cout<<"?shiritori"<<endl<<flush;
	for(;i<50;i++){
		cin>>s;
		if(s[0]!='i'||m[s]){cout<<"!OUT"<<endl;return 0;}
		m[s]=1;cout<<'?'<<s[s.size()-1]<<z(i)<<'i'<<endl<<flush;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<long long>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int MOD=1e9+7;
int INF=1e9+7;
//
int main(){
  long long A,B;
  cin>>A>>B;
  if(A*B<=0){
    cout<<"Zero"<<endl;
  }else if(0<A){
    cout<<"Positive"<<endl;
  }else{
    if((B-A)%2==0){
      cout<<"Negative"<<endl;
    }else{
      cout<<"Positive"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256