akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 7;
int nex[MAXN], nex2[MAXN];
void GetNext(char *p, int *nex)
{
    int m = strlen(p);
    memset(nex, 0, sizeof(nex));
    nex[0] = -1;
    int k = -1, j = 0;
    while (j < m)
    {
        if (k == -1 || p[j] == p[k]) nex[++j] = ++k;
        else k = nex[k];
    }
}
char s[MAXN], t[MAXN];
int main()
{
    scanf("%s", s); int len = strlen(s);
    for (int i = 0; i < len; i++) t[i] = s[len - 1 - i]; t[len] = '\0';
    GetNext(s, nex);
    int pd = 0;
    if (nex[len] && (len % (len - nex[len]) == 0)) pd = len - nex[len];
    if (pd == 0) printf("1\n1\n");
    else if (pd == 1) printf("%d\n1\n", len);
    else 
    {
        int ans = 0;
        GetNext(t, nex2);
        for (int i = 1; i < len; i++)
        {
            if (nex[i] && (i % (i - nex[i]) == 0)) continue;
            int j = len - i;
            if (nex2[j] && (j % (j - nex2[j]) == 0)) continue;
            ans++;
        }
        printf("2\n%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 5120
/*************************************************************************
    > File Name: A.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-11-29 13:15:52
 ************************************************************************/

#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,s,now,ans,a[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        s+=a[i];
    }
    int ans=INF,now=-1;
    for(int i=1;i<=n;i++)
    {
        if(abs(a[i]*n-s)<ans) 
        {
            ans=abs(a[i]*n-s);
            now=i;
        }
    }
    printf("%d\n",now-1);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
using namespace std;

bool graph[8][8];
int ans;
int n, m;
bool reached[8];
int dfs(int x)
{
	bool allReached = true;
	for (int i = 0; i < n; i++) {
		if (!reached[i])
			allReached = false;
	}

	if (allReached)
		return 1;

	int ret = 0;
	for (int i = 0; i < n; i++) {
		if (!graph[x][i])
			continue;
		if (reached[i])
			continue;

		reached[i] = true;
		ret += dfs(i);
		reached[i] = false;
	}

	return ret;

}

int main()
{

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
	}


	for (int i = 0; i < n; i++) {
		reached[i] = false;
	}
	reached[0] = true;
	cout << dfs(0) << endl;

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) 
{
	int a, b, n = 0, suma = 0, sumb = 0, ave = 0;
	while (scanf("%d, %d", &a, &b) != EOF) {
		suma += a * b;
		sumb += b;
		n++;
	}
	ave = (double)sumb / (double)n + 0.5;
	printf("%d\n", suma);
	printf("%d\n", ave);
	return 0;
}


Measured memory_bytes: 2068
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)

# print('N,A:',N,A)
if N==2:
    out=A[-1]

else:
    out=A[-1]
    flag=0
    cnt=1
    i=1
    while cnt<N-1:
        if flag==0:
            flag=1
            out+=A[-1*(i+1)]
        elif flag==1:
            out+=A[-1*(i+1)]
            i+=1
            flag=0

        # print('i,tasu,out:', i,A[-1*(i+1)],out)
        cnt+=1

print(out)


Measured memory_bytes: 105176
#include <stdio.h>

int w[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int sw[10];

/* prototype declaration */
void measure(int weight);

int main(int argc, const char *argv[])
{
	int weight;
	while(scanf("%d", &weight)!=EOF)
		measure(weight);	
	return 0;
}

void init()
{
	int i;
	for(i=0; i<10; i++) sw[i] = 0;
}

void measure(int weight)
{
	init();
	int i, f=0, l=9;
	
	for(i=9; i>=0; i--){
		sw[i] = weight/w[i];
		weight %= w[i];
	}

	for(i=0; i<10; i++) if(sw[i]) l=i;
	for(i=9; i>=0; i--) if(sw[i]) f=i;


	for(i=f; i<l; i++)
		if(sw[i]) printf("%d ", w[i]);
	printf("%d\n", w[l]);
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
    int A,B,C,D;
    scanf("%d%d%d%d",&A,&B,&C,&D);
    if((A+B)>(C+D))printf("Left\n");
    else if((A+B)<(C+D))printf("Right\n");
    else
        printf("Balanced\n");


}

Measured memory_bytes: 1648
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    c = Counter(A)
    flag = True
    if N % 2 == 0:
        for i in range(1, N, 2):
            if c[i] != 2:
                flag = False
        if flag == False:
            print(0)
            return
    else:
        for i in range(0, N, 2):
            if i == 0:
                if c[i] != 1:
                    flag = False
            elif c[i] != 2:
                flag = False
        if flag == False:
            print(0)
            return
    print(pow(2, N//2, MOD))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19300
#include<iostream>
#include<algorithm>
using namespace std;
long long x[100][100], n, sum;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += min(x[i][j], x[j][i]);
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1236
n = int(input())

highest = 0
higher = 0
multiple = False


an = [0]*n

for i in range(n):
    t = an[i] = int(input())

    if  highest < t :
        higher = highest
        highest = t
        multiple = False

    elif highest == t:
        multiple = True

    elif higher < t:
        higher = t


if multiple:
    for _ in range(n):
        print(highest)

else:
    for a in an:
        print( highest if a != highest else higher )



Measured memory_bytes: 12508
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);

    static void solve() {
        int n = sc.nextInt();
        int[] data = new int[n];
        RSQ_RAQ rsq = new RSQ_RAQ(data);
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int cmd = sc.nextInt();
            if (cmd == 0) {
                int s = sc.nextInt() - 1;
                int t = sc.nextInt() - 1;
                int x = sc.nextInt();
                rsq.add(s, t + 1, x);
            } else if (cmd == 1) {
                int s = sc.nextInt() - 1;
                int t = sc.nextInt() - 1;
                System.out.println(rsq.query(s, t + 1));

            }
        }
    }

    static class RSQ_RAQ {
        long[] stAdd;
        long[] stSum;
        int n;

        public RSQ_RAQ(int[] data) {
            n = 1;
            while (n < data.length) {
                n *= 2;
            }
            stAdd = new long[2 * n - 1];
            stSum = new long[2 * n - 1];
            for (int i = 0, size = data.length; i < size; i++) {
                stSum[n - 1 + i] = data[i];
            }
            for (int i = n - 2; i >= 0; i--) {
                stSum[i] = stSum[2 * i + 1] + stSum[2 * i + 2];
            }
        }

        void add(int l, int r, int x) {
            add(l, r, x, 0, 0, n);
        }

        void add(int l, int r, int x, int k, int ll, int rr) {
            if (ll >= l && rr <= r) {
                stAdd[k] += x;
            } else if (ll >= r || rr <= l) {

            } else {
                stSum[k] += (Math.min(r, rr) - Math.max(l, ll)) * x;
                int mm = (ll + rr) / 2;
                add(l, r, x, 2 * k + 1, ll, mm);
                add(l, r, x, 2 * k + 2, mm, rr);
            }
        }

        long query(int l, int r) {
            return query(l, r, 0, 0, n);
        }

        long query(int l, int r, int k, int ll, int rr) {
            long ret;
            if (ll >= l && rr <= r) {
                ret = stSum[k] + (rr - ll) * stAdd[k];
            } else if (ll >= r || rr <= l) {
                ret = 0;
            } else {
                ret = (Math.min(r, rr) - Math.max(l, ll)) * stAdd[k];
                int mm = (ll + rr) / 2;
                ret += query(l, r, 2 * k + 1, ll, mm);
                ret += query(l, r, 2 * k + 2, mm, rr);
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        solve();
    }
}


Measured memory_bytes: 120160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main(){
    string s; cin>>s;
    if(s == "Sunny")
        OUT("Cloudy");
    else if(s == "Cloudy")
        OUT("Rainy");
    else if(s == "Rainy")
        OUT("Sunny");
}


Measured memory_bytes: 256
A,B,C,K = [int(x) for x in input().split()]

k = K
a = 0
b = 0
c = 0

if A <= k:
  a = A
  k -= a
else:
  a = k
  k = 0

if B <= k:
  b = B
  k -= b
else:
  b = k
  k = 0

if C <= k:
  c = C
  k -= C
else:
  c = k
  k = 0

print(a-c)

Measured memory_bytes: 9152
N,M = map(int,input().split(' '))
l = set([int(input()) for i in range(M)])

mod = 10**9+7
dp = {}
for i in range(N+1):
    dp[i] = 1
dp[1] = 0 if 1 in l else 1

for i in range(2,N+1):
    if i in l:
        dp[i] = 0
        continue
    else:
        dp[i] = dp[i-1]%mod + dp[i-2]%mod
        dp[i] = dp[i]%mod

print(dp[N]%mod)

Measured memory_bytes: 25228
#include <iostream>
#include <array>
#include <string>

using namespace std;

class Dice{

    private:
        array<int, 6> face;

        void moveNorth(){
            array<int, 6> face_copy;
            face_copy = face;
            face[0] = face_copy[1];
            face[1] = face_copy[5];
            face[4] = face_copy[0];
            face[5] = face_copy[4];

        }

        void moveSouth(){
            array<int, 6> face_copy;
            face_copy = face;
            face[0] = face_copy[4];
            face[1] = face_copy[0];
            face[4] = face_copy[5];
            face[5] = face_copy[1];
        }

        void moveWest(){
            array<int, 6> face_copy;
            face_copy = face;
            face[0] = face_copy[2];
            face[2] = face_copy[5];
            face[3] = face_copy[0];
            face[5] = face_copy[3];
        }

        void moveEast(){
            array<int, 6> face_copy;
            face_copy = face;
            face[0] = face_copy[3];
            face[2] = face_copy[0];
            face[3] = face_copy[5];
            face[5] = face_copy[2];
        }

    public:

        Dice(int face1, int face2, int face3, int face4, int face5, int face6){
            face[0] = face1;
            face[1] = face2;
            face[2] = face3;
            face[3] = face4;
            face[4] = face5;
            face[5] = face6;
        }

        void inputQuery(string q){
            int qsize = q.size();

            for(int i=0; i<qsize; i++){
                if(q[i]=='N'){
                    moveNorth();
                }else if(q[i]=='S'){
                    moveSouth();
                }else if(q[i]=='W'){
                    moveWest();
                }else if(q[i]=='E'){
                    moveEast();
                }
            }
            cout << face[0] << endl;
        }


};



int main(){
    
    int face1, face2, face3, face4, face5, face6;

    cin >> face1 >> face2 >> face3 >> face4 >> face5 >> face6;

    Dice d(face1, face2, face3, face4, face5, face6);

    string query;
    cin >> query;
    d.inputQuery(query);

    return 0;
}




Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

bool check(int x, int y, int z, int w){
	if((y==0 && z==2 && w==1) || (y==0 && z==1 && w==2) || (y==2 && z==0 && w==1) || (x==0 && z==2 && w==1) || (x==0 && y==2 && w==1))
		return false;
	return true;
}

int main(void){
	int n;
	cin>>n;
	ll dp[105][4][4][4];
	rep(i,105)rep(j,4)rep(k,4)rep(l,4)dp[i][j][k][l]=0;
	rep(i,4){
		rep(j,4){
			rep(k,4){
				if(check(3,i,j,k))dp[3][i][j][k]=1;
				else dp[3][i][j][k]=0;
			}
		}
	}

	for(int i=3;i<n;i++){
		rep(w,4){
			rep(x,4){
				rep(y,4){
					rep(z,4){
						if(check(x,y,z,w)){
							dp[i+1][y][z][w]+=dp[i][x][y][z];
							dp[i+1][y][z][w] = dp[i+1][y][z][w]%MAX;
						}
					}
				}
			}
		}
	}
	ll ans=0;
	rep(i,4)rep(j,4)rep(k,4)ans=(ans+dp[n][i][j][k])%MAX;
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main(){
    int x,y;
    set<int> st{1,3,5,7,8,10,12};
    cin >> x >> y;
    if(x==2&&y==2)  cout << "Yes\n";
    else if(x==2||y==2)     cout << "No\n";
    else if(st.find(x)==st.end()&&st.find(y)==st.end()) cout << "Yes\n";
    else if(st.find(x)!=st.end()&&st.find(y)!=st.end()) cout << "Yes\n";
    else    cout << "No\n";
}

Measured memory_bytes: 256
a = int(input())  # 500
b = int(input())  # 100
c = int(input())  # 50
x = int(input())  # objecive

counter = 0
for use_a in range(a + 1):
    if 500 * use_a > x:
        continue
    rest = x - 500 * use_a
    for use_b in range(b + 1):
        if 100 * use_b > rest:
            continue
        rest_c = rest - 100 * use_b
        for use_c in range(c + 1):
            if 50 * use_c != rest_c:
                continue
            counter += 1

print(counter)


Measured memory_bytes: 9040
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

long long gcd(long long x, long long y) {
	while (1) {
		if (x < y)swap(x, y);
		x %= y;
		if (x == 0)return y;
	}
}

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

	vector<long long> A(N),L(N),R(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			L[i] = A[i]; R[N-1] = A[N-1];
		}
		else {
			L[i] = gcd(A[i], L[i - 1]); 
			R[N - i - 1] = gcd(A[N - i - 1], R[N - i]);
		}
	}
	long long ans = R[1];
	for (int i = 1; i < N-1; i++) {
		ans = max(ans, gcd(L[i-1], R[i+1]));
	}
	ans=max(ans,L[N-2]);
	cout << ans << endl;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9

int gcd(int m, int n) {
  int temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

int main() {
  int N;
  cin >> N;
  
  int a;
  vector<int> A;
  A.reserve(N);
  for (int i = 0; i < N; i++) {
    cin >> a;
    A.emplace_back(a);
  }

  int t = A[0];
  for (int i = 1; i < N; i++) {
    t = gcd(t, A[i]);
  }
  cout << t << endl;
  
  return 0;
}

Measured memory_bytes: 640
path = []
for _ in range(3):
	a, b = map(int, input().split(" "))
	path.append([a,b])


a = [0, 0, 0, 0]
for line in path:
	for d in line:
		a[d - 1] += 1

if sorted(a) == [1,1,2,2]:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int a,b,c;
    int tmp;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        tmp = a;
        a = b;
        b = tmp;
    }
    if(a>c){
        tmp = a;
        a = c;
        c = tmp;
    }
    if(b>c){
        tmp = b;
        b = c;
        c = tmp;
    }
    printf("%d %d %d\n",a,b,c);
    
    
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
double EPS=1e-10;
double add(double a, double b)
{
	if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
	return a+b;
}
double x[3],y[3],X,Y;
bool input()
{
	for(int i=0;i<3;i++) cin >> x[i] >> y[i] ;
	if(cin.eof()) return false;
	cin >> X >> Y ;
	return true;
}
int main()
{
	while(input())
	{
		bool failed=false;
		for(int i=0;i<3;i++)
		{
			double dx=x[i]-X, dy=y[i]-Y;
			int cnt=0;
			double ext[2];
			for(int j=0;j<3;j++)
			{
				if(i==j) continue;
				double vx=x[j]-x[i],vy=y[j]-y[i];
				ext[cnt++]=add(dx*vy,-dy*vx);
			}
			if(ext[0]*ext[1]>=0) failed=true;
		}
		if(failed) cout << "NO" << '\n' ;
		else cout << "YES" << '\n' ;
	}
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> array(n+1);
  vector<int> box(n+1);
  for(int i=1;i<=n;i++){
    cin>>array[i];
  }
  int half=n/2;
  int sum=0;
  for(int i=n;i>half;i--){
    box[i]=array[i];
    sum+=box[i];
  }
  for(int i=half;i>0;i--){
    int num=n/i;
    int buf=0;
    for(int j=2;j<=num;j++){
      buf+=box[i*j];
    }
    buf+=array[i];
    buf=buf%2;
    box[i]=buf;
    sum+=box[i];
  }
  cout<<sum<<endl;
  if(sum!=0){
  for(int i=1;i<=n;i++){
    if(box[i]==1){
      cout<<i<<" ";
    }
  }
  cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define Inf 100000000000ll
#define MAXN 100000
#define ll long long
using namespace std;

int main() {
    string S;
    cin>>S;
    bool ok = false;
    for(int i=0;i<S.size();i++)
        for(int j=i+1;j<S.size();j++) {
            if (S[i]=='C' && S[j]=='F')
                ok=true;
        }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define ll long long
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
vector<int> e[MAXN+5], g[MAXN+5]; int A[MAXN+5], B[MAXN+5], fa[MAXN+5], rk[MAXN+5] ,o[MAXN+5], n, m; ll f[MAXN+5], s[MAXN+5];
inline bool cmp(int i, int j){return A[i]<A[j];} inline int getf(int x){return x^fa[x]?fa[x]=getf(fa[x]):x;}
ll DP(int p){for(auto v:g[p]) f[p] = min(f[p],max((ll)A[o[p]],DP(v))-s[v]), s[p] += s[v]; return f[p] += s[p];}
int main()
{
	n = read(); m = read(); for(rint i = 1; i <= n; A[i] = read(), B[i] = read(), A[i] = max(A[i]-B[i],0), fa[i] = o[i] = i, i++); sort(o+1,o+n+1,cmp);
	for(rint i = 1; i <= n; rk[o[i]] = i, f[i] = A[o[i]], s[i] = B[o[i]], i++); for(rint a, b; m--; a = rk[read()], b = rk[read()], e[a].push_back(b), e[b].push_back(a));
	for(rint u = 1, U, V; u <= n; u++) for(auto v:e[u]) v<u&&(V=getf(v))^(U=getf(u))?g[U].push_back(V),fa[V]=U:0; printf("%lld\n",DP(getf(1))); return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll INF = 1e15;
  ll n,m,l;
  cin >> n >> m >> l;
  vector<vector<vl>> edge(n);
  vector<vl> cost(n,vl(n,INF));
  REP(i,m){
    ll a,b,c;
    cin >> a >> b >> c;
    a--; b--;
    edge[a].push_back({b,c});
    edge[b].push_back({a,c});
    cost[a][b] = c;
    cost[b][a] = c;
  }
  vector<vector<vl>> dp(n+1,vector<vl>(n,vl(n)));
  REP(t,n+1){
    if(t==0){
      REP(i,n){
        REP(j,n){
          if(i==j) dp[t][i][j] = 0ll;
          else dp[t][i][j] = cost[i][j];
        }
      }
      continue;
    }
    REP(i,n){
      REP(j,n){
        dp[t][i][j] = min(dp[t-1][i][j],dp[t-1][i][t-1]+dp[t-1][t-1][j]);
      }
    }
  }
  //REP(i,n){
  //  REP(j,n) cout << dp[n][i][j] << ",";
  //  cout << endl;
  //}

  vector<vl> hokyu_cost(n,vl(n,INF));
  vector<vector<vl>> hokyu_dp(n+1,vector<vl>(n,vl(n)));
  REP(i,n){
    REP(j,n){
      if(dp[n][i][j]<=l) hokyu_cost[i][j] = 0;
      hokyu_dp[0][i][j] = hokyu_cost[i][j];
    }
  }
  REP(t,n){
    REP(i,n){
      REP(j,n){
        hokyu_dp[t+1][i][j] = min(hokyu_dp[t][i][j],hokyu_dp[t][i][t]+hokyu_dp[t][t][j]+1);
      }
    }
  }
  ll q;
  cin >> q;
  REP(i,q){
    ll a,b;
    cin >> a >> b;
    a--; b--;
    ll ans = hokyu_dp[n][a][b];
    if(ans>=INF) cout << -1 << endl;
    else cout << hokyu_dp[n][a][b] << endl;
  }

  return 0;
}


Measured memory_bytes: 439168
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  int count = 0;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
      count++;
    }
    else {
      count = 0;
      continue;
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
}

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

int N,L,T;
int X[100005];
int rnk;

int main(){
	scanf("%d%d%d",&N,&L,&T);
	for(int i=0;i<N;i++){
		int w;scanf("%d%d",&X[i],&w);
		if(w==1) X[i]+=T;else X[i]-=T;
		rnk+=X[i]/L;
		rnk-=(X[i]%L<0);
		X[i]=(X[i]%L+L)%L;
	}
	rnk=(rnk%N+N)%N;
	sort(X,X+N);
	for(int i=0;i<N;i++)
		printf("%d\n",X[(i+rnk)%N]);
}

Measured memory_bytes: 4136
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

l = []

kb = bin(k)
ll = [k]

for i in range(len(kb) - 2):
    if kb[i + 2] == '1':
        ll.append(int(kb[:i + 2] + '0' + '1' * (len(kb) - (i + 3)), 2))

for i in ll:
    ans = 0
    for j in range(n):
        if i == ab[j][0] | i:
            ans += ab[j][1]
        l.append(ans)

print(max(l))


Measured memory_bytes: 115068
#include <iostream>

using namespace std;

int a[100000];

int partition(int *a, int p, int r) {
    int x = a[r];
    int i = p;
    for (int j = p; j < r; ++j) {
        if (a[j] <= x)
            swap(a[i++], a[j]);
    }
    swap(a[i], a[r]);
    return i;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int j = partition(a, 0, n - 1);
    for (int i = 0; i < n; ++i) {
        if (i == j)
            cout << "[";
        cout << a[i];
        if (i == j)
            cout << "]";
        if (i < n - 1)
            cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3464
x1,y1,x2,y2 = map(int, input().split())
a = x2 - x1
b = y2 - y1
  

x3 = x2 - b
x4 = x1 - b
y3 = y2 + a
y4 = y1 + a

print("{} {} {} {}".format(x3, y3, x4, y4))

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>

#include <map>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <random>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}


int main() {
  ll H,W,N; cin >> H>>W>>N;
  V<V<int>> e(W+1);
  REP(i,N){
    int x,y;cin>>x>>y;
    e[y].push_back(x);
  }
  FOR(i,1,W+1){
    e[i].push_back(H+1);
    sort(ALL(e[i]));
  }
  int ans=500000;
  int x=1,y=1;
  while(y<W+1 && x<H+1){
    int z=*lower_bound(ALL(e[y]),x);
    if(x==z){
      x++;
      continue;
    }
    ans=min(ans,z-1);
    x++;
    y++;
  }
  print(ans);
	
	
	return 0;
}



Measured memory_bytes: 11392
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [int(x) for x in input().split()]
n, d = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
a = []
for x in range(n):
#  a.append(int(input()))
  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def count(c):
  r = b // c - (a - 1) // c;
  print(c, r, file=sys.stderr)
  return r

def doit():
  res = 0
  for x in range(n):
    for y in range(x+1, n):
      s = 0
      for p in range(d):
        print(a[x][p], a[y][p], file=sys.stderr), 
        s += (a[x][p] - a[y][p]) ** 2
      print(s, math.sqrt(s), file=sys.stderr)
      if math.sqrt(s) % 1 == 0:
        res += 1
  return res

#print(doit([0] * 4))
#doit(s)
#print(doit())
try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)


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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

int N;
int a[131072];
int dp[131072];
vvi c(131072);



int saiki(int p){
	if (c[p].empty()) return 0;
	vi b;
	for(int i=0;i<c[p].size();i++){
		b.pb(saiki(c[p][i]));
	}
	sort(b.begin(), b.end());
	int ret = 0;
	for(int i=0;i<b.size();i++){
		ret = max(ret, b[i]) + 1;
	}
	return ret;
}

int main(void){
	cin >> N;
	for(int i=1;i<N;i++){
		cin >> a[i];
		a[i]--;
	}
	
	for(int i=1;i<N;i++){
		c[a[i]].pb(i);
	}
	cout << saiki(0) << endl;
	return 0;
}


Measured memory_bytes: 14592
#include <cstdio>
#include <vector>
#include <stack>
using namespace std;

int N;
vector<vector<int>> edge;
vector<bool> visited;
vector<int> ps, path;
vector<int> color;

void dfs(int at)
{
    visited[at] = true;
    ps.push_back(at);
    if (at == N - 1) {
        path = vector<int>(begin(ps), end(ps));
        return;
    }
    for (int p : edge[at]) {
        if (!visited[p])
            dfs(p);
    }
    ps.pop_back();
}

void paint(int at, int c)
{
    color[at] = c;
    for (int p : edge[at]) {
        if (color[p] == 0) {
            paint(p, c);
        }
    }
}

int count(int at)
{
    visited[at] = true;
    int sum = color[at] == 1;
    for (int p : edge[at]) {
        if (!visited[p])
            sum += count(p);
    }

    return sum;
}

int main()
{
    scanf("%d", &N);
    edge = vector<vector<int>>(N, vector<int>());
    visited = vector<bool>(N, false);

    int a, b;
    for (int i = 0; i < N - 1; i++) {
        scanf("%d%d", &a, &b);
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    dfs(0);

    color = vector<int>(N, 0);
    for (int i = 0; i < ((path.size() + 1) >> 1); i++) {
        color[path[i]] = 1;
    }
    for (int i = 0; i < path.size() >> 1; i++) {
        color[path[path.size() - 1 - i]] = -1;
    }

    for (int i = 0; i < path.size(); i++) {
        paint(path[i], color[path[i]]);
    }

    visited = vector<bool>(N, false);
    if (count(0) > N >> 1)
        puts("Fennec");
    else
        puts("Snuke");
}

Measured memory_bytes: 13304
# -*- coding: utf-8 -*-

#----------
a,b = input().rstrip().split()
#----------

if (a == "H" and b == "H") or (a == "D" and b == "D"):
    print("H")

if (a == "H" and b == "D") or (a == "D" and b == "H"):
    print("D")


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll c, k;
	cin >> n >> c >> k;
	vector<ll> t(n);
	rep(i,n) cin >> t[i];
	sort(t.begin(), t.end());
	int ans = 0;
	ll cap = 0, bus_time = 0;
	rep(i,n){
		if(cap == 0){
			++ans;
			cap = c - 1;
			bus_time = t[i] + k;
		}
		else --cap;
		if(bus_time < t[i]){
			++ans;
			cap = c - 1;
			bus_time = t[i] + k;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

const int K=3000000;
int p[K];

void furui(){
   for(int i=0; i<K; i++) p[i]=1;
   p[0]=p[1]=0;
   for(int i=2; i*i<=K; i++){
      if(p[i]){
         for(int j=2; i*j<K; j++){
            p[i*j]=0;
         }
      }
   }
}

int main(){

   furui();
   while(1){

      int a, d, n;
      cin>> a>> d>> n;
      if(!(a||d||n)) break;

      int cnt=0;
      while(1){
         if(p[a]) cnt++;
         if(cnt==n) break;
         a+=d;
      }

      cout<< a<< endl;
   }

   return 0;
}

Measured memory_bytes: 14776
#include<bits/stdc++.h>
#define LL long long
#define vc vector<int>
#define db long double

using namespace std;
const int N=10000+10,M=(1<<16)+10,mod=998244353;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
int rdr[M],W[20],iW[20],pu[M],pv[M];
void ntt(int *a,int n,int op)
{
    int l=0,y;
    while(1<<l<n) ++l;
    for(int i=0;i<n;++i)
    {
	rdr[i]=(rdr[i>>1]>>1)|((i&1)<<(l-1));
	if(i<rdr[i]) swap(a[i],a[rdr[i]]);
    }
    for(int i=1,p=0;i<n;i<<=1,++p)
    {
	int ww=op?W[p]:iW[p];
	for(int j=0;j<n;j+=i<<1)
	    for(int k=0,w=1;k<i;++k,w=1ll*w*ww%mod)
	    {
		y=1ll*a[j+k+i]*w%mod;
		a[j+k+i]=(a[j+k]-y+mod)%mod;
		a[j+k]=(a[j+k]+y)%mod;
	    }
    }
    if(!op) for(int i=0,w=ginv(n);i<n;++i) a[i]=1ll*a[i]*w%mod;
}
void polymul(int *a,int nn,int *b,int mm,int *c)
{
    int len=1;
    while(len<nn+mm) len<<=1;
    if(!nn||!mm) return;
    memcpy(pu,a,sizeof(int)*nn),memcpy(pv,b,sizeof(int)*mm);
    memset(c,0,sizeof(int)*(nn+mm-1));
    if(1ll*nn*mm<=1ll*len*40)
    {
	for(int i=0;i<nn;++i)
	    for(int j=0;j<mm;++j)
		ad(c[i+j],1ll*pu[i]*pv[j]%mod);
    }
    else
    {
	ntt(pu,len,1),ntt(pv,len,1);
	for(int i=0;i<len;++i) pu[i]=1ll*pu[i]*pv[i]%mod;
	ntt(pu,len,0);
	memcpy(c,pu,sizeof(int)*(nn+mm-1));
    }
    memset(pu,0,sizeof(int)*len),memset(pv,0,sizeof(int)*len);
}
char cc[N],ss[N];
int fac[M],iac[M],aa[M],bb[M],n,m,a1,b1;

int main()
{       
    for(int i=1,p=0;p<=19;i<<=1,++p)
	W[p]=fpow(3,(mod-1)/(i<<1)),iW[p]=ginv(W[p]);
    fac[0]=1;
    for(int i=1;i<=M-5;++i) fac[i]=1ll*fac[i-1]*i%mod;
    iac[M-5]=ginv(fac[M-5]);
    for(int i=M-5;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
    scanf("%s%s",cc+1,ss+1);
    m=strlen(cc+1);
    for(int i=1;i<=m;++i)
    {
	if((cc[i]=='1')^(ss[i]=='1')) ++b1;
	else if(cc[i]=='1'&&ss[i]=='1') ++a1;
    }
    b1/=2,n=a1+b1;
    for(int i=1;i<=n;++i) bb[i]=iac[i];
    aa[0]=1;
    int rbb=b1;
    while(rbb)
    {
	if(rbb&1)
	{
	    polymul(aa,n+1,bb,n+1,aa);
	    for(int i=n+1;i<=n+n+2;++i) aa[i]=0;
	}
	polymul(bb,n+1,bb,n+1,bb);
	for(int i=n+1;i<=n+n+2;++i) bb[i]=0;
	rbb>>=1;
    }
    int ans=0;
    for(int i=0;i<=n;++i) ad(ans,aa[i]);
    ans=1ll*ans*fac[n]%mod*fac[a1]%mod*fac[b1]%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1280
//26
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int d[]={1,2,3,5,4,6};
    int ans=d[0];
    while(n--){
      string s;
      cin>>s;
      int t;
      switch(s[0]){
      case 'N':
	t=d[0];
	d[0]=d[1];
	d[1]=d[5];
	d[5]=d[3];
	d[3]=t;
	break;
      case 'E':
	t=d[0];
	d[0]=d[4];
	d[4]=d[5];
	d[5]=d[2];
	d[2]=t;
	break;
      case 'W':
	t=d[0];
	d[0]=d[2];
	d[2]=d[5];
	d[5]=d[4];
	d[4]=t;
	break;
      case 'S':
	t=d[0];
	d[0]=d[3];
	d[3]=d[5];
	d[5]=d[1];
	d[1]=t;
	break;
      case 'R':
	t=d[1];
	d[1]=d[2];
	d[2]=d[3];
	d[3]=d[4];
	d[4]=t;
	break;
      case 'L':
	t=d[1];
	d[1]=d[4];
	d[4]=d[3];
	d[3]=d[2];
	d[2]=t;
	break;
      }
      ans+=d[0];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
long long int a[105];
long long int gcd(long long int x,long long int y)
{
	long long int r=x%y;
	if(r==0)
	return y;
	else
	return gcd(y,r);
}
int main ()
{
	long long int n,i,s,u,v,m=1;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	s=a[0];
	for(i=1;i<n;i++)
	{
		m=gcd(a[i],s);
		s=a[i]/m*s;
	} 
	 printf("%lld\n",s);
	 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int n;
    cin >> n;
    vector< pair< pair<int, string >, int > >  v;
    int  m = 100000000;
    REP(i,n){
	string s;
	int a;
	cin >> s >> a;
	bool flg = true;
	REP(j,v.size()){
	    if(v[j].first == pair<int,string>((int)(s.length()),s)) {
		v[j].second -= a;
		flg = false;
	    }
	}
	if(flg)
	    v.PB( make_pair( make_pair(s.length(),s ),m-a));
    }
    sort(ALL(v));
    REP(i,v.size()) printf("%s %d\n",v[i].first.second.c_str(),m-v[i].second);
    return 0;
}

Measured memory_bytes: 1236
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))
p1 = len(list(filter(lambda x: x <= a, P)))
p2 = len(list(filter(lambda x: a+1 <= x <= b, P)))
p3 = len(list(filter(lambda x: x >= b+1, P)))
print(min(p1, p2, p3))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;

int par[MAX_N]; //親
int union_rank[MAX_N]; // 木の深さ

// n要素で初期化
void init(int n){
    for(int i=0; i<n; i++){
        par[i] = i;
        union_rank[i] = 0;
    }
}

// 木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

// xとyが属する集合を併合
void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x==y) return;
    if(union_rank[x] < union_rank[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(union_rank[x] == union_rank[y]) union_rank[x++];
    }
}

// xとyが同じ集合に属すか否か
bool same(int x, int y){
    return find(x) == find(y);
}

int main(){
    int n,m;
    cin >> n >> m;
    init(n);
    for(int i=0; i<m; i++){
        int x,y,z;
        cin >>  x >> y >> z;
        unite(x-1,y-1);
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(find(i) == i) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

signed main() {
	string s,t;
	cin>>s;
	cin>>t;

	vector<vector<ll>> s_position(26,vector<ll>());
	vector<ll> t_num(26,0);
	rep(i,s.size()){
		ll alphabet=s[i]-'a';
		s_position[alphabet].push_back(i);
	}
	rep(i,t.size()){
		ll alphabet=t[i]-'a';
		t_num[alphabet]++;
	}
	rep(i,26){
		if(s_position[i].size()==0 && t_num[i]>0){
			cout<<-1<<endl;
			return 0;
		}
	}

	ll ans=0;
	ll index=0;
	rep(i,t.size()){
		ll alphabet=t[i]-'a';
		auto it=lower_bound(s_position[alphabet].begin(), s_position[alphabet].end(), index);
		if(it!=s_position[alphabet].end()){
			ans+=*it-index+1;
			index=*it+1;
		}else{
			ans+=(s.size()-index)+(s_position[alphabet][0]+1);
			index=s_position[alphabet][0]+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;cin>>a>>b;
    cout << a*b << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define mkp make_pair
#define cerr if (0) cerr

const int INF = 1e18;

void solve() {
    double a, b;
    cin >> a >> b;
    cout << (ll)floor(a * b);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}


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

int main()
{
    int M, N;
    cin >> N >> M;
    if(N==M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,k;
long long C[2001][2001];
int main(){
    cin>>n>>k;
    for(int i=0;i<=2000;i++){
        C[i][0]=1;
        C[i][i]=1;
        for(int j=1;j<i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%1000000007;
    }
    for(int i=1;i<=k;i++){
        cout<<(C[n-k+1][i]*C[k-1][i-1])%1000000007<<endl;
    }
    return 0;
}

Measured memory_bytes: 30080
import math

a, b, c = map(float, input().split())
c = math.radians(c)

S = 0.5 * a * b * math.sin(c)
L = (a ** 2 + b ** 2 - 2 * a * b * math.cos(c)) ** 0.5 + a + b
h = S / a * 2

print(S)
print(L)
print(h)

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

int main(void){
	int N;
	cin >> N;
	int a[N];
	rep(i,N) cin >> a[i];
	int ans = 0;
	rep(i,N){
		if ((i+1)%2==1 && a[i]%2==1) ans++;
	}
	cout << ans << endl;

return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,A,B,i;
  cin >> K >> A >> B;
  for(i=A; i<=B; i++)
    if(i%K==0){
      cout << "OK";
      break;
    }else{
      if(i==B){
        cout << "NG";
      }
    }
}

Measured memory_bytes: 3632
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	a = sort(a)
	x=div(a[n]+1,2)
	s = x-a[1]
	sx = a[1]
	for i in 1:n-1
		if abs(a[i]-x)<s
			s = abs(a[i]-x)
			sx = a[i]
		end
	end
	println(a[n]," ",sx)
end

main()

Measured memory_bytes: 119996
from bisect import bisect_left, bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

summ = 0
for i in range(N):
    summ += bisect_left(A, B[i])*(N-bisect_right(C, B[i]))
print(summ)

Measured memory_bytes: 29192
"""
~~ Author : Bhaskar
~~ Dated : 10~06~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")
input = lambda : sys.stdin.readline()

def solve():
    n, k = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    a.sort()
    s = 0
    for i in range(k):
        s += a[i]
    print(s)


if __name__ == "__main__":
    try:
        sys.stdin = open('input.txt','r')
        sys.stdout = open('output.txt','w')
    except:
       pass
    solve()



Measured memory_bytes: 9584
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
using namespace std;
#define MAX_V 10240

// ?????¶???from????????¶???to????????????cost??????
typedef struct edge
{
	int to, distance, cost;
	edge(){}
	edge(int to, int distance, int cost) : to(to), distance(distance), cost(cost){}
};

// first ???????????????????????????second????????¶?????????
typedef pair<int, int> P;

// ???
vector<edge> G[MAX_V];

// ????????????
int d[MAX_V];
// V?????¶?????°
int V;

// ?±??§£?????¶???s????????°?????????????????????????????¶???????°???±?´????
void dijkstra(int s)
{
	priority_queue<P, vector<P>, greater<P> > que;
	memset(d, 0x3f, sizeof(d));
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.distance)
			{
				d[e.to] = d[v] + e.distance;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{

	int /*N = V,*/ M;
	while (cin >> V >> M && V)
	{
		for (int i = 0; i < V; ++i)
		{
			G[i].clear();
		}
		for (int i = 0; i < M; ++i)
		{
			int u, v, d, c;
			cin >> u >> v >> d >> c;
			--u, --v;
			G[u].push_back(edge(v, d, c));
			G[v].push_back(edge(u, d, c));
		}
		// ?????????0???
		dijkstra(0);
		int ans = 0;
		for (int i = 1; i < V; ++i)
		{
			int min_cost = 0x3f3f3f3f;
			// ??????????¶????????????????????????¶????´???¨???????????£??????????´???¨
			for (int j = 0; j < G[i].size(); ++j)
			{
				if (d[G[i][j].to] + G[i][j].distance == d[i] && G[i][j].cost < min_cost)
				{
					min_cost = G[i][j].cost;
				}
			}
			ans += min_cost;
		}
		cout << ans << endl;
	}

	return 0;
}
///////////////////////////End Sub//////////////////////////////////

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

int main(){
	long long n;
	std::cin>>n;

	std::vector<char> name;

	std::vector<long long> pow26;
	long long t= 26;

	while (t< 1000000000000001){
		pow26.push_back(t);
		t*=26;
	}


	while(n>0){
		n= n-1;

		int tmp= n%26;
		name.push_back(tmp+'a');

		n= n/26;
	}

	std::string ans;
	for(int i=0; i< name.size(); i++)
		ans+= name[name.size()- i- 1];

	std::cout<<ans<<std::endl;


	return 0;
}

Measured memory_bytes: 3620
import sys
while True:
    H,W=[int(i) for i in input().split(" ")]
    if H==0 and W==0:
        break
    Tiles=[]
    for i in range(H):
        Tiles.append(input())

    step=0

    x=0
    y=0
    while True:

        if Tiles[y][x]==">":
            x+=1
        elif Tiles[y][x]=="<":
            x-=1
        elif Tiles[y][x]=="^":
            y-=1
        elif Tiles[y][x]=="v":
            y+=1
        step+=1

        if Tiles[y][x]==".":
            print(x,y)
            break
        if step>H*W+5:
            print("LOOP")
            break



Measured memory_bytes: 5624
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<numeric>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

using namespace std;
using Int = long long;
using P = pair<Int, Int>;

Int H, W;
map<char, Int> name_num;

int main(){
    Int N;
    vector<string> names;

    cin >> N;

    name_num['M'] = 0;
    name_num['A'] = 0;
    name_num['R'] = 0;
    name_num['C'] = 0;
    name_num['H'] = 0;

    FOR(i, 0, N){
        string buf;
        cin >> buf;
        auto c = buf[0];
        if (c == 'M' || c == 'A' || c == 'R' ||
            c == 'C' || c == 'H'){
                name_num[c]++;
                names.push_back(buf);
            }
    }

    Int cnt = 0;
    cnt += name_num['M'] * name_num['A'] * name_num['R'];
    cnt += name_num['M'] * name_num['A'] * name_num['C'];
    cnt += name_num['M'] * name_num['A'] * name_num['H'];
    cnt += name_num['M'] * name_num['R'] * name_num['C'];
    cnt += name_num['M'] * name_num['R'] * name_num['H'];
    cnt += name_num['M'] * name_num['C'] * name_num['H'];

    cnt += name_num['A'] * name_num['R'] * name_num['C'];
    cnt += name_num['A'] * name_num['R'] * name_num['H'];
    cnt += name_num['A'] * name_num['C'] * name_num['H'];
    
    cnt += name_num['R'] * name_num['C'] * name_num['H'];

    COUT(cnt);
}

Measured memory_bytes: 5748
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <map>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for (int i = 0; i < (int)n; ++i)
#define loop1(i, n) for (int i = 1; i <= (int)n; ++i)
#define pb push_back
#define pi pair<int, int>
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define ti tuple<int, int, int, int>
#define mkt make_tuple
#define mkp make_pair
#define cerr if (1) cerr

void solve() {
    int a[10] = { 1, 1, 0, 2, 0, 0, 1, 0, 1, 0 };
    int n; cin >> n;
    cout << (a[n % 10] == 0 ? "hon" : (a[n % 10] == 1 ? "pon" : "bon"));
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3668