akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
public static void main(String[] args) {
	InputStream inputStream = System.in;
	OutputStream outputStream = System.out;
	FastInput in = new FastInput(inputStream);
	PrintWriter out = new PrintWriter(outputStream);
	ABC179C solver = new ABC179C();
	solver.solve(1, in, out);
	out.close();
}

static class ABC179C {

	public void solve(int testNum, FastInput in, PrintWriter out) {

		int n = in.nextInt();
		int cnt = 0;
		
		for(int i = 1 ; i  <= n-1 ; i++) {
			for(int j = i ; j <=n-1 ; j+= i) {
				//out.println(i+" "+(j/i)+" "+(n-j)); 
				cnt++;
			}
		}
		
		out.println(cnt);
		
	}
	
	
	

}

static class FastInput{
	private final BufferedReader in;
	private String[] buff;
	private int index = 0;
	
	public FastInput(InputStream is) {
		in = new BufferedReader(new InputStreamReader(is));
	}
	String nextLine() {
		try {
			return in.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	String next() {
		while (buff == null || index >= buff.length) {
			buff = nextLine().split(" ");
			index = 0;
		}
		return buff[index++];
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	
	long nextLong() {
		return Long.parseLong(next());
	}
	
	Double nextDouble() {
		return Double.parseDouble(next());
	}
	
	BigInteger nextBigInteger() {
		return new BigInteger(next());
	}
	
	BigDecimal nextBigDecimal() {
		return new BigDecimal(next());
	}
	
	public int[] nextIntArray(final int n) {
		final int[] res = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextInt();
		}
		return res;
	}
	
	public long[] nextLongArray(final int n) {
		final long[] res= new long [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextLong();
		}
		return res;
	}
	
	public double[] nextDoubleArray(final int n ) {
		final double[] res = new double [n];
		
		for(int i = 0 ; i < n ;i++) {
			res[i] = nextDouble();
		}
		return res;
	}
	
	
	public int[][] nextInt2DArray(final int n , final int m){
		int [][]res = new int [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextInt();
			}
		}
		return res;
	}
	public long[][] nextLong2DArray(final int n , final int m){
		long [][]res = new long [n][m];
		
		for(int i = 0 ; i < n ;i++) {
			for(int j = 0 ; j < m ;j++) {
				res[i][j] = nextLong();
			}
		}
		return res;
	}
	
	public char[][] nextChar2DArray(final int n){
		char [][]res = new char [n][];
		
		for(int i = 0 ; i < n ;i++) {
			String s = next();
			res[i] = s.toCharArray();
		}
		
		return res;
	}
}
}




Measured memory_bytes: 33080
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	/*int a1,a2,a3,b1,b2,b3;*/

	int a[3];
	int b[3];
	
	vector<vector<int>> vec(3,vector<int>(3));
	
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> vec.at(i).at(j);
		}
	}

	bool OK = true;

	//a1を0とする、、a2を、、a3を、、
	for (int i = 0; i <= 100; i++)
	{
		a[0] = i;

		for (int j = 0; j <= 100; j++)
		{
			a[1] = j;
			for (int k = 0; k <= 100; k++)
			{
				a[2] = k;

				OK = true;
				int count = 0;


				b[0] = vec.at(0).at(0) - a[0];
				b[1] = vec.at(1).at(1) - a[1];
				b[2] = vec.at(2).at(2) - a[2];

				

				for (int z = 0; z < 3; z++)
				{
					for (int x = 0; x < 3; x++)
					{

						if (vec.at(z).at(x) != a[z] + b[x]) {
							OK = false;
							break;
						}

						count++;
					}
					if (!OK) {
						break;
					}
				}
				if (count == 9) {
					cout << "Yes" << endl;
					return 0;
				}


			}
		}


	}


	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
//int dp[1000001] = {0};

void solve(){
	string s, t;
	cin>>s>>t;
	cout<<t+s;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	return 0;
 
}


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

int main()
{
    int n;
    cin >> n;
    int ans = -1;
    int max = 0;
    int count = 0;

    for (int i = 1; i <= n; i++)
    {   
        int obj = i;
        while (obj % 2 == 0)
        {
            obj /= 2;
            count++;
        }

        if (max <= count)
        {
            max = count;
            ans = i;
        }
        count = 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

// ll modexp(ll x, ll y, ll p)
// {
// 	ll res = 1;
// 	x = x % p;
// 	while (y > 0)
// 	{
// 		if (y & 1)
// 			res = (res * x) % p;
// 		y = y >> 1;
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll mulmod(ll a, ll b,ll m)
// {
// 	return ((a % m) * (b % m)) % m;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b) 
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

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

// ll modInv(ll a) 
// { 
//     ll g = gcd(a, mod); 
//     if (g != 1) 
//         return -1; 
//     else
//         return modexp(a, mod-2, mod); 
// } 
int main()
{
	fastio;
	// #ifndef ONLINE_JUDGE   
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	string s;
	cin>>s;
	ll n=s.length();
	if(n%2!=0)
		cout<<"No\n";
	else
	{
		bool f=true;
		for(ll i=0;i<n-1;i+=2){
			if(s[i]!='h' || s[i+1]!='i'){
				f=false;
				break;
			}
		}
		if(f)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}

}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		int k=ir.nextInt();
		int[] x=ir.nextIntArray(n);
		int ret=0;
		for(int i=0;i<n;i++)
			ret+=Math.min(x[i],k-x[i])<<1;
		out.println(ret);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21204
#include <stdio.h>

void sort(int *,int size);

int main(void){
	
	 int N,x,a[100] ,i,count=0;
  
 	 scanf("%d %d",&N,&x);

  	for(i=0;i<N;i++){
    	scanf("%d",&a[i]);
    }
  	sort(a,N);
  
  	for(i=0;i < N && x >= 0;i++){
    	x -= a[i];
      	if(x >= 0){
          count++;
        }
    }
	if(x>0){
		count--;		
	}
	
	printf("%d",count);
  
	return 0;
}

void sort(int *array,int size){
	
	int tmp,i,j;

  	for(i=0;i<size-1;i++){
    	for(j=i+1;j<size;j++){
        	if(array[i] > array[j]){
            	tmp = array[i];
            	array[i] = array[j];
              	array[j] = tmp;
            }
        }
    }
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

int main()
{
  int t[5];
  int minmod = 10;
  int minidx = -1;
  int ans = 0;
  for (int i=0;i<5;i++) {
    scanf("%d", &t[i]);
    int a = t[i] % 10;
    if (a != 0 && a < minmod) {
      minmod = a;
      minidx = i;
    }
  }
  for (int i=0;i<5;i++) {
    if (i==minidx)
    {
      ans += t[i];
    } else {
      int a = t[i] % 10;
      if (a == 0) ans += t[i];
      else ans += (t[i] - a + 10);
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

// int64_t Ryuka(int n) {
//     if(n==0) return 2;
//     if(n==1) return 1;

//     int64_t L = Ryuka(n-1) + Ryuka(n-2);
//     return L;
// }

int main() {
    int N;
    cin >> N;
    // printf("%ld\n",Ryuka(N));
    vector<int64_t> L(N+1);
    L[0] = 2;
    L[1] = 1;
    for(int i=2;i<=N;i++) L[i] = L[i-1] + L[i-2];
    // printf("%ld\n",L[3]);
    printf("%ld\n",L[N]); 
    return 0;
}

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

using namespace std;

using ll = long long;

#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define ALL(A) A.begin(),A.end()

int main()
{
    int N;
    cin >> N;
    vector<int> H(N,0);
    
    rep(i,N) cin >> H.at(i);

    /*
    H.at(N-2) - min(N-2~N-1)
    H.at(N-3) - min(N-3~N-1)
    .
    .
    .
    H.at(1)   - min(1~N-1)
    H.at(0)   - min(1~N-1)
    */

    bool TF = true;

    int minH = H.at(N-1);
    for(int i=N-2;i>=0;i--)
    {
        if(i!=0)
        {    
            if(H.at(i) < minH)
            {
                minH = H.at(i);
            }
        }
        if(H.at(i) - minH > 1)
        {
            TF = false;
        }
    }    

    if(TF) cout << "Yes" << endl;
    else   cout << "No" << endl;

    return 0;
}

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

typedef long long ll;

const int maxn = 105, maxw = 1e5 + 5;

int main(int argc, const char * argv[])
{
    ll n, W, w[maxn], v[maxn], dp[maxw] = {0};
    cin >> n >> W;
    for (int i = 0; i < n; i++)
        scanf("%lld %lld", &w[i], &v[i]);

    for (int i = 0; i < n; i++)
        for (int j = W; j >= w[i]; j--)
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    
    cout << dp[W] << endl;
    return 0;
}

Measured memory_bytes: 4000
import numpy as np

N = int(input())
A = tuple(map(int, input().split()))

rain = [None]*N

rain[0] = sum(A) - 2*(sum(A[1:N-1:2]))
for i in range(1, N):
    rain[i] = 2*A[i-1] - rain[i-1]


print(*rain)

Measured memory_bytes: 23192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    int ans = 0, count;
    bool flag1, flag2;
    for(int i=1;i<S.size()-1;i++){
        string substr1 = S.substr(i);  // S[i]~
        string substr2 = S.substr(0, i);   // S[0]からi文字
        count = 0;
        for(int i=0;i<26;i++){
            char tmp = 'a' + i;
            flag1 = false;
            flag2 = false;
            for(int i=0;i<substr1.size();i++){
                if(substr1.at(i) == tmp)
                    flag1 = true;
            }
            for(int i=0;i<substr2.size();i++){
                if(substr2.at(i) == tmp)
                    flag2 = true;
            }
            if(flag1 && flag2)
                count++;
        }
        if(count > ans)
            ans = count;        
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
from collections import deque
N,M=map(int,input().split())

outs = [[] for _ in range(N+1)]
outs_rev = [[] for _ in range(N+1)]
ins = [0]*(N+1)
for _ in range(N+M-1):
  v1,v2=map(int,input().split())
  outs[v1].append(v2)
  outs_rev[v2].append(v1)
  ins[v2] += 1
#print(outs,ins)
#print(outs_rev)

q = deque(v1 for v1 in range(N+1) if ins[v1] == 0)
res = []
while q:
  v1 = q.popleft()
  res.append(v1)
  for v2 in outs[v1]:
    ins[v2] -= 1
    if ins[v2] == 0:
      q.append(v2)
#print(res)

res_rev=[0]*(N+1)
for i in range(N):
  res_rev[res[i]]=i
#print(res_rev)

answer_list=[0]*(N+1)
for i in range(1,N+1):
  r=res[i]
  if not outs_rev[r]:
    answer_list[r]=0
  else:
    max_v=-1
    max_index=-1
    for rr in outs_rev[r]:
      ind=res_rev[rr]
      if ind>max_index:
        max_v=res[ind]
        max_index=ind
  
    answer_list[r]=max_v
    
#print(answer_list)
for i in range(1,N+1):
  print(answer_list[i])

Measured memory_bytes: 107440
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
typedef long long ll;

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

	int N;
	double temp;
	vector<double> A;

	cin >> N;

	REP(i, N)
	{
		cin >> temp;
		A.pb(temp);
	}

	sort(ALL(A));

	REP(i, N - 1)
	{
		A[0] = (A[0] + A[1]) / 2;
		A.erase(A.begin() + 1);
	}

	cout << A[0] << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
 
def main():
    N, Y = map(int, input().split())
 
    for i in range(0, N+1):
        for j in range(0, (N+1)-i):
            if(10000*i+5000*j+1000*(N-i-j) == Y):
                print("{0} {1} {2}".format(i,j,N-i-j))
                sys.exit()
 
    print("-1 -1 -1")
 
main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());

		System.out.println(Math.min(n*a, b));
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    ll n;
    cin >> n;
    ll o=0;
    vector<ll> a(33);
    rep(i,33){
        ll c=1;
        rep(j,i) c*=2;
        if (i%2==1) o+=c;
        a[i]=c;
    }   
    vector<int> ans(33,0);
    n+=o;
    rep(i,33){
        if (n%2==1){
            ans[i]=1;
        }
        if (i%2==1) ans[i]=1-ans[i];
        n/=2;
    }
    bool e=false;
    string s;
    rep(i,33){
        if (ans[32-i]==1) e=true;
        if (e) s.push_back(ans[32-i]+'0');
    }
    if (!e) s.push_back('0');
    cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<long long> t(n),a(n);
    for(int i=0;i<n;i++)cin>>t[i]>>a[i];
    for(int i=1;i<n;i++){
        long long p;
        p=max((t[i-1]+t[i]-1)/t[i],(a[i-1]+a[i]-1)/a[i]);
        t[i]*=p;
        a[i]*=p;
    }
    cout<<t[n-1]+a[n-1]<<endl;
}

   


Measured memory_bytes: 632
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

int n, m, k, s, p, q;
vi c;
vi g[100000];
bool hazard[100000], zombie[100000];
vi d;

void hazardcheck()
{
  REP(_, s) {
    vi t;
    for (int u : c) for (int v : g[u]) {
      if (hazard[v]) continue;
      hazard[v] = true;
      t.pb(v);
    }
    c = t;
  }
}

ll dijkstra()
{
  vector<ll> dist(n, LINF);
  minpq<pair<ll, int>> pq;
  pq.emplace(0, 0);
  dist[0] = 0;

  while (!pq.empty()) {
    auto t = pq.top(); pq.pop();
    int v = t.Se;
    if (dist[v] < t.Fi) continue;
    for (int e : g[v]) {
      if (zombie[e]) continue;
      ll cost = hazard[e] ? q : p;
      if (dist[e] > dist[v] + cost) {
        dist[e] = dist[v] + cost;
        pq.emplace(dist[e], e);
      }
    }
  }

  return dist[n - 1];
}

signed main()
{
  cin >> n >> m >> k >> s >> p >> q;
  d = vi(n, INF);
  REP(i, k) {
    int a = in() - 1;
    zombie[a] = true;
    d[a] = 0;
    c.pb(a);
  }
  REP(i, m) {
    int a = in() - 1, b = in() - 1;
    g[a].pb(b);
    g[b].pb(a);
  }
  hazardcheck();
  print(dijkstra() - (hazard[n - 1] ? q : p));

  return 0;
}

Measured memory_bytes: 11184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
    lint x,y,z,k;
    cin>>x>>y>>z>>k;
    vector<lint> a;
    vector<lint> b;
    vector<lint> c;
    rep(i,x){
        lint v;cin>>v;
        a.push_back(v);
    }
     rep(i,y){
        lint v;cin>>v;
        b.push_back(v);
    }
     rep(i,z){
        lint v;cin>>v;
        c.push_back(v);
    }
    vector<lint>d;
    rep(i,a.size()){
        rep(j,b.size()){
            d.push_back(a[i]+b[j]);
        }
    }
    sort(all(d),greater<lint>());
    vector<lint>e;
    lint aa=min(k,(lint)d.size());
    rep(i,aa){
        e.push_back(d[i]);
    }
    vector<lint> f;
    rep(i,e.size()){
        rep(j,c.size()){
            f.push_back(e[i]+c[j]);
        }
    }
    sort(all(f),greater<lint>());
    rep(i,k){
        cout<<f[i]<<endl;
    }
  }
  
  
     
  

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

int main(){
  int a,b,cta=1,ctb=1,sum;
  char f[100][100];
  cin>>a>>b;
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      if(i==0)
        f[i][j]='.';
      else f[i][j]=(j>=50?'#':'.');
    }
  }
  cout<<100<<" "<<100<<endl;
  for(int i=0;a!=cta;i++){
    int y=2+i*2;
    for(int j=1;a!=cta&&j<25;j++){
      int x=50-j*2;
      for(int xp=x-1;xp<=x+1;xp++){
        for(int yp=y-1;yp<=y+1;yp++){
          if(xp==x&&yp==y) continue;
          f[yp][xp]='#';
        }
      }
      cta++;
    }
  }
  for(int i=0;b!=ctb;i++){
    int y=2+i*2;
    for(int j=1;b!=ctb&&j<25;j++){
      int x=50+j*2;
      for(int xp=x-1;xp<=x+1;xp++){
        for(int yp=y-1;yp<=y+1;yp++){
          if(xp==x&&yp==y) continue;
          f[yp][xp]='.';
        }
      }
      ctb++;
    }
  }
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      cout<<f[i][j];
    }
    cout<<endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include<iostream>
#include<ctype.h>
using namespace std;
int main(){
char A[11],B[11],C[11];
cin>>A>>B>>C;
char ANS[4];
 ANS[0]=toupper(A[0]);
 ANS[1]=toupper(B[0]);
 ANS[2]=toupper(C[0]);
cout<<ANS<<endl;
return 0;
}

Measured memory_bytes: 256
//(bool) ? (if true) : (if false)
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pf push_front
#define sz size()
#define FORN(i,j,n) for(long long i=j; i<(long long)n;i++) 
#define FOR(i,n) FORN(i,0,n)
#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )
#define LIM 262150
#define ones(x) __builtin_popcount(x)
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
using namespace std;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;
string cad1,cad2;
ll dp[3005][3005];
deque<char> ans;
int main() {
	fastio;
	cin>> cad1 >> cad2 ;
	FOR(i,cad1.sz+1){
		FOR(j,cad2.sz+1){
			if (i == 0 | j == 0){ dp[i][j] = 0; continue; }
            if(cad1[i-1] == cad2[j-1]){
			    dp[i][j] = dp[i-1][j-1] + 1;
			}			
			else{
				dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
			}
		}
	}
	ll a = cad1.sz; 
	ll b = cad2.sz;
	while(a>0 && b>0){
		if(dp[a][b] == dp[a][b-1]) b--;
		else if(dp[a][b] == dp[a-1][b]) a--;
		else if(dp[a][b] == dp[a-1][b-1] + 1){
			ans.pf(cad1[a-1]); 
			a--; b--;
		}
	}
	FOR(i,ans.sz){
		cout<< ans[i] ;
	}
	cout<< '\n';
	return 0;
}

Measured memory_bytes: 74096
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W, N;
set<pair<int, int> > F;
set<pair<int, int> > cand;

i64 ans[10];

void add_cand(int y, int x)
{
	if (y >= 0 && y < H - 2 && x >= 0 && x < W - 2) cand.insert({ y, x });
}

int main()
{
	scanf("%d%d%d", &H, &W, &N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a; --b;
		F.insert({ a, b });

		for (int dy = 0; dy <= 2; ++dy) for (int dx = 0; dx <= 2; ++dx) add_cand(a - dy, b - dx);
	}

	for (int i = 0; i <= 9; ++i) ans[i] = 0;
	ans[0] = (i64)(H - 2) * (W - 2);
	for (auto aa : cand) {
		int y = aa.first, x = aa.second;
		int num = 0;
		for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) {
			if (F.count({ y + i, x + j })) ++num;
		}
		--ans[0];
		++ans[num];
	}
	for (int i = 0; i <= 9; ++i) printf("%lld\n", ans[i]);

	return 0;
}


Measured memory_bytes: 47104
#include<stdio.h>
int main(void){

	int a,b,ans;
	char op;

	while(1){

		scanf("%d %c %d",&a,&op,&b);

		switch(op){

			case '+':
				ans = a+b;
				printf("%d\n",ans);
				break;

			case '-':
				ans = a-b;
				printf("%d\n",ans);
				break;

			case '*':
				ans = a*b;
				printf("%d\n",ans);
				break;

			case '/':
				ans = a/b;
				printf("%d\n",ans);
				break;

			case '?':
				return 0;

			default:
				break;
		}
	}
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	

	int a,b;
	
	cin >> a >> b;
	double g = a,j =b,f;
	
	/*a / b = d;
	a % b = r;
	*/

	f = g /j;
	
	
	printf("%d %d %.8lf\n",a / b, a % b, f);
	
return 0;
}

Measured memory_bytes: 3188
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// edpc-coins.rs --- Coins
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        ps: [f64; n],
    };

    let mut dp = vec![vec![0.0; n + 1]; n + 1];
    dp[0][0] = 1.0;

    for (i, p) in ps.into_iter().enumerate() {
        for j in 0..n {
            // i 枚目までの表が j 枚であるような確率は
            // i-1 枚目までの表が j-1 枚であるような確率 * p
            // i-1 枚目までの表が j 枚であるような確率 * (1-p)
            // の2つの和
            dp[i + 1][j + 1] += dp[i][j] * p;
            dp[i + 1][j] += dp[i][j] * (1.0 - p);
        }
    }

    let ans = dp[n][((n + 1) / 2)..].into_iter().sum::<f64>();
    println!("{}", ans);
}


Measured memory_bytes: 90364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

const ll MAX = 4e5+10;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	COMinit();
	ll n, k;
	cin >> n >> k;
	ll ans = COM(2*n-1, n);
	if(k < n-1){
		ll pos = n-k-1;
		rep(i, 1, pos){
			ll tmp = COM(n, i)*COM(n-1, i-1)%MOD;
			ans += MOD-tmp;
			ans %=MOD;
		}
	}
	if(k == 1){
		ans--;
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 9600
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pr;

map<char, int> m;

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

	for (int i = 0; i < s.size(); i++) {
		if (m[s[i]]) {
			cout << "no" << endl;
			return 0;
		}
		m[s[i]] = 1;
	}
	cout << "yes" << endl;
	return 0;
}

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

using namespace std;

typedef pair<int,int>pii;

int dp1[101][301],dp2[101][301];

int main(void){

	int s,d,m;
	while(cin >> s >> d >> m){
		vector<pii>a[s];
		for(int i=0;i<s;i++){
			int w,p,k;
			cin >> k;
			for(int j=0;j<k;j++){
				cin >> w >> p;
				a[i].push_back(pii(p,w));
			}
		}

		vector<int>f(d);
		for(int i=0;i<d;i++)cin >> f[i];

		fill(dp1[0],dp1[101],0);

		for(int i=0;i<s;i++){
			for(int j=0;j<a[i].size();j++){
				for(int k=300;k>=0;k--){
					if(k+a[i][j].first<=300){
						dp1[i][k+a[i][j].first]=
							max(dp1[i][k+a[i][j].first],dp1[i][k]+a[i][j].second);
					}
				}
			}
		}

		fill(dp2[0],dp2[101],0);
		for(int i=0;i<d;i++){
			for(int j=0;j<=m;j++){
				for(int k=0;k<=m;k++){
					if(j+k<=300)dp2[i+1][j+k]=max(dp2[i+1][j+k],dp2[i][j]+dp1[f[i]][k]);
				}
			}
		}

		int minp=(1<<29),maxw=-1;
		for(int j=0;j<=m;j++){
			for(int i=0;i<=d;i++){
				if(maxw<dp2[i][j]){
					maxw=dp2[i][j];
					minp=j;
				}
			}
		}
		
		cout << maxw << " " << minp << endl;
	}
	return 0;
}

Measured memory_bytes: 1472
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int a[1000005],b[1000005],c[1000005];

int main()
{
	int i,n,k;
	while(~scanf("%d %d",&n,&k)){
		if(n%3 == 0 || k%3 == 0 || (n+k)%3 == 0) printf("Possible\n");
		else printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 128
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0])

Big = 0
for i in range(1,N):
    Big = max(Big,abs(A[i] - A[i-1]))

ans = min(K-Big, max(A)-min(A))
print(ans)

Measured memory_bytes: 26060
import java.util.HashSet;
import java.util.Queue;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		final int[] dx = {0, -1, 0, 1};
		final int[] dy = {1, 0, -1, 0};
		final int sx = 100;
		final int sy = 100;
		while(true){
			int n = in.nextInt();
			if(n == 0) break;
			int[] res = new int[6];
			int[][] height = new int[201][201];// 高さマップ
			int[][] map = new int[201][201]; // 上から見える面マップ
			for(int i=0; i<n; i++){
				int t = in.nextInt();
				int f = in.nextInt();
				int x = sx;
				int y = sy;
				Dice dice = new Dice(t, f);
				while(true){
					// 転がりうる方向を求める
					HashSet<Integer> set = new HashSet<Integer>();
					for(int j=0; j<4; j++){
						if(height[y+dy[j]][x+dx[j]] < height[y][x]){
							set.add(j);
						}
					}
					int dirnum = dice.dirNum(set);
					if(dirnum < 4) break;
					int dir = dice.getDir(dirnum);
					dice.rolling(dirnum, dir);
					y += dy[dir];
					x += dx[dir];
				}
				map[y][x] = dice.top;
				height[y][x]++;
			}
			for(int i=0; i<=200; i++){
				for(int j=0; j<=200; j++){
					if(map[i][j] > 0) res[map[i][j]-1]++;
				}
			}
			StringBuilder sb = new StringBuilder();
			for(int i=0; i<6; i++){
				sb.append(res[i]+" ");
			}
			System.out.println(sb.toString().trim());
		}
	}
	
	public static String dump(int[][] map, int hs, int ws, int he, int we){
		StringBuilder sb = new StringBuilder();
		for(int i=hs; i<he; i++){
			for(int j=ws; j<we; j++){
				sb.append(map[i][j]+" ");
			}
			sb.append("\n");
		}
		return sb.toString();
	}
}

class Dice{
	int front;
	int top;
	class Node{
		int num;
		int[] edge;
		public Node(int num){
			this.num = num;
			edge = new int[4];
		}
		
	}
	Node[] state;
	
	public Dice(int top, int front){
		this.top = top;
		this.front = front;
		init();
	}
	
	static final int[][] map = {
		{2, 4, 5, 3},
		{1, 3, 6, 4},
		{1, 5, 6, 2},
		{1, 2, 6, 5},
		{1, 4, 6, 3},
		{2, 3, 5, 4},		
	};
	private void init(){
		state = new Node[6];
		for(int i=1; i<=6; i++){
			state[i-1] = new Node(i);
		}
		for(int i=0; i<6; i++){
			for(int j=0; j<4; j++){
				state[i].edge[j] = map[i][j];
			}
		}
	}
	
	public int dirNum(HashSet<Integer> set){
		int res = 0;
		int fidx = getDirIdx(front);
		for(int i=0; i<4; i++){
			if(!set.contains((4+i-fidx)%4)) continue;
			res = Math.max(state[top-1].edge[i], res);
		}
		return res;
	}
	
	public int getDir(int dirnum){
		int idx = -1;
		int diridx = -1;
		for(int i=0; i<4; i++){
			// find front idx
			if(state[top-1].edge[i] == front){
				idx = i;
			}
			// find dirnum idx
			if(state[top-1].edge[i] == dirnum){
				diridx = i;
			}
		}
		return (4+diridx - idx)%4;
		// number of "front to dirnum"
	}
	
	public int getDirIdx(int dirnum){
		int diridx = -1;
		for(int i=0; i<4; i++){
			if(state[top-1].edge[i] == dirnum){
				diridx = i;
				break;
			}
		}
		return diridx;
	}
	
	public void rolling(int dirnum, int dir){
		int diridx = getDirIdx(dirnum);
		if(dir == 0) front = top;
		else if(dir == 2) front = 7-top;
		top = state[top-1].edge[(diridx+2)%4];
	}
}

Measured memory_bytes: 57832
#include <cstdio>
#include <cstring>
#include <algorithm>

template <typename Tp>Tp Max(const Tp &a, const Tp &b) {return a > b ? a : b;}
template <typename Tp>Tp Min(const Tp &a, const Tp &b) {return a < b ? a : b;}

template <typename Tp>void Read(Tp &x) {
	Tp in = 0, f = 1; char ch = getchar();
	while(ch<'0' || ch>'9') {if(ch=='-') f = -1; ch = getchar();}
	while(ch>='0' && ch<='9') {in = in*10+ch-'0'; ch = getchar();}
	x = in*f;
}

const int SN = 1000000 + 10;

int max[SN], v[SN], c[SN], deep[SN], head[SN], finl[SN], n, m, q;

int num;

struct Edge {
	int v, next;
}E[SN];

void Add(int u, int v) {
	E[++num].v = v, E[num].next = head[u], head[u] = num;
}

void Dfs(int now, int fa, int d, int c) {
	if(max[now] >= d) return ;

	max[now] = d;

	if(!finl[now]) finl[now] = c;
	
	if(!d) return ;
	
	for(int i = head[now]; i; i = E[i].next) {
		int to = E[i].v;
		if(to != fa) Dfs(to, now, d-1, c);
	}
}

int main() {
	int x = 0, y = 0, z = 0;

	memset(max, -1, sizeof max);
	
	Read(n), Read(m);

	for(int i = 1; i <= m; i++) Read(x), Read(y), Add(x, y), Add(y, x);

	Read(q);
	
	for(int i = 1; i <= q; i++) Read(v[i]), Read(deep[i]), Read(c[i]);

	for(int i = q; i >= 1; i--) Dfs(v[i], 0, deep[i], c[i]);

	for(int i = 1; i <= n; i++) printf("%d\n", finl[i]);

	return 0;
}


Measured memory_bytes: 19072
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,Q = map(int,readline().split())
data = np.array(read().split(),np.int64)

ABCD = data[:4*N-4].reshape(-1,4).tolist()

graph = [[] for _ in range(N+1)]
for a,b,c,d in ABCD:
    graph[a].append((b,c,d))
    graph[b].append((a,c,d))

color = [0] * (N+1) # 自身と親を結ぶ辺の色
length = [0] * (N+1) # 自身と親を結ぶ辺の長さ

def EulerTour(graph,start=1):
    """
    1-indexed graph
    graphを破壊しているので場合によっては注意
    """
    V = len(graph)
    par = [0] * V
    depth = [0] * V; depth[start] = 0
    tour = [start]; st = [start]
    while st:
        x = st[-1]
        if not graph[x]:
            st.pop()
            tour.append(par[x])
            continue
        y,c,d = graph[x].pop()
        if y == par[x]:
            continue
        par[y] = x
        color[y] = c
        length[y] = d
        depth[y] = depth[x] + 1
        st.append(y)
        tour.append(y)
    return tour,depth

tour,depth = EulerTour(graph)

Ltour = len(tour)
tour_arr = np.array(tour)
depth_arr = np.array(depth)
tour_d = depth_arr[tour_arr]
idx = np.arange(len(depth))
idx[tour_arr] = np.arange(Ltour)

# depth最小を実現するインデックスのsparse tableを作る
sp = np.empty((Ltour.bit_length(),Ltour),np.int32)
sp[0] = np.arange(Ltour)
for n in range(1,Ltour.bit_length()):
    prev,width = sp[n-1],1<<(n-1)
    x = prev[:-width]; y = prev[width:]
    condition = tour_d[x] > tour_d[y]
    sp[n] = prev
    sp[n,:-width][condition] = y[condition]

def LCA(A,B):
    AB = np.vstack([A,B]).T
    LR = idx[AB]
    LR.sort(axis=1)
    # [L,R] におけるRmQ
    L = LR[:,0]; R = LR[:,1]
    x = R-L
    n = np.zeros_like(x) # 2^n <= R-L
    for _ in range(20):
        x >>= 1
        n[x>0] += 1
    x = sp[n,L]; y = sp[n,R-(1<<n)+1]
    return np.where(tour_d[x] < tour_d[y], tour_arr[x], tour_arr[y])

XYUV = data[4*N-4:]
U = XYUV[2::4]; V = XYUV[3::4]
lca = LCA(U,V)

answer = [0] * Q
task = [[] for _ in range(N+1)]
for i,((x,y,u,v),w) in enumerate(zip(XYUV.reshape(-1,4).tolist(),lca.tolist())):
    # x,yの条件下での距離の何倍かをanswer[i]に加算する
    task[u].append((x,y,1,i))
    task[v].append((x,y,1,i))
    task[w].append((x,y,-2,i))

color_cnt = [0] * N
color_sum = [0] * N
d = 0 # いじらないときの距離

for fr,to in zip(tour,tour[1:]):
    d1 = depth[fr]; d2 = depth[to]
    if d1 > d2:
        # 上る前にクエリ処理
        for x,y,coef,i in task[fr]:
            answer[i] += coef * (d - color_sum[x] + color_cnt[x] * y)
    if d1 < d2:
        c = color[to]; l = length[to]
        color_cnt[c] += 1
        color_sum[c] += l; d += l
    else:
        c = color[fr]; l = length[fr]
        color_cnt[c] -= 1
        color_sum[c] -= l; d -= l

print('\n'.join(map(str,answer)))

Measured memory_bytes: 149772
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

x, y = map(int, input().split())
list_x = make_divisors(x)
list_y = make_divisors(y)
#listの一致するところをとってくる
list_xy = set(list_x) & set(list_y)

a = 0
for i in list_xy:
    if is_prime(i) == True:
        a = a + 1
    else:
        continue
print(a+1)

Measured memory_bytes: 5264
n = int(input())
import math
def F (a,b):
    a_len = len(str(a))
    b_len = len(str(b))
    return max(a_len,b_len)
result = 0
if n % 2 == 0:
    for i in range(2,int(math.sqrt(n))+1,2):
        if n % i == 0:
            result = len(str(n//i))
else:
    for j in range(1,int(math.sqrt(n))+1,2):
        if n % j == 0:
            result = len(str(n//j))
print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

long long strtoi(string s)
{
	long long val = 0;
	for (auto c : s)
		val *= 10,
		val += c - '0';
	return val;
}

int n;
long long total = 0;
string s;

void gen(int i, int last, long long sum)
{
	if (i == n)
	{
		total += sum + strtoi(s.substr(last, i - last));
		return;
	}
	if (i >= last && i != n - 1)
		gen(i + 1, i + 1, sum + strtoi(s.substr(last, i + 1 - last)));
	gen(i + 1, last, sum);
}

int main()
{
	::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	n = s.length();
	gen(0, 0, 0);
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,d[105][80000],l[80000],r[80000],cnt,M=1e9+7;
int main()
{
	cin>>n>>k;
	int x=1,y;
	while(x<=n)
	{
		y=n/(n/x);
		l[++cnt]=x;
		r[cnt]=y;
		x=y+1;
	}
	for(int i=1;i<=cnt;i++)d[1][i]=r[i];
	for(int i=2;i<=k;i++)
		for(int j=1;j<=cnt;j++)
			d[i][j]=(1ll*d[i-1][cnt-j+1]*(r[j]-l[j]+1)+d[i][j-1])%M;
	printf("%d",d[k][cnt]);
}

Measured memory_bytes: 32384
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(int argc,char** argv) {
	int n,t;
	vector<int> a;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> t;
		a.push_back(t);
	}
	bool flag = true;
	int count = 0;
	while(flag) {
		flag = false;
		for(auto itr = a.begin() + 1;itr != a.end();itr++) {
			if(*itr < *(itr - 1)) {
				iter_swap(itr,itr-1);
				flag = true;
				count++;
			}
		}
	}
	for(int i = 0;i < a.size()-1;i++) cout << a[i] << " ";
	cout << a[a.size()-1] << endl << count << endl;
}



Measured memory_bytes: 3128
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,rl[maxn],rr[maxn],b[maxn],tot,ans,cnt;
struct node{int l,r;}p[maxn];

inline bool cmp(node a,node b)
{
	if(a.l==b.l) return a.r<b.r;
	return a.l<b.l;
}

inline bool cmp2(int a,int b){return a<b;}

int main()
{
	n=read(); rep(i,1,n) p[i].l=read(),p[i].r=read(),b[++cnt]=p[i].r;
	sort(p+1,p+n+1,cmp); sort(b+1,b+cnt+1,cmp2);
	rl[0]=inf; rr[n+1]=inf;
	rep(i,1,n) rl[i]=min(rl[i-1],p[i].r);
	per(i,n,1) rr[i]=min(rr[i+1],p[i].r);
	rep(i,1,(n-1))
	{
		int tmp=0;
		if(rl[i]>=p[i].l) tmp+=(rl[i]-p[i].l+1);
		if(rr[i+1]>=p[n].l) tmp+=(rr[i+1]-p[n].l+1);
		ans=max(ans,tmp);
	}
	rep(i,2,(n-1))
	{
		int tmp=0,p2=0;
		if(p[i].r==b[1]) tmp=b[2]; else tmp=b[1];
		if(tmp>=p[n].l) p2+=(tmp-p[n].l+1);
		ans=max(ans,p[i].r-p[i].l+1+p2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9216
package main

import (
	"bufio"
	"flag"
	"fmt"
	"os"
	"sort"
	"strconv"
	"testing"
)

/*-----------Main-----------*/

func main() {
	a, b := readI(), readI()
	fmt.Println(a * b)
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	testing.Init()
	if flag.Parse(); flag.Arg(0) == "debug" {
		debug()
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Println("Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

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

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
vector<vector<ll>> sc(26,vector<ll>(0));
vector<vector<ll>> tc(26,vector<ll>(0));
//
void solve(std::string s, std::string t){
  rep(i,s.size()){
    sc[s[i]-'a'].push_back(i);
  }
  rep(i,t.size()){
    tc[t[i]-'a'].push_back(i);
  }
  ll cnt=1;
  ll now=-1;
  ll flag=0;
  ll lnow=0;
  rep(i,t.size()){
    
    auto n = upper_bound(all(sc[t[i]-'a']),now);
    if(n!=sc[t[i]-'a'].end()){
      now=*n;
      flag=1;
      lnow=now;
      //op(now)
    }else {
      if(flag==0){
        op(-1);
        return;
      }
      i--;
      flag=0;
      now=-1;
      cnt++;
    }
  }
  //op(cnt)
  op((cnt-1)*(s.size())+lnow+1);
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 2932