akhauriyash/Code-Regression huggingface dataset:
object Main extends App{
    // Your code here!
    import scala.io.Source.stdin
    def calc_exp(args: List[String]): Int = {
        val stack = new scala.collection.mutable.Stack[Int]
        def tryToInt( s: String ) = scala.util.Try(s.toInt).toOption
        def calc(e: String): Unit = {
            val element = tryToInt(e)
            element match {
                case Some(i) => {stack.push(i); return}
                case None => -1
            }
            var result = 0
            e match {
                case "+" => result = stack.pop + stack.pop
                case "-" => result = -stack.pop + stack.pop
                case "*" => result = stack.pop * stack.pop
                case _ => -1
            }
            stack.push(result)
        }
        args.foreach(calc)
        stack.pop
    }
    val input = scala.io.StdIn.readLine.split(" ").toList
    println(calc_exp(input))
}



Measured memory_bytes: 43896
def solve(N, As):
    ans = 1
    for a in sorted(As):
        ans *= a
        if ans == 0:
            return 0
        if ans > 10 ** 18:
            return -1
    return ans


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 21476
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    static int n;
    static ArrayList<Integer>[]A;
    static int[]B;
    
    void solve() throws IOException {
        n=ni();
        A=new ArrayList[n+1];
        for (int x=1;x<=n;x++) A[x]=new ArrayList();
        for (int x=1;x<n;x++) {
            int u=ni(),v=ni();
            A[u].add(v);
            A[u].add(x);
            A[v].add(u);
            A[v].add(x);
        }
        int m=0;
        for (int x=1;x<=n;x++) m=Math.max(m,A[x].size()/2);
        out.println(m);
        
        B=new int[n];
        dfs (1,0,-1);
        
        for (int x=1;x<n;x++) out.println(B[x]);
        out.flush();
    }
    
    void dfs(int v,int p,int d) {
        int c=1;
        if (c==d) c++;
        
        for (int x=0;x<A[v].size();x+=2) {
            int u=A[v].get(x);
            int e=A[v].get(x+1);
            if (u==p) continue;
            B[e]=c;
            dfs(u,v,c);
            c++;
            if (c==d) c++;
        }
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 59844
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, min, max, minpos = 1, maxpos = 1;
    cin >> n;
    cout << 2 * n - 1 << endl;
    int a[n];
    cin >> a[0];
    min = a[0];
    max = a[0];
    for (int i = 1; i < n; i++)
    {
        cin >> a[i];
        if (min > a[i])
        {
            min = a[i];
            minpos = i + 1;
        }
        if (max < a[i])
        {
            max = a[i];
            maxpos = i + 1;
        }
    }
    if (abs(max) >= abs(min))
    {
        for (int i = 1; i <= n; i++) cout << maxpos << ' ' << i << endl;
        for (int i = 1; i <= n - 1; i++) cout << i << ' ' << i + 1 << endl;
    }
    else
    {
        for (int i = 1; i <= n; i++) cout << minpos << ' ' << i << endl;
        for (int i = n; i > 1; i--) cout << i << ' ' << i - 1 << endl;
    }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	if(K==1) cout<<0<<endl;
	else cout<<N-K<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using static Input;
using static Util;
class Program
{
    static int L, R, d;
    static void INPUT()
    {
        L = NextInt();
        R = NextInt();
        d = NextInt();

    }

    static void OUT()
    {
        var c = 0;
        for (int i = L; i <= R; i++)
        {
            if (i % d == 0)
                c++;
        }
        Console.WriteLine(c);
    }

    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}


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

const int maxn = 3e5+10 ;

int a[maxn] ;
int b[maxn] ;

int main() {

    ios::sync_with_stdio(false) ;
    cin.tie(0) ;

    string s ;

    cin >> s ;
    for(int i = 1; i < s.size(); i++){

        if(s[i] == s[i-1] ){

            cout << "Bad" ;
            return 0 ;

        }

    }

    cout << "Good" ;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int main() { 
  int n, m; 
  vector<int> a; 
  while(1) {  
    int x;  
    multimap<int, int> c;  
    cin >> n >> m;  
    if(n==0 && m==0) break; 
    for(int i=1; i<=n; i++) {  
      for(int j=1;j<=m; j++) {
	cin >> x;  
	if(x==0) a.push_back(j);   
      }   
    }  
    for(int i=1; i<=m; i++) {  
      c.insert(make_pair(count(a.begin(), a.end(), i), i));   
    }     
    for(multimap<int,int>::iterator it=c.begin(); it!=c.end(); it++) { 
      if(it!=c.begin()) cout << " ";    
      cout << it->second;  
    }  
    cout << endl;     
    a.clear();  
    c.clear(); 
  } 
  return 0;
}


Measured memory_bytes: 1532
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n,a,b; cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int n,p;
  int i,j;
  int bowl;

  for(;;){
    int mayor=51;
    scanf("%d %d",&n,&p);
    if(n==0&&p==0)break;
    bowl=p;

    int i=0;
    int cand[50]={0};

    for(;;){

      for(j=0;j<n;j++){
        if(cand[j]==p){
          mayor=j;
          break;
        }
      }

      if(mayor!=51)break;

      if(bowl!=0){
        cand[i%n]++;
        bowl--;
      }

      else if(bowl==0){
        bowl=cand[i%n];
        cand[i%n]=0;
      }

      i++;
    }

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

  }
  return 0;
}

Measured memory_bytes: 596
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int[] di = [1,0,-1,0,1,1,-1,-1], dj = [0,1,0,-1,1,-1,1,-1];
int ans;

void main() {
    while (1) {
        int w, h;
        scan(w, h);

        if (!w) return;

        auto c = iota(h).map!(i => readln.split.to!(int[])).array;

        int ans;

        foreach (i ; 0 .. h) {
            foreach (j ; 0 .. w) {
                if (c[i][j]) {
                    dfs(h, w, c, i, j);
                    ans++;
                }
            }
        }

        writeln(ans);
    }
}

void dfs(int h, int w, int[][] c, int i, int j) {
    c[i][j] = 0;

    foreach (k ; 0 .. 8) {
        int ni = i + di[k];
        int nj = j + dj[k];

        if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;

        if (c[ni][nj]) {
            dfs(h, w, c, ni, nj);
        }
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 3428
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        HashSet<Integer> hashSet =  new HashSet<>();
        hashSet.add(sc.nextInt());
        hashSet.add(sc.nextInt());
        hashSet.add(sc.nextInt());
        System.out.println(hashSet.size());
    }

    private static double cal(final int n) {
        double res = 0;
        double resm1 = 1;
        double ressum2 = 1;
        for (int i = 3; i < n + 1; i++) {
            res = 1.0 + 2.0 / i * ressum2;
            ressum2 += resm1;
            resm1 = res;
        }
        return res;
    }
}


Measured memory_bytes: 9800
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,A,B = (int(_) for _ in input().split())
    ans = 0
    for i in range(N+1):
        digit_sum = sum((int(_) for _ in list(str(i))))
        if digit_sum >=A and digit_sum<=B:
            ans += i
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <cmath>
#define MAXSIZE 7500000
using namespace std;

int main() {
  int m, n;

  while(1) {
    cin >> m >> n;
    if(m == 0 && n == 0) break;

    vector<int>	bam(MAXSIZE, 0);
    int cnt	= 0;

    for(int i = m; cnt < n; i++) {
      if(bam[i] == 0) {
	for(int j = i; j < MAXSIZE; j+=i) {
          bam[j] = 1;
	}
        cnt++;
      }
    }

    for(int i = m; i < MAXSIZE; i++) {
      if(bam[i] == 0) {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}


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

bool check( const vector<int>& v, int n ) {
	while( n > 0 ) {
		int dg = n % 10;

		if( count( v.begin(), v.end(), dg ) > 0 ) {
			return false;
		}

		n /= 10;
	}

	return true;
}

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

	vector<int> D( K );
	for( auto& v: D ) { cin >> v; }

	int result = N;

	while( !check( D, result ) ) {
		result += 1;
	}

	cout << result << endl;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

string S;
ll K;

int main() {
	cin >> S >> K;
	ll N = S.size();
	ll seq = 1;
	ll ans = 0;
	ll tmp = 0;

	if (S[0] == S[N - 1]) {
		ll lN = 0;
		ll rN = 0;
		ll cnt = 1;
		bool lEven = true;
		bool all = false;
		REP(i, N - 1) {
			if (S[i] == S[i + 1]) cnt++;
			else break;
		}
		lEven = cnt % 2 == 0;
		all = cnt == N;
		cnt = 1;
		bool rEven = true;
		for (int i = N - 1; i >= 1; i--) {
			if (S[i - 1] == S[i]) cnt++;
			else break;
		}
		rEven = cnt % 2 == 0;
		if (!lEven && !rEven) {
			if (all) tmp += K / 2;
			else tmp += K - 1;
//			tmp += K / 2;
		}
	}

	REP(i, N - 1) {
		if (S[i] == S[i + 1])
		{
			seq++;
			if (i == N - 1 - 1)
			{
				ans += seq / 2;
				seq = 1;
			}
		}
		else {
			ans += seq / 2;
			seq = 1;
		}
	}
	cout << ans * K  + tmp << endl;
}

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

int main()
{
    string s;
    cin >> s;
    int sum = 0;
    rep(i, s.size()) sum += s[i] - '0';
    if (sum % 9 == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}

string s;
ll tree[400000+5];
ll a[100000+5];
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a;
    if(a==0)
        return b; 
    return gcd(b, a % b);  
      
}
void build(ll node,ll start,ll end)
{
    if(start==end)
    {
        tree[node]=a[start];
        
    }
    else
    {
        ll mid = (start+end)/2;
        build(2*node+1,start,mid);
        build(2*node+2,mid+1,end);
        tree[node]=gcd(tree[2*node+1],tree[2*node+2]);
    }
}
void update(ll tree[],ll node,ll start,ll end,ll idx)
{
    if(start==end)
    {
        tree[node] = max(0LL,tree[node]-1);
    }
    else
    {
        ll mid = (start+end)/2;
        if(start<=idx && mid>=idx)
        {
            update(tree,2*node+1,start,mid,idx);
        }
        else
        {
            update(tree,2*node+2,mid+1,end,idx);
        }
        tree[node] = tree[2*node+1]+tree[2*node+2];
    }
}
ll query(ll node,ll start,ll end,ll l,ll r)
{
    if(r<start || l>end)
    {
        return 0;
    }
    if(l<=start && r>=end)
    {
        return tree[node];
    }
    ll mid = (start+end)/2;
    ll p1 = query(2*node+1,start,mid,l,r);
    ll p2 = query(2*node+2,mid+1,end,l,r);
   return gcd(p1,p2);
}

int main()
{                       
    fastio();
  
    int n,x,y;
    cin>>n>>x>>y;
    int dp[n+1][n+1];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=min({abs(j-i),abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1});
        }
    }
    int ans[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            ans[dp[i][j]]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<ans[i]/2<<endl;
}

Measured memory_bytes: 15872
#include<iostream>
#define N 105
using namespace std;
int n,u,k,v,M[N][N];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int i=0;i<k;i++)
      cin>>v,M[u-1][v-1]=1;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout<<' ';
      cout<<M[i][j];
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include<vector>
#include<cstdio>
using namespace std;
class Set{
    public: vector<int> set;
    Set(int n){
        set.resize(n+1);
        for(int i = 0;i < n+1;++i){
            set[i] = 0;
        }
        
    }
    
    public: void add(int x,int y){
        set[x] += y;
    }
    
    public: int getsum(int s,int e){
        int sum=0;
        for(int i = s;i <= e;++i){
            sum += set[i];
        }
        return sum;
    }
    
};

int main(void){
    int n,q,x,y,c;
    scanf("%d %d",&n,&q);
    Set set(n);
    for(int i = 0;i < q;++i){
        scanf("%d",&c) ;
        scanf("%d %d",&x,&y);
        if(c==0){
            set.add(x,y);
        }else{
            printf("%d\n",set.getsum(x,y));
        }
    }
    
}



Measured memory_bytes: 3412
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
c = RS()

# print(c)

r = c.count('R')
# print(r)

ans = 0
for i in range(r):
    if c[i]=='W':
        ans += 1
    else:
        pass
print(ans)

Measured memory_bytes: 87900
/**
        ______________________
      AnTi-MiRaGe on Anti-Mage xD
      --------------------------
**/
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <memory.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <vector>
#include <set>
#include <map>

#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define show puts("Debug")
#define int long long

using namespace std;

int a, b;

main()
{
    cin >> a >> b;
    cout << abs(a - 2) * abs(b - 2) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	public static void main(String[] args) {

	int[] n;
	n = new int[3];
	
	int min, mid, max;

	Scanner scan = new Scanner(System.in);

	n[0] = scan.nextInt();
	n[1] = scan.nextInt();
	n[2] = scan.nextInt();
	
	mid = n[0]+n[1]+n[2];
	
	min = (n[1] < n[2]) ? n[1] : n[2];
	min = (n[0] < min) ? n[0] : min;
	
	max = (n[1] < n[2]) ? n[2] : n[1];
	max = (n[0] < max) ? max : n[0];
	
	mid = mid - (min + max);

	System.out.println(min + " " + mid + " " + max);

	scan.close();
	
	}
}

Measured memory_bytes: 26164
if __name__ == '__main__':
    n = int(input())
    ryokans = list(map(lambda x: int(x), input().split()))

    answer = 0
    for i in range(n):
        ryokans_before_target = ryokans[:i+1]
        highest_indexes = [i for i, x in enumerate(ryokans_before_target) if x == max(ryokans_before_target)]

        if i in highest_indexes:
            answer += 1
    
    print(answer)

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

int main() {
    ll n,k;
    std::cin >> n>>k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i]--;
    }
    
    if(k<=1e6){
        ll now = 0;
        while(k>0){
            k--;
            now = a[now];
        }
        std::cout << now+1 << std::endl;
        return 0;
    }
    
    vector<ll> used(n,0);
    used[0] = 1;
    ll now = 0;
    ll cnt = 0;
    vector<ll> one(n,0),sec(n,0);
    ll hoi = 0;
    while(true){
        // std::cout << now << std::endl;
        cnt++;
        now = a[now];
        if(used[now]==1){
            one[now] = cnt;
        }else if(used[now]==2){
            sec[now] = cnt;
            hoi = now;
            break;
        }
        used[now]++;
    }
    k-=one[hoi];
    now=hoi;
    k%=(sec[hoi]-one[hoi]);
    now = hoi;
    while(k>0){
        k--;
        now = a[now];
    }
    std::cout << now+1 << std::endl;
}


Measured memory_bytes: 9596
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iterator>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  // 距離
  const int dx=tx-sx, dy=ty-sy;

  // 1
  cout<<string(dy,'U')<<string(dx,'R');
  
  // 2
  cout<<string(dy,'D')<<string(dx,'L');
  
  // 3
  cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
    
  // 3
  cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
  
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int K = sc.nextInt();
		Set<String> set = new TreeSet<>();
		for (int i = 0; i < s.length() ; i++) {
			for (int j = 0 ; j <=  s.length(); j++) {
				if (i < j && Math.abs(i - j) <= K) {
					set.add(s.substring(i, j));
				}
			}
		}
		Iterator<String> it = set.iterator();
		int i = 0;
		String answer = "";
		while (it.hasNext() && i < K) {
			answer = it.next();
			i++;
		}
		System.out.println(answer);
	}

}

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

#define loop(i, x, y) for (i = x; i < y; i++)
#define loopr(i, x, y) for (i = x; i > y; i--)

//use *it instead of it
#define vloop(it, x) for (auto it = x.begin(); it != x.end(); it++)
#define vloopr(it, x) for (auto it = x.end() - 1; it != x.begin() - 1; it--)

#define yes printf("YES\n")
#define no printf("NO\n")
#define pb push_back
#define mp make_pair

#define debug(x) cerr << #x << ":" << x << endl
#define yo cerr << "yo" << endl

typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;

const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

#define test(t) \
    ll t;       \
    cin >> t;   \
    while (t--)

//use double
#define precision(x)       \
    cout.setf(ios::fixed); \
    cout << setprecision(10) << x << endl;

// ll gcd(ll x_f, ll y_f)
// {
//     if (x_f == 0)
//         return y_f;
//     return gcd(y_f % x_f, x_f);
// }

// ll power(ll x_f, ll y_f, ll m_f)
// {
//     ll res_f = 1;

//     x_f = x_f% m_f;
//     while (y_f)
//     {
//         if (y_f & 1)
//             res_f = (res_f * x_f) % m_f;
//         y_f = y_f >> 1;
//         x_f = (x_f * x_f) % m_f;
//     }
//     return res_f;
// }

// ll less(ll x_f, ll y_f)
// {
//     return (x_f > y_f) ? y_f : x_f;
// }
// ll more(ll x_f, ll y_f)
// {
//     return (x_f < y_f) ? y_f : x_f;
// }

ll fac(ll x_f)
{
    ll fac_f = 1;
    for (ll i = 1; i <= x_f; i++)
    {
        fac_f *= i;
        fac_f = fac_f % MOD;
    }
    return fac_f;
}

bool composite[1000007] = {false};
ll seive(ll x)
{
    composite[0] = true;
    composite[1] = true;
    for (ll i = 2; i <= x; i++)
    {
        if (!composite[i])
        {
            for (ll j = 2 * i; j <= x; j += i)
            {
                composite[j] = true;
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll w, x, y, z;
    w = a * c;
    x = a * d;
    y = b * c;
    z = b * d;
//    cout << w << " " << x << " " << y << " " << z << endl;
    cout << max(w, max(x, max(y, z))) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <string>
#include <cstdint>
#include <iterator>
#include <algorithm>
#include <fstream>
#include <unordered_map>

using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Int int_fast64_t

int main()
{
    FAST_IO;
    Int n;
    cin >> n;
    if(n>=30)
        cout << "Yes" << endl;
    else
        cout << "No"  << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
int mitaball(int n,int Bn,int Cn);
int ball[10],B[10]={0},C[10]={0};
int judge;
int a;
int x;
int main(){
    scanf("%d",&x);
    for(int j=0;j<x;j++){
        judge=0;
        for(int i=0;i<10;i++)
            scanf("%d",&ball[i]);
        mitaball(0,0,0);
        if(judge==1)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}
int mitaball(int n,int Bn,int Cn){
    /*
    if(judge==0){
        if(n==10){
                                for(int k=0;k<10;k++)
                    printf("[%d][%d]\n",B[k],C[k]);
            for(int i=0;i<Bn-1;i++){
                if(B[i]>B[i+1])
                    break;
                judge=1;
            }
            for(int i=0;i<Cn-1;i++){
                if(C[i]>C[i+1]||judge==0){
                    judge=0;
                    break;
                }
                judge=1;
            }
        }
        else{
    */      if(n==10)
                judge=1;
            if(judge==0)
                if(Bn==0||B[Bn-1]<ball[n]){
                    B[Bn]=ball[n];
                        mitaball(n+1,Bn+1,Cn);
                    B[Bn]=0;
                }
                if(Cn==0||C[Cn-1]<ball[n]){
                C[Cn]=ball[n];
                    mitaball(n+1,Bn,Cn+1);
                C[Cn]=0;
            }
    /*
        }
    }
    */
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    const string days[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

    string s;
    cin >> s;

    int ans = 0;
    for (int i = 0; i < 7; i++) {
        if (s == days[i]) {
            ans = 7 - i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

def getsum(n):
  if n > 36: return 0
  else:
    i = n if n < 19 else 36-n
    return (i+3)*(i+2)*(i+1)//6 - max(2*(i-9)*(i-8)*(i-7)//3,0)

for i in sys.stdin:
    print(getsum(int(i)))

Measured memory_bytes: 7692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

struct edge {
  ll to;
};
vector<vector<edge>> graph;
stack<ll> q;
vector<bool> check(100000, false);
vector<ll> color(100000, 0);
vector<ll> prever(100000, -1);

void bfs(ll x, ll y){
    if(check.at(x)){
        return;
    }
    check.at(x) = true;
    prever.at(x) = y;
    q.push(x);
}

ll fennec = 0;
ll snuke = 0;

void paint(ll x, ll y){
    if(color.at(x) != 0){
        return;
    }
    color.at(x) = y;
    if(y == 1){
        fennec++;
    }
    else{
        snuke++;
    }
    q.push(x);
}

int main()
{
    ll N;
    cin >> N;
    graph.resize(N);
    rep(i, N-1){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph.at(a).push_back({b});
        graph.at(b).push_back({a});
    }
    q.push(0);
    while(!q.empty()){
        ll p = q.top();
        q.pop();
        for(auto e : graph.at(p)){
            bfs(e.to, p);
        }
    }
    vector<ll> route(0);
    route.push_back(N-1);
    ll x = N-1;
    while(true){
        if(x == 0){
            break;
        }
        route.push_back(prever.at(x));
        x = prever.at(x);
    }
    rep(i, sz(route)-2){
        if(i % 2 == 0){
            color.at(route.at(sz(route)-i/2-2)) = 1;
        }
        else{
            color.at(route.at(i/2+1)) = 2;
        }
    }
    vector<ll> black(0);
    vector<ll> white(0);
    rep(i, sz(route)){
        if(i % 2 == 0){
            black.push_back(route.at(sz(route)-i/2-1));
        }
        else{
            white.push_back(route.at(i/2));
        }
    }
    color.at(0) = 1;
    color.at(N-1) = 2;
    rep(i, sz(black)){
        q.push(black.at(i));
        while(!q.empty()){
            ll p = q.top();
            q.pop();
            for(auto e : graph.at(p)){
                paint(e.to, 1);
            }
        }
    }
    rep(i, sz(white)){
        q.push(white.at(i));
        while(!q.empty()){
            ll p = q.top();
            q.pop();
            for(auto e : graph.at(p)){
                paint(e.to, 2);
            }
        }
    }
//    cout << fennec << " " << snuke << endl;
    if(sz(route) % 2 == 0){
        if(fennec > snuke){
            cout << "Fennec" << endl;
        }
        else{
            cout << "Snuke" << endl;
        }
    }
    else{
        if(snuke > fennec){
            cout << "Snuke" << endl;
        }
        else{
            cout << "Fennec" << endl;
        }
    }
}

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

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

    long long s = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            s += i;
        }
    }

    cout << s << "\n";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 29;
 
int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b.begin(), b.end(), greater<int>());
	rep(i, n) {
		if (a[i] == b[0]) cout << b[1] << endl;
		else cout << b[0] << endl;
	}
	return 0;
}

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

int main() {
  int n, a[101];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  cout << a[n - 1] - a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*200100
c=[0]*200100
for i in range(n):
    if a[i]+i<n:
        c[a[i]+i]+=1
    if i-a[i]>=0:
        b[i-a[i]]+=1
ans=0
for i in range(n):
    ans+=b[i]*c[i]
print(ans)

Measured memory_bytes: 93056
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    vector<int> x;
    int a;
    int cnt = 1;
    while(1){
        cin >> a;
        if(a == 0){
            cout << cnt << endl;
            break;
        }
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  ios_base::sync_with_stdio(false);

  int N;
  llint X;
  cin >> N >> X;

  vector<llint> x(N);
  REP(i, N) cin >> x[i];

  vector<llint> p(N + 1);
  p[0] = 0;
  REP(i, N) p[i + 1] = p[i] + x[i];

  llint ret = 1e18;
  for (int K = 1; K <= N; ++K) {
    llint cost = (N + K) * X;

    int i = N, it = 0;
    while (i > 0 && cost < ret) {
      int it_cost = it == 0 ? 5 : 3 + 2 * it;
      int ni = max(0, i - K);
      cost += (p[i] - p[ni]) * it_cost;
      i = ni;
      it++;
    }

    ret = min(ret, cost);
  }

  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i, m) for (int i = 0; i < (m); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using ul = unsigned long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

int DIGIT = 64;

int count(ul state) {
    int cnt = 0;
    rep(i, DIGIT) {
        if (state & 1ul) cnt++;
        state = state>>1;
    }
    return cnt;
}

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

    int m;
    cin>>m;
    vector<int> ds(m);
    vector<ul> ms(m);
    rep(i, m) {
        int k;
        cin>>k;
        ds[i] = k;
        rep(j, k) {
            int b;
            cin>>b;
            ms[i] |= (1ul << b);
        }
    }

    int q;
    cin>>q;
    ul state = 0;
    rep(i, q) {
        int c, m;
        cin>>c>>m;
        if (c == 0) {
            cout<<((state&(1ll<<m)) != 0)<<endl;
        }
        else if (c == 1) {
            state |= ms[m];
        }
        else if (c == 2) {
            state &= ~ms[m];
        }
        else if (c == 3) {
            state ^= ms[m];
        }
        else if (c == 4) {
            cout<<(count(state&ms[m])==ds[m])<<endl;
        }
        else if (c == 5) {
            cout<<(count(state&ms[m])>0)<<endl;
        }
        else if (c == 6) {
            cout<<(count(state&ms[m])==0)<<endl;
        }
        else if (c == 7) {
            cout<<count(state&ms[m])<<endl;
        }
        else {
            cout<<(state&ms[m])<<endl;
        }
    }
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 1000005
#define db double
#define mod 1000000007
using namespace std;
void solve()
{
	ll n,k;
	cin >> n >> k;
	ll pre[n+1],suff[n+1];
	for(ll i=0;i<=n;i++)
	{
		pre[i]=i;
		suff[n-i]=n-i;
		if(i>0)
		{
			pre[i]+=pre[i-1];
			suff[n-i]+=suff[n-i+1];
		}
	}
	k--;
	ll ans = 0;
	for(ll i=k;i<=n;i++)
	{
		ans = (ans + (suff[n-i]-pre[i]+1))%mod;
	}
	cout << ans ;
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(6);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

Measured memory_bytes: 6692
#![allow(dead_code,unused_variables)]
use proconio::{fastout, input};
const MOD : usize = 1_000_000_007;

#[fastout]
fn main() {
    input! {
        S: usize,
    }
    let mut ans = 0;
    let c = Combination::new(S+2,MOD);
    for i in 1..S{
        if S < i*3{
            break;
        }
        let res = c.comb(S-i*3+i-1, i-1);
        ans = (ans + res) % MOD;
    }
    println!("{}",ans%MOD);
}

pub struct Combination{
    fac : Vec<usize>,
    finv : Vec<usize>,
    m : usize,
}

impl Combination{
    pub fn new(n : usize, m : usize) -> Self{
        let mut inv = vec![1;n+1];
        let mut fac = vec![1;n+1];
        let mut finv = vec![1;n+1];

        for i in 2..(n+1){
            fac[i] = (fac[i-1] * i) % m;
            inv[i] = m - (inv[m%i] * (m/i) % m);
            finv[i] = (finv[i-1]*inv[i])%m;
        }

        Combination{
            fac,
            finv,
            m,
        }
    }

    pub fn comb(&self, n : usize, k: usize) -> usize{
        if n < k{
            return 0;
        }

        (self.fac[n] * (self.finv[k] * self.finv[n-k] % self.m)) % self.m
    }
}

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define N 2010
#define mod 1000000007
#define ll long long
using namespace std;

ll f[N][N];
ll jc[N*N],inv[N*N];

ll C(int a,int b){
	if(a==b || b==0) return 1;
	if(a<b) return 0;
	return 1ll*jc[a]*1ll*inv[a-b]%mod*inv[b]%mod;
}
int main(){
	int n,k,i,j;
	scanf("%d%d",&n,&k);
	if(k==1){ puts("1");return 0; }
	jc[1]=inv[1]=1;
	for(i=0;i<=n;++i) f[i][0]=1;
	for(i=2;i<=n*k;++i) inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	for(i=2;i<=n*k;++i){
		jc[i]=1ll*jc[i-1]*i%mod;
		inv[i]=1ll*inv[i-1]*inv[i]%mod;
	}
	inv[1]=jc[1]=1;
	for(i=1;i<=n;++i)
		for(j=1;j<=i;++j)
			f[i][j]=(f[i-1][j]+1ll*f[i][j-1]*(n-j+1)%mod*C(n*k-i-(j-1)*(k-1)-1,k-2)%mod)%mod;		
	printf("%lld",f[n][n]);
}

Measured memory_bytes: 94848
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;


int main(){
    ll n,w;
    cin >> n >> w;
    vector<ll> ws(n);
    vector<ll> vs(n);
    rep(i,n) cin >> ws[i] >> vs[i];
    const int wmax = 1001001001;
    const int vmax = 100000;
    vector<vector<ll>> dp(2*vmax, vector<ll>(n+1,wmax));
    
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= vmax; j++){
            // not chosen
            dp[j][i] = min(dp[j][i],dp[j][i-1]);
            
            // chosen
            ll nw = dp[j][i-1] + ws[i-1];
            int nv = j + vs[i-1];  
            if (nw <= w){
                dp[nv][i] = min(dp[nv][i], nw);
            }
        }
    }

    ll ans = 0LL;
    for(ll i = 0LL; i <= 100000;i++){
        if (dp[i][n] <= w) ans = i;
    }
    cout << ans;
    
}









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

int main()
{
    int n, i, j;
    int cnt[5] = {0};
    char *id[5] = {"AC","WA","TLE","RE"};

    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        int m;
        char s[10] = {0};
        
        scanf("%s", s);
        for(m = 0; m < 4; m++)
            if(strcmp(s,id[m]) == 0)
                break;
        cnt[m]++;
    }
    printf("AC x %d\n", cnt[0]);
    printf("WA x %d\n", cnt[1]);
    printf("TLE x %d\n", cnt[2]);
    printf("RE x %d\n", cnt[3]);

    return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

const int N = 1e5 + 5;
int red[N], green[N], noc[N];

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	for(int i = 1; i <= a; i++) {
		cin >> red[i];
	}
	for(int i = 1; i <= b; i++) {
		cin >> green[i];
	}
	for(int i = 1; i <= c; i++) {
		cin >> noc[i];
	}
	sort(red + 1, red + a + 1);
	reverse(red + 1, red + a + 1);
	sort(green + 1, green + b + 1);
	reverse(green + 1, green + b + 1);
	vector<int> v;
	for(int i = 1; i <= x; i++) {
		v.push_back(red[i]);
	}
	for(int i = 1; i <= y; i++) {
		v.push_back(green[i]);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	for(int x : v) {
		ans += x;
	}
	sort(noc + 1, noc + c + 1);
	reverse(noc + 1, noc + c + 1);
	int n = x + y;
	ll cur = ans;
	for(int i = 1; i <= c; i++) {
		if(i <= n) {
			cur += noc[i];
			cur -= v[i - 1];
			ans = max(ans, cur);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    scanf("%d",&N);
    std::vector<int> A(N);
    for (size_t i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    int minan=1;
    for (size_t i = 0; i < N; i++) {
        if(A[i]%2==0){
            minan*=2;
        }else{
            minan*=1;
        }
    }
    int ans=pow(3,N);
    printf("%d\n",ans-minan);
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
int rot[24][7] = {
    { 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
    { 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
    { 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
    { 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
    { 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
    { 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];
 
int main()
{
    int i, j;
    int a[7], b[7], dice[7];
 
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    for (i = 1; i <= 6; i++) scanf("%d", a+i);
    for (j = 0; j < 24; j++) {
        for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
        for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
        for (i = 1; ; i++) {
            if (i > 6) { puts("Yes"); return 0; }
            if (a[i] != b[i]) break;
        }
    }
    puts("No");
    return 0;
}


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

int main(){
  int N,M;
  vector<int> kyougi,kyouginum,iin;
  
  cin >> N >> M;
  
  kyougi.resize(N);
  kyouginum.resize(N,0);
  iin.resize(M);

  for(int i=0;i<kyougi.size();++i)
    cin >> kyougi[i];
  for(int i=0;i<iin.size();++i)
    cin >> iin[i];

  for(int i=0;i<iin.size();++i){
    for(int ix = 0; ix<kyougi.size();++ix){
      if(kyougi[ix] <= iin[i]){
	++kyouginum[ix];
	break;
      }
    }
  }


  int ans = 1,maxn = kyouginum[0];
  for(int i=1;i<kyouginum.size();++i){
    if(maxn < kyouginum[i]){
      maxn = kyouginum[i];
      ans = i+1;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3112
import java.util.*;
public class Main{
	static String ShiriJudge(int m,String[] s){
		boolean bl = true;
		for(int i=0; i<m-1; i++){
			if(s[i].charAt(s[i].length()-1) != (s[i+1].charAt(0)))return "No";
		}
		for(int i=0; i<m; i++){
			for(int j=i+1; j<m; j++){
				if(s[i].equals(s[j]))return "No";
			}
		}
		return "Yes";
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] w = new String[n];
		for(int i=0; i<n; i++){
			w[i] = sc.next();
		}
		System.out.println(ShiriJudge(n,w));
	}
}

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


int main() {
  double V , M ;
  int T , N;
  cin >> N >> M ; 
  vector<int> A(N) ;
  T = 0 ; 
  V = 0 ;
  
  for (int i = 0 ; i < N ; i++){
    cin >> A.at(i) ;
    V = V + A.at(i) ; 
  }
  
    for (int i = 0 ; i < N ; i++){
    
    if (A.at(i) >= V/(4*M)){
    	T++ ; 
    }
  }


  if (T >= M){
    cout << "Yes" << endl ; 
    return 0 ; 
  }
  
  else {
    cout << "No" << endl ;  
    return 0 ; 
  }





}


Measured memory_bytes: 3760
class N:
    def __init__(self, a):
        self.a = a

    def __mul__(self, b):
        if self.a == 0:
            return N(0)
        elif self.a == 1:
            return N((b.a >= 1) * 1)
        else:
            return b

    def __add__(self, b):
        if self.a == 0:
            return b
        elif self.a == 1:
            return N((b.a > 1) + 1)
        else:
            return N(2)

    def __neg__(self):
        if self.a == 2:
            return N(0)
        elif self.a == 1:
            return N(1)
        else:
            return N(2)

while True:
    s = input().replace("-", "-").replace("0", "N(0)").replace("1", "N(1)").replace("2", "N(2)")
    N(1) + N(2)
    if s == ".": break

    result = []
    for P in map(N, range(3)):
        for Q in map(N, range(3)):
            for R in map(N, range(3)):
                result.append(eval(s).a)
    print(result.count(2))

Measured memory_bytes: 7476
from functools import reduce

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
      
n,m = map(int, input().split())
l = [list(map(int, input().split()))[1:] for i in range(n)]
langs = [list() for i in range(m)]
for p,i in enumerate(l):
  for lang in i:
    langs[lang-1].append(p)
commu = UnionFind(n)
for i in langs:
  if i:
    now = i[0]
    for j in i[1:]:
      commu.union(now,j)
      now = j
if commu.get_size(0) == n:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 77656