akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  string S;

  cin>>S;

  S[5]=' ';
  S[13]=' ';

  cout << S <<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

#define M 1000001
#define NIL -1

int T[M];

int h1(int k)
{
	return k % M;
}

int h2(int k)
{
	return (1 + (k % (M-1)));
}

int h(int k, int i)
{
	return (h1(k) + i * h2(k)) % M;
}

int insert(int key)
{
	int i = 0, p;
	while (1) {
		if (i >= M)
			return NIL;
		p = h(key, i++);
		if (NIL == T[p]) {
			T[p] = key;
			return p;
		}
	}
}

int find(int key)
{
	int i = 0, p;
	while (1) {
		if (i >= M)
			return NIL;
		p = h(key, i++);
		if (key == T[p]) {
			return p;
		} else if (NIL == T[p]) {
			return NIL;
		}
	}
}

int get_char(char ch)
{
	switch (ch) {
	case 'A': return 1;
	case 'C': return 2;
	case 'G': return 3;
	case 'T': return 4;
	default: return 0;
	}
}

int get_key(char *cargs)
{
	int key = 0, p = 1;
	while (*cargs != 0) {
		key += p * get_char(*cargs);
		p *= 5;
		cargs++;
	}
	return key;
}

int main(int argc, char *argv[])
{
	int i, n, key;
	char cmd[10], cargs[12];
	memset(T, NIL, sizeof(T));

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", cmd, cargs);
		key = get_key(cargs);

		if (!strcmp(cmd, "insert")) {
			insert(key);
		} else if (!strcmp(cmd, "find")) {
			if (NIL != find(key)) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}

	return 0;
}


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


int main(){
    int a,b,c,k; cin >> a >> b >> c >> k;
    ll cnt = 0;
    while(a>=b){
        b*=2;
        cnt++;
    }
    while (b>=c){
        c*=2;
        cnt++;
    }
    if(cnt <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin>>n>>x;
  vector<int> l(n);
  vector<int> d(n+2);
  d[0]=0;
  int ans=1;
  for(int i=0;i<n;i++){
    cin>>l[i];
    d[i+1]=d[i]+l[i];
    if(d[i+1]<=x){ans++;}
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

int gcd(int c,int d){
    return d ? gcd(d, c % d) : c;
}



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

    int x; cin >> x;
    int a,b;

    for(int i = -1000;i < 1001;i ++){
        for(int j = -1000;j < 1001;j ++){
            if(pow(i,5) - pow(j,5) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 4112
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int n;
int han[6]={0};
int han1[6]={185.0,180.0,175.0,170.0,165.0,0};
cin>>n;
rep(i,n){
double in1;
cin>>in1;
rep(j,6){if(in1>=han1[j]){han[5-j]++;break;}}
}
rep(i,6){
//cout<<han[i];
cout<<i+1<<":";
rep(j,han[i])cout<<"*";
cout<<endl;
}
}

Measured memory_bytes: 1232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int n = nextInt();
        init(n);
        for (int i = 0; i < n - 1; i++) {
            int x = nextInt() - 1;
            int y = nextInt() - 1;
            addEdge(x, y);
        }
        dfs(0, -1, false);
//        System.out.println(r);
        if (r == (n + 1) / 2) {
            out.println("Second");
        } else {
            out.println("First");
        }
    }

    void init(int n) {
        this.n = n;
        this.m = (n - 1) * 2;
        last = 0;
        head = new int[n];
        nx = new int[m];
        dst = new int[m];
        Arrays.fill(head, -1);
    }


    void addEdge(int x, int y) {
        nx[last] = head[x];
        dst[last] = y;
        head[x] = last;
        last++;
        nx[last] = head[y];
        dst[last] = x;
        head[y] = last;
        last++;
    }

    int r = 0;

    private boolean dfs(int x, int p, boolean can) {
        int j = head[x];
        boolean z = true;
        while (j >= 0) {
            int y = dst[j];
            if (y != p) {
                z &= dfs(y, x, z);
            }
            j = nx[j];
        }
        if (z && can) {
//            System.out.println(x + " " + p);
            r++;
            return false;
        } else {
            return true;
        }
    }

    int n, m;
    int[] head;
    int[] nx;
    int[] dst;
    int last;




    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


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

int main() {  
  int n;
  cin >> n;
  vector< int > x(n), y(n), h(n);
  for (int i=0; i<n; ++i) cin >> x[i] >> y[i] >> h[i];
  
  for (int hi=0; hi<=100; ++hi) {
    for (int wi=0; wi<=100; ++wi) {
      int ans = -1;
      for (int i=0; i<n; ++i) {
        if (h[i] > 0) {
          int tmp = h[i] + abs(x[i]-wi) + abs(y[i]-hi);
          if (ans < 0) ans = tmp;
          else if (ans != tmp) {
            ans = -2;
            break;
          }
        }
      }

      for (int i=0; i<n; ++i) {
         if (h[i] == 0) {
          int dist = abs(x[i]-wi) + abs(y[i]-hi);
          if (ans > dist) {
            ans = -2; 
            break;
          }
        }    
      }
    
      if (ans > 0) {
        cout << wi << " " << hi << " " << ans << endl;
        return 0;
      } 
    }
  }
  return 0;
}
  

Measured memory_bytes: 256
from math import factorial
import sys 
import math
sys.setrecursionlimit(400000000)
mod=1000000007
n,a,b=map(int,input().split())
def fac(n,k,mod):
    sum=1
    for i in range(k):
        sum=sum*(n-i)%mod
    return sum

def nck(x,y,mod):
    y=min(y,x-y)
    ans=fac(x,y,mod)*pow(fac(y,y,mod),mod-2,mod)%mod
    return ans
    
ans=pow(2,n,mod)-1-nck(n,a,mod)-nck(n,b,mod)
ans=ans%mod
print(ans)


Measured memory_bytes: 3064
s =input()
ym=0
my=0
d1=int(s[0:2])
d2=int(s[2:4])
#print(d1,d2)

if 0<=d1:
    ym+=1
    if 0<d1<13:
        my+=1

if 0<=d2:
    my+=1
    if 0<d2<13:
        ym+=1
    
if ym==2 and my==2:
    print("AMBIGUOUS")    
elif ym==2:
    print("YYMM")
elif my==2:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    int left = A + B;
    int right = C + D;
    
    if(left == right)
        cout << "Balanced" << endl;
    else if(left > right)
        cout << "Left" << endl;
    else
        cout << "Right" << endl;

}


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

using namespace std;

using ll = long long;

struct Edge {
    int dst;
    ll w;
    Edge() {}
    Edge(int _d, ll _w) : dst(_d), w(_w) {}
};

void Dfs(int cur, int p, ll d, auto &dis, auto &adj) {
    dis[cur] = d;
    for (auto e : adj[cur])
        if (e.dst != p) Dfs(e.dst, cur, d + e.w, dis, adj);
}

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

    int n;
    cin >> n;


    vector<vector<Edge>> adj(n);
    for (int i = 0, a, b, c; i < n - 1; ++i) {
        cin >> a >> b >> c;
        adj[a - 1].emplace_back(Edge(b - 1, c));
        adj[b - 1].emplace_back(Edge(a - 1, c));
    }

    int q, k;
    cin >> q >> k;

    vector<ll> dis(n);
    Dfs(k - 1, -1, 0, dis, adj);

    for (int i = 0, x, y; i < q; ++i) {
        cin >> x >> y;
        cout << dis[x - 1] + dis[y - 1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 17408
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    int i;
    getline(cin, s);

    for (i = 0; i < s.length(); i++) {
        if (s[i] >= 'A' && s[i] <= 'Z')
            s[i] += 'a' -'A';
        else if (s[i] >= 'a' && s[i] <= 'z')
            s[i] -= 'a' - 'A';
    }

    cout << s << endl;
    return 0;
}



Measured memory_bytes: 3216
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, K;

int main()
{
	in >> N >> K;
	out << (N%K == 0 ? 0 : 1) << std::endl;
	return 0;
}


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N; cin >> N;
	ll sum = 0;
	ll tmp = N;
	while (N) {
		sum += (N % 10);
		N /= 10;
	}
	if (tmp%sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
  int n, l;
  string s[110];
  cin >> n >> l;
  rep(i,n){
    cin >> s[i];
  }
  sort(s, s + n);
  string ans;
  rep(i,n) {
    ans += s[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vvi d(10, vi(10));
    rep(i, 10) rep(j, 10) cin >> d[i][j];
    vvi a(h, vi(w));
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(k, 10) rep(i, 10) rep(j, 10) chmin(d[i][j], d[i][k]+d[k][j]);
    ll ans = 0;
    rep(i, h) rep(j, w) {
        if (a[i][j] != -1) ans += d[a[i][j]][1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.PriorityQueue
import java.util.Comparator
import scala.io.StdIn.{readLine,readInt}
import scala.collection.mutable.ArrayBuffer

object Main {

  class Node(val cost:Int, val id:Int) { }

  class NodeComparator extends Comparator[Node] {
    def compare(node1:Node,node2:Node) = { node1.cost-node2.cost }
  }

  def main(args:Array[String]) = {
    val comp:Comparator[Node] = new NodeComparator()
    val n = readInt
    val pq = new PriorityQueue[Node](n, comp)
    val g = for(i<-0 until n) yield { readLine.trim.split(" ").map(_.toInt) }
    val dist = new Array[Int](n)
    val nodes = new Array[Node](n)
    pq.add(new Node(0,0))
    for(i<-1 until n) {
      dist(i) = 1000000
      nodes(i) = new Node(1000000, i)
      pq.add(nodes(i))
    }
    dist(0) = 0

    while(!pq.isEmpty()) {
      val nd = pq.poll()
      val v = g(nd.id)

      for(i<-0 until v(1)) {
        val j = i*2+2
        val k = i*2+3
        val alt = v(k) + dist(v(0))
        if(alt < dist(v(j))) {
          dist(v(j)) = alt
          pq.remove(nodes(v(j)))
          pq.add(new Node(dist(v(j)), v(j)))
        }
      }
    }

    println{
      { for(i<-0 until n) yield (i.toString + " " + dist(i).toString) }.mkString("\n")
    }
  }
}

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

int main(){
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n;
    int v[50];

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

    sort(v, v+n);

    double ans = (v[0] + v[1]) * 0.5;
    for(int i=2;i<n;i++) ans = (ans + v[i]) * 0.5;

    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

const double EPS = 1e-7;
const int N = 4e5+5, M = 1e5+5, OO = 0x3f3f3f3f;
typedef long long ll;

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

int n,A[M];
int dp[M];
int main(){
//    freopen("araf_bara.txt", "wt", stdout);
    cin>>n;
    for(int i=0; i<n; i++)cin>>A[i];

    memset(dp, OO, sizeof dp);
    dp[0]=0;
    for(int i=0; i<n; i++){
        if(i+1<n){
            int&ret= dp[i+1];
            ret = min(ret, dp[i]+abs(A[i]-A[i+1]));
        }
        if(i+2<n){
            int&ret2= dp[i+2];
            ret2= min(ret2, dp[i]+abs(A[i]-A[i+2]));
        }
    }
    cout<<dp[n-1]<<endl;



    }


Measured memory_bytes: 1024
use std::collections::HashMap;
use std::num;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        a: [usize; n],
    }
    let mut e = 0;
    let mut d = 2;
    loop {
        if a.iter().any(|num| num % d != 0) {
            println!("{}", e);
            break;
        } else {
            e += 1;
            d *= 2;
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main()
{
    long long int N;
    cin>>N;
    unsigned long long int sum=0;

    while(N)
    {
        sum++;
        N=N/2;
    }

    cout<<(long long int )(pow(2,sum)-1);
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  s <- getLine
  putStrLn $ if (s !! 1 == s !! 2) && ((s !! 0 == s !! 1) || (s !! 2 == s !! 3)) then "Yes" else "No"

  

Measured memory_bytes: 380
A, B, C, X, Y = map(int, input().split())

if A+B <= 2*C:
    ans = X*A + Y*B
else:
    z = min(X, Y)
    if z == X:
        c = B
    else:
        c = A
    ans = C*2*z
    Z = max(X, Y) - z
    if c <= 2*C:
        ans += c*Z
    else:
        ans += 2*C*Z
    
print(ans)

Measured memory_bytes: 9112
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	k := nextInt()

	n := 50
	a := make([]int, n)
	for i := range a {
		a[i] = i + k/n
	}
	for i := 0; i < k%n; i++ {
		for j := 0; j < n; j++ {
			if j != i {
				a[j]--
			} else {
				a[j] += n
			}
		}
	}

	puts(n)
	for i := range a {
		if i < n-1 {
			putf("%d ", a[i])
		} else {
			puts(a[i])
		}
	}
}


Measured memory_bytes: 640
data = list(map(int, input().split()))
row = data[0]+1
column = data[1]+1
table = [[0 for j in range(column)] for i in range(row)]
for i in range(row-1):
    data_in = list(map(int, input().split()))
    for j in range(column-1):
        table[i][j] = data_in[j]
for i in range(row):
    sum_row = 0
    for j in range(column):
        sum_row += table[i][j]
    table[i][column-1] = sum_row
for i in range(column):
    sum_column = 0
    for j in range(row):
        sum_column += table[j][i]
    table[row-1][i] = sum_column
for i in range(row):
    for j in range(column):
        if(j==column-1):
            print(str(table[i][j]))
        else:
            print("{0}".format(table[i][j]), end=" ")


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

n, *h = map(int, read().split())

ans = h[0]
for i in range(1,n):
    if h[i] > h[i-1]:
        ans += (h[i]-h[i-1])

print(ans)

Measured memory_bytes: 3060
a=[]
b=int(input())
for x in input().split(" "):
    a.append(int(x))

i=0
x=0
xx=0

while i<b:
    x=a[i]
    if i>=1 and xx-x>1:
        break
    elif i>=1 and xx-x==1:
        a[i]+=1
    x=a[i]
    xx=x
    i+=1
if i==b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include<stdio.h>
int main(void){
	
	int W,H,x,y,r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(x>=r && y>=r && x<=W-r && y<=H-r){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 584
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		long K = long.Parse(str[1]);
		int[,]A = new int[N,2];
		long mod = 1000000007;
		var list = new List<int>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int>();
		}
		for(var i=0;i<N-1;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i,0] = int.Parse(str2[0]);
			A[i,1] = int.Parse(str2[1]);
			list[A[i,0]-1].Add(A[i,1]-1);
			list[A[i,1]-1].Add(A[i,0]-1);
		}
		var listB = new List<int>();
		int[]F = new int[N];
		for(var i=0;i<N;i++){
			if(list[i].Count==1){
				listB.Add(i);
				F[i] = 1;
			}
		}
		int t = -1;
      	if(N==1){
          Console.Write(K);
        } else {
		while(listB.Count>0){
			var listC = new List<int>(listB);
			listB.Clear();
			for(var i=0;i<listC.Count;i++){
				for(var j=0;j<list[listC[i]].Count;j++){
					if(F[list[listC[i]][j]]==0){
						listB.Add(list[listC[i]][j]);
						F[list[listC[i]][j]] = 1;
					}
				}
			}
			if(listB.Count==0){
				t = listC[0];
			}
		}
		long ans = K;
		int[]G = new int[N];
		G[t] = 1;
		var list3 = new List<int>();
      	list3.Add(t);
		while(list3.Count>0){
			var list4 = new List<int>(list3);
			list3.Clear();
			for(var i=0;i<list4.Count;i++){
				long ct = 0;
				for(var j=0;j<list[list4[i]].Count;j++){
					if(G[list[list4[i]][j]]==0){
						ct++;
						list3.Add(list[list4[i]][j]);
						G[list[list4[i]][j]] = 1;
					}
				}
				for(var j=0;j<ct;j++){
					if(list4[0]==t){
						ans = (ans * (K - j - 1)) % mod;
					} else {
						ans = (ans * (K - j - 2)) % mod;
					}
				}
			}
		}
		Console.Write(ans);
        }
	}
}

Measured memory_bytes: 33680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, ll>;

vector<vector<P>> graph;
ll ans[100005];

void dfs(int node, ll cost, int pre = -1){

    ans[node] = cost;
    for(auto i : graph[node]){
        int u = i.first;
        if(u == pre){
            continue;
        }
        ll c = i.second;
        dfs(u, c+cost, node);
    }
}


int main() {

    int n;
    cin >> n;
    graph.resize(n);
    rep(i, n-1){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        --a; --b;
        graph[a].emplace_back(b, c);
        graph[b].emplace_back(a, c);
    }

    int q, k;
    cin >> q >> k;

    dfs(k-1, 0LL);

    rep(i, q){
        int x, y;
        cin >> x >> y;
        cout << ans[x-1] + ans[y-1] << endl;
    }


    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e9
//dp[i][j] - till i, j heads probab
//dp[][][] - expected no. of ops for a,b,c to get over
double dp[305][305][305];
// bool vis[305][305][305];
double N;
double top(int a,int b,int c){
	// cout<<dp[a][b][c];
	if(a<0||b<0||c<0) return 0;
	if(a==0&&b==0&&c==0) return 0;
	if(dp[a][b][c]!=-1) return dp[a][b][c];
	// cout<<a<<b<<c<<endl;
	double eva = top(a-1,b,c);
	double evb = top(a+1,b-1,c);
	double evc = top(a,b+1,c-1);
	double sum = (a+b+c);
	double ans =(N + eva*a + evb*b + evc*c)/sum;
	return dp[a][b][c] = ans;
}
int main(){
	// memset(dp,-1,sizeof(dp));
	int n;cin>>n;
	N=n;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=n;k++)
				dp[i][j][k]=-1;
	int k;
	int a=0,b=0,c=0;
	for(int i=0;i<n;i++){
		cin>>k;
		if(k==1) a++;
		else if(k==2) b++;
		else c++;
	}
	printf("%.10lf\n", top(a,b,c)); 
	// cout<<top(a,b,c)<<endl;
}

Measured memory_bytes: 220712
#include<stdio.h>

int z;//パブリック変数

int main(void){//floatよりもdoubleを
int n,a[52+1],i,as[4+1][13+1],j;
char c[52+1],dummy;
scanf("%d",&n);
for(i=1;i<=n;i++){
	scanf("%c",&dummy);
	scanf("%c %d",&c[i],&a[i]);
}
//全数導入↓
for(j=1;j<=4;j++){
	for(i=1;i<=13;i++) as[j][i]=1;
}
//在るもの全て塗りつぶす↓
for(i=1;i<=n;i++){
	if(c[i]=='S') as[1][a[i]]=0;
	if(c[i]=='H') as[2][a[i]]=0;
	if(c[i]=='C') as[3][a[i]]=0;
	if(c[i]=='D') as[4][a[i]]=0;
}
//残った者を出力↓
for(j=1;j<=4;j++){
	for(i=1;i<=13;i++){
		if(as[j][i]==1){
			if(j==1) printf("S %d\n",i);
			if(j==2) printf("H %d\n",i);
			if(j==3) printf("C %d\n",i);
			if(j==4) printf("D %d\n",i);
		}
	}
}
return 0;
}


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

#define ll              long long int
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; 
#define endl            '\n'
#define pb              push_back
#define vll             vector<ll> 
#define f(i,x,y)        for(i=x;i<y;i++)
#define INF             LLONG_MAX
#define fast            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s(x)            sort(x.begin(),x.end())
#define all(v)          v.begin(),v.end()
#define p2(n,x)         cout << fixed << setprecision(x) <<n<<endl; 
#define pll             pair<ll,ll> 
#define ff              first
#define ss              second
#define blt(x)          __builtin_popcount(x)

void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d});
}

int main()
{
    
    fast
    ll t = 1;

    while(t--)
    solve();
    
    return 0;
}

Measured memory_bytes: 3688
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;


	int dp[10][2][2][2][2] = {};
	int k = 1000000000;
	int saisho = 0;

	for (int i = 9; i > 0; i--) {
		k /= 10;
		int amari = N / k % 10;
		if (saisho) {
			dp[i][0][0][0][1] = 1;
		}
		else if (amari) {
			dp[i][0][0][0][0] = 1;
			saisho = 1;
		}

		rep(j3, 2) rep(j5, 2) rep(j7, 2) {

			if (3 <= amari) dp[i - 1][j3 | 1][j5][j7][3 < amari] += dp[i][j3][j5][j7][0];
			if (5 <= amari) dp[i - 1][j3][j5 | 1][j7][5 < amari] += dp[i][j3][j5][j7][0];
			if (7 <= amari) dp[i - 1][j3][j5][j7 | 1][7 < amari] += dp[i][j3][j5][j7][0];

			dp[i - 1][j3 | 1][j5][j7][1] += dp[i][j3][j5][j7][1];
			dp[i - 1][j3][j5 | 1][j7][1] += dp[i][j3][j5][j7][1];
			dp[i - 1][j3][j5][j7 | 1][1] += dp[i][j3][j5][j7][1];
		}

	}
	co(dp[0][1][1][1][0] + dp[0][1][1][1][1]);


	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
   int n,i,sz,r;
   string s;
   cin>>n>>s;
   sz=s.size();
   for(i=0; i<sz; i++)
   {
     r=s[i]+n;
     if(r>90) r=(r-90)+64;
    printf("%c",r);

   }
  cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
num = 0
ans = 0


for j in range(1, N):
    if H[j-1] >= H[j]:
        num +=1
        # print(num)
    else:
        if num > ans:
            ans = num
        num = 0
else:
    if num > ans:
        ans = num



print(ans)

Measured memory_bytes: 14252
from itertools import combinations

input = open(0).read

Sn = [i[0] for i in input().split() if i[0] in "MARCH"]


def main():

    print(
        sum(x * y * z for x, y, z
            in combinations([Sn.count(s) for s in "MARCH"], 3)))

    return


main()


Measured memory_bytes: 10864
def actual(n, H):
    count = 0

    for i in range(len(H)):
        if i == 0:
            count += 1
            continue

        me = H[i]
        left_towers = H[:i]

        can_see_the_sea = all([h <= me for h in left_towers])
        count += int(can_see_the_sea)

    return count

n = int(input())
H = list(map(int, input().split()))

print(actual(n, H))

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int main()
{   
    string s;
    cin>>s;
    if(s.back() == 's'){
        cout<<s<<"es"<<endl;
    }   
    else {
        cout<<s<<"s"<<endl;
    } 
    return 0;
}   
    

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemB
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var a = abcd[0];
            var b = abcd[1];
            var c = abcd[2];
            var d = abcd[3];
            long div = 998244353;
            var cMinusA = c - a;
            var dMinusB = d - b;
            var dp = new long[cMinusA + 1, dMinusB + 1];
            dp[0, 0] = 1;

            for (int i = 0; i <= cMinusA; i++)
            {
                for (int j = 0; j <= dMinusB; j++)
                {
                    if (i == 0 & j == 0)
                        continue;
                    if (i != 0 && j != 0)
                    {
                        dp[i, j] = (dp[i, j - 1] * (a + i)) % div;
                        dp[i, j] += (dp[i - 1, j] * (b + j)) % div;
                        dp[i, j] %= div;
                        dp[i, j] -= -div + (dp[i - 1, j - 1] * (a + i - 1) * (b + j - 1)) % div;
                        dp[i, j] %= div;
                    }
                    else if (i != 0)
                        dp[i, j] = (dp[i - 1, j] * b) % div;
                    else if (j != 0)
                        dp[i, j] = (dp[i, j - 1] * a) % div;
                }
            }
            Console.WriteLine(dp[cMinusA, dMinusB]);
        }

        static long modinv(long a,long m)
        {
            long b = m, u = 1, v = 0;
            while (b != 0)
            {
                long t = a / b;
                a -= t * b;
                var temp = a;
                a = b;
                b = temp;
                u -= t * v;
                temp = u;
                u = v;
                v = temp;
            }
            u %= m;
            if (u < 0) u += m;
            return u;
        }
//long firstCase = 1;
//var cMinusA = c - a;
//var dMinusB = d - b;
//long res = 0;
//            for (int i = 0; i<cMinusA; i++)
//            {
//                firstCase = (firstCase* b) % div;
//            }
//            for (int i = 0; i<dMinusB; i++)
//            {
//                firstCase = (firstCase* c) % div;
//            }
//            res += firstCase;

//            for (int i = 0; i<cMinusA; i++)
//            {
//                firstCase = (firstCase* modinv(b, div)) % div;
//                var temp = firstCase;
//var caseNum = c - i - 1;
//                for (int j = 0; j<dMinusB; j++)
//                {
//                    temp = ((temp* modinv(c, div)) % div* caseNum) % div;
//                    res = (res + temp) % div;
             

    }
}


Measured memory_bytes: 97780
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long a, b;
    
    cin >> a >> b;
    
    cout << (a - 1) * (b - 1) << endl;
    
    return 0;
}

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


  int a,b;
  int r;
  int tmp;

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

  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }

  while((r=a%b)!=0){
    a=b;
    b=r;
  }

  printf("%d\n",b);

  return 0;
}



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

int main()
{
    char ch;

    scanf("%c",&ch);
    if(ch=='a'|| ch=='e'|| ch=='i'|| ch=='u' ||ch=='o')
    {
        printf("vowel");
    }
    else{
            printf("consonant");

    }
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n+1), a_inv(n+1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a_inv[a[i]] = i;
    }
    for (int i = 1; i <= n; ++i) {
        cout << a_inv[i] << " ";
    }
    cout << endl;
   return 0;
}


Measured memory_bytes: 1664
class Solve:
    def __init__(self, n, data):
        # write variables you use here
        self.n = n
        self.data = data
        self.honest = 0
        self.flag = 0

    
    def main(self):
        for i in range(2 ** n):
            for j in range(n):
                if i & (1 << j):
                    for k in self.data[j]:
                        if (i & (1 << (k[0] - 1))) != 0 and k[1] == 0:
                            break
                        if (i & (1 << (k[0] - 1))) == 0 and k[1] != 0:
                            break

                    else:
                        continue  # 矛盾なく回ったとき
                    break
                else:
                    continue
            else:
                self.honest = max(self.honest, bin(i).count('1'))
        
        print(self.honest)
                     

if __name__ == "__main__":
    # write standard input here
    n = int(input())
    data = []
    for i in range(n):
        tmp = int(input())
        data.append([list(map(int, input().split())) for j in range(tmp)])
    s = Solve(n, data)
    s.main()


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

int n;
long long k;
vector<long long> a,p,m,z;

bool judge_minus(long long mid){
    long long sum=0;
    for(int i=0;i<p.size();++i){
        long long d=(mid-p[i]+1)/p[i];
        sum+=upper_bound(m.begin(),m.end(),d)-m.begin();
    }
    return sum>=k;
}

bool judge_plus(long long mid){
    long long sum=0;
    for(int i=0;i<p.size();++i){
        long long d=mid/p[i];
        long long temp=upper_bound(p.begin(),p.end(),d)-p.begin();
        if(i<temp) --temp;
        sum+=temp;
    }
    for(int i=0;i<m.size();++i){
        long long d=mid/m[i];
        long long temp=upper_bound(m.begin(),m.end(),d)-m.begin();
        if(i<temp) --temp;
        sum+=temp;
    }
    sum/=2;
    return sum>=k;
}

int main(){
    cin>>n>>k;
    a.resize(n);
    for(int i=0;i<n;++i) cin>>a[i];
    for(int i=0;i<n;++i){
        if(a[i]>0) p.push_back(a[i]);
        else if(a[i]<0) m.push_back(a[i]);
        else z.push_back(a[i]); 
    }

    long long pn=p.size();
    long long mn=m.size();
    long long zn=z.size();
    long long minus=pn*mn;
    long long zero=zn*(zn-1)/2+(pn+mn)*zn;
    long long plus=(pn*(pn-1)+zn*(zn-1))/2;
    
    if(k<=minus){
        sort(m.begin(),m.end());
        long long l=-1e18-5;
        long long r=1;
        while(r-l>1){
            long long mid=(r+l)/2;
            if(judge_minus(mid)) r=mid;
            else l=mid;
        }
        cout<<r<<endl;
        return 0;
    }
    else if(k<=minus+zero){
        cout<<0<<endl;
        return 0;
    }
    else{
        k-=(minus+zero);
        for(int i=0;i<mn;++i) m[i]=abs(m[i]);
        sort(p.begin(),p.end());
        sort(m.begin(),m.end());
        long long l=-1;
        long long r=1e18+5;
        while(r-l>1){
            long long mid=(r+l)/2;
            if(judge_plus(mid)) r=mid;
            else l=mid;
        }
        cout<<r<<endl;
        return 0;
    }
}

Measured memory_bytes: 6968
def solve(i, m, n)
  if m == 0
    return true
  end

  if i >= n
    return false
  end

  res = solve(i+1, m, n) || solve(i+1, m - A[i], n)
  return res
end


a = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.to_i
B = gets.chomp.split(" ").map(&:to_i)

B.each do |bb|
  if solve(0, bb, a)
    puts "yes"
  else
    puts "no"
  end
end


Measured memory_bytes: 6860
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int m,n,cnt;
  string s[55]={},t[55]={};
  cin >> n >> m;
  for(int i=0; i<n; i++) {
    cin >> s[i];
  }
  for(int i=0; i<m; i++) {
    cin >> t[i];
  }
  for(int i=0; i<n-m+1; i++) {
    for(int j=0; j<n-m+1; j++) {
      if(s[i][j]==t[0][0]) {
        cnt=0;
        for(int k=0; k<m; k++) {
          for(int l=0; l<m; l++) {
            if(t[k][l]==s[i+k][j+l]) {
              cnt++;
            }
          }
        }
        if(cnt==m*m) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct knapsack{
    ll wt , val;
};
ll maxmimum_value(vector<knapsack> a , ll n , ll W){
    ll dp[n+1][W+1] ;
    for(ll w=0 ; w<=W ; w++){
        dp[1][w] = 0;
    }
    dp[1][a[1].wt] = a[1].val;

    for(ll i=2 ; i<=n ; i++){
        for(ll w=0 ; w<=W ; w++){
            dp[i][w] = dp[i-1][w];
            if(w - a[i].wt <0){
                continue;
            }
            dp[i][w] = max(dp[i][w] , a[i].val + dp[i-1][w-a[i].wt]);
        }
    }
    return *max_element(dp[n] , dp[n] + W  + 1);
}
int main(){
    ll n , W;
    cin>>n>>W;
    vector<knapsack> a(n+1);
    for(ll i=1 ; i<=n ; i++){
        cin>>a[i].wt>>a[i].val;
    }
    cout<<maxmimum_value(a , n , W);
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111
 
typedef long long ll;
typedef long double ld;


const ld del = 5.0L * M_PI;

vector<pair<ll, ll> > p;
map<ll, ll> m;
ld ans;

vector<ll> temp;
ll fen[maxn];

void add(ll x, ll val){
	while(x < maxn){
		fen[x] = max(fen[x], val);
		x += (x & -x);
	}
}

ll get(ll x){
	ll ret = 0;
	while(x){
		ret = max(ret, fen[x]);
		x -= (x & -x);
	}
	return ret;
}

int main(){
	ll xs, xe, ys, ye, n;
	scanf("%lld%lld%lld%lld", &xs, &ys, &xe, &ye);
	ll pot = llabs(xs - xe) + llabs(ys - ye);
	pot *= 100LL;
	if(xs > xe){
		swap(xs, xe);
		swap(ys, ye);
	}

	int c = 1;
	if(ys > ye)
		c = -1;

	scanf("%lld", &n);
	for(ll i = 0; i < n; i++){
		ll x, y;
		scanf("%lld%lld", &x, &y);
		if(xs <= x && x <= xe && min(ye, ys) <= y && y <= max(ye, ys))
			p.pb(mp(x, y * c));
	}

	sort(p.begin(), p.end());

	n = p.size();
	for(ll i = 0; i < n; i++)
		temp.pb(p[i].se);
	
	sort(temp.begin(), temp.end());

	ll cnt = 0;
	for(ll i = 0; i < n; i++)
		p[i].se = lower_bound(temp.begin(), temp.end(), p[i].se) - temp.begin() + 1;

	for(ll i = 0; i < n; i++){
		ll cur = get(p[i].se) + 1;
		cnt = max(cnt, cur);
		add(p[i].se, cur);
	}

	if(cnt == min(llabs(xs - xe) + 1, llabs(ys - ye) + 1))
		ans = 1.0L * pot + (2.0L * del - 20.0L) - (20.0L - del) * (1.0L * cnt - 1.0L); 

	if(cnt < min(llabs(xs - xe) + 1, llabs(ys - ye) + 1))
		ans = 1.0L * pot - cnt * (20.0L - del);
	
	cout << fixed << setprecision(22) << ans << endl;
	return 0;
}

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
    int A = inputValue();
    int B = inputValue();
    int ans = -1;
    if(A < 10 && B < 10){
        ans = A * B;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;

//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

int main() {
	int N;cin >> N;
	vector<string> S(N);rep(i,N)cin >> S[i];

	ll a = 0, w=0, t=0, r=0;
	rep(i,N){
		if(S[i][0] == 'A') a++;
		else if(S[i][0] == 'W') w++;
		else if(S[i][0] == 'T') t++;
		else r++;
	}

	cout << "AC x " << a << endl; 
	cout << "WA x " << w << endl; 
	cout << "TLE x " << t << endl; 
	cout << "RE x " << r << endl; 
}	

Measured memory_bytes: 14368
def expectation(li):
  total = 0
  for i in li:
    total += (i+1)/2
  return total

n,k = map(int,input().split())
p = list(map(int,input().split()))
ex = expectation(p[0:k])
li = [ex]
for i in range(1,n-k+1):
  ex = ex - (p[i-1]+1)/2 + (p[i+k-1]+1)/2
  li.append(ex)
print(max(li))

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

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  char a;
  cin>>a;
  if(a<'a') cout<<'A'<<endl;
  else cout<<'a'<<endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int N, i;
    cin >> N >> i;
    cout << N + 1 - i << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int count[] = new int[100001];
		
		for(int i = 0; i < n; i++) {
			count[sc.nextInt()]++;
		}
		
		//Arrays.sort(count);
		int remain = 0;
		int kind = 0;
		
		for(int i = 1; i < count.length; i++) {
			if(count[i] >= 1) {
				kind++;
				remain += count[i] - 1;
			}
		}
	
		if(remain % 2 == 0) {
			System.out.println(kind);
		}
		else {
			System.out.println(kind - 1);
		}
	}

}


Measured memory_bytes: 49204
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    if(s[0] == 'A'){
        if(s[1] == 'B' || s[2] == 'B')
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    else{
        if(s[1] == 'A' || s[2] == 'A')
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
import copy
N=int(input())
X=list(map(int,input().split()))
X2=copy.deepcopy(X)
X2.sort()
upper=X2[N//2]
downer=X2[(N-2)//2]

for i in range(N):
    if X[i]>=upper:
        print(downer)
    elif X[i]<=downer:
        print(upper)


Measured memory_bytes: 121464
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


const int MAX = 5100000;
long long fac[MAX], finv[MAX], inv[MAX];

/* 前処理 O(n) */
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

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

signed main() {
  int N, P;
  cin >> N >> P;
  vector<int> A(N);
  int zero = 0, one = 0;
  rep(i, N) {
    cin >> A[i];
    A[i] %= 2;
    if (A[i] == 0)
      zero++;
    else
      one++;
  }

  COMinit();
  int ans = 0;

  for (int i = P; i <= one; i += 2) {
    ans += COM(one, i);
  }

  rep(i, zero) {
    ans *= 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 119808
while 1:
    n=int(input())
    if n==0:break
    c=0
    a=[int(input()) for _ in range(n)]
    for i in range(n):
        for j in range(n-1,0,-1):
            if a[j]<a[j-1]:c,(a[j],a[j-1])=c+1,(a[j-1],a[j])
    print(c)

Measured memory_bytes: 7656