akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        LinkedList<Integer> as = new LinkedList<>(), bs = new LinkedList<>();
        HashSet<Integer> ain = new HashSet<>();

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            for (int j = s.length() - 2; j > 0; j--) {
                if (s.charAt(j - 1) == 'A' && s.charAt(j) == 'B') ans++;
            }
            if (s.charAt(0) == 'B') {
                if (s.charAt(s.length() - 1) == 'A') bs.addFirst(i);
                else bs.addLast(i);
            }
            if (s.charAt(s.length() - 1) == 'A') {
                if (s.charAt(0) == 'B') {
                    as.addLast(i);
                } else {
                    as.addFirst(i);
                }
                ain.add(i);
            }
        }
//        debug(ans, as, bs);

        boolean[] used = new boolean[n];
        if (!as.isEmpty()) {
            int i = as.removeFirst();
            while (!bs.isEmpty()) {
                if (ain.contains(i)) {
                    // nothing
                } else {
                    used[i] = true;
                    while (!as.isEmpty() && used[i]) i = as.removeFirst();
                    if (used[i]) break;
                }
                used[i] = true;
                while (!bs.isEmpty()) {
                    int j = bs.remove();
                    if (used[j]) continue;
//                debug(i, j);
                    i = j;
                    ans++;
                    break;
                }
            }
        }
        System.out.println(ans);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 33440
myCompare :: [Int] -> String
myCompare (a:b:_) =
    let com = a `compare` b
    in case com of
          EQ -> "a" ++ " == " ++ "b"
          LT -> "a" ++ " < " ++ "b"
          GT -> "a" ++ " > " ++ "b"

main = do
    line <- getLine
    putStrLn . myCompare . map read . words $ line

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

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

		Scanner scan = new Scanner(System.in);
		ArrayList<Double> array = new ArrayList<Double>();

		int n = scan.nextInt();
		double x = 0;
		double y = 0;

		for(int i = 0; i < n; i++) {
			array.add(scan.nextDouble());
			y += 1/array.get(i);/*逆数の総和*/
		}
		x = 1/y;
		System.out.println(x);
	}

}

Measured memory_bytes: 24276
import math
menu = [int(input()) for i in range(5)]
time = [0]*5
last = 0
num = 0
for i in range(5):
    time[i] = math.ceil(menu[i]/10)*10
    if time[i]-menu[i]>=last:
        last = time[i]-menu[i]
        num = i
    else:
        continue
print(sum(time)-time[num]+menu[num])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()

int main() {
    double a, b, x, theta;
    cin >> a >> b >> x;
    if (x > (a * a * b) / 2) {
        theta = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        theta = atan((a * b * b) / (2 * x));
    }

    double PI = 3.14159265358979;
    theta = theta * 180 / PI;
    cout << fixed << setprecision(10) << theta << endl;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

long long dp[110][100010];

int main(){

  int n, W; cin >> n >> W;
	long long w[n + 10], v[n + 10];

	for (int i = 0; i < n; i++)cin >> w[i] >> v[i];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= W; j++) {

			if (j  < w[i]) dp[i + 1][j] =  dp[i][j];
      else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);

		}
	}

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

  return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    st s ;
    lli cnt = 0 ;
    cin >> s ;
    loop(3)
        if(s[i] == '1')
            cnt++ ;

    cout << cnt ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

void koch(long double x0,long double y0,long double x1,long double y1,int d){
    if(d == 0){
        cout << x0 << ' ' << y0 << endl;
        if(x1 == 100.0 && y1 == 0){
            cout << x1 << ' ' << y1 << endl;
        }
    }
    else{
        long double xa = (x0*2.0+x1*1.0)/3.0;
        long double ya = (y0*2.0+y1*1.0)/3.0;
        long double vecx = (x1-x0)/3.0;
        long double vecy = (y1-y0)/3.0;
        long double midx = (x0+x1)*0.50;
        long double midy = (y0+y1)*0.50;
        long double xb = midx + vecy * (-sqrt(3.0)*0.50);
        long double yb = midy + vecx * ( sqrt(3.0)*0.50);
        long double xc = (x0*1.0+x1*2.0)/3.0;
        long double yc = (y0*1.0+y1*2.0)/3.0;
        
        koch(x0,y0,xa,ya,d-1);
        koch(xa,ya,xb,yb,d-1);
        koch(xb,yb,xc,yc,d-1);
        koch(xc,yc,x1,y1,d-1);
    }
}

int main(void){
    int n;
    cin >> n;
    koch(0.0,0.0,100.0,0.0,n);
    return 0;
}

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

int main() {
    array<tuple<int, int, int>, 2> birth;
    for(int i = 0; i < 2; ++i) {
        cin >> get<0>(birth[i]) >> get<1>(birth[i]) >> get<2>(birth[i]);
    }
    if(birth[0] > birth[1]) swap(birth[0], birth[1]);
    int ans = get<0>(birth[1]) - get<0>(birth[0]);
    if(make_pair(get<1>(birth[0]), get<2>(birth[0])) < make_pair(get<1>(birth[1]), get<2>(birth[1]))) {
        ans += 1;
    }
    cout << ans << endl;
}



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

int main() {
  string a,b;
  cin >> a >> b;
  if(islower(b.at(b.size() - 1)) && a == b.erase(b.size()-1)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
using namespace std;
int main() {
	vector<int>l;
	int n;
	while (cin >> n) {
		if (n == 0)break;
		int sum = 0;
		n = 1000 - n;
		if (n >= 100) {
			int a = n % 10;//1??????
			n -= a;
			n /= 10;
			int b = n % 10;//10??????
			n -= b;
			n /= 10;
			int c = n;//100??????
			if (a >= 5) {
				sum++;
				a -= 5;
			}
			sum += a;
			if (b >= 5) {
				sum++;
				b -= 5;
			}
			sum += b;
			if (c >= 5) {
				sum++;
				c -= 5;
			}
			sum += c;
		}
		else if (n >= 10){
			int a = n % 10;
			n -= a;
			n /= 10;
			int b = n;
			if (a >= 5) {
				sum++;
				a -= 5;
			}
			sum += a;
			if (b >= 5) {
				sum++;
				b -= 5;
			}
			sum += b;
		}
		else{
			if (n >= 5) {
				sum++;
				n -= 5;
			}
			sum += n;
		}
		l.push_back(sum);
	}
	for (int i : l) {
		cout << i << endl;
	}
}

Measured memory_bytes: 2992
#include <stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if (a < b)
	{
		printf("a < b\n");
	}
	else if (a>b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}
	


Measured memory_bytes: 2552
s = input()
front = int(s[:2])
back = int(s[2:])
if 0 < front < 13 and 0 < back < 13:
    ans = 'AMBIGUOUS'
elif 0 < front < 13:
    ans = 'MMYY'
elif 0 < back < 13:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

constexpr int64_t MOD = 1'000'000'007;

int64_t modinv(int64_t a) {
    int64_t b = MOD, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

int64_t gcd(int64_t a, int64_t b){
	return (b > 0)? gcd(b, a % b) : a ;
}

int64_t lcm(int64_t a, int64_t b){
	return (((a*b) % MOD) * (gcd(a, b) % MOD)) % MOD;
	// return a / gcd(a, b) * b;
}

// C++ program to compute LCM of array elements modulo M 
#define F first 
#define S second 
#define MAX 10000003 
using namespace std; 
  
typedef long long ll; 
const int mod = 1000000007; 
  
int prime[MAX]; 
unordered_map<int, int> max_map; 
  
// Function to return a^n 
int power(int a, int n) 
{ 
    if (n == 0) 
        return 1; 
    int p = power(a, n / 2) % mod; 
    p = (p * p) % mod; 
    if (n & 1) 
        p = (p * a) % mod; 
    return p; 
} 
  
// Function to find the smallest prime factors 
// of numbers upto MAX 
void sieve() 
{ 
    prime[0] = prime[1] = 1; 
    for (int i = 2; i < MAX; i++) { 
        if (prime[i] == 0) { 
            for (int j = i * 2; j < MAX; j += i) { 
                if (prime[j] == 0) { 
                    prime[j] = i; 
                } 
            } 
            prime[i] = i; 
        } 
    } 
} 
  
// Function to return the LCM modulo M 
ll lcmModuloM(const int* ar, int n) 
{ 
  
    for (int i = 0; i < n; i++) { 
        int num = ar[i]; 
        unordered_map<int, int> temp; 
  
        // Temp stores mapping of prime factor to 
        // its power for the current element 
        while (num > 1) { 
  
            // Factor is the smallest prime factor of num 
            int factor = prime[num]; 
  
            // Increase count of factor in temp 
            temp[factor]++; 
  
            // Reduce num by its prime factor 
            num /= factor; 
        } 
  
        for (auto it : temp) { 
  
            // Store the highest power of every prime 
            // found till now in a new map max_map 
            max_map[it.first] = max(max_map[it.first], it.second); 
        } 
    } 
  
    ll ans = 1; 
  
    for (auto it : max_map) { 
  
        // LCM is product of primes to their highest powers modulo M 
        ans = (ans * power(it.F, it.S)) % mod; 
    } 
  
    return ans; 
}

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

    int64_t inv = 0;
    int A[10000];
    for(int i=0; i<N; i++) {
        cin >> A[i];
        inv = (inv + modinv(A[i])) % MOD;
    }
    int64_t L = lcmModuloM(A, N);

    cout << (L*inv) % MOD << endl;;
    return 0;
}


Measured memory_bytes: 39808
num = int(input())

ls = []

for i in range(num):
    ls.append(True)

f = 3
z = 5

while f <= num:
    ls[f-1] = False
    f += 3

while z <= num :
    ls[z-1] = False
    z += 5

ans = 0

for i in range(num):
    if ls[i]:
        ans += i+1
    
print(ans)

Measured memory_bytes: 16952
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
int n,m,i,j,x;
map<int,int> cnt;
long long mx1,mx; 
string st;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>x;
		cnt[x]++;
	}
	for (map<int,int>::iterator it=cnt.begin();it!=cnt.end();it++)
	{
		if (it->second>=2)
		{
		 	if (mx<it->first)
			{
				 mx=it->first;
				 it->second-=2;
			} 
		}
		if (it->second>=2)
		{
		 	if (mx1<it->first)
			{
				 mx1=it->first;
				 it->second-=2;
			} 
		}
		if (mx>mx1) swap(mx,mx1);
	}
	cout<<mx*mx1;
	return 0;
}

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

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> l(n), r(n);
    rep(i,n) cin >> l[i] >> r[i];

    rep(i,n){
        ans += r[i] - l[i] + 1;
    }

    put(ans);
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
struct edge{ int to, time, cost; };
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;
const double infd = (double)1e+9;

int dat[10][10];

int main(){
	std::string s;
	while (std::cin >> s){
		rep(i, 10)dat[0][i] = s[i] - '0';
		REP(i, 1, 10){
			rep(j, 10 - i)dat[i][j] = (dat[i - 1][j] + dat[i - 1][j + 1]) % 10;
		}
		std::cout << dat[9][0] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){

  int  a;
  int ans;
  cin >> a;

  ans = 0;
  ans += a%10;
  a /= 10;
  ans += a%10;
  a  /= 10;
  ans += a;

  cout << ans << endl;


}


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

int main(){
	int n, z, w; cin >> n >> z >> w; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	if(n == 1){
		cout << abs(a[0] - w) << endl;
		return 0;
	}
	
	cout << std::max(std::abs(a[n - 1] - a[n - 2]), std::abs(a[n - 1] - w)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string S;
    cin >> S;
    int N = S.size();

    int kai2[10];
    kai2[0] = 1;
    for(int i=1;i<10;i++){
      kai2[i] = 2 * kai2[i-1];
    }
    int ans = 0;
    for(int i=0;i<N;i++){
      for(int j=1;j<=N;j++){
        if(i+j > N) break;
        string T = S.substr(i,j);
          int M = stol(T);
          ans += M * kai2[max((int)0,i-1)] * kai2[max((int)0,N-1-i-j)];
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	public void solve()
	{
		String s = next();
		if(s.charAt(s.length() - 1) == '?')
		{
			int sum = 0;
			for(int i = 0;i < s.length() - 1;i++)
			{
				int n = 11 - i;
				int q = 0;
				int p = s.charAt(i) - '0';
				if(n <= 6 && n >= 1)
				{
					q = n + 1;
				}else //if(n >= 7 && n <= 11)
				{
					q = n - 5; 
				}
				sum += q * p;
			}
			sum %= 11;
			if(sum <= 1)sum = 0;
			else sum = 11 - sum;
			out.println(sum);
		}else
		{
			int check = s.charAt(s.length() - 1) - '0';
			int cnt = 0;
			int ans = 0;
			for(int j = 0;j <= 9;j++)
			{
				int sum = 0;
				for(int i = 0;i < s.length() - 1;i++)
				{
					int n = 11 - i;
					int q = 0;
					int p = 0;
					if(s.charAt(i) == '?')
					{
						p = j;
					}else
					{
						p = s.charAt(i) - '0';
					}

					if(n <= 6 && n >= 1)
					{
						q = n + 1;
					}else //if(n >= 7 && n <= 11)
					{
						q = n - 5; 
					}
					sum += q * p;
				}
				sum %= 11;
				if(sum <= 1)sum = 0;
				else sum = 11 - sum;
				if(check == sum)
				{	
					cnt++;
					ans = j;
				}
			}
		if(cnt == 1)
		{
			out.println(ans);
		}else
		{
			out.println("MULTIPLE");
		}
	}
	}
	public static void main(String[] args)
	{
		out.flush();
		new Main().solve();
		out.close();
	}
	/*Input*/
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte()
	{
		if(p < buflen)return true;
		p = 0;
		try
		{
			buflen = in.read(buffer);
		}catch(IOException e)
		{
			e.printStackTrace();
		}
		if(buflen <= 0)return false;
		return true;
	}
	public boolean hasNext()
	{
		while(hasNextByte() && !isPrint(buffer[p]))
		{
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch)
	{
		if(ch >= '!' && ch <= '~')return true;
		return false;
	}
 
	private int nextByte()
	{
		if(!hasNextByte())return -1;
		return buffer[p++];
	}
 
	public String next()
	{
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while(isPrint((b = nextByte())))
		{
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt()
	{
		return Integer.parseInt(next());
	}
 
	public long nextLong()
	{
		return Long.parseLong(next());
	}
 
	public double nextDouble()
	{
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24528
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int N, K;
  cin >> N >> K;
  int ans=0;
  for(int ii=0; ii<N; ii++){
    int h;
    cin >> h;
    if(h>=K) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
struct UnionFind{
    vi data;
    UnionFind(int size):data(size,-1){}
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    vp vec(m);
    REP(i,m){
        cin>>vec[i].fi>>vec[i].se;
        vec[i].fi--;vec[i].se--;
    }
    int ans=0;
    REP(i,m){
        UnionFind uf(n);
        REP(j,m){
            if(i!=j){
                uf.unite(vec[j].fi,vec[j].se);
            }
        }
        if(uf.size(0)!=n){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int N, I, M;
string S;

int main(void){
	//IO("test.in", "test.out");
	cin >> N >> S;
	I = 0, M = 0;
	for(int i = 0 ; i < S.length(); i++){
		if(S[i] == 'I') I++;
		else if(S[i] == 'D') I--;
		if(I > M) M = I;
	}
	printf("%d\n", M);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    bool flag=true;
    for(int i=1;i<s.length();i++)
    if(s[i]==s[i-1])flag=false;
    if(flag)cout<<"Good";
    else
    cout<<"Bad";
    return 0;
}

Measured memory_bytes: 256
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
a, b, c, d = gi()
print(max(a * c, a * d, b * c, b * d))

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

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

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let kx: Vec<u32> = read_vec();
    if 500 * kx[0] >= kx[1] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<iostream>
//#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include <iomanip>
#include <set>
#include<cmath>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
#define int long long
#define mp make_pair
#define error(x) cout<<#x<<"="<<(x)<<endl;
void sp(double y,int x){cout<<fixed<<setprecision(x)<<y;}
int inf=5e18+10;
int const M=2e5+10;
int const M2=1e6+10;
int const M3=1e3+10;
int mod=1e9+7;
int x[M],y[M],n,k;
int dp[M3][M3];
int ans=inf;
void check(int x1,int y1,int x2,int y2)
{
    if(x1>x2)
        swap(x1,x2);
    if(y1>y2)
        swap(y1,y2);
    int tmp=0;
    for(int i=1;i<=n;i++)
    {
        if(x[i]<=x2 && x1<=x[i] && y[i]<=y2 && y1<=y[i])
            tmp++;
    }
    if(tmp>=k)
        ans=min(ans,(x2-x1)*(y2-y1));
}
int sa(int x,int y){if(x%y==0)return x/y;return x/y+1;}
int binp(int x,int y){int ans=1;int t=x;while(y!=0){if(y%2==1){ans*=t;ans;}y/=2;t*=t;t;}return ans;}
main(){
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)
    {
        cin>>x[i]>>y[i];
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                for(int l=1;l<=n;l++)
                {
                    check(x[i],y[j],x[k],y[l]);
                }
            }
        }
    }
    cout<<ans;
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  int n,i;cin>>n;vint w(n);
  for(i=0;i<n;i++){cin>>w[i];}
  //caricurate
  for(i=0;i<n-1;i++){w[i+1]+=w[i];} lint mi=INF;lint y;
  for(i=0;i<n;i++){
    y=abs((w[n-1]-w[i])-w[i]);
    if(mi>y){mi=y;}
  }
  //output
  cout<<mi<<endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
tmp = float(0)
#print (tmp)
if N<K:
	for i in range (1,N+1):
		#print(i)
		count = 1
		while(1):
			#print (count)
			if i*2**count < K:
				count += 1
			else:
				break
		tmp += float(1/N)*float(1/(2**count))
else:
	for i in range (1,K):
		#print(i)
		count = 1
		while(1):
			#print (count)
			if i*2**count < K:
				count += 1
			else:
				break
		tmp += float(1/N)*float(1/(2**count))
	tmp += float(N-K+1)*float(1/N)
print(tmp)

Measured memory_bytes: 3316
def is_over(L):
    for l in L:
        if l < X:
            return False
    return True


def dfs(i, c, A):
    if i == N:
        if is_over(A):
            global min_c
            min_c = min(min_c, c)
    else:
        dfs(i+1, c, A)
        next = [A[k]+B[i][1][k] for k in range(M)]
        dfs(i+1, c+B[i][0], next)


N, M, X = map(int, input().split())
B = []
S = [[0]*(M) for _ in range(N+1)]
for i in range(1, N+1):
    ipt = list(map(int, input().split()))
    A = ipt[1:]
    B.append((ipt[0], A))
    for j in range(M):
        S[i][j] = S[i-1][j] + A[j]
min_c = 10**10
if is_over(S[-1]):
    dfs(0, 0, [0]*M)
    print(min_c)
else:
    print(-1)

Measured memory_bytes: 9272
#include<bits/stdc++.h>
using namespace std;
int dfs(int i,int sum);
int n;
int c[39],v[29];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
  cout<<dfs(0,0)<<endl;
  return(0);
}

int dfs(int i,int sum){
  int rec;
  if(i==n)return sum;
  rec=dfs(i+1,sum);
  rec=max(rec,dfs(i+1,sum+v[i]-c[i]));
  return rec;
}


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

int main() {
  string S;
  cin >> S;
  
  if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2))
    cout << "Yes" << endl;
  else if (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0)!= S.at(1))
    cout << "Yes" << endl;
  else if (S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(1))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  long long n, k;
  cin >> n >> k ;
  vector<int> a(n);
  for(int j=0;j<n;j++){
    cin >> a[j];
  }
  
  vector<int> s;
  vector<int> ord(n+1, -1);
  int v = 1, c=1, l=0;
  while(ord[v] == -1){
    ord[v] = s.size();
    s.push_back(v);
    v = a[v-1];
  }
  c = s.size() - ord[v];
  l = ord[v];
  
  if(k < l) cout << s[k] << endl;
  else{
   k -= l;
   k %= c;
  cout << s[l + k] << endl;
  }
  
}


Measured memory_bytes: 5804
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define double long double
#define M_PI 3.14159265358979323846 
const int mod = 1e9 + 7;
#define MAXN   100001 

int32_t main()
{
    fastio;

    int n; cin >> n;
    unordered_map<int,int> mp;
    int arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
        mp[arr[i]]++;
    }

    vector<bool> v(1e6+5, true);
    for(auto x: mp){
        for(int j=2*x.first; j<=1e6+5; j+=x.first){
            v[j] = false;
        }
    }

    int ans = 0;
    for(int i=0; i<v.size(); i++){
        if(v[i] && mp[i] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

/*
2x + 4y= legs
x + y = total

*/

Measured memory_bytes: 44360
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
#define vv(name,a,b,c) vector<vector<int>>name(a,vector<int>(b,c))
using namespace std;
//ll MOD = 1e9 + 7;
ll MOD = 998244353;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
ll dp[300][300 * 300 + 1][4];
ll intpow(ll a, ll b) {
	ll res = 1;
	for (int i = 0; i < b; i++)res = res * a % MOD;
	return res % MOD;
}
int main() {
	cin >> N;
	vector<int>a(N, 0);
	for (int i = 0; i < N; i++)cin >> a[i];
	ll s = accumulate(a.begin(), a.end(), 0);
	for (int i = 0; i < N; i++)for (int j = 0; j <= s; j++)for (int c = 1; c <= 3; c++)dp[i][j][c] = 0;

	dp[0][a[0]][1] = 1;
	dp[0][0][1] = 2;

	for (int i = 1; i < N; i++) {
		for (int j = 0; j <= s; j++) {
			for (int c = 1; c <= 3; c++) {
				if (j == 0) {
					dp[i][j + a[i]][c + 1] += dp[i - 1][j][c] % MOD;
					dp[i][j][c + 1] += (2 - c) * dp[i - 1][j][c] % MOD;
					dp[i][j][c] += c * dp[i - 1][j][c] % MOD;
				}
				else {
					dp[i][j + a[i]][c] += dp[i - 1][j][c] % MOD;
					dp[i][j][c + 1] += (3 - c) * dp[i - 1][j][c] % MOD;
					dp[i][j][c] += (c - 1) * dp[i - 1][j][c] % MOD;
				}
			}
		}
	}
	for (int i = s / 2 + 1; i <= s; i++)ans += 3 * (dp[N - 1][i][3] + dp[N - 1][i][2] + dp[N - 1][i][1]) % MOD;
	if (s % 2 == 0)ans += 3 * dp[N - 1][s / 2][3] + 3 * dp[N - 1][s / 2][2] / 2;
	ans = (intpow(3, N) - ans)%MOD;
	cout << ((ans>=0)? ans : ans+MOD) << endl;
}


Measured memory_bytes: 844032
#include <iostream>
#include <vector>
#include <set>
#include <bitset>
#include <algorithm>
#include <map>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back

vector<vector<int> > G(100);
typedef bitset<100> bs;
map<bs, int> dp;

namespace std {
    bool operator<(const bs& a, const bs& b){
        rep(i, 100){
            if(a[i] != b[i]) return a[i] < b[i];
        }
        return false;
    }
}

int dfs(int v, bs vis){
    vis[v] = true;
    int res = 1;
    rep(i, G[v].size()){
        int to = G[v][i];
        if(!vis[to]){
            res = max(res, dfs(to, vis) + 1);
        }
    }
    return res;
}

int main(){
    int n;
    while(cin >> n, n){
        rep(i, 100) G[i].clear();
        rep(i, n){
            int a, b; cin >> a >> b;
            G[a - 1].push_back(b - 1);
            G[b - 1].push_back(a - 1);
        }
        bs init;
        int ans = 1;
        rep(i, 100){
            ans = max(dfs(i, init), ans);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1224
#include <stdio.h>

const long long inf = 1e18;

int n, W;
int w[110], v[110];
long long dp[100100];

long long min(long long a, long long b) {
    return (a < b ? a : b);
}

int main() {
    scanf("%d%d", &n, &W);
    for (int i = 0; i < n; i++) scanf("%d%d", &w[i], &v[i]);

    for (int i = 0; i <= 100000; i++) dp[i] = inf;
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 100000; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j - v[i]] + 1ll * w[i]);
        }
    }

    int ans = 0;
    for (int i = 0; i <= 100000; i++) {
        if (dp[i] <= W) ans = i;
    } 
    printf("%d\n", ans);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* coma = strchr(names + 1, ',');cerr.write(names, coma - names) << " : " << arg1<<" | ";__f(coma+1, args...);
}
#else
#define trace(...)
#endif
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

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

int N, k;

std::vector<int> dp(100005, INT_MAX), h;

int main(int argc, char const *argv[])
{
    // file();
    fast();

    cin>>N>>k;
    
    h.resize(N);
    
    for (int i = 0; i < N; ++i)
    {
        cin>>h[i];
    }
    
    dp[0] = 0;

    for (int i = 0; i < N; ++i)
    {
        for (int j = 1; j <= min(k, N - i); ++j)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout<<dp[N - 1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

int sToInt(string s) {
    int ret = 0;
    int sign = 1;

    int i = 0;
    if (s[0] == '-') {
        i++;
        sign = -1;
    }

    while (i < s.size()) {
        ret *= 10;
        ret += s[i] - '0';
        i++;
    }

    return ret * sign;
}

void solve(int N) {
    const int INF = 1e12;
    V a(N + 2);
    a[0] = INF;
    a[N + 1] = ((N + 1) % 2 ? -1 : 1) * INF;
    V dead(N + 2, false);
    bool exist_x = false;

    rep2(i, 1, N + 1) {
        string s;
        cin >> s;
        if (s[0] == 'x') {
            dead[i] = true;
            exist_x = true;
        } else {
            a[i] = sToInt(s);
        }
    }

    // rep(i, a.size()) cout << a[i] << " ";
    // cout << endl;
    // rep(i, dead.size()) cout << dead[i] << " ";
    // cout << endl;

    rep2(i, 1, N + 1) {
        if (!dead[i] && !dead[i + 1]) {
            if (i % 2 == 1 && !(a[i] < a[i + 1])) {
                cout << "none" << endl;
                return;
            }
            if (i % 2 == 0 && !(a[i] > a[i + 1])) {
                cout << "none" << endl;
                return;
            }
        }
        if (dead[i] && dead[i + 1]) {
            cout << "none" << endl;
            return;
        }
    }

    if (!exist_x) {
        cout << "ambiguous" << endl;
        return;
    }

    int lb = -INF;
    int ub = INF;
    rep2(i, 1, N + 1) {
        if (dead[i]) {
            if (i % 2 == 1) {
                ub = min(ub, a[i - 1] - 1);
                ub = min(ub, a[i + 1] - 1);
            }
            else {
                lb = max(lb, a[i - 1] + 1);
                lb = max(lb, a[i + 1] + 1);
            }
        }
    }
    // cout << "lb = " << lb << ", ub = " << ub << endl;

    if (lb == ub)       cout << lb << endl;
    else if (lb > ub)   cout << "none" << endl;
    else                cout << "ambiguous" << endl;

}


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

    int N;
    while (cin >> N, N) {
        solve(N);
    }
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,Q; cin >> N >> Q;
	vector<int> A(N),X(Q),s(Q);
	repp(i,0,N) cin >> A[i];
	repp(i,0,Q){
		cin >> X[i];
		s[i] = i;
	}
	sort(s.begin(),s.end(),[&](const int &a, const int &b){return X[a] < X[b];});
	vector<LL> ans(Q);
	LL z = A[N-1];
	for(int i = N-3 ; i >= 0 ; i -= 2) z += A[i];
	int k = 1;
	repm(i,Q-1,-1){
		while(N-2*k-1 >= 0 && 2*X[s[i]] <= A[N-2*k-1]+A[N-k-1]){
			++k;
			z += A[N-k] - A[N-2*k+1];
		}
		ans[s[i]] = z;
	}
	repp(i,0,Q) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
        int[] p = new int[n], index = new int[3];
        int i = 0, j = 0, flag = 0;
        while(i<n){
            p[i] = scan.nextInt();
            if(flag<=2&&p[i]!=i+1){
                flag++;
                index[j] = i;
                j++;
            }
            i++;
        }
        if(flag==0)
            System.out.println("YES");
        else if(flag>2)
            System.out.println("NO");
        else{
            if(p[index[0]]==index[1]+1)
                System.out.println("YES");
            else
                System.out.println("NO");
        }
	}
}

Measured memory_bytes: 35672
n = int(input())
ss = []
tt = []
for _ in range(n):
    s,t = input().split()
    ss.append(s)
    tt.append(int(t))
x = input()

for i in range(n):
    if ss[i] == x:
        ans = sum(tt[i+1:])
        break

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0) dump("Even") else dump("Odd")
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n;
    cin >> n;
    vint a(n);
    map<int,int > m;
    REP(i,n){
        cin >> a[i];
        m[a[i]]++;
    }
    for(map<int,int >::iterator i=m.begin(); i!=m.end(); ++i){
        if(i->second>=2){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 10368
N, Q = map(int, input().split())
S = input()
X = [list(map(int, input().split())) for _ in range(Q)]

cnt = [0] * (N + 1)
for i in range(N - 1):
    cnt[i + 1] = int(S[i] == "A" and S[i + 1] == "C") + cnt[i]

for l, r in X:
    print(cnt[r - 1] - cnt[l - 1])


Measured memory_bytes: 69080
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<s64, s64>;
using PP = pair<P, int>;
const s64 inf = 1e18;
int n;
s64 l;
vector< vector<P> > g;

void dijkstra(int u, vs64& cnt)
{
    cnt[u] = 0;
    vs64 lit(n, 0);
    lit[u] = l;
    priority_queue<PP, vector<PP>, greater<PP>> pq;
    pq.push(PP{P{0, -l}, u});
    while (!pq.empty())
    {
        auto dgv = pq.top(); pq.pop();
        s64 num = dgv.first.first;
        s64 gas = -dgv.first.second;
        s64 from = dgv.second;
        if (cnt[from] != num) continue;
        if (lit[from] > gas) continue;
        for (const auto& e : g[from])
        {
            s64 to = e.first;
            s64 cost = e.second;
            s64 remain;
            if (gas - cost < 0)
            {
                remain = l - cost;
                if (cnt[to] > num + 1 || (cnt[to] == num + 1 && lit[to] < remain))
                {
                    cnt[to] = num + 1;
                    lit[to] = remain;
                    pq.push(PP{P{cnt[to], -remain}, to});
                }
            }
            else
            {
                remain = gas - cost;
                if (cnt[to] > num || (cnt[to] == num && lit[to] < remain))
                {
                    cnt[to] = num;
                    lit[to] = remain;
                    pq.push(PP{P{cnt[to], -remain}, to});
                }
            }
        }
    }
}

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

    int m;
    cin >> n >> m >> l;

    g.resize(n);
    vector< vs64 > cnt(n, vs64(n, inf));

    rep (i, m)
    {
        int a, b;
        s64 c;
        cin >> a >> b >> c;
        --a, --b;
        if (c <= l)
        {
            g[a].emplace_back(b, c);
            g[b].emplace_back(a, c);
        }
    }

    rep (i, n)
    {
        dijkstra(i, cnt[i]);
    }

    int q;
    cin >> q;
    while (q--)
    {
        int s, t;
        cin >> s >> t;
        --s, --t;
        if (cnt[s][t] == inf) cout << "-1\n";
        else cout << cnt[s][t] << "\n";
    }

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<ll> vi;

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

	ll A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	if(T*(V-W) >= abs(A-B)) cout << "YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 3688
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	ll N, X, M;
	cin >> N >> X >> M;
	vector<ll> A(1, X);
	vector<int> seen_idx(M, -1);
	seen_idx[X] = 0;
	ll lst = X;
	int cycle_idx;
	for (;;){
		lst = lst * lst % M;
		if (seen_idx[lst] >= 0){
			cycle_idx = seen_idx[lst];
			break;
		}
		seen_idx[lst] = A.size();
		A.push_back(lst);
	}

	ll res = 0;

	if (N <= cycle_idx){
		for (int i = 0; i < N; ++i)
			res += A[i];
		cout << res << endl;
		return 0;
	}

	ll cycle_sum = 0;
	int cycle_size = A.size() - cycle_idx;
	for (int i = cycle_idx; i < A.size(); ++i)
		cycle_sum += A[i];
	for (int i = 0; i < cycle_idx; ++i)
		res += A[i];
	N -= cycle_idx;
	res += cycle_sum * (N / cycle_size);
	N %= cycle_size;
	for (int i = 0; i < N; ++i)
		res += A[cycle_idx + i];

	cout << res << endl;


	return 0;
}

Measured memory_bytes: 4312
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, d, n, k, x;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";

    cin  >> n;
    ll p[20];

    rep(i, n) cin >> p[i];

    rep(i, n-2){
        if(p[i] < p[i+1] && p[i+1] < p[i+2]) ans++;
        else if(p[i] > p[i+1] && p[i+1] > p[i+2]) ans++;
    }



    std::cout << ans << endl; 
    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define  pb(x) push_back(x)
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n,m;
	cin>>n>>m;
	multiset<pair<ll,ll> >ms;
	set<ll>days;
	for(ll i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		if(x<=m)
		{
			ms.insert({y,-x});
		}
	}
	for(ll i=1;i<=m;i++)
	days.insert(i);
	ll ans=0;
	multiset<pair<ll,ll> >::iterator it;
	set<ll>::iterator day;
	while(days.size()>0&&ms.size()>0)
	{
		it=ms.end();
		it--;
		ll val=-(it->second);
		day=days.lower_bound(val);
		if(day!=days.end())
		{
			ans+=it->first;
			days.erase(day);
		}
		ms.erase(it);
	}
	cout<<ans;
}
	


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
using namespace std;

int main(){
  int x,y; cin >>x>> y;
  cout << x + y/2 << endl;
}

Measured memory_bytes: 256
N = int(input())
color = list(map(str,input().split()))

pp = 0
wp = 0
gp = 0
yp = 0


for i in range(N):
    if color[i] == 'P' and pp == 0:
        pp += 1
    if color[i] == 'W' and wp == 0:
        wp += 1
    if color[i] == 'G' and gp == 0:
        gp += 1
    if color[i] == 'Y' and yp == 0:
        yp += 1

if (pp + wp + gp + yp) == 3:
    print('Three')
else:
    print('Four')


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

typedef long long ll;
typedef long double ld;
#define res register

const int INF=0x3f3f3f3f;

template<typename T>
inline T read(){
	char ch=getchar();T s=0;int f=1;
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=(s<<1)+(s<<3)+(ch^48);ch=getchar();}
	return s*f;
}
int main() {
	int x = read<int>();
	for (ll i = -2000; i <= 2000; ++i) {
		for (ll j = -2000; j <= 2000; ++j) {
			if (i*i*i*i*i - j*j*j*j*j == x) {
				printf("%lld %lld\n", i, j);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3788