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

const double PI = atan2(1.0, 0.0);

int main()
{
  int n; cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
  
  double maxd = 0, p1, p2;
  for (int i = 0; i < n-1; ++i)
    for (int j = i+1; j < n; ++j)
    {
      double d = sqrt( (x[j]-x[i])*(x[j]-x[i]) + (y[j]-y[i])*(y[j]-y[i]) );
      if (d > maxd)
      {
        p1 = i; p2 = j;
        maxd = d;
      }
    }
  
  double xc, yc, rc;
  xc = (x[p1] + x[p2]) / 2.0; yc = (y[p1] + y[p2]) / 2.0;
  rc = maxd / 2.0;
  bool contain = true;
  for (int i = 0; i < n; ++i)
    if ( rc < sqrt(pow(x[i]-xc, 2) + pow(y[i]-yc, 2)) )
    {
      contain = false;
      break;
    }
  
  if (contain)
  {
    printf("%0.18f\n", rc);
    return 0;
  }
  
  double maxr = 0;
  for (int i = 0; i < n-2; ++i)
  for (int j = i+1; j < n-1; ++j)
  for (int k = j+1; k < n; ++k)
  {
    double aa = pow(x[j]-x[i], 2) + pow(y[j]-y[i], 2);
    double bb = pow(x[k]-x[j], 2) + pow(y[k]-y[j], 2);
    double cc = pow(x[i]-x[k], 2) + pow(y[i]-y[k], 2);
    if (aa >= bb + cc || bb >= cc + aa || cc >= aa + bb) continue;
    
    vector< vector<int> > mat = { {x[j]-x[i], y[j]-y[i]}, {x[k]-x[j], y[k]-y[j]} };
    vector<double> b = { ( mat[0][0]*(x[j]+x[i]) + mat[0][1]*(y[j]+y[i]) ) / 2.0,
                        ( mat[1][0]*(x[k]+x[j]) + mat[1][1]*(y[k]+y[j]) ) / 2.0 };
    double det = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0];
    vector< vector<double> > inv_mat = { {mat[1][1]/det, -mat[0][1]/det}, {-mat[1][0]/det, mat[0][0]/det} };
    xc = inv_mat[0][0] * b[0] + inv_mat[0][1] * b[1];
    yc = inv_mat[1][0] * b[0] + inv_mat[1][1] * b[1];
    rc = sqrt(pow(x[i]-xc, 2) + pow(y[i]-yc, 2));
    
    maxr = max(maxr, rc);
  }
  
  printf("%0.18f\n", maxr);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

void solve()
{   
    ll r,c,k;
    cin>>r>>c>>k;

    ll a[r+3][c+3];
    memset(a,0,sizeof(a));

    vector<vector<vector<ll>>> dp(r+3, vector<vector<ll>>(c+3, vector<ll>(4)));
    // memset(dp,0,sizeof(dp));

    for(ll i=0;i<k;i++){
        ll t1,t2,t3;
        cin>>t1>>t2>>t3;
        a[t1][t2] = t3;
    }

    // cout<<dp[1][1];

    for(ll i=r;i>=1;i--){
        for(ll j=c;j>=1;j--){
            // for(ll k1 = 0;k1<4;k1++){
            //     dp[i][j][k1] = max(dp[i+1][j][k1],dp[i][j+1][k1]);
            // }
            // if(a[i][j]){
            //     dp[i][j][0] = max()
            // }

            dp[i][j][0] = max({dp[i+1][j][0],dp[i+1][j][1],dp[i+1][j][2],dp[i+1][j][3],dp[i][j+1][0]});
            dp[i][j][1] = max({dp[i][j][0]+a[i][j],dp[i][j+1][0]+a[i][j],dp[i][j+1][1]});
            dp[i][j][2] = max(dp[i][j+1][2], dp[i][j+1][1]+a[i][j]);
            dp[i][j][3] = max(dp[i][j+1][3], dp[i][j+1][2]+a[i][j]);

        }
    }

    // cout<<dp[1][2][2]<<endl;

    cout<<max({dp[1][1][0],dp[1][1][1],dp[1][1][2],dp[1][1][3]});


}

int main() {



    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 707280
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    veci L(2*N); REP(i,2*N) cin >> L[i];
    sort(L.begin(),L.end());
    int ans = 0;
    for(int i = 0; i < 2*N; i+= 2) {
        ans += L[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000001
#define VMAX 20000

int main() {

	unsigned short *A, *B;

	int C[VMAX + 1], n, i;
	scanf("%d", &n);

	A = (unsigned short*)malloc(sizeof(short) * n + 1);
	B = (unsigned short*)malloc(sizeof(short) * n + 1);

	for (i = 0; i <= VMAX; i++) C[i] = 0;

	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
		C[A[i+1]]++;
	}

	for (i = 1; i <= VMAX; i++) C[i] += C[i-1];

	for (i = 1; i <= n; i++) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 10512
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<pair<long long, int>> fs;//素数・係数のペア

	//素因数分解
	for (long long i = 2; i * i <= n; ++i) {
		int x = 0;//係数
		while (n%i == 0)
		{
			n /= i;
			++x;
		}
		fs.emplace_back(i, x);
	}
	if (n != 1)fs.emplace_back(n, 1);


	int ans = 0;
	for (auto i: fs)
	{
		int x = i.second;//係数の取り出し
		int tmp = 1;
		while (tmp <= x)
		{
			x -= tmp;
			tmp++;
			ans++;
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 19728
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int b[22], a[22][22];

int main()
{
	IO_OP;
	
	int n, m, c, ans = 0;
	cin >> n >> m >> c;
	for(int i=0;i<m;i++)
		cin >> b[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin >> a[i][j]; 
	for(int i=0;i<n;i++) {
		int t = c;
		for(int j=0;j<m;j++)
			t += a[i][j] * b[j];
		if(t > 0)
			ans++;
	}
	cout << ans << endl; 
}



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

int main()
{
	int n, s, count = 0,count2 = 0;
	int ans[100], data[100];
	while (1) {
		cin >> n >> s;
		if (n == 0 && s == 0)
			break;
		for (int a = 0; a <= 9; a++) {
			if (n == 1) {
				if (a == s)
					count2++;
			}
			for (int b = a+1; b <= 9; b++) {
				if (n == 2) {
					if (a + b == s)
						count2++;
				}
				for (int c = b+1; c <= 9; c++) {
					if (n == 3) {
						if (a + b + c == s)
							count2++;
					}
					for (int d = c+1; d <= 9; d++) {
						if (n == 4) {
							if (a + b + c + d == s)
								count2++;
						}
						for (int e = d+1; e <= 9; e++) {
							if (n == 5) {
								if (a + b + c + d + e == s)
									count2++;
							}
							for (int f = e+1; f <= 9; f++) {
								if (n == 6) {
									if (a + b + c + d + e + f == s)
										count2++;
								}
								for (int g = f+1; g <= 9; g++) {
									if (n == 7) {
										if (a + b + c + d + e + f + g == s)
											count2++;
									}
									for (int h = g+1; h <= 9; h++) {
										if (n == 8) {
											if (a + b + c + d + e + f + g + h == s)
												count2++;
										}
										for (int i = h+1; i <= 9; i++) {
											if (n == 9) {
												if (a + b + c + d + e + f + g + h + i == s)
													count2++;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
		ans[count] = count2;
		count2 = 0;
		count++;
	}
	for (int i = 0; i < count; i++)
		cout << ans[i] << endl;
}

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

Measured memory_bytes: 61336
#include<iostream>
using namespace std;
int main(){
  string a,b; cin >> a >> b;
  // 桁数が異なる場合を排除
  if(a.size()>b.size()){
    cout << "GREATER" << endl;
    return 0;
  }else if(a.size()<b.size()){
    cout << "LESS" << endl;
    return 0;
  }else{ // 以下桁数が同じ時
    int count=0;
    for(int i=0;i<a.size();i++){
      if(a[i]>b[i]){
        cout << "GREATER" << endl;
        return 0;
      }else if(a[i]<b[i]){
        cout << "LESS" << endl;
        return 0;
      }else{
        count++;
      }
    }
    if(count==a.size()){
      cout << "EQUAL" << endl;
      return 0;
    }
  }
}

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

int main()
{
	string s, t;
	cin >> s;
	cin >> t;
	sort(begin(s), end(s));
	sort(rbegin(t), rend(t));
	if(s < t)
	{
		cout << "Yes\n";
	}else
	{
		cout << "No\n";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a>>b;
  if(a + b == 15) {
    cout << "+" << endl;
  } else if(a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    arr :=[3]uint32{}
    fmt.Scan(&arr[0], &arr[1])

	if arr[0]<=arr[1] {
		fmt.Println(arr[0])
	} else {
		fmt.Println(arr[0]-1)
	}
	return
}

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

int main(){
  int N,K; //N人のすぬけ君、K種類のお菓子
  cin >> N >> K;
  
  vector<bool> has(N,false); //お菓子を持っていたらtrue
  int d,a;
  for(int j=0;j<K;j++){
  	cin >> d;
  	for(int i=0;i<d;i++){
    	cin >> a;
    	if(!has.at(a-1)) has.at(a-1)=true;
  	}
  }
  
  int ans=0;
  for(bool b: has){
    if(!b) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

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

int lst[10];
int n,m,q;
//vector <int> a(q),b(q),c(q),d(q);
vector <int> a(50),b(50),c(50),d(50);
ll ans=0;

void dfs(int dep, int x){
    if (dep==(n-1)){
        lst[dep] = x;
        ll count = 0;
        for (int i = 0; i < q; i++) {
            if (lst[b.at(i)-1] - lst[a.at(i)-1] == c.at(i)) {
                count +=d.at(i);
            }
        }
        ans = max(ans,count);
    }else{
        lst[dep]=x;
        for (int i = x; i <= m; i++) {
            dfs(dep+1,i);
        }
    }
}


int main() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }
    for(int k=1;k<=m;k++){
        dfs(0,k);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
	int w, h; char c; cin >> w >> h >> c;
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
		if (i == 0 || i == h - 1) {
			if (j == 0 || j == w - 1) cout << "+";
			else cout << "-";
		}
		else {
			if (j == 0 || j == w - 1) cout << "|";
			else if (i == (h - 1) / 2 && j == (w - 1) / 2) cout << c;
			else cout << ".";
		}
		if (j == w - 1) cout << endl;
	}
	return 0;
}


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

int main()
{
    int x;
    cin>>x;
    if(x>=400&&x<=599) cout<<8;
    else if(x>=600&&x<=799) cout<<7;
    else if(x>=800&&x<=999) cout<<6;
    else if(x>=1000&&x<=1199) cout<<5;
    else if(x>=1200&&x<=1399) cout<<4;
    else if(x>=1400&&x<=1599) cout<<3;
    else if(x>=1600&&x<=1799) cout<<2;
    else if(x>=1800&&x<=1999) cout<<1;
}


Measured memory_bytes: 3620
splitBy :: Char -> String -> [String]
splitBy _ [] = []
splitBy a x =
  let s = takeWhile (/= a) x
      x'= dropWhile (/= a) x
  in
    if x' == []
    then [s]
    else s:(splitBy a $ drop 1 x')

judge (a:b:c:_) =
  let x = if ((a*a) + (b*b)) == (c*c)
          then 1
          else 0
      y = if a == b
          then 1
          else 0
  in
    (x,y)

main = do
  c <- getContents
  let i = map (map read) $ map (splitBy ',') $ lines c :: [[Int]]
      t = map judge i
      (o0,o1) = foldr (\ (a,b) (a0,b0) -> (a+a0,b+b0)) (0,0) t
  print o0
  print o1
  
  

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
//#define rep(i,s,e) for(int i = s; i < e; i++)

int main()
{
	int ans = 0;
	int l, r;
	cin >> l >> r;
	int t = r % 2019;
	int r2 = r - t;
	if(l <= r2)
	{
		ans = 0;
	}
	else
	{
		int m = 2018;
		for (int i = l; i <= r-1; i++)
		{
			for (int j = i+1; j <= r ;j++)
			{
				m = min(m, (i%2019)*(j%2019)%2019);
			}
		}
		ans = m;
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void){
    int K, X, max_x=1000000, min_x=-1000000;
    cin >> K >> X;

    for(int i=max(min_x, X-K+1);i < min(max_x+1, X+K);i++){
        printf("%d ", i);
    }
}

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

using namespace std;

int main()
{

    string s;
    cin >> s;
    long long int sum = 0;
    for (int i = 0; i < s.length(); i++)
    {
        sum = sum + s.at(i) - 48;
    }
    if (sum % 9 == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3716
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
int w, h;
int c[100][100];
bool inrange(int i, int j){
    return i >= 0 && j >= 0 && i < h && j < w;
}
int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dj[] = {-1,-1,-1, 0, 0, 1, 1, 1};
void rec(int i, int j){
    c[i][j] = 0;
    rep(k, 8){
        int ni = i + di[k];
        int nj = j + dj[k];
        if(inrange(ni, nj) && c[ni][nj]) rec(ni, nj);
    }
}
int main() {
    while(cin >> w >> h, w){
        rep(i, h) rep(j, w) cin >> c[i][j];
        int cnt = 0;
        rep(i, h) rep(j, w){
            if(c[i][j]){
                rec(i, j);
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
    if (a < b && b < c) System.out.println("Yes");
    else                System.out.println("No");
  }
}

Measured memory_bytes: 26024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // 入力を取得
    int n = sc.nextInt();
    String s = sc.next();

    s = s.replace("R", "");
    if(s.length()<n-s.length()){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

    // 出力
    // System.out.println(Math.min(count[0],count[1]) *2);
  }
}

Measured memory_bytes: 23764
object Main extends App {

  import scala.io.StdIn._
  val Array(n, q) = readLine.trim.split(' ').map(_.toInt)
  val cards = readLine.trim.split(' ').map(_.toLong).sorted
  val sumBySeq = cards.clone()
  for (i ← (1 until n).reverse) sumBySeq(i - 1) += sumBySeq(i)
  val sumByStep = cards.clone()
  for (i ← 2 until n) sumByStep(i) += sumByStep(i - 2)

  for (_ ← 0 until q){
    val x = readLine.trim.toLong
    val splitter = upperBound(1 to n) { c ⇒
      if (c * 2 - 1 <= n) {
        math.abs(cards(n - c * 2 + 1) - x) <= math.abs(cards(n - c) - x)
      }else false
    } - 1
    if (n > splitter * 2){
      println(sumBySeq(n - splitter) + sumByStep(n - splitter * 2 - 1))
    }else {
      println(sumBySeq(n - splitter))
    }
  }

  //[0, x) => true
  //[x, end) => falseになるx
  def upperBound(range: Range)(@inline func: Int ⇒ Boolean): Int = {
    var left = range.head
    var right = range.end
    while(left < right){
      val mid = (left + right) / 2
      if (func(mid)){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }

  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}

Measured memory_bytes: 61936
#include <stdio.h>
int main (void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==b){
        printf("%d\n",(a+b));
    }else if(a>b){
        printf("%d\n",(2*a-1));
    }else{
        printf("%d\n",(b*2-1));
    }
    return 0;
}



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

int main() {
    ll X, Y;
    cin >> X >> Y;
    vector<bool> s1 = {true, true, false, false};
    vector<bool> s2 = {true, false, true, false};
    priority_queue<ll, vector<ll>, greater<ll>> ans;
    rep(i, 4) {
        ll count = 0;
        ll x = X;
        ll y = Y;
        if (s1[i]) {
            count++;
            x = -X;
        }
        if (s2[i]) {
            count++;
            y = -Y;
        }
        if (x <= y) {
            count += y-x;
            ans.push(count);
        }
    }
    cout << ans.top() << endl;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String SA = keyboard.nextLine();	
		String SB = keyboard.nextLine();	
		String SC = keyboard.nextLine();	
		
		String input = SA.substring(0,1);
		int Along = SA.length();
		int Blong = SB.length();
		int Clong = SC.length();
		String ans = "X";
		
		while(ans.equals("X")) {
			if(input.equals("a")) {
				if(Along != 0) {
					input = SA.substring(0,1);
					SA = SA.substring(1, Along);
					Along--;
					continue;
				}else {
					ans = "A";
				}
			}else if(input.equals("b")) {
				if(Blong != 0) {
					input = SB.substring(0,1);
					SB = SB.substring(1, Blong);
					Blong--;
					continue;
				}else {
					ans = "B";
				}
			}else{ 	//(input.equals("c")) 
				if(Clong != 0) {
					input = SC.substring(0,1);
					SC = SC.substring(1, Clong);
					Clong--;
					continue;
				}else {
					ans = "C";
				}
			}
		}
		
		System.out.print(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 22996
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int T[210], A[210], B[210], C[210];
int dp[210][110];
signed main() {
    int D, N; cin >> D >> N;
    for(int i=0; i<D; i++) {
        cin >> T[i];
    }
    for(int i=0; i<N; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }

    fill(dp[0], dp[D+1], -1);
    dp[0][0] = 0;
    for(int i=0; i<D; i++) {
        int temp = T[i];
        for(int j=0; j<=100; j++) {
            if(dp[i][j] == -1) continue;
            for(int k=0; k<N; k++) {
                if(A[k] <= temp and temp <= B[k]) {
                    int cost = (i == 0 ? 0 : abs(j - C[k]));
                    chmax(dp[i+1][C[k]], dp[i][j] + cost);
                }
            }
        }
    }

    cout << *max_element(dp[D], dp[D] + 101) << endl;
    return 0;
}



Measured memory_bytes: 3248
NL = input().split()
N = int(NL[0])
L = int(NL[1])

st = []
for i in range(N):
    a = input()
    st.append(a)
s_st = sorted(st)
dic = ""
for j in range(len(s_st)):
    dic += s_st[j]
print(dic)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
using namespace std;
typedef pair<ll, ll> pll;


map< multiset<char> , ll > mp;
ll n;
ll f(ll x)
{
        return (x*(x-1))/2;
}
int main()
{
        cin >> n;
        for(ll i=0;i<n;i++) {
                string s;
                cin >> s;
                multiset<char> S;
                for(ll j=0;j<s.length();j++) {
                        S.insert(s[j]);
                }
                mp[S]++;
        }
        ll ans = 0;
        for(auto &i : mp) {
                ans += (f(i.second));
        }
        cout <<ans << endl;
        return 0;
}


Measured memory_bytes: 56448
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int p=1e9+7;
char s[300010];
int n,i,j,ans,k,f[300010][3][3];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	f[0][0][0]=1;
	for(i=1;i<=n;i++){
		if(s[i]!='1'){
			for(j=0;j<3;j++)
			 for(k=0;k<3;k++){
			 	if(k==2){
			 		f[i][j][k-1]=(f[i][j][k-1]+f[i-1][j][k])%p;
				 }
				  else f[i][j][k+1]=(f[i][j][k+1]+f[i-1][j][k])%p;
			 }
		}
		if(s[i]!='0'){
			for(j=0;j<3;j++)
			 for(k=0;k<3;k++){
			 	if(k==0)(f[i][j+(j!=2)][k]+=f[i-1][j][k])%=p;
			 	 else (f[i][j][k-1]+=f[i-1][j][k])%=p;
			 }
		}
	}
	for(i=0;i<3;i++)
	 for(j=0;j<=i;j++)ans=(ans+f[n][i][j])%p;
	printf("%d",ans);
}

Measured memory_bytes: 14628
#include<bits/stdc++.h>
 using namespace std;
 const long long mod=1e9+7;

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

 vector<int>oks(N+1,true);
 for(int i=0;i<M;++i){
 int a;cin>>a;
 oks[a]=false;
 }

 vector<long long int>dp(N+1);
 dp[0]=1;
   for(int now=0;now<N;++now){
for(int next=now+1;next<=min(N,now+2);++next){
 if(oks[next]){
 dp[next]+=dp[now];
 dp[next]%=mod;
 }
 }
 }

 cout<<dp[N]<<endl;
 return 0;
 }


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k;
ll a[200001];
int main()
{
    cin >> n >> k;
    for(ll i = 1;i <= n;i ++)
        cin >> a[i];
    if(k >= n) cout << 0;
    else
    {
        ll tong = 0;
        sort(a + 1,a + 1 + n);
        for(int i = 1;i <= n - k;i ++)
        {
            tong += a[i];
        }
        cout << tong ;
    }
    return 0;
}


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

int main() {
    int N;
    bool first = true;
    while (cin >> N, N) {
        if (!first) cout << endl;
        first = false;

        set<int> s;
        vector<string> name(N);
        vector<int> score(N);
        for (int i = 0; i < N; i++) {
            cin >> name[i];
            int x, y, z;
            cin >> x >> y >> z;
            score[i] = x * 3 + z;
            s.insert(-score[i]);
        }

        vector<int> idx;
        for (auto i : s) {
            for (int j = 0; j < N; j++) {
                if (score[j] == -i) {
                    idx.push_back(j);
                }
            }
        }

        for (auto i : idx) cout << name[i] << "," << score[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,a[N],c[N],b[N],d[N],idx,h[N],ne[N<<1],e[N<<1],w[N<<1];
// void add(int a,int b,int c){e[idx]=b;ne[idx]=h[a];w[idx] =c;h[a]=idx ++;}
bool vis[N],use[N];
// int get(int x)
// {
//     return lower_bound(d+1,d+1+n,x)-d;
// }
int get(int x)
{
  return lower_bound(d + 1 , d + n + 1 , x) - d ;
}
void add(int a , int b , int c)
{
  e[idx] = b , ne[idx] = h[a] , w[idx] = c ,  h[a] = idx ++ ;
}
// bool dfs(int u)
// {
//     vis[u]=true;
//     int x=c[u];
//     for(int i=h[u];~i;i=ne[i])
//     {
//         int v=e[i];
//         if(!vis[v]&&dfs(v))
//         {
//             x^=1;use[w[i]]=true;
//         }
//     }
//     return x;
// }
int dfs(int u)
{
  vis[u] = 1 ;
  int x = c[u] ;
  for(int i = h[u] ; ~i ; i = ne[i])
   {
     int v = e[i] ;
     if(!vis[v] && dfs(v))
      x ^= 1 , use[w[i]] = 1 ;
   }
  return x ;
}
int main()
{
    // scanf("%d%d",&n,&m);
    // for(int i = 0 ;i < N ;i ++) h[i] = -1 ;
    // for(int i=1;i<=n;i++)
    //     scanf("%d%d",&a[i],&b[i]),d[i]=a[i];
    // sort(d+1,d+1+n);
    // for(int i=1;i<=n;i++)
    //     a[i]=get(a[i]),c[a[i]]=b[i];
    // for(int i=n+1;i>=1;i--)
    //     c[i]^=c[i-1];
    // for(int i=1;i<=m;i++)
    // {
    //     int l,r;scanf("%d%d",&l,&r);
    //     l=get(l);
    //     r=upper_bound(d+1,d+1+n,r)-d -1;
    //     if(l<=r)
    //         add(l,r+1,i),add(r+1,l,i);
    // }
    for(int i = 0 ;i < N ;i ++) h[i] = -1 ;
    ios::sync_with_stdio(false) ;
    cin.tie(0) , cout.tie(0) ;
    cin >> n >> m ;
    for(int i = 1; i <= n ; i ++) cin >> a[i] >> b[i] , d[i] = a[i] ;
    sort(d + 1 , d + n + 1) ;
    for(int i = 1; i <= n ;i ++)
     c[get(a[i])] = b[i] ;
    for(int i = n + 1; i >= 1 ;i --) c[i] ^= c[i - 1] ;
    for(int i = 1; i <= m ;i ++)
     {
       int l , r ;
       cin >> l >> r ;
       l = get(l) , r = upper_bound(d + 1 , d + n + 1 , r) - d - 1 ;
       if(l <= r)
       add(l , r + 1 , i) , add(r + 1 , l , i) ;
     }
    // for(int i=1;i<=n+1;i++)
    //     if(!vis[i]&&dfs(i))
    // {
    //     cout << -1 << endl ;;return 0;
    // }
    // int ans=0;
    // for(int i=1;i<=m;i++)
    //     if(use[i]) ans++;
    // cout << ans << endl ;
    // for(int i=1;i<=m;i++)
    // if(use[i])
    //    cout << i << " " ;
    for(int i = 1; i <= n + 1 ;i ++)
     if(!vis[i] && dfs(i))
      {
        cout << -1 << endl ;
        return 0 ;
      }
      int ans =  0 ;
      for(int i = 1; i <= m ;i ++)
       if(use[i]) ans ++ ;
     cout << ans << endl ;
     for(int i = 1;i <= m ;i ++)
      if(use[i])
       cout << i << " " ;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,k;
ll a[200001],sum[200001];
map<ll,int> mp;
int main(){
    cin>>n>>k;
    rep(i,n) cin>>a[i];
    rep(i,n) sum[i+1]=(sum[i]+a[i]-1)%k;
    ll ans=0;
    FOR(i,0,n+1){
        if(i>=k) --mp[sum[i-k]];
        ans+=mp[sum[i]];
        ++mp[sum[i]];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define int ll

const int md = 1000000007;
const int INF = 1e10 + 7;



signed main(){
    int n,m; cin >> n >> m;

    vector<vector<int>> e(n,vi(n,INF+INF));
    rep(i,n) e[i][i] = 0;

    rep(i,m){
        int a,b,c; cin >>a >> b >> c;
        e[a][b] = c;
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                e[i][j] = min(e[i][j], e[i][k] + e[k][j]);

            }
        }
    }

    bool f = true;
    rep(i,n){
        if(e[i][i] < 0) f = false;
    }

    if(f) {
        rep(i, n) {
            rep(j, n) {
                if (e[i][j] >= INF) cout << "INF";
                else cout << e[i][j];
                cout << (j == n - 1 ? '\n' : ' ');
            }
        }
    }else{
        cout << "NEGATIVE CYCLE" << endl;
    }

    //cout << INF << endl;

}



Measured memory_bytes: 3228
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int diff = Math.min(b, d) - Math.max(a, c);
            out.println(diff < 0 ? 0 : diff);
        }

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                String nextLine = null;
                try {
                    nextLine = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (nextLine == null)
                    return null;
                st = new StringTokenizer(nextLine);
            }
            return st.nextToken();
        }

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

    }
}
 

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>
#include <type_traits>
#include <map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

// 最大公約数算出
int calc_gcd(const vector<int> vec){
	int gcd = *min_element(vec.begin(), vec.end());
	for (const int ele: vec){
		gcd = gcd_euclid(gcd,ele);
	}
	return gcd;
}

// 最小公倍数
int calc_lcm(const vector<int> vec) {
	int tmp = 1;
	for (const int ele: vec){
		tmp *= ele;
	}
	int gcd = calc_gcd(vec);
	return tmp/gcd;
}

void run() {
    int x; get x;
    int y; get y;

    put x + y / 2;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
from itertools import combinations

N, M = map(int, input().split())
S = []

for _ in range(M):
    S.append(list(map(int, input().split()[1:])))

P = list(map(int, input().split()))
ans = 0

for i in range(N+1):
    for c in combinations(range(N), i):
        flag = True
        state = [0] * N
        for n in c:
            state[n] = 1
        for p, s in zip(P,S):
            a = 0
            for k in s:
                a += state[k-1]
            if a % 2 != p:
                flag = False
                break
        
        if flag:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll L;
int N;
ll A[MAX_N];
ll S[MAX_N];
ll ans = 0;

void pre() {
	rep(i, 0, N) S[i + 1] = S[i] + A[i];
	rep(i, 0, N) {
		int mv = min(i, N - i - 1);
		ll tmp = 0;
		tmp += A[i];
		tmp += 2 * (S[i] - S[i - mv]);
		// debug(i, tmp);
		tmp += 2 * (L * mv - (S[i + 1 + mv] - S[i + 1]));
		// debug(i, tmp);
		if(i + 1 + mv < N) tmp += 2 * (L - A[i + 1 + mv]);
		// debug(i, tmp);
		MAX(ans, tmp);
	}
}

void solve() {
	cin >> L >> N;
	rep(i, 0, N) cin >> A[i];
	pre();
	reverse(A, A + N);
	rep(i, 0, N) A[i] = L - A[i];
	pre();
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
#define int LL
const int M = 1024 * 256;
const int MM = 31;
const LL inf = 1e18L;

VPII V;
VI V2;
LL dp[M][MM];
int n, t;

bool cmp(PII a, PII b)
{
	return a.f * b.s > a.s * b.f;
}

int32_t main()
{
	scanf("%lld%lld", &n, &t);
	t++;
	FOR(i, 1, n)
	{
		int a, b;
		scanf("%lld%lld", &a, &b);
		b++;
		if (a)
		{
			V.PB(MP(a, b));
		}
		else
		{
			V2.PB(b);
		}
	}
	sort(ALL(V2));
	sort(ALL(V), cmp);
	FOR(i, 1, MM - 1)
	{
		dp[0][i] = t + 1;
	}
	dp[0][0] = 1;
	FOR(i, 1, SIZ(V))
	{
		FOR(j, 0, MM - 1)
		{
			dp[i][j] = dp[i - 1][j];
			if (j > 0)
			{
				mini(dp[i][j], dp[i - 1][j - 1] * (V[i - 1].f + 1) + V[i - 1].s);
			}
			if (dp[i][j] > t)
			{
				dp[i][j] = t + 1;
			}
		}
	}
	int res = 0;
	FOR(i, 0, MM - 1)
	{
		if (dp[SIZ(V)][i] > t)
		{
			break;
		}
		int tt = dp[SIZ(V)][i], r = i;
		for (auto x : V2)
		{
			if (tt + x > t)
			{
				break;
			}
			tt += x;
			r++;
		}
		maxi(res, r);
	}
	printf("%lld\n", res);
}














Measured memory_bytes: 52972
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    vector<long long >v;
    vector<long long >t;
    vector<long long >f;
    set<long long>s;
    set<long long>::iterator it;
    map<long long,long long>m;
    for(int i=0;i<n;i++)
    {
        long long x;
        cin>>x;
        m[x]+=1;
       s.insert(x);
    }
    long long mx=0;
    for(it=s.begin();it!=s.end();it++)
    {
        if(m[*it]>=2)
        {
            t.push_back(*it);
        }
        if(m[*it]>=4)
        {
            f.push_back(*it);
        }
    }
    if(f.size()!=0)
    {
       mx=max(mx,f[f.size()-1]*f[f.size()-1]);
    }
     if(t.size()>=2)
    {
         mx=max(mx,t[t.size()-1]*t[t.size()-2]);
    }


cout<<mx<<endl;

}


Measured memory_bytes: 14440
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        long[] h = new long[N];
        for (int i = 0; i < N; i++) {
            h[i] = scan.nextLong();
        }
        Arrays.sort(h);
        long answer = Long.MAX_VALUE;
        for (int i = 0; i <= N - K; i++) {
            answer = Math.min(answer, h[i+K-1]-h[i]);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 50260
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 area=a*b;
	int length=2*a+2*b;
	
	System.out.println(area+" "+length);
    }
}

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


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

ll dp[3005][3005];
ll n,t,res;
pair<ll,ll> ar[3005];

ll f(int cur_index, int cur_time){
	if(cur_time>=t || cur_index>n) return 0;
	if(dp[cur_index][cur_time]) return dp[cur_index][cur_time];
	ll r = 0;
	r = max(r,f(cur_index+1,cur_time));
	r = max(r,f(cur_index+1,cur_time+ar[cur_index].first)+ar[cur_index].second);
	res = max(r,res);
	return dp[cur_index][cur_time]=r;
}

int main(){
	cin>>n>>t;	
	for(int i=1;i<=n;i++){
		cin>>ar[i].first>>ar[i].second;
	}
	sort(ar+1,ar+n+1);
	f(1,0);
	cout<<res;
}


Measured memory_bytes: 69376
#include <iostream>
using namespace std;
int main(void){
 int n;
 int d[102];
 int ans, sum = 0;
 
 cin >> n;
 
 for(int i = 0; i < n; i++){
   cin >> d[i];  
 }
 
 for(int i = 0; i < n-1; i++){
     for(int j = i+1; j < n; j++){
         sum += d[i]*d[j];
     }
 }
 ans = sum;
 
 cout << ans << endl;
 
 return 0;
}


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

#define Task "abc"
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int n;
int a[maxn];
ll ans[maxn];

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], a[i] = a[i] * 2;
  ll sum = 0;
  for (int i = 1; i <= n; ++i) sum = sum + a[i];
  sum /= 2;
  ll t = 0;
  for (int i = 2; i <= n; i += 2) t += a[i];
  ans[1] = sum - t;
  for (int i = 2; i <= n; ++i) ans[i] = a[i-1] - ans[i-1];
  for (int i = 1; i <= n; ++i) cout << ans[i] <<' ';

}



Measured memory_bytes: 4756
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int N;
    int ans;
    cin >> N;

    if(N%2==0){
        ans=N;
    }else{
        ans=N*2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int w[100];

int main() {
  int n;
  while(cin>>n) {
    inputs(w,n);
    int ans = INF;
    for(int t=0; t<n-1; t++) {
      int s1 = 0;
      int s2 = 0;
      for(int i=0; i<=t; i++) {
        s1 += w[i];
      }
      for(int i=t+1; i<n; i++) {
        s2 += w[i];
      }
      chmin(ans, abs(s1-s2));
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back
#define pf push_front
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1000000007;
const ll LLINF = 1000000000000000007LL;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i,n/2){
        if(s.at(i) != s.at(n-i-1)) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

const int64_t mod=1e9+7;

int main() {
  int H,W,i,j,lx=0,x;
  cin >> H >> W;
  vector<string> S(H);
  vector<vector<int>> L(H, vector<int>(W,0)), R(H, vector<int>(W,0)),
                      D(H, vector<int>(W,0)), U(H, vector<int>(W,0));
  for(i=0; i<H; i++)
    cin >> S.at(i);
  
  for(i=0; i<H; i++)
    for(j=0; j<W; j++)
      if(S.at(i).at(j) == '.') {
        if(i==0)
          U.at(i).at(j) = 1;
        else
          U.at(i).at(j) = U.at(i-1).at(j)+1;
        if(j==0)
          L.at(i).at(j) = 1;
        else
          L.at(i).at(j) = L.at(i).at(j-1)+1;
      }
  
  for(i=H-1; i>=0; i--)
    for(j=W-1; j>=0; j--)
      if(S.at(i).at(j) == '.') {
        if(i==H-1)
          D.at(i).at(j) = 1;
        else
          D.at(i).at(j) = D.at(i+1).at(j)+1;
        if(j==W-1)
          R.at(i).at(j) = 1;
        else
          R.at(i).at(j) = R.at(i).at(j+1)+1;
      }
  
  for(i=0; i<H; i++)
    for(j=0; j<W; j++) {
      x = L.at(i).at(j) + R.at(i).at(j) + 
             D.at(i).at(j) + U.at(i).at(j) - 3;
      if(x > lx)
        lx = x;
    }
  
  cout << lx << endl;
}

Measured memory_bytes: 67200
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let mut set: HashSet<&str> = HashSet::new();

    for i in 0..n {
        set.insert(&s[i]);
    }

    println!("{}", set.len());
}


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

int main() {
  int n;
  cin >> n;
  map<int, int> counter;

  int max = 0;

  for(int i=0;i<n;i++) {
    int a;
    cin >> a;
    counter[a-1]++;
    if(counter[a-1]>max) max = counter[a-1];
    counter[a+1]++;
    if(counter[a+1]>max) max = counter[a+1];
    counter[a]++;
    if(counter[a]>max) max = counter[a];
  }

  cout << max << endl;

}

Measured memory_bytes: 4736