akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        A: usize,
        B: usize,
        S: String,
    }

    let mut is_ok = true;
    for i in 0..A {
        if &S[i..=i] == "-" {
            is_ok = false;
        }
    }

    if &S[A..=A] != "-" {
        is_ok = false;
    }

    for i in A + 1..A + B + 1 {
        if &S[i..=i] == "-" {
            is_ok = false;
        }
    }

    let ans = if is_ok { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 2184
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pqM = priority_queue<int>;
using pqm = priority_queue<int,vector<int>,greater<int>>;
using q = queue<int>;

const int INF = 1001001001;
int a[12][12]; 

int main() {
   int n,m,x;
   cin >> n >> m >> x;
    vector<int> c(n);
    rep(i,n){
        cin >> c[i];
        rep(j,m) cin >> a[i][j];
                }

    int yen = INF;
rep(s,1<<n) {
    int cost = 0;
        vector<int> d(m);
    rep(i, n) {
        if(s>>i&1) {
            cost += c[i];
            rep(j,m) d[j] += a[i][j];
        }
    }
    bool ok = true;
    rep(j,m) if(d[j] < x) ok = false;
    if(ok) yen = min(yen,cost);
}

if(yen == INF) cout << -1 << endl;
else cout << yen << endl;
return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,temp,r=0,ans=0;
    cin>>n;
    temp=n;
    while(temp){
        r=temp%10;
        temp=temp/10;
        ans+=r;
    }
    if(n%ans==0)
        cout<<"Yes";
    else
        cout<<"No";
return 0;
}

   

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

#define N 100000

int a[N + 1];
map<int, int> m;
 
int main(){
	map<int, int>::iterator it;
	int ans, n, i;

	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		scanf("%d", a + i);
		m[a[i]]++;
	}

	ans = 0;

	for (it = m.begin(); it != m.end(); it++){
		if (it->second < it->first){
			ans += it->second;
		}
		else{
			ans += it->second - it->first;
		}
	}

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

	return 0;
} 

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> a;
    for(int i=0; i<N; i++)
    {
    	int x;
    	cin >> x;
    	a.push_back(x);
    }

    int even = 0, odd = 0, four = 0;
    for(int i=0; i<N; i++)
    {
    	if(a[i]%2==0) even++;
    	else odd++; 

    	if(a[i]%4==0) four++;
    }

    if(even!=four) odd++;

    if(odd-1<=four) cout << "Yes" << endl;
    else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
	int h, w; cin >> h >> w;
    
	vector<string> a(h);
	for (int i = 0; i < h; i++) cin >> a.at(i);

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a.at(i).at(j) == '#') {
				row.at(i) = true;
				col.at(j) = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row.at(i)) {
			for (int j = 0; j < w; j++) {
				if (col.at(j)) {
					cout << a.at(i).at(j);
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
def solver(n ,m, coins):
  dp = [[100000] * (n + 1) for i in range(m + 1)]
  for i in range(m + 1): dp[i][0] = 0
  for r in range(1, m + 1):
    for c in range(1, n + 1):
      if 0 > c - coins[r - 1]:
        dp[r][c] = dp[r - 1][c]
      else:
        dp[r][c] = min(dp[r - 1][c], dp[r][c - coins[r - 1]] + 1)
  print(dp[m][n])


n, m = map(int, input().split())
coins = sorted(list(map(int, input().split())))
solver(n, m, coins)


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

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

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

    ll cnt=0, mini=1e+10;
    for(int i=0; i<n; i++){
        int a;  cin >> a;
        if(mini<a) continue;
        cnt += 1;
        mini = a;
    }

    cout << cnt << endl;
    
    
}

Measured memory_bytes: 256
l = list(map(int, input().split()))
n, y = l[0], l[1]
y /= 1000
ans = '-1 -1 -1'
flag = 0
for i in range(n+1):
    for j in range(n-i+1):
        k = n-(i+j)
        total = 10*i+5*j+k
        if total == y:
            ans = '{} {} {}'.format(i, j, k)
            flag = 1
            break
    if flag: break
print(ans)


Measured memory_bytes: 3064
Module Module1

    Sub Main()
        Dim readline As String
        Dim hogelen As Integer = 0
        Dim hogehoge() As String

        hogelen = CType(Console.ReadLine(), Integer)
        readline = Console.ReadLine()

        hogehoge = readline.Split(" ")

        Dim wasawasa(hogelen) As Integer

        Dim i As Integer = 0
        For Each tempstr As String In hogehoge
            wasawasa(i) = CType(tempstr, Integer)
            i += 1
        Next

        If nyukokucheck(wasawasa) Then
            Console.Write("APPROVED")
        Else
            Console.Write("DENIED")
        End If



    End Sub


    Private Function nyukokucheck(ByVal hogehoge As Integer()) As Boolean

        For Each value As Integer In hogehoge
            If value Mod 2 = 0 Then
                If value Mod 3 = 0 Then
                    Continue For
                ElseIf value Mod 5 = 0 Then
                    Continue For
                Else
                    Return False
                End If
            End If
        Next
        Return True
    End Function

End Module


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <unordered_set>
#include <map>

const std::string MARCH = "MARCH";

int main() {
    int N;
    std::cin >> N;

    std::map<char, std::unordered_set<std::string>> initial_sets;
    for (char initial : MARCH) {
        initial_sets[initial] = std::unordered_set<std::string>();
    }
    for (int i = 0; i < N; i ++) {
        std::string s;
        std::cin >> s;
        initial_sets[s[0]].insert(s);
    }

    long count = 0;
    for (int i = 0; i < 5; i ++) {
        char initial1 = MARCH[i];
        for (int j = i + 1; j < 5; j ++) {
            char initial2 = MARCH[j];
            for (int k = j + 1; k < 5; k ++) {
                char initial3 = MARCH[k];
                count += initial_sets[initial1].size()
                         * initial_sets[initial2].size()
                         * initial_sets[initial3].size();
            }
        }
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 9344
#include <cstdio>

int main(){
    char s[100];
    char p[100];
    int n;
    for(int i = 0;i < 100;i++){
        s[i] = 0;
        p[i] = 0;
    }
    scanf("%s %s",s,p);
    for(int i = 0;;i++){
        if(s[i] == 0){
            n = i;
            break;
        }
    }
    for(int i = 0;i <= n + 1;i++){
        if(i == n + 1){
            printf("No\n");
        }
        for(int j = 0;;j++){
            if(s[(i + j) % n] != p[j]){
                if(p[j] == 0){
                    printf("Yes\n");
                    i = n + 2;
                    break;
                }
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

int main(void) {
    int n, q;
    string s;
    scanf("%d%d", &n, &q);
    cin >> s;

    vector<int> count(n);
    for (int i = 0; i < n - 1; i++) {
        count[i + 1] = count[i];
        count[i + 1] += strcmp(s.substr(i, 2).c_str(), "AC") == 0;
    }

    for (int i = 0; i < q; i++) {
        int l, r;
        scanf("%d%d", &l, &r);
        l--, r--;
        printf("%d\n", count[r] - count[l]);
    }
    return 0;
}

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

#define MAX_N 100000

struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
};

typedef struct Node* NodePointer;
NodePointer nil[MAX_N];

int memo[MAX_N];
int getDepth(int,int*);
void init(int);
void insert(int,int);
void displayList(int,int);

int main(){
  int n,i,j,id,child,type;
  int parent[MAX_N],k[MAX_N],num[MAX_N];
  char name[3][14] = {"root","leaf","internal node"};

  memset(parent,-1,sizeof(parent));
  memset(memo,-1,sizeof(memo));
  memset(num,0,sizeof(num));

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&id,&k[i]); init(id);
    num[id] = k[i];
    for(j = 0 ; j < k[i] ; j++){
      scanf("%d",&child);
      parent[child] = id;
      insert(child,id);
    }
  }
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, depth = %d, "
           ,i,parent[i],getDepth(i,parent));
    if(parent[i] == -1){ type = 0; }
    else if(num[i] == 0){ type = 1; }
    else{ type = 2; }
    printf("%s, [",name[type]);
    displayList(i,k[i]);
  }
  return 0;
}

int getDepth(int x,int *parent){
  if(parent[x] == -1){ return 0; }
  if(memo[x] >= 0){ return memo[x]; }
  return memo[x] = getDepth(parent[x],parent) + 1;
}

void init(int idx){
  nil[idx] = malloc(sizeof(struct Node));
  nil[idx]->next = nil[idx];
  nil[idx]->prev = nil[idx];
  nil[idx]->key = -1;
}

void insert(int key,int idx){
  NodePointer x,y;
  x = malloc(sizeof(struct Node));
  x->key = key;
   
  y = nil[idx]->next;
  nil[idx]->next = x;
  x->prev = nil[idx];
  x->next = y;
  y->prev = x;
}

void displayList(int idx,int len){
  NodePointer cur;
  int i = 0;
  for(cur = nil[idx]->prev ; cur != nil[idx] ; cur = cur->prev, i++){
    if(i > 0){ printf(", "); }
    printf("%d",cur->key);
  }
  printf("]\n");
}

Measured memory_bytes: 9212
#include<stdio.h>

int main(void){
    int n,i,flag=0;
    char s;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%c",&s);
        if(s=='Y'){
            flag=1;
        }
    }
    if(flag==1){
        printf("Four\n");
    }else{
        printf("Three\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  if (a < 10 && b < 10) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import math
n=input()
n=n.split()
for i in range(0,len(n)):
        n[i]=int(n[i])
angle = abs(n[2]+n[3]/60 - n[3]/5)*30
if(angle > 180):
    angle=360 - angle
angle=math.pi*angle/180.00000
c=(n[0]**2) + (n[1]**2)- (2*n[0]*n[1]*math.cos(angle))
print(float(math.sqrt(c)))


Measured memory_bytes: 9416
s=input()
ans=7
for i in range(8):
  func=""
  num=str(bin(i))[2:]
  num=num.zfill(3)
  for j in range(3):
    func+=s[j]
    if num[j]=='1':
      func+="+"
    else:
      func+="-"
  func+=s[-1]
  if eval(func)==7:
    print(func+"=7")
    exit()

Measured memory_bytes: 3064
def fact(a):
    ret = 1
    for i in range(2,a+1):
        ret *= i
    return ret

def count(a,lst):
    cnt = 0
    for atr in lst:
        if atr < a:
            cnt += 1
    return cnt
N = int(input())
Ps = list(map(int,input().split()))
Qs = list(map(int,input().split()))

a = 1
temp = 0
cntP = 1
for i in range(N):
    if N - 1 - i != 0:
        cntP = cntP + fact(N - 1 - i) * count(Ps[i],Ps[i+1:])

cntQ = 1
for i in range(N):
    if N-1-i != 0:
        cntQ = cntQ + fact(N - 1 - i) * count(Qs[i],Qs[i+1:])

print(abs(cntP-cntQ))


Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;


int main() {
    string s,t;cin>>s>>t;ll lens=s.length(),lent=t.length();
    ll dp[lens+1][lent+1];
    for(int i=0;i<=lens;i++)
    {
        for(int j=0;j<=lent;j++)
        {
            if(i==0 || j==0)
            dp[i][j]=0;
            else if(s[i-1]==t[j-1])
            {dp[i][j]=dp[i-1][j-1]+1;}
            else 
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }   
    string lcs;
    // to print lcs
    ll i=lens,j=lent;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {lcs.push_back(s[i-1]);i--;j--;}
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else
        j--;
    }
    reverse(lcs.begin(),lcs.end());
    cout<<lcs;
    return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void judge(bool b){b?Yes():No();}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstr;

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

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

    int n, l;
    cin >> n >> l;
    vstr s(n);
    string ans = "";
    rep(i, n)
        cin >> s[i];

    sort(ALL(s));
    rep(i, n)
        ans += s[i];
    ppp(ans);


    return 0;
}


Measured memory_bytes: 256
while 1:
    n, a, b, c, x = map(int, input().split())
    if n == 0:
        break

    target = list(map(int, input().split()))
    if x == target[0]:
        target.pop(0)
    if target == []:
        print(0)
        continue

    for i in range(10000):
        x = (a * x + b) % c
        if x == target[0]:
            target.pop(0)
            if target == []:
                print(i+1)
                break
    else:
        print(-1)



Measured memory_bytes: 5612
N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
    j = input()
    if j == "AC":
        AC += 1
    elif j == "WA":
        WA += 1
    elif j == "TLE":
        TLE += 1
    elif j == "RE":
        RE += 1


print("AC x ", AC)
print("WA x ", WA)
print("TLE x ", TLE)
print("RE x ", RE)


Measured memory_bytes: 69816
#include<iostream>
#include<stdio.h>
#include <string>
using namespace std;
int main(){
  long long int L;
  scanf("%lld",&L);
  L = (long double )L;
  //printf("%lld",L);
  //printf("%llf",(long double)L);
  //printf("%llf",L*L);
  printf("%llf",(long double)L*(long double)L*(long double)L/27.0);
}

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

const int N=505;
int n,a[N],b[N],c[N*N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i),c[a[i]]=b[i]=i;
	std::sort(b+1,b+n+1,[](int x,int y){return a[x]<a[y];});
	for(int i=1,p=1;i<=n;++i)
	{
		for(int j=1;j<b[i];c[p]=b[i],++j)while(c[p])++p;
		if(p>a[b[i]])return puts("No"),0;
	}
	for(int i=n,p=n*n;i>=1;--i)
	{
		for(int j=b[i]+1;j<=n;c[p]=b[i],++j)while(c[p])--p;
		if(p<a[b[i]])return puts("No"),0;
	}
	puts("Yes");
	for(int i=1;i<=n*n;++i)printf("%d%c",c[i],i==n*n?'\n':' ');
	return 0;
}

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

using namespace std;
int h[200050];
int n;
int main(){
    cin >> n;
    for (int i = 0; i < n;i++)
        cin >> h[i];
    long long tot = 0;
    int mn = h[0];
    for (int i = 1; i < n;i++){
        if(h[i]>=mn)
            mn = h[i];
        else
            tot += mn - h[i];
    }
    cout << tot << endl;
    return 0;
}

Measured memory_bytes: 4252
#include<cstdio>
typedef long long ll;
const int N=16,M=1e9+7;
inline int Pow(int a,int m){int s=1;for(;m;m>>=1)m&1?s=(ll)s*a%M:0,a=(ll)a*a%M;return s;}
int n,m,b[N],f[N+1][1<<N],func[(1<<N)+1],invf[(1<<N)+1],ans;
inline int C(int n,int m){return m<0||m>n?0:(ll)func[n]*invf[m]%M*invf[n-m]%M;}
inline int V(int A){
	if(!A)return 1;
	return(A&1?-1:1)*V(A>>1);
}
int main(){
	scanf("%d%d",&n,&m);
	func[0]=1;
	for(int i=1;i<=(1<<n);i++)func[i]=(ll)func[i-1]*i%M;
	invf[1<<n]=Pow(func[1<<n],M-2);
	for(int i=1<<n;i;i--)invf[i-1]=(ll)invf[i]*i%M;
	for(int j=0;j<m;j++)scanf("%d",b+j),--b[j];
	f[m][0]=1;
	for(int j=m-1;~j;j--)
	  for(int I=0;I<(1<<n);I++){
		f[j][I]=f[j+1][I];
		for(int k=0;k<n;k++)if(I>>k&1)
		  f[j][I]=(f[j][I]+(ll)f[j+1][I-(1<<k)]*C((1<<n)-b[j]-1-I+(1<<k),(1<<k)-1)%M*func[1<<k])%M;
	  }
	for(int I=0;I<(1<<n);I++)
	  ans=(ans+(ll)f[0][I]*func[(1<<n)-1-I]*V(I))%M;
	printf("%lld\n",(ll)(ans+M)*(1<<n)%M);
	return 0;
}

Measured memory_bytes: 6308
#include <iostream>
#define ll long long
#define pii pair<int, int>
#define fst first
#define snd second
using namespace std;

int main()
{
	ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int k; string s;
	cin >> k >> s;
	for (int i = 0; i < min((int)s.size(), k); i++)
	{
		cout << s[i];
	}
	if (s.size() > k) {cout << "...";}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>

int main(void)
{
	int x;
	int h;
	double s;
	double takasa;
	
	while(1){
		scanf("%d %d", &x, &h);
		if(x == 0 && h == 0){
			break;
		}
		takasa = sqrt(((x/2.0) * (x/2.0)) + (h * h));
		s = (x * x) + (x * takasa * 2);
		printf("%lf\n", s);
		
	}
	
	return (0);
}

Measured memory_bytes: 632
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    A.sort()
    from collections import deque

    def make1():
        d = deque(A)
        ret = deque([d.popleft()])
        for i in range((N-1)//2):
            if i & 1:
                j = d.popleft()
                k = d.popleft()
            else:
                j = d.pop()
                k = d.pop()
            if abs(ret[0] - j) < abs(ret[-1] - j):
                ret.appendleft(j)
                ret.append(k)
            else:
                ret.append(j)
                ret.appendleft(k)
        if len(d) == 1:
            j = d.pop()
            if abs(ret[0] - j) < abs(ret[-1] - j):
                ret.append(j)
            else:
                ret.appendleft(j)
        ans = 0
        for i in range(1, N):
            ans += abs(ret[i-1] - ret[i])
        return ans

    def make2():
        d = deque(A)
        ret = deque([d.pop()])
        for i in range((N-1)//2):
            if i & 1:
                j = d.pop()
                k = d.pop()
            else:
                j = d.popleft()
                k = d.popleft()
            if abs(ret[0] - j) < abs(ret[-1] - j):
                ret.appendleft(j)
                ret.append(k)
            else:
                ret.append(j)
                ret.appendleft(k)
        if len(d) == 1:
            j = d.pop()
            if abs(ret[0] - j) < abs(ret[-1] - j):
                ret.append(j)
            else:
                ret.appendleft(j)
        ans = 0
        for i in range(1, N):
            ans += abs(ret[i-1] - ret[i])
        return ans

    print(max(make1(), make2()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61448
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    REP(i,h){
        REP(j,w){
            cin >> a[i][j];
        }
    }
    REP(i,h + 2){
        REP(j,w + 2){
            if(i == 0 || j == 0 || i == h + 1 || j == w + 1) cout << "#";
            else cout << a[i - 1][j - 1];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long MOD = 1e9 + 7;
const int MAX = 2002;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

vector<ll> fac(MAX, 0);
void bincombpre(int n, ll mod) {
    assert(n >= 0);
    fac[0] = 1;
    rep(i, 1, n + 1) fac[i] = fac[i - 1] * i % mod;
}

ll modinv(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while(b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= mod;
    if(u < 0) u += mod;
    return u;
}
ll modpow(ll a, ll n, ll mod) { // a^n % mod
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <typename T> T gcd(T a, T b) {
    if(a > b) gcd(b, a);
    T r;
    while(r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, O = 0;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    rep(i, N) {
        rep(j, i + 1, N) { O += d[i] * d[j]; }
    }
    cout << O << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a==1){
      if(b==1){
        System.out.println("Draw");
      }else{
        System.out.println("Alice");
      }
    }else{
      if(b==1){
        System.out.println("Bob");
      }else{
        if(a>b){
          System.out.println("Alice");
        }else if(a==b){
          System.out.println("Draw");
        }else{
          System.out.println("Bob");
        }
      }
    }
  }
}

Measured memory_bytes: 21844
n = int(input())
count = 0
flag = False
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        if count == 2:
            flag = True
        else:
            count += 1
    else:
        count = 0
if flag:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main(){
    long long int n, num, count_num, select = -1;
    vector<long long int> stick;
    cin >> n;
    stick.resize(n);
    for(vector<long long int>::iterator itr = stick.begin(); itr < stick.end(); itr++)
        cin >> *itr;
    sort(stick.begin(), stick.end());
    for(vector<long long int>::iterator itr = stick.end() - 1; itr >= stick.begin();){
        num = *itr;
        count_num = 0;
        while(itr >= stick.begin() && *itr == num){
            count_num++;
            itr--;
        }
        if(count_num < 2)
            continue;
        else if(count_num < 4){
            if(select < 1){
                select = num;
                continue;
            }else{
                cout << select * num  << endl;
                return 0;
            }
        }else{
            if(select < 1){
                cout << num * num << endl;
                return 0;
            }else{
                cout << select * num  << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

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

    int N;
    std::cin >> N;
    
    ll m, n;
    for(int i=0;i<N;++i){
        ll a, b;
        std::cin >> a >> b;

        if(i == 0){
            m = a;
            n = b;
        }else{
            // if minimizing, lb satisfies lb > ub
            // if maximizing, lb satisfies lb < ub
            ll lb = 1000000000000000100ll, ub = -1ll;
            
            while(std::abs(ub - lb) > 1){
                ll mid = (lb + ub) / 2;

                ll x = mid - mid % (a + b);
                
                if(x / (a + b) * a >= m && x / (a + b) * b >= n){
                    lb = mid;
                }else{
                    ub = mid;
                }
            }
            

            m = lb / (a + b) * a;
            n = lb / (a + b) * b;
        }

        // std::cout << m << " " << n << std::endl;
    }

    std::cout << (m + n) << std::endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] a = new int[n];
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
    }

    long sum = 0;
    while (true){
      boolean flag = true;
      for (int i=0;i<n;i++){
        if (a[i] == 0){
          if (flag == false){
            break;
          }
        }
        else{
          a[i] -= 1;
          flag = false;
        }
      }

      if (flag == true){
        System.out.println(sum);
        return;
      }

      sum += 1;


    }
  }
}


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


int main(){


  double x[2],y[2];
  cin >> x[0] >> y[0] >> x[1] >> y[1];

  printf("%.10f\n",sqrt( (x[0]-x[1])*(x[0]-x[1]) + (y[0]-y[1])*(y[0]-y[1]) ));


}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll n, m;
  cin >> n >> m;
  ll ans = min(n, m/2);
  m -= n*2;
  if(m > 0){
    ans += m/4;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3540
n,k,l=map(int,input().split())
road=[list(map(int,input().split())) for _ in range(k)]
rail=[list(map(int,input().split())) for _ in range(l)]

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n+1)]
        self.rank=[0]*(n+1)
    def find(self,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=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.rank[x]<self.rank[y]:
            self.par[x]=y
        else:
            self.par[y]=x
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1
    def same_check(self,x,y):
        return self.find(x)==self.find(y)

from collections import Counter
uf_road=UnionFind(n)
uf_rail=UnionFind(n)
ans=0
for i,j in road:
    uf_road.union(i-1,j-1)
for i,j in rail:
    uf_rail.union(i-1,j-1)
pairs=[None]*n
for i in range(n):
    pairs[i]=(uf_road.find(i), uf_rail.find(i))
cnt=Counter(pairs)
ans=[]
for i in range(n):
    ans.append(cnt[pairs[i]])
print(' '.join(map(str,ans)))

Measured memory_bytes: 111660
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll A;
ll B;
ll H;
ll M;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> A;
    cin >> B;
    cin >> H;
    cin >> M;
    solve();
}

// 入力はすべて整数
// 1 <= A, B <= 1000
// 0 <= H <= 11
// 0 <= M <= 59

// ll A, ll B, ll H, ll M
// 答えを、単位を除いて出力せよ。正しい値との絶対誤差または相対誤差が 10^{-9} 以下であれば正解とみなされる。
void solve(){
    double p1=M/60.0;
    double p2=H/12.0+p1/12.0;

    double y1=B*cos(2*M_PI*p1);
    double x1=B*sin(2*M_PI*p1);
    double y2=A*cos(2*M_PI*p2);
    double x2=A*sin(2*M_PI*p2);

    double ans=sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2));
    cout<<fixed<<setprecision(12)<<ans<<endl;
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();  
  int n;
  cin >> n;
  map <int, int> cnt;              
  for (int i = 1; i <= n; i++) {
  	int x;
  	cin >> x;
  	cnt[x]++;  
  }
  ll ans = 1;
  for (int i = 1; i <= n/2; i++)
  	ans = (ans * 2 ) % Mod;         
  if (n%2 == 1) {
  	for (int i = 2; i < n; i+= 2) {
  		if (cnt[i] != 2) {
  			cout << 0;
  			return 0;
  		}
  	}
  	if (cnt[0] != 1) {
  		cout << 0;
  		return 0;
  	}
  	cout << ans; 
  }
  else {
  	for (int i = 1; i < n; i += 2) {
  		if (cnt[i] != 2) {
  			cout << 0;
  			return 0;
  		}
  	}
  	cout << ans;
  }         	
  		 
  	

  return 0;
}






// Coded by Z..

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cntr = 0, cntb = 0, cntg = 0;
    unordered_map<int,int> mpr, mpg, mpb;

    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') {
            cntr++;
            mpr[i]++;
        }
        else if(s[i] == 'B') {
            cntb++;
            mpb[i]++;
        }
        else {
            cntg++;
            mpg[i]++;
        }
    }
    ll total = 1LL * cntr * cntg * cntb;
    ll sub = 0;
    for(auto i : mpr) {
        for(auto j : mpb) {
            int mx = max(i.first, j.first);
            int mn = min(i.first, j.first);
            if(mpg.find(2*mn - mx) != mpg.end()) sub++;
            if(mpg.find(2*mx - mn) != mpg.end()) sub++;
            if( (mx-mn+1)%2 == 1 ) {
                if(mpg.find((mn + mx)/2) != mpg.end()) sub++;
            }
        }
    }
    ll ans = total - sub;
    cout << ans << endl;


}


Measured memory_bytes: 3788
#include<stdio.h>
int main(void)
{
	int N,T,ba,Player[10];
	char c[101];
	while(1){
		ba = 0;
		for(int i=0;i<10;i++)
			Player[i] = 0;
		scanf("%d",&N);
		if(N == 0) break;
		scanf("%s",c);
		for(int i=0;i<100;i++){
			switch(c[i]){
			case 'S':
				Player[i%N]++;
				ba = ba + Player[i%N];
				Player[i%N] = 0;
				break;
			case 'M':
				Player[i%N]++;
				break;
			case 'L':
				Player[i%N]++;
				Player[i%N] = Player[i%N] + ba;
				ba = 0;
				break;
			}
		}
		for(int i=0;i<N-1;i++){
			for(int j=i;j<N;j++){
				if(Player[i] > Player[j]){
					T = Player[i];
					Player[i] = Player[j];
					Player[j] = T;
				}
			}
		}
		for(int i=0;i<N;i++)
			printf("%d ",Player[i]);
		printf("%d\n",ba);
	}
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

    int main(){
        lint a,b,c,d;
        cin>>a>>b>>c>>d;
        lint e=a*c,f=a*d,g=b*c,h=b*d;
        cout<<max({e,f,g,h})<<endl;
    
    
    }
      

Measured memory_bytes: 3680
H, W = gets.split.map &:to_i
board = $<.map{|s|s.chomp.chars}

puts H.times.any?{|i|
  W.times.any?{|j|
    next if board[i][j] != ?#
    ![0, 1, 0, -1, 0].each_cons(2).any?{|dx, dy|
      ii = i + dy
      jj = j + dx
      ii.between?(0, H-1) && jj.between?(0, W-1) && board[ii][jj] == ?#
    }
  }
} ? :No : :Yes


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

int main()
{
	int n,x;
	long long a;
	while(cin >> n, n)
	{
		a=0;
		for(int i=30; i>=0; i-=3)
		{
			a *= 10;
			x = (int)((n>>i)&7);
			x += x/4 + x/5;
			a += x;
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 868
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){
int n;
cin >> n;
vector<int> h(n);
REP(i, n) cin >> h[i];
int ma = -1;
REP(i, n){
    ma = max(ma, h.at(i));
}

int cnt = 0;
while(true){
    if(ma == 0) break;
    int i = 0;
    while(i < n){
        if(h[i] == 0) ++i;
        else{
            ++cnt;
            while(i < n && h[i] > 0){
                --h[i];
                ++i;
            }
        }
    }
ma--;
}
cout << cnt << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Password | diff Password.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Password.cpp && ./a.out

/*
 
 9/7/2019
 
 5:00-
 
 */

LL N;

void solve() {
  cout<<N*N*N<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
#include<math.h>

#define MAX 500
#define INF (1 << 21)

int cost[MAX][MAX]; // cost[u][v]は辺e=(u,v)のコスト(存在しない場合はINF)
int mincost[MAX]; // 集合Xからの辺の最小コスト
int used[MAX]; // 頂点iがXに含まれているか
int V; // 頂点数

int solve() {
	int i, v, u;
    int res = 0;
    for(i=1;i<=V;i++) {
        mincost[i] = INF;
        used[i] = 0;
    }

    mincost[0] = 0;
    used[1] = 1;
    for(u=1; u<=V;u++) {
        mincost[u] = cost[1][u];
    }

    while(1) {
        v = 0;
        // Xに属さない頂点のうちXからの辺のコストが最小になる頂点を探す
        for(u=1;u<=V;u++) {
            if (!used[u] && (v == 0 || mincost[u] < mincost[v])) v = u;
        }

        if (v == 0) break;
        used[v] = 1; // 頂点vをXに追加
        res += mincost[v]; // 辺のコストを加える

        for(u=1; u<=V;u++) {
            if(mincost[u] > cost[v][u]) {
                mincost[u] = cost[v][u];
            }
        }
    }
    return res;
}

int main(void) {
    int n, i, j, e;

    scanf("%d\n", &n);
    V = n;
    for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
            scanf("%d", &e);
            cost[i][j] = (e == -1) ? INF : e;
        }
    }

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

    return 0;
}

Measured memory_bytes: 804
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
	    Scanner sc=new Scanner(System.in);
	    int[] arr=new int[4];
	    for(int i=0;i<4;i++) {
	    	arr[i]=sc.nextInt();
	    }
		long val1=arr[0]*1l*arr[2];
		long val2=arr[0]*1l*arr[3];
		long val3=arr[1]*1l*arr[2];
		long val4=arr[1]*1l*arr[3];
		System.out.println(Math.max(Math.max(val1, val2), Math.max(val3, val4)));
	}
}

Measured memory_bytes: 35904
#include<stdio.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define swap(a,b) (a+=b,b=a-b,a-=b)
const int mask=0xff,MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void Radix32(int *a,const int sz)
{
  int temp[sz],shift=0;
  while(shift<32)
  {
    int u[256]={},v[256]={};
    rep(i,sz){u[(a[i]>>shift)&mask]++;}rep(i,mask){u[i+1]+=u[i];}
    rep(i,sz){temp[--u[(a[sz-1-i]>>shift)&mask]]=a[sz-1-i];}shift+=8;
    rep(i,sz){v[(temp[i]>>shift)&mask]++;}rep(i,mask){v[i+1]+=v[i];}
    rep(i,sz)a[--v[(temp[sz-1-i]>>shift)&mask]]=temp[sz-1-i];
    shift+=8;
  }
}
int main()
{
  int N=IN(),K=IN(),l,m=0,r,accum=1,sign=1,A[N];long x,y;
  rep(i,N)A[i]=IN(),m+=A[i]<0?1:0;
  Radix32(A,N);
  rep(i,m/2)swap(A[N-m+i],A[N-1-i]);
  rep(i,(N-m)/2)swap(A[i],A[N-m-1-i]);
  rep(i,N/2)swap(A[i],A[N-1-i]);
  if(K&1)accum=A[N-1],sign=(A[N-1]<0?-1:1),N--,K--;
  l=0,r=N-1;
  while(K)
  {
    x=1l*A[l]*A[l+1],y=1l*A[r]*A[r-1];
    if(x*sign>y*sign)x%=MOD,accum=1l*accum*x%MOD,l+=2;
    else y%=MOD,accum=1l*accum*y%MOD,r-=2;
    K-=2;
  }
  return printf("%ld\n",(1l*accum%MOD+MOD)%MOD),0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>

void test_case()
{
    int n, j=1;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) {
        if(a[i]==j) {
            j++;
        }
    }
    if(j==1){
        cout<<"-1";
    } else {
        cout<<n-j+1;
    }

}


int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string w = Console.ReadLine();
            bool beautiful = true;
            for (char c = 'a'; c <= 'z'; c++)
            {
                if (w.Count(x => x == c) % 2 != 0) beautiful = false;
            }
            Console.WriteLine(beautiful ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}

int main()
{
    int x;
    cin >> x;
    if(x==0){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,A,B,C,D; cin>>N>>A>>B>>C>>D;
  N--;
  int X=B-A;
  REP(i,0,N){
    int P=D*i,Q=C*i,R=D*(N-i),S=C*(N-i);
    int Y=Q-R,Z=P-S;
    if(Y<=X&&X<=Z){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  }



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}




ll power(ll a, ll b, ll m){
    ll ret = 1;
    while(b){
        if(b & 1) ret = (ret * a) % m;
        a = (a * a) % m;
        b /= 2;
    }
    return ret;
}


ll power(ll a, ll b) {
    return power(a, b, MOD);
}

int main(){
    int N; cin >> N;
    ll a = power(4, N-1);
    VLL C(N);
    REP(i, N) cin >> C[i];
    RSORT(C);
    ll ans = 0;
    REP(i, N)
        ans = (ans + C[i]*(i+2)%MOD) % MOD;
    if(ans < 0) ans += MOD;
    ans = ans * a % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
string s;
int main(){
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256