akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
graph = [[] for _ in range(N+1)]  # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

MOD = 10 ** 9 + 7

def perm(n,k):
    if k > n or k < 0: return 0
    return fact[n] * fact_inv[n-k] % MOD

def cmb(n, k):
    if k < 0 or k > n: return 0
    return fact[n] * fact_inv[k] % MOD * fact_inv[n-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 10 ** 6  # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)
#print(answer % MOD)
# np.int64とint型の違いに注意
answer = 1
root = 1
parent = [0] * (N+1)
order = []
stack = [root]
answer = K * perm(K-1, len(graph[root])) % MOD
while stack:
    cur = stack.pop()
    order.append(cur)
    if cur != 1:
        answer *= perm(K-2, len(graph[cur])-1)
        answer %= MOD
    for next in graph[cur]:
        if next == parent[cur]:
            continue
        parent[next] = cur
        stack.append(next)

print(answer%MOD)


Measured memory_bytes: 76244
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int a, L;
  while(scanf("%d%d", &a, &L) != EOF && L) {
    map<int, int> M; // (a_i, i)
    int i=0;
    while (M.count(a) == 0) {
      M.insert(make_pair(a, i));
      i++;
      string S = to_string(a); // C++11追加要素
      S += string(L - S.size(), '0'); // 0を付け加えてL桁に。
      sort(S.begin(), S.end());
      int min = stoi(S);
      reverse(S.begin(), S.end());
      int max = stoi(S);
      a = max - min;
      // cerr << "max=" << max << ", min=" << min << ", a=" << a << endl;
    }
    printf("%d %d %d\n", M[a], a, i-M[a]);
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  while (k--) {
    if (b <= a) {
      b *= 2;
      continue;
    }
    if (c <= b) {
      c *= 2;
      continue;
    }
    break;
  }
  cout << (a < b && b < c ? "Yes" : "No") << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const ll MAXN = 15e3;
long long nthRoot(ll A, int N) 
{ 
 return pow(A,1/(double)N);
} 
int main() {
    
ios::sync_with_stdio(0);
cin.tie(0);

ll x;
cin >> x;
ll Ans = 0;

for(int i = 0 ; i <= MAXN ; i++)
{
    ll w = (x + pow(i,5));
    ll w1 = (x - pow(i,5));
    ll p1 = nthRoot(w,5);
    ll p2 = nthRoot(w1,5);
    if(pow(p1,5) == w)
    {
        
     cout << p1 << ' ' << i ;
     break;
    }
    
      if(pow(p2,5) == w1)
    {
        
     cout << p2 << ' ' << -i ;
     break;
    }
    
    
}
    
    
}

Measured memory_bytes: 4116
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

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

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

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

ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n,h[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i];
	int r=0;
	for (int i=1;i<n-1;++i) r+=(h[i]<max(h[i-1],h[i+1]) && h[i]>min(h[i+1],h[i-1]));
	cout<<r;
}




Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		//
		int matches = 0;
		int taro_points = 0;
		int hanako_points = 0;
		// 対戦者達
		String[] players = { "太郎", "花子" };
		// 標準入力
		Scanner sc = new Scanner(System.in);
		//
		ArrayList<player> players_beans = null;

		// 対戦回数
		while (sc.hasNext()) {

			matches = sc.nextInt();
			break;
		}

		// 対戦回数分まわす
		for (int m = 0; m < matches; m++) {

			// カードを入れるリスト
			ArrayList<String> battle = new ArrayList<String>();
			// 対戦者達のインスタンスを入れるリスト
			players_beans = new ArrayList<player>();

			while (sc.hasNext()) {
				// 対戦者達のインスタンスを作る
				for (String val : players) {
					player obj = new player();
					obj.setName(val);
					obj.setCard(sc.next());
					players_beans.add(obj);
					// アルファベット順にソートするためにリストに入れる
					battle.add(obj.getCard());
				}

				// アルファベット順にソート
				Collections.sort(battle);

				// 引き分けの場合
				if (players_beans.get(0).getCard()
						.equals(players_beans.get(1).getCard())) {
					players_beans.get(0).setPoints(1);
					players_beans.get(1).setPoints(1);
				}

				// 太郎が勝つ場合
				else if (battle.get(0).equals(players_beans.get(1).getCard())) {
					players_beans.get(0).setPoints(3);
				}

				// 花子が勝つ場合
				else if (battle.get(0).equals(players_beans.get(0).getCard())) {
					players_beans.get(1).setPoints(3);
				}

				taro_points = taro_points + players_beans.get(0).getPoints();
				hanako_points = hanako_points
						+ players_beans.get(1).getPoints();

				break;
			}
		}

		// 出力
		System.out.println(taro_points + " " + hanako_points);
	}
}

// 各プレイヤーのプロパティ
class player {

	//
	private String name = "";
	private String card = "";
	private int points = 0;

	// セッター
	public void setName(String n) {
		name = n;
	}

	public void setCard(String c) {
		card = c;
	}

	// 合計値を持つようにする
	public void setPoints(int p) {
		points += p;
	}

	// ゲッター
	public String getName() {
		return name;
	}

	public String getCard() {
		return card;
	}

	public int getPoints() {
		return points;
	}

}

Measured memory_bytes: 23104
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  pair<pair<string,int>,int> P[N];
  for(int i=0;i<N;i++){
    cin>>P[i].first.first>>P[i].first.second;
    P[i].first.second*=-1;
    P[i].second=i+1;
  }
  sort(P,P+N);
  
  for(int i=0;i<N;i++){
    cout<<P[i].second<<endl;
  }
}

Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	int l[1005];
	int r[1005];
	for(int i=0;i<n;i++){
		cin >> l[i] >> r[i];
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		ans = ans + (r[i]-l[i]+1);
	}
	cout << ans << endl;
	return 0;
}

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

    # divisors.sort()
    return divisors

N = int(input())
print(len(str(make_divisors(N)[-1])))

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

int main(){
    int n;
    cin >> n;
    vector<int> ans;
    while (n!=0){
        int d;
        //cout << "N" << n;
        if(n>0){
            d=n%2;
            n=-(n/2);
        }
        else{
            d=(-n)%2;
            n=(-n+1)/2;
        }
        //cout << "d" << d << "n" << n << endl;
        ans.push_back(d);
    }
    reverse(ans.begin(), ans.end());
    if(ans.size() == 0){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0; i<ans.size(); i++){
        cout << ans.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3608
///In the name of Almighty Allah(swt).

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    string s;
    cin>>s;
    ll sum=0,i,m;
    for(i=0; i<s.size(); i++){
        m = s[i]-48;
        sum += m;
    }

    if(sum % 9 ==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM 1000000000;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 1000000005
#define NIL -1
ll mod = 1e9+7;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(){
    ll x; cin >> x;
    cout << 1 + (x-1)*2/11 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <array>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <array>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
typedef pair<long long int, long long int> ii;
typedef vector<long long int> vi;
typedef vector<ii> vii;
#define INF 100000000
       
#define endl '\n'
#define MOD 1000000007
// #define INF 1ll<<30
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long fact(long a)
// {
//     if(a<=1)
//         return 1;
//     long ans = 1;
//     for(long i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long double ncr(long double a,long double b)
// {
//     long double  pans=1;
//     for(long double i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long double div = fact(min(b,a-b));
//     pans = pans/div;
//     return pans;
// }

int n;
long long int solved[506][506];
long long int solve(int rem,int lastsize)
{
    long long int ans = 0;
    if(rem==0)
        return 1;
    else if(rem<=lastsize)
        return 0;
    if(solved[rem][lastsize]!=-1)
        return solved[rem][lastsize];
    else
    {
        for(int i=lastsize+1;i<=rem;i++)
        {
            ans+=solve(rem-i,i);
        }
        return solved[rem][lastsize] = ans;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(1);
    cout<<fixed;

#ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
#endif
    string a;
    cin>>a;
    for(int i=0;i<a.length()-8;i++)
        cout<<a[i];
#ifndef ONLINE_JUDGE
   cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

typedef pair<ll,ll> P;

int main(){
  ll n,m; cin >> n >> m;
  priority_queue<P, vector<P>, less<P>> ba;
  REP(i,n){
    ll a, b; cin >> a >> b;
    ba.push({b,a});
  }

  ll ans = 0;
  set<ll> rem;
  FOR(i,1,m+1) rem.insert(i);
  while(!ba.empty()){
    P p = ba.top();
    ba.pop();
    ll b = p.first;
    ll a = p.second;

    auto it = rem.lower_bound(a);
    if(it==rem.end()) continue;
    rem.erase(it);
    ans += b;

  }
  cout << ans << endl;
}


Measured memory_bytes: 6512
w, h, n = map(int, input().split())
p, q = 0, 0
for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        p = max(x, p)
    elif a == 2:
        w = min(x, w)
    elif a == 3:
        q = max(y, q)
    else:
        h = min(y, h)

if w - p >= 0 and h - q >= 0:
    print((w - p) * (h - q))
else:
    print(0)

Measured memory_bytes: 3064
while s = gets do
    a = s.split.map(&:to_i)
    b = gets.split.map(&:to_i)
    hit = 0
    blow = 0
    0.upto(3) do |i|
        0.upto(3) do |j|
            (i == j ? hit += 1 : blow += 1) if a[i] == b[j]
        end
    end
    printf("%d %d\n", hit, blow)
end

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

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int X, Y;
    cin >> X >> Y;
    cout << X + Y/2 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
  char in;
  while(1){
    scanf("%c",&in);
    if(in >= 'A' && in <= 'Z') in += 32;
    else if(in >= 'a' && in <= 'z') in -= 32;
    if(in == '\n') break;
    printf("%c",in);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2548
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int dp[101][101],p[101];

int main(){
	int i,n,j,k,l;
	cin >> n;
	for( i = 0; i < n; i++ ){
        cin >> p[i] >> p[i+1];
	}
	for( i = 1; i <= n; i++ ) dp[i][i] = 0;
	for( l = 2; l <= n; l++ ){
        for( i = 1; i <= n-l+1; i++ ){
            j = i+l-1;
            dp[i][j] = (1 << 21);
            for( k = i; k <= j-1; k++ ){
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
	}
	cout << dp[1][n] << endl;
}



Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define f first
#define s second

const int k = 15;
int n;
long long p[k];

void init(){
	p[0] = 1;
	for(int i = 1; i < k; i++) p[i] = 3 * p[i - 1];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	init();
	
	cin >> n;
	
	for(int d = 0;;d++)
	for(int x = 1; x < 10; x++)
	for(long long j = 0; j < p[d]; j++){
		long long ret = x;
		int t = 1;
		for(int i = d - 1, s = x; i >= 0; i--){
			s += ((j / p[i]) % 3) - 1;
			if(s < 0 || s >= 10) t = 0;
			ret = 10 * ret + s;
		}
		n -= t;
		if(!n){
			cout << ret << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
//package beginner176;

import java.util.Scanner;

public class Main {


    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int X = in.nextInt();
        int T = in.nextInt();
        int cnt = N / X;
        if(N % X != 0){
            cnt++;
        }
        System.out.println(cnt * T);
    }
}


Measured memory_bytes: 35604
#include <algorithm>
#include <cstdio>
const int MAXN = 2e5+5;
char S[MAXN];
int N;

bool is_white(char c) { return (c == '.'); }

int main() {
  scanf(" %d%s", &N, S);
  int cnt = std::count_if(S, S+N, is_white);
  int ret = cnt;
  for (int i = 0; i < N; ++i) {
    if (is_white(S[i])) {
      --cnt;
    } else {
      ++cnt;
    }
    ret = std::min(cnt, ret);
  }
  printf("%d\n", ret);
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(){
 
    string s;
    
    cin >> s;
    
    s[5] = ' ';
        
    s[13] = ' '; 
    
    cout << s <<endl;

    
    
    return 0;

}

Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
	public static void Main()
	{
		char[] right = {'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};
		while (true)
		{
			var s = Console.ReadLine();
			if (s == "#")
			{
				return;
			}
			int changed = 0;
			for (int i = 1; i < s.Length; i++)
			{
				changed += right.Count(item => item == s[i])
					^ right.Count(item => item == s[i - 1]);
			}
			Console.WriteLine(changed);
		}
	}
}

Measured memory_bytes: 9592
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;
int main(){
  long long x,y,z,k;cin>>x>>y>>z>>k;
  long long a[x],b[y],c[z];
  long long i,j,l;
  for(i=0;i<x;i++){
    cin>>a[i];
  }
  for(i=0;i<y;i++){
    cin>>b[i];
  }
  for(i=0;i<z;i++){
    cin>>c[i];
  }

  sort(a,a+x);
  sort(b,b+y);
  sort(c,c+z);

  long long tmp[x*y];

  for(i=0;i<x;i++){
    for(j=0;j<y;j++){
        tmp[i*y+j]=a[i]+b[j];
    }
  }

  sort(tmp,tmp+x*y,greater<long long>());

  long long xy=min(x*y,k);
  long long t[xy];
  for(i=0;i<xy;i++){
    t[i]=tmp[i];
  }

  long long ans[xy*z];

  for(i=0;i<xy;i++){
    for(j=0;j<z;j++){
      ans[i*z+j]=t[i]+c[j];
    }
  }

  sort(ans,ans+xy*z,greater<long long>());

  for(i=0;i<k;i++){
    cout<<ans[i]<<endl;
  }


}


Measured memory_bytes: 31616
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int m;
	cin >> m;

	vector<int> b(m);
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	println((lexicographical_compare(all(a), all(b)) ? 1 : 0));
}


Measured memory_bytes: 3132
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }


/*

ビットDP


x[m]: ビットマップmで表されるうさぎたちがなすグループの得点

m = (1<<i) | m' であるとき
x[m] = x[m'] + sum(j; (1<<i) & j)(a[i, j])


y[m]: ビットマップmで表されるうさぎたちを最適にグループ分けしたときの得点


y[m] = max(x[m], max(m'; m' subsetof m)(y[m'] + y[m - m']))
※subsetof は、 m - m' == m ^ m' として実装できる

これは(2^16)×(2^16)なのでオーダー的にはTLEだが、がんばれば通るだろう
定数倍をがんばる

*/


long tmp, dt; // 高速化

void main(){

 int n = read.to!int;

 long[][] as = new long[][](16, 16);
 foreach(i; 0 .. n) foreach(j; 0 .. n) as[i][j] = read.to!long;

 debug StopWatch sw;
 debug sw.start();

 long[] xs = new long[](1<<n);
 foreach(i; 0 .. n){
  foreach(m; 0 .. 1<<i){
   xs[1<<i | m] = xs[m];
   foreach(j; 0 .. i){
    if(1<<j & m) xs[1 << i | m] += as[i][j];
   }
  }
 }
 debug writeln("xs:", xs[0 .. 1<<n]);

 long[] ys = new long[](1<<n);
 foreach(m; 0 .. 1<<n){
  ys[m] = xs[m];

  int t = 1, u = m - 1; // u は m - t のこと
  while(t < u){
   if((m ^ t) == u){ // t が m のサブセットであるとき
    tmp = ys[t] + ys[u];
    if(tmp > ys[m]) ys[m] = tmp;
    t += 1, u -= 1;
   }
   else{
	// t の最後の桁と同じだけ上げる(例：10110100 がだめだったら、100の位がだめということなので、+100する）
    dt = (t ^ (t - 1)) & t;
    t += dt, u -= dt; 
   }
  }

 }
 debug writeln("ys:", ys[0 .. 1<<n]);

 ys[(1<<n) - 1].writeln;

 debug writeln(sw.peek().msecs);

}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    double n;
    double k;
    cin >> n >> k;

    double p = 0;

    for (int i = 1; i <= n; i++)
    {
        double l = ceil(log2(k / (double)i));
        if (l <= 0)
            p += (1 / n);
        else
            p += (1 / pow(2, l)) * (1 / n);
    }
    printf("%.10f\n", p);

    return 0;
}

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



int main() {

  int N;
  cin >> N;
  
  int H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  
  int ans = 1;
  int check = H[0];
  for (int i = 1; i < N; i++) {
    if(check <= H[i]) {
      ans++;
      check = H[i];
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string nap;
    cin >> nap;
    string odp = "";
    for (int i = 0; i < nap.size(); ++i)
    {
        if (nap[i] == '0')
            odp += "0";
        if (nap[i] == '1')
            odp += "1";
        if (nap[i] == 'B')
            if (odp.size() != 0)
                odp.erase(odp.size() - 1, 1);
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll K,A[100001],B[100001];
	scan(N>>K);
	rep(i,N){
		scan(A[i]>>B[i]);
	}
	ll ans=0;
	ll Know=K;
	vint onenum;
	for(int i=0;Know;i++){
		if(Know&1) onenum.push_back(i);
		Know>>=1;
	}
	vll Klist;
	Klist.push_back(K);
	rep(i,onenum.size()){
		Klist.push_back(((K>>onenum[i])<<onenum[i])-1);
		//printf("onenum:%d shift:%lld k:%lld\n",onenum[i],K>>onenum[i],((K>>onenum[i])<<onenum[i])-1);
	}
	rep(i,Klist.size()){
		ll k=Klist[i];
		ll sum=0;
		rep(j,N){
			if((k|A[j])==k) sum+=B[j];
		}
		ans=max(ans,sum);
		//printf("i:%d k:%lld sum:%lld\n",i,k,sum);
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
const int N=1e9+7;
int main()
{
   int n,w;
   cin>>n>>w;
   ll arr[n][2];
   forl(i,0,n)forl(j,0,2)cin>>arr[i][j];
   ll dp[n+1][w+1];
   forl(i,0,w+1) dp[0][i]=0;
   forl(i,0,n+1) dp[i][0]=0;
   forl(i,1,n+1)
   {
       forl(j,0,w+1)
       {
           if(j>=arr[i-1][0])dp[i][j]=max(dp[i-1][j],dp[i-1][j-arr[i-1][0]]+arr[i-1][1]);
           else dp[i][j]=dp[i-1][j];
       }
   }


//    forl(i,0,n+1)
//    {
//        forl(j,0,w+1)cout<<dp[i][j]<<" ";
//        cout<<endl;
//    }
   ll maxi=-1;
   forl(i,0,w+1)maxi=max(maxi,dp[n][i]);
   cout<<maxi<<endl;

}


Measured memory_bytes: 79104
#include <iostream>
#include <stdlib.h>

struct Card{ char suit,value; };

void bubbleSort(Card C[],int N){
	for(int i = 0;i < N;i++){
		for(int j = N-1;j >= 0;j--){
			if(C[j].value < C[j-1].value){
				Card buf = C[j];
				C[j] = C[j-1];
				C[j-1] = buf;
			}
		}
	}
}
void selectionSort(Card C[],int N){
	for(int i = 0;i < N;i++){
		int minj;
		minj = i;
		Card buf;
		for(int j = i;j < N;j++){
			if(C[j].value < C[minj].value){
				minj = j;
			}
		}
		buf = C[i];
		C[i] = C[minj];
		C[minj] = buf;
	}
}
void print(Card C[],int N){
	for (int i = 0; i < N; i++) {
		if(i > 0 ) std::cout << " ";
		std::cout << C[i].suit << C[i].value;
	}
	std::cout << std::endl;
}
bool isStable(Card C1[],Card C2[],int N){
	for(int i = 0;i < N;i++){
			if(C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main(){
	int n;
	char card_char[36][3];
	Card C1[36],C2[36];

	std::cin >> n;
	for(int i = 0;i < n; i++) std::cin >> card_char[i];
	for(int i = 0;i < n; i++){
		C1[i].suit = card_char[i][0];
		C1[i].value = card_char[i][1];
		C2[i] = C1[i];
	}
	bubbleSort(C1,n);
	print(C1,n);
	std::cout << "Stable" << std::endl;
	selectionSort(C2,n);
	print(C2,n);
	if(isStable(C1,C2,n)){
		std::cout << "Stable" << std::endl;
	}else{
		std::cout << "Not stable" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

typedef struct {
	char *rank;
	double min;
	double max;
} RANK_TABLE;

RANK_TABLE rank_table[] = {
{"light fly",    0,     48.00}, 
{"fly",          48.00, 51.00},
{"bantam",       51.00, 54.00},
{"feather",	    54.00, 57.00},
{"light",        57.00, 60.00},
{"light welter",	60.00, 64.00},
{"welter",       64.00, 69.00},
{"light middle", 69.00, 75.00},
{"middle",       75.00, 81.00},
{"light heavy",  81.00, 91.00},
{"heavy",     	91.00, 100000}
};

int main(void)
{
	int i;
	double weight;
	
    while (scanf("%lf", &weight) != EOF){
		for (i = 0; i < 11; i++){
			if (rank_table[i].min < weight && weight <= rank_table[i].max){
				printf("%s\n", rank_table[i].rank);
				break;
			}
		}
    }
	
	return (0);
}

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

int asc(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}
int main() {
    char c;
    scanf("%c", &c);
    printf("%c", c + 1);
    return 0;
}


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

typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define eps 1e-9
using namespace std;

int freq[26][(int)1e5 + 5];

struct hh {
    char curr;
    int ctr;
    int first;
    int last;
};

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ctr = 1;
    int idx = 0;
    char curr = s[0];
    vector<hh> vec;
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i - 1]) {
            ctr++;
        }
        else {
            hh z = {curr, ctr, idx, i - 1};
            vec.push_back(z);
            ctr = 1;
            curr = s[i];
            idx = i;
        }
    }
    hh z = {curr, ctr, idx, n - 1};
    vec.push_back(z);
    for (int i = 0; i < vec.size(); i++) {
        if (vec[i].ctr >= 2) {
            return cout << vec[i].first + 1 << ' ' << vec[i].last + 1, 0;
        }
        if (i - 1 >= 0 && i + 1 < vec.size()) {
            if (vec[i - 1].curr == vec[i + 1].curr && vec[i - 1].ctr == 1 && vec[i + 1].ctr == 1) {
                return cout << vec[i - 1].first + 1 << ' ' << vec[i + 1].last + 1, 0;
            }
        }
    }
    cout << -1 << ' ' << -1;
    return 0;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	char x;
	cin >> x;
	if (x == 'A')
		cout << 'T';
	else if (x == 'T')
		cout << 'A';
	else if (x == 'G')
		cout << 'C';
	else
		cout << 'G';

	return 0;
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26,K=7;

int d;
int c[A],s[D][A],last[A];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j],
        last[j]=-1;
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]+c[j]*(i-last[j])*min(K,d-i)>
               s[i][best]+c[best]*(i-last[best])*min(K,d-i))
                best=j;
        last[best]=i;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3724
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main() {
	LL a,b;
	cin >> a >> b;
	if(a*b<=0){
		cout << "Zero" << endl;
	}
	else
	if(a>0){
		cout << "Positive" << endl;
	}
	else
	if((b-a)%2){
		cout << "Positive" << endl;
	}
	else{
		cout << "Negative" << endl;
	}
}


Measured memory_bytes: 256
N, C, K=map(int, input().split())
X=[]
for _ in range(N):
  X.append(int(input()))
X.sort()
X.append(10**19)
ans=0
tamatta=0
hayaihito=X[0]
for i in range(N+1):
  if tamatta<C and hayaihito+K>=X[i]:
    tamatta+=1
  else:
    ans+=1
    tamatta=1
    hayaihito=X[i]
    
print(ans)

Measured memory_bytes: 13272
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
lnt n,q;
lnt queri[100000][2];
bool marked[100000];
lnt par[100000];
void init(void)
{
	for(int i=0;i<n;i++){
		par[i]=i;
	}
}

lnt find(lnt x){
	if(par[x]==x) return x;
	return par[x]=find(par[x]);
}	

bool same(lnt x,lnt y){
	return find(x)==find(y);
}

void unite(lnt x,lnt y){
	x=find(x);
	y=find(y);
	par[x]=y;
	return;
}

char str[10];
lnt anc[100000];
lnt m;

int main()
{while(1){
	lnt ans=0;
	scanf("%lld%lld",&n,&q);
	init();
	if(!n&&!q) return 0;
	memset(marked,0,sizeof(marked));
	for(lnt i=1;i<n;i++){
		scanf("%lld",&anc[i]);
		anc[i]--;
	}
	marked[0]=1;
	for(lnt i=0;i<q;i++){
		scanf("%s%lld",str,&queri[i][1]);
		queri[i][1]--;
		if(*str=='M'){
			queri[i][0]=1;
			if(!marked[queri[i][1]]) queri[i][0]=2;
			marked[queri[i][1]]=1;
		}
		else queri[i][0]=0;
	}
	for(lnt i=0;i<n;i++){
		m=i;
		while(!marked[m]&&!same(m,anc[m])){
			unite(m,anc[m]);
			m=anc[m];
		}
	}
	for(lnt i=q-1;i>=0;i--){
		if(queri[i][0]){
			if(queri[i][0]==2) unite(queri[i][1],anc[queri[i][1]]);
		}
		else{
			m=queri[i][1];
			ans+=(find(m)+1);
		}
	}
	cout<<ans<<endl;
}}

Measured memory_bytes: 4532
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

bool isPrime[1000001];

int main(){

	memset(isPrime,1,sizeof(isPrime));
	isPrime[0] = false;
	isPrime[1] = false;

	for(int i=2;i*i<=1000000;i++){
		if(isPrime[i]){
			for(int j=i+i;j<=1000000;j+=i){
				isPrime[j] = false;
			}
		}
	}
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int res = 0;
		for(int i=2;i<=n;i++){
			if(n-i < i) break;
			if(isPrime[i] && isPrime[n-i]) res++;
		}

		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
typedef long long ll;
int seg[400005], arr[400005], val[400005];
void modify(int pos)
{
	for (; pos < 400005; pos += pos & -pos)
		seg[pos]++;
}
int query(int pos)
{
	int res = 0;
	for (; pos; pos -= pos & -pos)
		res += seg[pos];
	return res;
}
int main()
{
	// freopen("ARC101-D.in", "r", stdin);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i);
	int l = 0, r = 1e9, ans = 0;
	while (l <= r)
	{
		memset(seg, 0, sizeof(seg));
		int m = l + r >> 1;
		ll sum = 0;
		modify(n + 1);
		for (int i = 0; i < n; i++)
		{
			val[i] = (i ? val[i - 1] : 0) + (arr[i] >= m ? 1 : -1);
			sum += query(val[i] + n + 1);
			modify(val[i] + n + 1);
		}
		if (sum >= (ll)n * (n + 1) / 2 - sum)
		{
			ans = m;
			l = m + 1;
		}
		else
			r = m - 1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3712
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> like(m, 0);
  rep(i, n) {
    int k;
    cin >> k;
    rep(j, k) {
      int a;
      cin >> a;
      a--;
      like[a]++;
    }
  }
  int cnt = 0;
  rep(i, m) {
    if (like[i] == n) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
    int n;
    cin >> n;
    int ans = 114514810;
    rep(i, n+1){
        int tmp = 0;
        int rem = i;
        while(rem > 0){
            tmp += rem%6;
            rem /= 6;
        }
        rem = n-i;
        while(rem > 0){
            tmp += rem%9;
            rem /= 9;
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;

}



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

bool isPrime(int x)
{
    if (x == 2)
    {
        return true;
    }
    if (x % 2 == 0)
    {
        return false;
    }
    for (int i = 3; i * i <= x; i += 2)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    int cnt = 0, x;
    while (n > 0)
    {
        cin >> x;
        if (isPrime(x))
        {
            cnt++;
        }
        n--;
    }
    cout << cnt << endl;
    return 0;
}


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

int main()
{
//	freopen("1.txt","r",stdin);
	char s[10],t[10];
	scanf("%s%s",&s,&t);
	int a=0;
	for(int i=0;i<=4&&(s[i]-'A'>0);++i)
		if(s[i]==t[i])	a++;
	printf("%d",a);
	return 0;	
} 

Measured memory_bytes: 384
import sys

N, M = map(int, input().split())

WA = [0] * N
isAC = [False] * N

for _ in range(M):
	p, S = input().split()
	if S == "AC":
		isAC[int(p) - 1] = True
	elif not isAC[int(p) - 1]:
		WA[int(p) - 1] += 1

ACsum, WAsum = 0, 0
for i in range(N):
	if isAC[i]:
		ACsum += 1
		WAsum += WA[i]

print(ACsum, WAsum)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    if(a+b == 15){
        cout << "+" << endl;
    }else if(a*b == 15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 16;

int n, i, d, j, r, k, tab[N][N], bat[N];
LL S[1<<N], R[1<<N];

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) for (j=0;j<n;j++) scanf("%d", &tab[i][j]);
for (i=0;i<(1<<n);i++) {
	for (j=0;j<n;j++) if (i & (1<<j)) {
		S[i] = S[i - (1 << j)];
		for (k = j + 1;k<n;k++) if (i & (1<<k)) S[i] += tab[j][k];
		break;
	}
	//cout << i << " " << S[i] << endl;
}
for (i=0;i<(1<<n);i++) {
	R[i] = S[i];
	d = 0;
	for (j=0;j<n;j++) if (i & (1<<j)) bat[d++] = j;
	for (j=0;j<(1<<d);j++) {
		r = 0;
		for (k=0;k<d;k++) if (j & (1<<k)) r += (1 << bat[k]);
		R[i] = max(R[i], R[r] + R[i - r]);
	}
	//cout << i << " " << R[i] << endl;
}
cout << R[(1<<n) - 1] << endl;
return 0;
}

Measured memory_bytes: 1280
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {
        n:usize,
        k:i64,
        ab:[(Usize1,Usize1);n-1],
    }
    let mut g = vec![Vec::new(); MX + 1];
    for (a, b) in ab {
        g[a].push(b);
        g[b].push(a);
    }
    let mut st = VecDeque::new();
    let mut ans = 1i64;
    let mut md = ModComb::new(MX, MOD);
    st.push_back((0usize, 0usize, 1));
    while let Some(s) = st.pop_front() {
        let (now, prev, cnt) = (s.0, s.1, s.2);
        if cnt == 1 {
            ans *= md.perm(k, g[now].len() as i64 + 1);
        } else {
            ans *= md.perm(k - 2, g[now].len() as i64 - 1);
        }
        for &nxt in g[now].iter() {
            if nxt == prev {
                continue;
            }
            st.push_back((nxt, now, cnt + 1));
        }
        ans %= MOD;
    }
    println!("{}", ans);
}
const MOD: i64 = 1000000007;
const MX: usize = 100001;
/// x ^ n % m
pub fn mod_pow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
struct ModComb {
    fact: Vec<i64>,
    fact_inv: Vec<i64>,
    n: usize,
    p: i64,
}
impl ModComb {
    fn initialize(&mut self) {
        let n = self.n;
        self.fact[0] = 1;
        for i in 1..n {
            self.fact[i] = (self.fact[i - 1] * i as i64) % self.p;
        }
        self.fact_inv[n - 1] = mod_pow(self.fact[n - 1], self.p - 2, self.p);
        for i in (0..n - 1).rev() {
            self.fact_inv[i] = (self.fact_inv[i + 1] * (i + 1) as i64) % self.p;
        }
    }
    fn new(max_n: usize, p: i64) -> ModComb {
        let mut ft = ModComb {
            fact: vec![0; max_n + 1],
            fact_inv: vec![0; max_n + 1],
            n: max_n + 1,
            p: p,
        };
        ModComb::initialize(&mut ft);
        ft
    }
    fn fact(&self, n: usize) -> i64 {
        self.fact[n]
    }
    fn comb(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        (self.perm(n, k) * self.fact_inv[k as usize]) % self.p
    }
    fn perm(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        self.fact[n as usize] * self.fact_inv[(n - k) as usize] % self.p
    }
    fn nsk(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        let mut res = 0;
        for i in 0..k + 1 {
            let v = self.comb(k, i) * mod_pow(i, n, self.p) % self.p;
            if (k - i) % 2 == 1 {
                res = (res + self.p - v) % self.p;
            } else {
                res = (res + v) % self.p;
            }
        }
        return res * self.fact_inv[k as usize] % self.p;
    }
}


Measured memory_bytes: 14804
#include<bits/stdc++.h>
using namespace std;
int a,b,d;
int main()
{
    cin>>a>>b;
    char c[a+5][b+5];
    for(int i=0;i<a;i++)
        for(int j=0;j<b;j++)cin>>c[i][j];
    for(int i=0;i<a;i++)
	{
        for(int j=0;j<b;j++)
		{
            d=0;
            if(c[i][j]=='#')cout<<"#";
            else
			{
                if(c[i-1][j-1]=='#')d++;
                if(c[i-1][j]=='#')d++;
                if(c[i-1][j+1]=='#')d++;
                if(c[i][j-1]=='#')d++;
                if(c[i][j+1]=='#')d++;
                if(c[i+1][j-1]=='#')d++;
                if(c[i+1][j]=='#')d++;
                if(c[i+1][j+1]=='#')d++;
                cout<<d;
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, A, B = MAP()

if (N ==1 and A != B) or A > B:
	print(0)
	exit()

MIN = A*(N-1)+B
MAX = B*(N-1)+A

print(MAX - MIN + 1)

Measured memory_bytes: 5144
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m>>l>>r;
    cout<<max((n*m),(l*r))<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
 
ll n;
 
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    ll sum = 0;
    rep(i,n+1){
        if(i==0)continue;
        if(i%3==0)continue;
        if(i%5==0)continue;
        sum += i;
    }
    print(sum);
    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[][][] array = new int[4][3][10];
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		for (int i=0; i < n; i++) {
			int b = Integer.parseInt(scanner.next());
			int f = Integer.parseInt(scanner.next());
			int r = Integer.parseInt(scanner.next());
			int v = Integer.parseInt(scanner.next());
			array[b-1][f-1][r-1] = array[b-1][f-1][r-1] + v;
		}
		scanner.close();
		for (int i=0; i < 4; i++) {
			for (int j=0; j < 3; j++) {
				for (int k=0; k < 10; k++) {
					System.out.print(k == 9 ?   " "  + array[i][j][k] + "\n" :  " " + array[i][j][k]);
				}
			}
			if (i != 3 ) System.out.println("####################");
		}
	}
}

Measured memory_bytes: 20408