akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

class UnionFind {
public:
  	vector<int> Parent;
  	UnionFind(int N) {
    	Parent = vector<int>(N, -1);
    }
  	int root(int A) {
    	if (Parent[A] < 0) return A;
      	return Parent[A] = root(Parent[A]);
    }
  	int size(int A) {
    	return -Parent[root(A)];
    }
  	bool connect(int A, int B){
    	A = root(A); B = root(B);
      	if (A == B) return false;
      	if (size(A) < size(B)) swap(A, B);
      	Parent[A] += Parent[B];
      	Parent[B] = A;
    }
};

int main()
{
	int N, M; cin >> N >> M;
  	vector<int> A(M), B(M);
  	for (int i = 0; i < M; i++) {
    	cin >> A[i] >> B[i];
      	A[i]--; B[i]--;
    }
  	vector<ll> ans(M);
  	ans[M - 1] = (ll)N * (N - 1) / 2;
  	UnionFind Uni(N);
  	for (int i = M - 1; i >= 1; i--) {
      	ans[i - 1] = ans[i];
    	if (Uni.root(A[i]) != Uni.root(B[i])){
        	ans[i - 1] = ans[i] - (ll)Uni.size(A[i]) * Uni.size(B[i]);
          	Uni.connect(A[i], B[i]);
        }
    }
  	for (int i = 0; i < M; i++)
    {
    	cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {

        
        static void Main(string[] args) 
        {
            string[] str = Console.ReadLine().Split(' ');
            int ab = int.Parse(str[0]);
            int bc = int.Parse(str[1]);

            Console.WriteLine(ab * bc / 2);

        }
    }
}


Measured memory_bytes: 11092
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();
      	int C = sc.nextInt();
        int K = sc.nextInt();

      	int ans = 0;
      	for(int i = 0; i < K ; i++){
        	if(A != 0){
              	A--;
            	ans++;
            }else if(B != 0){
              	B--;
            }else if(C != 0){
              	C--;
            	ans--;
            }
        }
			System.out.println(ans);
		
	}
}

Measured memory_bytes: 36016
a,b=map(int,input().split())
pls=(a)+(b)
mns=(a)-(b)
kak=(a)*(b)
if kak>=pls and kak>=mns:
    print(kak)
elif pls>=mns and pls>=kak:
    print(pls)
elif mns>=pls and mns>=kak:
    print(mns)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for (int i = 0; i < r; i++)
#define repeq(i,r) for (int i = 0; i <= r; i++)

int main() {
  int N;
  cin >> N;
  int A[N];
  unordered_map<int, int> balls;
  rep(i,N) {
    cin >> A[i];
    if (balls.count(A[i]) == 0) {
      balls[A[i]] = 0;
    }
    balls[A[i]]++;
  }
  
  long unbanned_patterns = 0;
  for (auto pair:balls) {
    unbanned_patterns += (long) pair.second * (pair.second - 1) / 2;
  }
  rep(i,N) {
    cout << unbanned_patterns - balls[A[i]] + 1 << endl;
  }
}


Measured memory_bytes: 8392
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

int n, a[200005];
int ans[200005];

int main()
{
    while(~scanf("%d", &n))
    {
        for(int i = 0; i < n; ++i)
            scanf("%d", &a[i]);
        int l = 0, r = n - 1;
        int cnts = 0;
        for(int i = n - 1; i >= 0; --i)
        {
            if(cnts % 2 == 0)
            {
                ans[l] = a[i];
                l++;
            }
            else
            {
                ans[r] = a[i];
                r--;
            }
            cnts++;
        }
        printf("%d",ans[0]);
        for(int i = 1; i < n; ++i)
            printf(" %d", ans[i]);
        printf("\n");
    }
}


Measured memory_bytes: 3712
const main=n=>{for(input=n.split("\n"),N=parseInt(input[0]),answer=0,moto_word=[],i=0;i<N;i++)answer+=new Set([input[1][i],input[2][i],input[3][i]]).size-1;console.log("%d",answer)};main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7628
import sys
import heapq
input = sys.stdin.readline
N = int(input())
XYI = sorted([[int(_) for _ in input().split()] + [_] for _ in range(N)])
visited = [False] * N
H = []
for j in range(N - 1):
    heapq.heappush(H, (XYI[j + 1][0] - XYI[j][0], XYI[j][2], XYI[j + 1][2]))
XYI.sort(key=lambda xs: xs[1])
for j in range(N - 1):
    heapq.heappush(H, (XYI[j + 1][1] - XYI[j][1], XYI[j + 1][2], XYI[j][2]))
ans = 0

UF = list(range(N + 1))
SIZE = [0] + [1] * N  # 1-indexed


def find(x):
    if UF[x] != x:
        UF[x] = find(UF[x])
    return UF[x]


def unite(x, y):
    if not is_same(x, y):
        X, Y = find(x), find(y)
        SX, SY = SIZE[X], SIZE[Y]
        if SX > SY:
            m = UF[X] = Y
        else:
            m = UF[Y] = X
        SIZE[m] = SX + SY
        SIZE[X + Y - m] = 0


def is_same(x, y):
    return find(x) == find(y)


def scan_uf():
    for i in range(len(UF)):
        find(i)


while H:
    d, i1, i2 = heapq.heappop(H)
    if not is_same(i1, i2):
        unite(i1, i2)
        ans += d
print(ans)


Measured memory_bytes: 51872
# -*- coding: utf-8 -*-


def main():
    a, b, c, d, e, f = map(int, input().split())
    ab = list()
    cd = list()

    for i in range(30 + 1):
        for j in range(30 + 1):
            if 100 * a * i + 100 * b * j <= f:
                ab.append((i, j))

    for x in range(100 + 1):
        for y in range(100 + 1):
            if c * x + d * y <= 30 * e:
                cd.append((x, y))

    ans = 0
    ans_water = 0
    ans_sugar = 0

    for i, j in ab:
        for x, y in cd:
            total_water = 100 * (a * i + b * j)
            total_sugar = c * x + d * y

            if total_water > 0 and total_water + total_sugar <= f and total_sugar <= e * total_water // 100:
                rate = 100 * total_sugar / (total_water + total_sugar)

                if rate - ans >= 0:
                    ans = rate
                    ans_water = total_water
                    ans_sugar = total_sugar

    print(ans_water + ans_sugar, ans_sugar)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41708
#include <stdio.h>
long csl(long x,long y);
int main()
{
    long A,B,ans=1,maxcdivisor,sub;
    scanf("%ld %ld",&A,&B);
    maxcdivisor=csl(A,B);
    sub=maxcdivisor;
    for(long i=2;i*i<=maxcdivisor;i++){
            if(sub%i==0) ans++;
            while(sub%i==0) sub/=i;
            if(sub==1) break;
    }
    if(sub!=1) ans+=1;
    printf("%ld",ans);
    return 0;
}
long csl(long x,long y)
{
    return y==0?x:csl(y,x%y);
}


Measured memory_bytes: 128
n = int(input())
edges = []

for id in range(n-1):
    a, b = map(int, input().split())
    edges.append([a-1, b-1, id])

edges.sort()

used = [0]*(n)
ans = [0]*(n-1)
num = 1
prev = 0
for edge in edges:
    _from, to, id = edge
    if _from != prev:
        num = 1
    if used[_from] == num:
        num += 1
    ans[id] = num
    used[to] = num
    num += 1
    prev = _from

print(max(ans))
for color in ans:
    print(color)


Measured memory_bytes: 25092
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	_, K := nextInt(), nextInt()
	S := next()

	fmt.Println(S[:K-1] + strings.ToLower(S[K-1:K]) + S[K:])
}


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

using namespace std;
using ll = long long;

int main() {
    int x = 0;
    cin >> x;
    
    while(1){
        bool flag = true;
        for(int i = 2;i < pow(x,0.5);i++){
            if(x % i == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            break;
        }
        x++;
    }
    cout << x <<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,x,t;
  cin>>n>>x>>t;
  int y1=0,y=0;   
  while(y<n)
  {
    y1+=t;
    y+=x;
  }
  cout<<y1;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  string s;
  cin >> s;
  int n = s.size();
  vector <char> st;
  st.push_back(s[0]);
  st.push_back(s[1]);
  int cnt = 0;
  for (int i = 2; i < n; ++i) {
    char c = s[i];
    while (st.size() > 1 && st.rbegin()[1] != c) {
      ++cnt;
      st.pop_back();
    }
    st.push_back(c);
  }
  if (cnt % 2 == 0) {
    cout << "Second\n";
  } else {
    cout << "First\n";
  }
}



Measured memory_bytes: 640
<?php

$a = trim(fgets(STDIN));
$b = explode(' ', $a);

$n = $b[0];
$k = $b[1];
$q = $b[2];

$i = $n;
if($k > $q){
    for($j =0; $j < $n; $j++){
        echo 'Yes' . PHP_EOL;
    }
    return;
}

$arr = array_fill(1, $n, $k - $q);
$scores = array_fill(1, $n, 0);
while ($index = (int)fgets(STDIN)) {
    $scores[$index] += 1;
}

foreach ($arr as $key => $val) {
    echo ($val + $scores[$key]) > 0 ? 'Yes' : 'No';
    echo  PHP_EOL;
}


Measured memory_bytes: 13176
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,k[50],ans=0;
  cin>>a>>b;
  for(int i=0;i<a;i++){
    cin>>k[i];
  }
  sort(k,k+a);
  reverse(k,k+a);
  for(int i=0;i<b;i++){
    ans+=k[i];
  }
  cout<<ans<<endl;
}

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

int main()
{
  string a, b, c; cin >> a >> b >> c;
  char dif = 'A' - 'a';
  printf("%c%c%c\n", a[0] + dif, b[0] + dif, c[0] + dif);
  return 0;
}

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

signed main(){
    
    int n,k;
    cin>>n>>k;
    
    if(n == 0 or n ==k){
    	cout<<"0"<<endl;
    	return 0;
    }else if(n < k){
        cout<<min(n,abs(n-k))<<endl;
    }else{

	     if(k == 1){
	    	cout<<"0"<<endl;
	    }else{
	    	n = n % k;
	    	  cout<<min(n,abs(n-k))<<endl;
	    }	
    }

  
	return 0;
}

Measured memory_bytes: 256
while True:
    h,w=map(int, input().split())
    if h == 0 and w == 0:
        quit()
    for i in range(h):
        for j in range(w):
            if i%2 == 0:
                if j%2 == 0:
                    print('#', end='')
                else:
                    print('.', end='')
            else:
                if j%2 == 0:
                    print('.', end='')
                else:
                    print('#', end='') 
        print()
    print()

Measured memory_bytes: 8988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<vector<ll>> v;
vector<ll> cost;



int main(){
    ll h, w;    cin >> h >> w;
    vector<vector<char>> g(h, vector<char>(w, '0'));
    map<char, ll> key;
    rep(i, h) rep(j, w){
        char c; cin >> c;
        key[c] += 1;
    }
    
    ll c2=0, c4=0, odd=0;
    for(auto x: key){
        if(x.second%4==0) c4++;
        else if(x.second%4==2)   c2++;
        else odd++;
    }
    string res="Yes";
    if(h*w%2) odd -= 1;
    if(h%2) c2 -= w/2;
    if(w%2) c2 -= h/2;
    if(0<odd || 0<c2) res = "No";
    
    cout << res << endl;
       
}


Measured memory_bytes: 3632
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int INF = 1 << 30;
#define rep(i,n) for(int i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll h, w,ct=0,nowmin=INF,c[55][55];
char v[55][55];
int main() {
	ll d[55][55] = {};
	cin >> h >> w;
	rep(i, h)rep(j, w) { d[i][j] = INF; cin >> v[i][j]; ct += v[i][j] == '.'; }
	queue<pp>q;
	q.push(pp{ 0,0 });
	d[0][0] = 0;
	while (!q.empty()) {
		pp p = q.front();
		if (p.first > 0 && d[p.first - 1][p.second] == INF&&v[p.first-1][p.second]=='.') { q.push(pp{ p.first - 1,p.second }); d[p.first - 1][p.second] = d[p.first][p.second] + 1; }
		if (p.first < h - 1 && d[p.first + 1][p.second] == INF&&v[p.first + 1][p.second] == '.') { q.push(pp{ p.first + 1,p.second }); d[p.first + 1][p.second] = d[p.first][p.second] + 1; }
		if (p.second > 0 && d[p.first][p.second - 1] == INF&& v[p.first][p.second-1] == '.') { q.push(pp{ p.first ,p.second- 1 }); d[p.first][p.second - 1] = d[p.first][p.second] + 1; }
		if (p.second < w - 1 && d[p.first][p.second + 1] == INF&& v[p.first][p.second+1] == '.') { q.push(pp{ p.first,p.second + 1 }); d[p.first][p.second + 1] = d[p.first][p.second] + 1; }
		q.pop();
	}
	cout << (d[h-1][w-1] == INF ? -1 : ct-d[h-1][w-1]-1);
	return 0;
}

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

using namespace std;

int data[502][502];

int main(){
  int h , w,moves=0;
  
  vector<int> h1,w1,h2,w2;
  cin >> h >> w;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >> data[i][j];
    }
  }
  
  int endi,endj;
  endi=h;
  if (h%2){
    endj=w;
  }
  else{
    endj=1;
  };
  
  for(int i=1;i<=h;i++){
    if(i%2){
      int j;
      for(j=1;j<w;j++){
        if(data[i][j]%2){
          data[i][j]-=1;
          data[i][j+1]+=1;
          moves++;
          h1.pb(i);h2.pb(i);
          w1.pb(j);w2.pb(j+1);
        }
      }
      if(endi==i && endj==j) continue;
      if(data[i][j]%2){
          data[i][j]-=1;
          data[i+1][j]+=1;
          moves++;
          h1.pb(i);h2.pb(i+1);
          w1.pb(j);w2.pb(j);
      }
    }
    else{
      int j;
      for(j=w;j>1;j--){
        if(data[i][j]%2){
          data[i][j]-=1;
          data[i][j-1]+=1;
          moves++;
          h1.pb(i);h2.pb(i);
          w1.pb(j);w2.pb(j-1);
        }
      }
      if(endi==i && endj==j) continue;
      if(data[i][j]%2){
          data[i][j]-=1;
          data[i+1][j]+=1;
          moves++;
          h1.pb(i);h2.pb(i+1);
          w1.pb(j);w2.pb(j);
      }
    }
  }
  cout << moves << endl;
  for(int i=0;i<moves;i++)
    printf("%d %d %d %d\n",h1[i],w1[i],h2[i],w2[i]);
  
  
  
  return 0;
}


Measured memory_bytes: 5220
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
  string s;
  
  cin >>s;
  rep(i,s.size()){
    if(i==5 || i==13){
    cout << " ";
    }else{
      cout << s[i];
    }
  }
    cout << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 998244353
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
} 
int main()
{
    fast;
        ll n,x;
        std::cin >> n;
        ll a[n],mark[1000006]={0};
        map<ll,ll>mp;
        fr(i,0,n)
        {
            std::cin >> a[i];
            mp[a[i]]++;
        }
        sort(a,a+n);
        fr(i,0,n)
        {
            if(mark[a[i]]==0)
            {
                ll j;
                for(j=a[i];j<=a[n-1];j=j+a[i])
                mark[j]=1;
                if(mp[a[i]]==1)
                mark[a[i]]=-1;
            }
        }
        sort(mark,mark+a[n-1]+1);
        ll ans=0;
        fr(i,0,n+1)
        {
            if(mark[i]==-1)
            ans++;
            else
            break;
        }
        cout<<ans<<"\n";
}

Measured memory_bytes: 25488
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, res = 0;
    string s;
    cin >> n >> s;
    for(int i = 0; i <= n - 3; i++) {
        res += ( s[i] == 'A' and s[i + 1] == 'B' and s[i + 2] == 'C' );
    }
    cout << res << "\n";
}

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

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

    // Problem B
    long long n;
    long long ans = 0;
    cin >> n;
    for(long long i=1 ; i<=n ; i++){
        if(i%3 != 0 && i%5 != 0)
            ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
struct pos { double x, y; };
double dir(pos p1, pos p2) { return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2)); }
int main() {
    pos p[3];
    for (int i = 0; i < 3; i++) scanf("%lf %lf%*c", &p[i].x, &p[i].y);
    double a = dir(p[0], p[1]),
        b = dir(p[0], p[2]),
        c = dir(p[1], p[2]),
        s = (a + b + c) / 2.0,
        S = sqrt(s * (s - a) * (s - b) * (s - c)),
        r = 2 * S / (a + b + c),
        D = max(a, max(b, c));
    printf("%.10f\n", r * D / (2 * r + D));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int hx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int hy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
vector<vector<int>> mp;
vector<vector<bool>> used;
int w, h;

void dfs(int i, int j) {
  if (used[i][j])
    return;
  used[i][j] = true;
  for (int k = 0; k < 8; k++) {
    int ni = i + hx[k], nj = j + hy[k];
    if (ni >= h || ni < 0 || nj >= w || nj < 0)
      continue;
    if (used[ni][nj] || mp[ni][nj] == 0)
      continue;
    dfs(ni, nj);
  }
}

int main() {
  while (true) {
    cin >> w >> h;
    if (w == 0)
      break;
    mp = vector<vector<int>>(h, vector<int>(w));
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++)
        cin >> mp[i][j];
    used = vector<vector<bool>>(h, vector<bool>(w));
    int ans = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (used[i][j])
          continue;
        if (mp[i][j] == 0)
          continue;
        dfs(i, j);
        ans++;
      }
    }
    cout << ans << endl;
  }
}


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

using namespace std;
int dp[3000+1][3000+1];
int main() {
    string s , t ; cin>>s>>t;
    int n = s.size() , m = t.size();
    vector<int>v;
    for(int i = 0 ; i <= n; ++i){
        for(int j = 0 ; j <= m; ++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;
                v.push_back(i);
            }
            else{
                dp[i][j] = max(dp[i - 1][j] , dp[i][j - 1]);
            }
        }
    }
    int ln = dp[n][m];
    string x = "";
    int i = n , j = m;
    while(i > 0 && j > 0){
        if(s[i - 1] == t[j - 1]){
            x += s[i - 1];i--;j--;
        }
        else if(dp[i - 1][j] > dp[i][j - 1])i--;
        else j--;
    }
    reverse(x.begin() , x.end());
    cout<<x<<endl;
  
}

Measured memory_bytes: 101864
x=[]
while True:
    try:
        z=list(input())
    except EOFError:
        break
    x=x+z
import collections
c=collections.Counter(x)
import string
a=string.ascii_letters
for i in range(26):
    print(a[i],":",(c[a[0+i]]+c[a[26+i]]))


Measured memory_bytes: 6700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}

const int n_max=1e5+5;
vector<int> g[n_max];
ll cnt[n_max];
ll dp[n_max];

int dfs(int p, int v){
  for(auto i:g[v]){
    if(i==p) continue;
    cnt[v]=mu(dfs(v,i)+1,cnt[v]);
  }
  //  cout << "p v cnt " << p << " " << v << " " <<cnt[v] << endl;
  return cnt[v];

}

void dfs2(int p, int v){
  dp[v]=1;
  for(auto to:g[v]){
    dp[v] = mu(cnt[to]+1,dp[v]);
  }
  //  cout << "v dp"  << v << " " << dp[v] << endl;
  int n=g[v].size();
  int lft[n],rht[n];
  rep(i,n) lft[i]=rht[i]=cnt[g[v][i]]+1;
  rep1(i,n-1) lft[i]=mu(lft[i-1],lft[i]);
  for(int i=n-2;i>=0;i--){
    rht[i] = mu(rht[i+1],rht[i]);
  }
  
  rep(i,n){
    if(g[v][i]==p) continue;
    cnt[v]=1;
    if(i>0) cnt[v]=mu(cnt[v],lft[i-1]);
    if(i+1<n) cnt[v]=mu(cnt[v],rht[i+1]);
    dfs2(v,g[v][i]);    
  }
}


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

  int n;
  cin >> n >> mod;
  int x,y;
  rep(i,n-1){
    cin >> x >> y;
    x--;y--;
    g[x].pb(y);
    g[y].pb(x);
  }
  rep(i,n) cnt[i]=1;
  rep(i,n) dp[i]=1;

  dp[0]=dfs(-1,0);
  
  dfs2(-1,0);
  rep(i,n){
    cout << dp[i] << endl;
  }
  
  return 0;
    

}


Measured memory_bytes: 18432
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;
const double PI = 3.14159265359;

int main()
{
    LLONG N; cin >> N;
    LLONG ans = 0;
    for (LLONG m = 1; m <= N; ++m)
    {
        LLONG k = N / m;
        ans += m * k * (k + 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

VI convi(int n, VI a) {
	VI ret(n);
	VI memo(101, -1);

	rep(i, n) {
		if (memo[a[i]] == -1) {
			int cnt = count(all(a), a[i]);
			ret[i] = cnt;
			memo[a[i]] = cnt;
		}
		else {
			ret[i] = memo[a[i]];
		}
	}

	return ret;
}

bool endCheck(VI a) {
	return a == convi(sz(a), a);
}

int main() {
	int n;
	while (cin >> n && n) {
		VI a(n); rep(i, n)cin >> a[i];

		int ans = 0;
		while (!endCheck(a)) {
			a = convi(n, a);
			ans++;
		}

		Cout(ans);
		rep(i, n)cout << a[i] << (i == n - 1 ? "\n" : " ");
	}
}


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

using namespace std;

#define pt pair<int, int>
#define x first
#define y second
#define what_is(x) cerr << #x << " is " << x << endl;
#define endl '\n'
#define int long long

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

	int n;
	cin >> n;
	vector<pt> vec(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> vec[i].x;
		vec[i].y = i;
	}

	sort(vec.begin(), vec.end());
	for (auto i: vec)
		cout << i.y + 1 << " ";
	cout << endl;

	return 0;
}


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

using namespace std;

const long double EPS = 1e-8;

void interC(vector<pair<long double, long double>> &res, long double x1, long double y1, long double r1, long double x2, long double y2, long double r2) {
    auto dx = x2 - x1;
    auto dy = y2 - y1;
    auto d = sqrt(dx*dx + dy*dy);
    if (d <= 0.0) {
        return;
    }
    auto l = (r1*r1 - r2*r2) / (2*d) + d/2;
    auto hsq = r1*r1 - l*l;
    if (hsq < 0.0) {
        return;
    }
    auto h = sqrt(hsq);
    auto xl = dx*l/d;
    auto xr = dy*h/d;
    auto yl = dy*l/d;
    auto yr = dx*h/d;
    res.push_back({xl+xr+x1, yl-yr+y1});
    res.push_back({xl-xr+x1, yl+yr+y1});
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> a(n);
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second >> c[i];
    }
    long double l = 0.0;
    long double r = 1e9;
    while (r-l > EPS) {
        long double mid = (l+r)/2;
        vector<pair<long double, long double>> pts;
        for (auto pr: a) {
            pts.push_back({1.0*pr.first, 1.0*pr.second});
        }
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                interC(pts, a[i].first, a[i].second, mid/c[i], a[j].first, a[j].second, mid/c[j]);
            }
        }
        bool ok = false;
        for (auto pr: pts) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                long double dx = pr.first - a[i].first;
                long double dy = pr.second - a[i].second;
                long double tm = c[i]*sqrt(dx*dx + dy*dy);
                if (tm <= mid+EPS) {
                    cnt++;
                }
            }
            if (cnt >= k) {
                ok = true;
            }
        }
        if (ok) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout.precision(10);
    cout << fixed << l << endl;
}




Measured memory_bytes: 440
abcd = list(map(int, list(input())))
res = abcd[0]
op = -1
for i in range(8):
    res = abcd[0]
    op_temp = i
    if op_temp%2:
        res += abcd[1]
    else:
        res -= abcd[1]
    op_temp = op_temp >> 1
    if op_temp%2:
        res += abcd[2]
    else:
        res -= abcd[2]
    op_temp = op_temp >> 1
    if op_temp%2:
        res += abcd[3]
    else:
        res -= abcd[3]
    if res == 7:
        op = i
        break

ans = str(abcd[0])
for j in range(3):
    if (op >> (j))%2:
        ans += '+'
    else:
        ans += '-'
    ans += str(abcd[j+1])
ans += '=7'

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <map>
#include <queue>
#include <tuple>
#include <math.h>
#include <iomanip>

using namespace std;

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


int main(){
    int A,B,K;
    cin >> K >> A >> B;
    string ans="NG";
    for(int i=A; i<=B; i++){
        if(i%K==0) ans="OK";
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = (pp[K-1]+K)/2
for i in range(N-K):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)


Measured memory_bytes: 25152
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            string answer;
            if (S.Length > K)
            {
                answer = $"{new string(S.Take(K).ToArray())}...";
            }
            else
            {
                answer = S;
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 28236
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define vll(A) vector<ll> A;
#define ivt(A,n,p) vector<ll> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(ll i=a;i<=b;i++)
#define forde(i,a,b) for(ll i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}

int main() 
{
	// #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
	fio;
	ll testcase=1;
	//cin>>testcase;
	while(testcase--)
	{
		ll n;
		cin>>n;
		ll ans=0;
		string s;
		cin>>s;
		stack<ll> z;
		forin(i,0,n-1)
		{
			if(s[i]=='R')
			{
				z.push(i);
			}
		}
		forin(i,0,n-1)
		{
			if(s[i]=='W' && !z.empty() && i<z.top())
			{
				z.pop();
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

const int maxn = 310, P = 998244353;
char s[maxn];
int K, f[maxn][maxn][maxn][2], sum[maxn][maxn];

int main() {
    scanf("%s %d", s + 1, &K);
    int n = strlen(s + 1), ans = 0;
    K = min(K, n);
    f[0][0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        memset(sum, 0, sizeof(s));
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= K; k++) {
                sum[j][k] = f[i - 1][j][k][0];
                if (j) (sum[j][k] += sum[j - 1][k]) %= P;
            }
        }
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k <= K; k++) {
                if (s[i] == '0') {
                    f[i][j][k][0] = (f[i - 1][j][k][0] + f[i - 1][j][k][1]) % P;
                    if (j) (f[i][j][k][0] += sum[j - 1][k]) %= P;
                } else {
                    f[i][j][k][0] = f[i - 1][j][k][0];
                    if (k) f[i][j][k][1] = (f[i - 1][j + 1][k - 1][0] + f[i - 1][j + 1][k - 1][1]) % P;
                }
            }
        }
    }
    for (int i = 0; i <= K; i++) {
        (ans += f[n][0][i][0]) %= P;
        (ans += f[n][0][i][1]) %= P;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 223624
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());

        StringBuilder result = new StringBuilder();
        result.append(n + ":");

        int i;
        while (n != 1) {
            for (i = 2; i * i <= n; i++) {
                if (n % i == 0) {
                    result.append(" " + i);
                    n /= i;
                    break;
                }
            }

            if (i * i > n) {
                result.append(" " + n);
                break;
            }
        }

        System.out.println(result.toString());
    }
}


Measured memory_bytes: 24456
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    int s=0,tmp_n;

    tmp_n=n;
    while(tmp_n>0){
        s += tmp_n%10;
        tmp_n /= 10;
    }
    Yes(n%s==0)
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,a=0,b=0;
	cin >> n;
	rep(i,n){
		string s,t;
		cin >> s >> t;
		if(s==t) a++,b++;
		else if(s<t) b+=3;
		else a+=3;
	}
	cout << a << " " << b << endl;
	return 0;
}


Measured memory_bytes: 3152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  deque<int> b;
  REP(i, n) {
    int a; cin >> a;
    if (i & 1) {
      b.emplace_front(a);
    } else {
      b.emplace_back(a);
    }
  }
  if (n & 1) {
    REP(i, n) {
      cout << b.back() << (i + 1 == n ? '\n' : ' ');
      b.pop_back();
    }
  } else {
    REP(i, n) {
      cout << b.front() << (i + 1 == n ? '\n' : ' ');
      b.pop_front();
    }
  }
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    while (true) {
        ll N, M;
        cin >> N >> M;
        if (N == 0 && M == 0)
            return;
        vector<ll> C(M), X(N);
        rep(i, M) cin >> C[i];
        rep(i, N) cin >> X[i];
        vector<vector<ll>> dp(N + 1, vector<ll>(256, INF));
        dp[0][128] = 0;
        rep(i, N) {
            ll x = X[i];
            rep(j, 256) {
                rep(m, M) {
                    ll c = C[m];
                    ll next = max(0LL, min(255LL, j + c));
                    ll y = abs(x - next);
                    dp[i + 1][next] = min(dp[i + 1][next], dp[i][j] + y * y);
                }
            }
        }
        ll ans = INF;
        rep(i, 256) {
            ans = min(ans, dp[N][i]);
        }
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}



Measured memory_bytes: 43940
import math
n, m = map(int, input().split())

mod = 10**9+7
ans = 0
if abs(n-m) > 1:
    ans = 0
elif abs(n-m) == 1:
    ans = math.factorial(n)*math.factorial(m)
elif abs(n-m) == 0:
    ans = 2 * (math.factorial(n)*math.factorial(m))

print(ans % mod)


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

unsigned int Euclid(unsigned int x, unsigned int y);

int main(void){
    
    unsigned int x,y,z;
    
    
    while(std::cin >> x >> y)
    {
        z = Euclid(x,y);
        cout << z << endl;
    }
    
}

unsigned int Euclid(unsigned int x, unsigned int y)
{
    if( (max(x,y) % min(x,y)) != 0)
    {
        return Euclid( min(x,y), max(x,y)%min(x,y));   
    }
    else
    {
        return y;
    }
}


Measured memory_bytes: 3096
/* Everything happens for a reason.
Be patient, things will be at their rightful place.
It was meant to happen this way, accept it.
And now decide what you can do about it.
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define c(x) cin >> x
#define fo(i,k,n) for( int i=k;i<n;i++)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

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

ll mex(ll x, ll y) 
{ 
	ll res = 1;	  
	x = x % M; 
	if (x == 0) return 0; 
	while (y > 0) 
	{ 
		if (y & 1) 
		res = (res*x) % M; 
		y = y>>1; 
		x = (x*x) % M; 
	} 
	return res; 
} 

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("YES\n");
}

void no()
{
    printf("NO\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

void solve()
{
    ll a,b,c,d;
    sc(a);
    sc(b);
    sc(c);
    sc(d);
    ll ans = a*c;
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    cout << ans;
    
}

int main()
{
//	ios_base::sync_with_stdio(0); cin.tie(0);
    ll t=1;
  //  sc(t);
    while(t--) solve();
}





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

int main(){
    int W, H, N;
    scanf("%d%d%d", &W, &H, &N);
    int a, b, pa = -1, pb = -1;
    int ans = 0;
    for(int i = 0; i < N; i++){
        scanf("%d%d", &a, &b);
        if(pa != -1){
            if((a - pa) * (b - pb) >= 0){
                ans += max(abs(a - pa), abs(b - pb));
            }else{
                ans += abs(a - pa) + abs(b - pb);
            }
        }
        pa = a; pb = b;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(void)
{
  int n;
  cin >> n;
  set<string> s;
  for(int i = 0; i < n; i++)
  {
    string in;
    cin >> in;
    s.insert(in);
  }
  int ans = s.size();
  cout << ans << endl;
}

Measured memory_bytes: 19232
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,L;
    cin >> N >> L;

    vector<string> s(N);

    for(int i=0;i<N;i++){
        cin >> s.at(i);
    }

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

    string ans="";

    for(int i=0;i<N;i++){
        ans += s.at(i);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
R, G, B, n=map(int, input().split())

r=n//R
g=n//G
b=n//B

cnt=0
for i in range(r+1):
    for j in range(g+1):
        tmp = i*R + j*G
        if (n-tmp)%B == 0 and 0 <= (n-tmp)//B :
            cnt+=1


print(cnt)

Measured memory_bytes: 67216
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

mod = 10 ** 9 + 7
ok = [True] * (n + 1)
for i in a:
    ok[i] = False

dp = [0 for i in range(n+1)]
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n+1, i+3)):
        if ok[j]:
            dp[j] += dp[i]
            dp[j] %= mod

print(dp[n])



Measured memory_bytes: 8600
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//素因数分解
vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

//std::cout << std::defaultfloat << std::setprecision(10);

const int M = 1000005;

////////////////////////////////////////
int main()
{

    ll N; cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];

    vector<int> res(M, 0);
    sort(A.begin(), A.end());

    for(int x:A){
        if(res[x]!=0){
            res[x] = 2;
            continue;
        }
        for(int i=x; i<M; i+=x) res[i]++;
    }

    int ans=0;

    for(int x:A) if(res[x]==1) ++ans;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8704
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        char[] x = sc.next().toCharArray();
        x[3] = '8';
        System.out.println(x);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#define N 50
using namespace std;
typedef struct circle{
  int x,y,z,r;
  long long l;
} Circle;
typedef struct point{
  int x,y,z;
} Point;
 
int main(){
  int n,q;
  double d;
  Point blue,red;
  Circle c[N];
  cin>>n>>q;
  for(int i=0;i<n;i++) cin>>c[i].x>>c[i].y>>c[i].z>>c[i].r>>c[i].l;
  while(q--){
    cin>>red.x>>red.y>>red.z>>blue.x>>blue.y>>blue.z;
    long long sum=0;
    for(int i=0;i<n;i++){
      int x=c[i].x-red.x,y=c[i].y-red.y,z=c[i].z-red.z;
      int x2=blue.x-red.x,y2=blue.y-red.y,z2=blue.z-red.z;
      int x3=c[i].x-blue.x,y3=c[i].y-blue.y,z3=c[i].z-blue.z;
      int t=x2*x2+y2*y2+z2*z2+x*x+y*y+z*z-(x3*x3+y3*y3+z3*z3);
      int b_c=x*x2+y*y2+z*z2;
      int a_c=(-x2)*x3+(-y2)*y3+(-z2)*z3;
      d=x*x+y*y+z*z-(1.0*t*t)/(x2*x2+y2*y2+z2*z2)/4;
      if(min(b_c,a_c)<0) d=min(x*x+y*y+z*z,x3*x3+y3*y3+z3*z3);
      if(d<=c[i].r*c[i].r) sum+=c[i].l;
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;

int main() {
   int a,b,c;
   cin>>a>>b>>c;
   if(a!=b&&b!=c&&a==c){cout<<2<<endl;}
   if(a!=b&&b!=c&&a!=c){cout<<3<<endl;}
   if(a==b&&b==c){cout<<1<<endl;}
   if(a!=b&&b==c){cout<<2<<endl;}
   if(a==b&&b!=c){cout<<2<<endl;}
   
return 0;}

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

const int MAXN = 3e5;
int N;
int K;
int cnt[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a; cin >> a; a--;
		cnt[a]++;
	}
	sort(cnt, cnt + N, greater<int>());

	int num = 0;
	while (cnt[num]) num++;
	int ans = 0;
	while (num > K) {
		num--;
		ans += cnt[num];
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1024