akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

@SuppressWarnings("unchecked")
class Main{

    static List<Integer> edges[];
    static long[] m;
    static long[] w;
    static long[] v;
    static long dfs(int p){
        w[p] += m[p];
        v[p] = 1;
        for(int q : edges[p]){
            w[p] += dfs(q);
            v[p] += v[q];
        }
        return w[p];
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N  =scan.nextInt();
        int X =scan.nextInt();
        int D = scan.nextInt();
        m = new long[N];
        edges = new ArrayList[N];
        for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
        m[0] = scan.nextLong();
        for(int i=1;i<N;++i){
            m[i]=scan.nextLong();
            edges[scan.nextInt()-1].add(i);
        }
        w = new long[N];
        v = new long[N];
        dfs(0);
        long[] dp = new long[50*50*50+1];
        Arrays.fill(dp, Long.MAX_VALUE/2);
        dp[0]=0;
//      dp[i][Y] : i番目まででY個作る時の最小コスト
//      dp[i][Y] = min(dp[i-1][Y-Yj]+Xj , dp[i-1][Y-2*Yj]+2*Xj, ..., dp[i-1][Y-50*Yj]+50*Xj);
//      (X0, Y0) , (X1, Y1), ..., (XN-1, YN-1)　→ (X0, Y0), (X0*2, Y0*2), (X0*4, Y0*4), ..., (XN-1*32, YN-1*32) ..01ナップサック
//      dp[i][Y] = Math.min(dp[i-1][Y], dp[i-1][Y-Yj]+Xj);
        for(int i=0;i<N;++i){
            int z = (i==0 ? 50 : Math.min(50,D));
            for(int k=0;z>0;++k){
                int kk = Math.min(z, (1<<k));
                z -= kk;
                for(int y=50*50*50;y>=0;--y)if(y-v[i]*kk>=0)dp[y]=Math.min(dp[y], dp[y-(int)v[i]*kk]+w[i]*(long)kk);
            }
        }

        class eff{
            double xy;
            int id;
            eff(double xy,int id){this.xy=xy;this.id=id;}
        }
        List<eff> list = new ArrayList<>();
        for(int i=0;i<N;++i)list.add(new eff((double)w[i]/(double)v[i], i));
        Collections.sort(list, (a,b)->a.xy > b.xy ? 1:-1);

        long ans = 0;
        for(int y=0;y<=50*50*50;++y){
            //id!=0のときD-50個、 id==0のとき無限個
            long x = X-dp[y];
            long n = y;
            if(x<0)continue;
            for(int i=0;i<N;++i){
                int id = list.get(i).id;
                if(id==0 || Math.max(0,D-50)*w[id]>=x){
                    n += (x/w[id])*v[id];
                    break;
                }else{
                    n += v[id]*Math.max(0,D-50);
                    x -= w[id]*Math.max(0,D-50);
                }
            }
            ans = Math.max(ans, n);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 27196
package main

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

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e9

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.next()
	ans := "Yes"
	for i := 0; i < len(n)/2; i++ {
		j := len(n) - i - 1
		if n[i] != n[j] {
			ans = "No"
			break
		}
	}

	fmt.Println(ans)
}

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

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  private static final int MOD = 1_000_000_007;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }
    // inside A
    int a = 0;
    for (int i = 0; i < N-1; i++) {
      for (int j = i+1; j < N; j++) {
        if (A[i] > A[j]) {
          a++;
        }
      }
    }
    
    Arrays.sort(A);
    int sumP = 0;
    for (int i = N-1; i >= 1; i--) {
      for (int j = i-1; j >= 0; j--) {
        if (A[i] > A[j]) {
          sumP++;
        }
      }
    }
    
    long KK = K%2 == 0 ? (long)K/2*(K-1) : (long)K*((K-1)/2);
    long ans = (((long)a*K)%MOD + ((KK%MOD)*sumP)%MOD)%MOD;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 27216
#include <stdio.h>
#include <cmath>
const int mod = (int)1e9 + 7;
bool is_prime(int n){
    for(int i = 2; i <= (int)sqrt(n); i ++){
        if(n % i == 0){
            return false;
        }
    }
    return true;
}
int main(){
    int n;
    int j = 0, k = 0;
    int primes[1000];
    int foo[1000];
    scanf("%d", &n);
    for(int i = 2; i <= n; i ++){
        if(is_prime(i)){
            primes[j++] = i;
        }
    }
    for(int i = 0; i < j; i ++){
        int s = 0;
        int cur_prime = primes[i];
        // printf("%d ", cur_prime);
        while(cur_prime <= n){
            s += floor(n / (1.0 * cur_prime));
            cur_prime *= primes[i];
        }
        foo[k ++] = s;
    }
    int res = 1;
    for(int i = 0; i < k; i ++){
        res = (long long)res * (foo[i] + 1) % mod;
    }
    printf("%d\n", res);
}


Measured memory_bytes: 128
//バブルソート
//2018-12-07
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

#define N 100

int main(){
  int count;
  int n, i;
  int array[N];
  int mark;
  int temp;

  scanf("%d",&n);

  if( n>100 || n<1){
    printf("要素数が範囲外です。\n");
    exit(1);
  }

  for( i=0 ; i<n ; i++ ){
    scanf("%d", &array[i]);
  }
  count=0;
  mark=1;
  while(mark){
    mark=0;
    for( i=n-1 ; i>=1 ; i-- ){
      if(array[i]<array[i-1]){
	temp=array[i];
	array[i]=array[i-1];
	array[i-1]=temp;
	count++;
	mark=1;

      }
      
    }
  }
  
  for( i=0 ; i<n ; i++ ){
    printf("%d",array[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  printf("\n%d\n",count);

  return 0;
}



Measured memory_bytes: 2084
n = int(input())
s = list(input())
total = 0
for i in range(1000):
  t = list(str(i).zfill(3))
  j = 0
  for c in range(len(s)):
    if (j<=len(t)-1):
      if(s[c] == t[j]):
        j += 1
  if (j == 3):
    total += 1
print(total)

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353 
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_backP
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;

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

	if(a==b){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 0x3f3f3f3f
#define ooLL 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define fastio() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> h(n+1);
    for(int i = 1; i <= n ; ++i) scanf("%d",&h[i]);

    vector<bool> v(n+1, true);
    for(int i = 0; i < m ; ++i){
        int a, b;
        scanf("%d%d", &a, &b);
        if(h[a] <= h[b]) v[a] = false;
        if(h[b] <= h[a]) v[b] = false;
    }
    int cnt = 0;
    for(int i = 1; i <= n ; ++i) if(v[i]) cnt++;

    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main(){
  int W , H , N;
  cin >> W >> H >> N;
  int maxx=0,maxy=0,minx=W,miny=H ;
  for(int i=0;i<N;i++){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1) maxx=max(x,maxx);
    if(a==2) minx=min(x,minx);
    if(a==3) maxy=max(y,maxy);
    if(a==4) miny=min(y,miny);
  }
  if(minx-maxx>0 && miny-maxy>0) cout<<(minx-maxx)*(miny-maxy)<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
class Sequence:
    def __init__(self,num, seq):
        self.n = num
        self.sequence = seq

def LinearSearch(A, n, key):
    i=0
    A[n] = key
    while A[i] != key:
        i += 1
    if i==n:
        return "NOT_FOUND"
    return i

if __name__ == "__main__":

    n = int(raw_input())
    x =	map(int, raw_input().split())
    x.append(" ")
    A = Sequence(n, x)
    n =	int(raw_input())
    x =	map(int, raw_input().split())
    x.append(" ")
    B = Sequence(n, x)

    C_num = 0

    for i in range(B.n):
        res = LinearSearch(A.sequence, A.n, B.sequence[i])
        if res != "NOT_FOUND":
            C_num += 1

    print(C_num)

Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>odd;
  vector<int>even;
  for(int i=0;i<n;i++){
  	int x;
  	cin>>x;
  	if(i%2==0){
  		odd.push_back(x);
  	}else{
  		even.push_back(x);
  	}
  }
  if(n%2==0){
  	for(int i=even.size()-1;i>=0;i--){
  		cout<<even[i]<<" ";
  	}
  	for(int i=0;i<odd.size();i++){
  		cout<<odd[i]<<" ";
  	}
  	cout<<endl;
  }else{
  	for(int i=odd.size()-1;i>=0;i--){
  		cout<<odd[i]<<" ";
  	}
  	for(int i=0;i<even.size();i++){
  		cout<<even[i]<<" ";
  	}
  	cout<<endl;
  }
}





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

int main(){
    int n; cin >> n;
    string s , t;
    cin >> s >> t;
    for(int i=n ; i<=n*2 ; ++i){
        string s1=s.substr(i-n,2*n-i);
        string t1=t.substr(0,2*n-i);
        if (s1 == t1) { cout << 2*i-i << endl; return 0; }
    }
    cout << 2*n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<string> g;

vector<int> elem;
vector<int> rrank;

void init(int num)
{
    elem = vector<int>(num, 0);
    rrank = vector<int>(num, 0);
    
    for (int i = 0; i < num; ++i)
    {
        elem[i] = i;
    }
}

int dfs(int num)
{
    if (elem[num] == num)
    {
        return num;
    }
    else
    {
        elem[num] = dfs(elem[num]);
        return elem[num];
    }
}

void unite(int a, int b)
{
    a = dfs(a);
    b = dfs(b);
    
    if (a == b)
    {
        return;
    }
    else
    {
        elem[b] = a;
    }
}

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n, m;
    cin >> n >> m;
    init(n);
    
    vector<P> v(m);
    for (int i = 0; i < m; ++i)
    {
        cin >> v[i].first >> v[i].second;
        v[i].first--;
        v[i].second--;
    }
    
    vector<ll> mm(n, 1);
    
    reverse(v.begin(), v.end());
    
    vector<ll> ret(m);
    ll cur = (n * (n - 1)) / 2;
    for (int i = 0; i < m; ++i)
    {
        ret[m - 1 - i] = max(0ll, cur);
        if (dfs(v[i].first) == dfs(v[i].second))
        {
            continue;
        }
        cur -= mm[dfs(v[i].first)] * mm[dfs(v[i].second)];
        mm[dfs(v[i].first)] += mm[dfs(v[i].second)];
        unite(v[i].first, v[i].second);
    }
    
    for (int i = 0; i < m; ++i)
    {
        cout << ret[i] << endl;
    }

    return 0;
}

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

namespace ABC138A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, max;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            max = a + b;
            if (max < a - b) max = a - b;
            if (max < a * b) max = a * b;
            Console.WriteLine(max);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;




int main(){	
	string s;cin>>s;
	int ini=-1,fin=-1;
	int n=sz(s);
	For(i,0,n)if(s[i]=='A'){
		ini=i;
		break;
	}
	roF(i,n-1,0)if(s[i]=='Z'){
		fin=i;
		break;
	}
	cout<<fin-ini+1<<endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int ans = pow(n, 3);

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

Measured memory_bytes: 384
N = int(input())
A = [int(i) for i in input().split()]

ans = -1
tmp_nums = []
check_num = 1

for i in range(len(A)):
  if A[i] == 1:
    check_num = 2
    tmp_nums = [1]
    ans = max(ans,len(tmp_nums))
  elif A[i] == check_num:
    check_num += 1
    tmp_nums.append(A[i])
    ans = max(ans,len(tmp_nums))

if ans == -1:
  print(-1)
else:
  print(N-ans)


Measured memory_bytes: 25768
#include<iostream>


using namespace std;
int main(){
	int k[4][13];
	char x;
	int n,i;
	cin >> n;
	for (int a = 0; a < 4; a++){
		
		for (int b = 0; b < 13; b++){
			k[a][b] = 0;

		}
	}
		for (int a = 0; a < n; a++){
			cin >> x >> i;
			if (x == 'S'){ k[0][i - 1] = 1; }
			if (x == 'H'){ k[1][i - 1] = 1; }
			if (x == 'C'){ k[2][i - 1] = 1; }
			if (x == 'D'){ k[3][i - 1] = 1; }
		}
		for (int a = 0; a < 4; a++){
			for (int b = 0; b < 13; b++){
				if (k[a][b] == 0){
					if (a == 0)	cout << "S "<<b+1<<endl;
					
					if (a == 1) cout << "H " << b + 1 << endl;

					if (a == 2)cout << "C " << b + 1 << endl;

					if (a == 3)cout << "D " << b + 1 << endl;
				}

			}

		}

		
	

	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans = 0;
int h, w;
vector<string> s;

bool can(pair<int, int> a, vector<vector<int>> dist) {
  int x = a.first;
  int y = a.second;

  return x >= 0 && x < h && y >= 0 && y < w && s[x][y] == '.' &&
         dist[x][y] == -1;
}

int vectormax(vector<vector<int>> dist) {
  int ans = 0;
  for (int i = 0; i < dist.size(); i++) {
    ans = max(ans, *max_element(dist[i].begin(), dist[i].end()));
  }
  return ans;
}
int main() {
  cin >> h >> w;
  s.resize(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }

  int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
  queue<pair<int, int>> que;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      vector<vector<int>> dist(h, vector<int>(w, -1));
      if (s[i][j] == '.') {
        que.push(make_pair(i, j));
        dist[i][j] = 0;  //始点は0

        while (!que.empty()) {
          pair<int, int> temp = que.front();
          que.pop();
          for (int k = 0; k < 4; k++) {
            pair<int, int> tmp;
            tmp.first = temp.first + dx[k];
            tmp.second = temp.second + dy[k];
            if (can(tmp, dist)) {
              dist[tmp.first][tmp.second] = dist[temp.first][temp.second] + 1;
              que.push(tmp);
            }
          }
        }
      }
      ans = max(ans, vectormax(dist));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
using ll = unsigned long long;

int main() {
  ll h, w;
  cin >> h >> w;

  vector<vector<char>> s(h + 2);
  for (ll i = 0; i < h + 2; i++) {
    vector<char> row(w + 2);
    for (ll j = 0; j < w + 2; j++) {
      if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
        row[j] = '#';
      } else {
        cin >> row[j];
      }
    }
    s[i] = row;
  }

  ll cnt = 0;
  vector<vector<int>> dirs = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  queue<vector<ll>> q;

  for (ll i = 1; i < h + 1; i++) {
    for (ll j = 1; j < w + 1; j++) {
      for (ll k = 1; k < h + 1; k++) {
        for (ll l = 1; l < w + 1; l++) {
          if (s[k][l] == 'x') {
            s[k][l] = '.';
          }
        }
      }
      if (s[i][j] == '#') continue;
      q.push({i, j, 0});
      while (!q.empty()) {
        vector<ll> current = q.front();
        q.pop();

        // cout << current[0] << " " << current[1] << " " << current[2] << endl;
        // for (ll k = 1; k < h + 1; k++) {
        //   for (ll l = 1; l < w + 1; l++) {
        //     cout << s[k][l];
        //   }
        //   cout << endl;
        // } 

        if (s[current[0]][current[1]] != '.') continue;
        s[current[0]][current[1]] = 'x';

        for (vector<int> dir : dirs) {
          ll ii = current[0] + dir[0];
          ll jj = current[1] + dir[1];
          ll depth = current[2] + 1;
          if (s[ii][jj] == '.') {
            q.push({ii, jj, depth});
            if (cnt < depth) cnt = depth;
          }
        }
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main( void )
{
	int n, input[10], stA[11], stB[11];
	cin >> n;
	while(n--) {
		for(int i=0; i < 10; ++i) {
			stA[i] = stB[i] = 0;
			cin >> input[i];
		}
		int idxI, idxA, idxB;
		idxI = 2; idxA = idxB = 0;
		stA[0] = input[0];
		if(stA[0] < input[1]) {
			stA[1] = input[1];
			idxA = 1;
		}
		else {
			stB[0] = input[1];
		}
		bool hit = true;
		while(10 > idxI && hit) {
			int tmp = input[idxI];
			if(stB[idxB] < stA[idxA]) { // A
				if(stA[idxA] < tmp) stA[++idxA] = tmp;
				else if(stB[idxB] < tmp) stB[++idxB] = tmp;
				else hit = false;
			}
			else {	// B
				if(stB[idxB] < tmp) stB[++idxB] = tmp;
				else if(stA[idxA] < tmp) stA[++idxA] = tmp;
				else hit = false;
			}
			++idxI;
		}
		if(idxI == 10 && hit)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

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

using namespace std;
using LL = long long;

const int MOD = 1e9+7;

class Edge{
public:
    LL from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

int parse(string str){
    int sum = 0;
    reverse(str.begin(), str.end());
    map<char, int> mp;
    mp['m'] = 1000;
    mp['c'] = 100;
    mp['x'] = 10;
    mp['i'] = 1;
    for(int i = 0;i < str.size();i++){
        if(i == str.size() -1 || mp.find(str[i+1]) != mp.end()){
            sum += mp[str[i]];
        }else{
            sum += mp[str[i]] * (str[i + 1] - '0');
            i++;
        }

    }
    return sum;
}
string usi(int num){
    string s = to_string(num);
    reverse(s.begin(), s.end());
    string ans;
    vector<char> a = {'m', 'c', 'x', 'i'};

    reverse(a.begin(), a.end());
    for(int i = 0;i < s.size();i++){
        if(s[i] == '0'){
            continue;
        }else if(s[i] == '1'){
            ans += a[i];
        }else{
            ans += a[i];
            ans += s[i];
        }
    }
    reverse(ans.begin(), ans.end());
    return ans;
}
int main(){
    int N;cin >> N;
    for(int i = 0;i < N;i++){
        string a,b;cin >> a >> b;
        cout<<usi(parse(a) + parse(b))<<endl;
    }
}



Measured memory_bytes: 3140
#include <iostream>
#include <vector>

using namespace std;

const int N = (int) 2e5;

vector <int> g[N];
int match;
int busy[N];

void dfs(int v, int p = -1) {
	for (int to : g[v]) if (to != p) {
		dfs(to, v);
		if (!busy[to] && !busy[v]) {
			match++;
			busy[v] = busy[to] = true;
		}
	}
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	if (match * 2 != n) {
		cout << "First\n";
	} else {
		cout << "Second\n";
	}
	return 0;
}

Measured memory_bytes: 8576
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
inline void solve(void){
  string S;
  in(S);
  rep(i,S.size())cout<<'x';
  cout<<endl;
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10,M=6e6+10;

int n,a[N],val[N],suf[N];
int pos[N][2],mx[2],mn[2][2],le[2][2];
char ans[N];

struct BIT{
	int t[N],tg[M],vl[M],cnt;
	inline void ad(int x,int vv)
	{
		for(;x<=n;x+=(x&(-x))){
			tg[++cnt]=x;vl[cnt]=t[x];
			t[x]=max(t[x],vv);
		}
	}
	inline int get(int x)
	{
		int re=-1e9;
		for(x=min(x,n);x;x-=(x&(-x))) re=max(re,t[x]);
		return re;
	}
	inline void reback(int x){for(;cnt>x;t[tg[cnt]]=vl[cnt--]);}

}bit[2];

int main(){
	scanf("%d",&n);
	int i,j,k,x,y,cur=n+1,ptr,nq=0;
    for(i=1;i<=n;++i){
    	scanf("%d",&a[i]);
    	a[i]=n+1-a[i];
    	if(cur>a[i]){
    		cur=a[i];val[i]=2;
    	}else val[i]=1;
    }
    memset(bit[1].t,0x8f,sizeof(bit[1].t));
    for(i=n;i;--i) suf[i]=suf[i+1]+(val[i]==2);
    for(i=n;i>1;--i){
    	 for(j=0;j<2;++j) mx[j]=max(0,bit[j].get(a[i]));
    	 for(j=0;j<2;++j){
    	 	x=mx[j]+val[i];
    	 	bit[x&1].ad(a[i],x);
    	 }
    	 for(j=0;j<2;++j) pos[i][j]=bit[j].cnt;
    }
    mn[0][0]=mn[0][1]=n+1;
    for(i=1;i<=n;++i){
    	nq^=1;
        if(i<n)	for(j=0;j<2;++j) bit[j].reback(pos[i+1][j]);
		for(j=0;j<2;++j){
			for(k=0;k<2;++k) mn[nq][k]=mn[nq^1][k],le[nq][k]=le[nq^1][k];
    		if(a[i]<mn[nq^1][j]){mn[nq][j]=a[i];le[nq][j]=le[nq^1][j]+1;}
    		ptr= i==n?(le[nq][0]==le[nq][1]):0;
    		if(i<n){
    			for(k=0;k<2;++k){
    				x=le[nq][k]-le[nq][k^1]+suf[i+1];
    				if(x>=0 && x<=bit[x&1].get(mn[nq][k^1])){ptr=1;break;}
    			}
    		}
    		if(ptr){ans[i]='0'+j;break;}
    	}
    	if(!ans[i]){printf("-1");return 0;}
    }
    for(i=1;i<=n;++i) putchar(ans[i]);
    return 0;
}


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

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= b; i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

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

int main() {
  ll n;
  cin >> n;
  vector<ll> p(n);
  rep(i, 0, n) cin >> p[i];

  vector<ll> a(n, 0), b(n, 0);
  ll m = n + 10000;
  rep(i, 0, n) a[i] += (i * m);
  rep(i, 0, n) b[i] = a[n - i - 1] + 1;
  rep(i, 0, n) a[p[i] - 1] += i + 1;

  rep(i, 0, n) cout << a[i] << " ";
  cout << endl;
  rep(i, 0, n) cout << b[i] << " ";
  cout << endl;
}

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

using ll = long long;
ll MOD = 998244353;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if (n > 0) {
    res = power(x, n / 2, m);
    if (n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, s;
  cin >> n >> s;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  vector<vector<ll>> dp(n + 1, vector<ll>(s + 1));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < s; j++) {
      dp[i + 1][j] += dp[i][j] * 2;
      dp[i + 1][j] %= MOD;
      if (a.at(i) + j > s) continue;
      dp[i + 1][j + a.at(i)] += dp[i][j];
      dp[i + 1][j + a.at(i)] %= MOD;
    }
  }
  
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += (power(2, n - i, MOD) * dp[i][s]) % MOD;
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 73636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    string s;
    cin >> s;
    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi") cout << "Yes" << endl;
    else cout <<"No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		int in0 = scan.nextInt();

		for (int i = 0; i < in0; i++) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			int z = scan.nextInt();
			
			int x2 = (int)Math.pow(x, 2);
			int y2 = (int)Math.pow(y, 2);
			int z2 = (int)Math.pow(z, 2);
			
			boolean sw = false;
			
			if(x2 == (y2 + z2))sw = true;
			if(y2 == (x2 + z2))sw = true;
			if(z2 == (y2 + x2))sw = true;
			
			if (sw) {
				System.out.println("YES");
			} else System.out.println("NO");
			
		}
	}

}

Measured memory_bytes: 32832
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int L, R, d; cin >> L >> R >> d;
  int cnt = 0;
  for (int i=L;i<=R;i++){
    if (i%d==0) cnt++;
  }
  cout << cnt << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3628
//Banned K

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nvarep(n,m);
    map<ll,ll>a;
    rep(i,0,n){
        a[m[i]]++;
    }
    ll ans = 0;
    irep(i,a){
        ans+=(i->second)*(i->second-1)/2;
    }
    rep(i,0,n){
        cout<<ans-a[m[i]]+1<<nnn;
    }
    return 0;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	int a[3][3];
	FOR(3)
	FOR(j, 3)
	cin >> a[i][j];
	int n;
	cin >> n;
	FOR(k, n)
	{
		int t;
		cin >> t;
		FOR(i, 3)
		FOR(j, 3)
		if (a[i][j] == t)
			a[i][j] = -1;
	}
	FOR(3)
	{
		int cnt = 0;
		FOR(j, 3)
		{
			if (a[i][j] == -1)
				cnt++;
		}
		if (cnt == 3)
		{
			cout << "Yes";
			return 0;
		}
	}
	FOR(3)
	{
		int cnt = 0;
		FOR(j, 3)
		{
			if (a[j][i] == -1)
				cnt++;
		}
		if (cnt == 3)
		{
			cout << "Yes";
			return 0;
		}
	}
	FOR(3)
	{
		if (a[i][i] != -1)
			break;
		if (i == 2)
		{
			cout << "Yes";
			return 0;
		}
	}
	for (int i = 2; ~i; --i)
	{
		if (a[i][2 - i] != -1)
			break;
		if (i == 0)
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

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

using namespace std;
typedef long long ll;

char a[1001][1001];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int dx2[] = {-2, -2, -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2, 2, 2,-1,1,-1,1};
int dy2[] = {-2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2,-1,1,1,-1};
bool c[1001][1001];

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

    int n, m;
    cin >> n >> m;
    int x, y, nx, ny;
    cin >> x >> y >> nx >> ny;
    x -= 1; y -= 1; nx -= 1; ny -=1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    queue<pair<int, int>> q;
    q.push({x, y});
    c[x][y] = true;
    int ans = 0;

    while (1)
    {
        queue<pair<int, int>> q2;
        while (!q.empty())
        {
            int x = q.front().first;
            int y = q.front().second;
            q.pop();
            q2.push({x, y});
            for (int i = 0; i < 4; i++)
            {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (nx >= 0 && ny >= 0 && nx < n && ny < m && a[nx][ny] != '#' && !c[nx][ny])
                {
                    c[nx][ny] = true;
                    q.push({nx, ny});
                }
            }
        }

        if (c[nx][ny])
        {
            break;
        }
        
        while (!q2.empty())
        {
            int x = q2.front().first;
            int y = q2.front().second;
            
            q2.pop();
            for (int i = 0; i < 20; i++)
            {
                int nx = x + dx2[i];
                int ny = y + dy2[i];
                if (nx >= 0 && ny >= 0 && nx < n && ny < m && a[nx][ny] != '#' && !c[nx][ny])
                {
                    c[nx][ny] = true;
                    q.push({nx, ny});
                }
            }
        }
        ans += 1;
        
        if (c[nx][ny])
        {
            break;
        }
        if(q.size() == 0){
            cout << -1<<'\n'; return 0;
        }
    }

    cout << ans << '\n';
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    int sum = 0;
    vector<int> a(n);
    for (int i = 0;i < n;++i) {
        cin >> a[i];
        sum ^= a[i];
    }
    for (int i = 0;i < n;++i) cout << (a[i]^sum) << " \n"[i == n-1];
}

Measured memory_bytes: 3964
#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int q;
int c, a, n;

int main()
{
    scanf("%d", &q);

    for (int i = 0; i < q; i++) {
        int ans = 0;
        scanf("%d %d %d", &c, &a, &n);

        for (int j = 0; j <= 1000; j++) {
            for (int k = 0; k <= 1000; k++) {
                if (c - (j * 3 + k * 2) < 0) continue;
                if (a - k < 0) continue;
                ans = max(ans, j + k +
                          min(n, min(c - (j * 3 + k * 2), a - k)));
            }
        }

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

    return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> t(n), x(n), y(n);

    rep(i, n) {
        cin >> t[i] >> x[i] >> y[i];
    }
    t.insert(t.begin(), 0), x.insert(x.begin(), 0), y.insert(y.begin(), 0);

    rep(i, n) {
        ll dx = abs(x[i+1] - x[i]);
        ll dy = abs(y[i+1] - y[i]);
        ll dt = abs(t[i+1] - t[i]);
        // cout << dt << " " << dx << " " << dy << endl;
        if (!(dt >= dx + dy && (dt - dx - dy) % 2 == 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
    
    return 0;
}

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

using namespace std;


int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i == j) {
                continue;
            }
            int counter = 0;
            for(int k = 0; k < d; k++) {
                int diff = abs(x[i][k] - x[j][k]);
                counter += diff * diff;
            }
            bool ok = false;
            for(int k = 0; k < 1000; k++) {
                if(k * k == counter) {
                    ok = true;
                }
            }
            if(ok) {
                ans++;
            }
        }
    }
    cout << ans / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int cnt=0;
  int m=1000000010;
  long long sum=0;
  bool z=false;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]<0){
      cnt++;
    }
    if(a[i]==0){
      z=true;
    }
    m=min(m,abs(a[i]));
    sum+=abs(a[i]);
  }
  if(cnt%2==0||z){
    cout << sum << endl;
  }
  else{
    cout << sum-2*m << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int a;cin >> a;
    cout << 3 * a * a << endl;
}


Measured memory_bytes: 256
n = gets.to_i
num = gets.strip.split.map(&:to_i)
ary = Array.new(n,0)
ary[0] = num[0]
for i in 1..n-1
  if ary[i-1] < num[i]
    ary[i] = num[i]
  else
    ary[i] = ary[i-1]
  end
end
#最大値をaryに記録した
puts ary.sum-num.sum

Measured memory_bytes: 31844
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = sc.nextInt();
        long ans = 0;
        for (int i = 1; i < n; i++) {
            int a = sc.nextInt();
            if (a <= max) {
                ans += max - a;
            } else {
                max = a;
            }
        }
        System.out.println(ans);
	}
}

Measured memory_bytes: 57868
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int r;
  if(s=="MON")
  {
    r=6;
  }
  else if(s=="TUE")
  {
    r=5;
  }
  else if(s=="WED")
  {
    r=4;
  }
  else if(s=="THU")
  {
    r=3;
  }
  else if(s=="FRI")
  {
    r=2;
  }
  else if(s=="SAT")
  {
    r=1;
  }
  else
  {
    r=7;
  }
  cout<<r<<endl;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    h,w = inpm()
    n = inp()
    a = inpl()
    ans = [[0 for _ in range(w)] for _ in range(h)]
    x,y,key = 0,0,1
    for i in range(n):
        for j in range(a[i]):
            ans[x][y] = str(i+1)
            if key:
                x += 1
                if x == h:
                    key = 0
                    x -= 1
                    y += 1
            else:
                x -= 1
                if x == -1:
                    key = 1
                    x += 1
                    y += 1
    for i in range(h):
        print(' '.join(ans[i]))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 4836
#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>
#include <functional>
#include <vector>
#include <math.h>
#include <typeinfo>
#include <numeric>
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
using namespace std;

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

	int begin = X - (K - 1);
	int end = X + (K - 1);

	begin = max(-1000000, begin);
	end = min(1000000, end);

	for (int i = begin; i <= end; i++)
	{
		cout << i << " ";
	}

	cout << endl;

	return 0;
 
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String op = sc.nextLine();
		String[] items = op.split(" ");

		Stack<Integer> stack = new Stack<>();
		for (int i=0; i<items.length; i++) {
			char c = items[i].charAt(0);
			if (c>='0'&&c<='9') {
				stack.push(Integer.parseInt(items[i]));
			} else {
				int b = stack.pop();
				int a = stack.pop();
				if (c=='+') {
					stack.push(a+b);
				} else if (c=='-') {
					stack.push(a-b);
				} else {
					stack.push(a*b);
				}
			}
		}

		System.out.println(stack.pop());

		sc.close();
	}

}

Measured memory_bytes: 26336
n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]

# 同チャンネルの連続する放送を一つにまとめる
stc.sort(key=lambda x: (x[2], x[0]))
 
imos = [0] * (10**5 + 1)

curr_c = 0
cuur_t = 0
for s, t, c in stc:
  if curr_c == c and curr_t == s:
    imos[s] += 1
  else:
    imos[s-1] += 1
  imos[t] -= 1
  curr_t = t
  curr_c = c
  
rui = [0] * (10**5 + 1)

for i in range(10**5):
  rui[i+1] = rui[i] + imos[i]
  
print(max(rui))

Measured memory_bytes: 35504
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
   int N;
   string S;
   cin >> N ;
   cin >> S;
   long r, g, b;
   r = 0; g = 0; b = 0;
   for(int i=0; i<N; i++){
       if(S[i] == 'R') r++;
       if(S[i] == 'G') g++;
       if(S[i] == 'B') b++;
   }
   long ans = 0;
   ans += r * b * g;
   for(int g=1; g * 2 < N; g++){
       for(int i=0; i + 2 * g < N; i++){
           if(S[i] != S[i+g] && S[i+g] != S[i+2*g] && S[i+2*g] != S[i]) ans --;
       }
   }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define see(x) cout<<(#x)<<" -> "<<(x)<<"\n"
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
  nimble;
  int tt=1;//cin>>tt;
  while(tt--){
    int n;
    cin>>n;
    vector<int> p(n),q(n),A(n),B(n);
    rep(i,0,n)
    cin>>p[i],A[i]=i+1;
    rep(i,0,n)
    cin>>q[i],B[i]=i+1;
    int a=0,b=0;
    do{
            a++;
        if(p==A){
            a++;
            break;
        }
    }while(next_permutation(all(A)));
  //  see(a);
    do{
        b++;
        if(q==B){
            b++;
            break;
        }
    }while(next_permutation(all(B)));
    cout<<abs(a-b);
  }
  return 0;
}


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

int main()
{
  int A,B,fee;
	cin >> A >> B;
	if( A >= 13 ){
		fee = B;
	}else if( 6 <= A && 12 >= A ){
		fee = B/2;
	}else{
		fee = 0;
	}
	cout << fee << endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>){
    val typesOfFood = readLine()!!.toInt()
    val foodList = readLine()!!.split(" ").map(String::toInt)
    val happyLevel = readLine()!!.split(" ").map(String::toInt)
    val addHappyLevel = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var ans = 0
//    println(foodList.size)
    for(i in 0..typesOfFood-1){
        ans += happyLevel[foodList[i]-1]
        if(i >= 1) {
            if (foodList[i] == foodList[i-1]+1) {
                ans += addHappyLevel[foodList[i]-1-1]  // 0-2
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 36388
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < 10 && b < 10) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }
        sc.close();
    }
}


Measured memory_bytes: 22228