akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);


        int n = in.nextInt();
        int d = in.nextInt();
        int[][] a = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                a[i][j] = in.nextInt();
            }
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                double distance = distance(a[i],a[j]);
                if(isInteger(distance)) count++;
            }
        }
        out.println(count);
        out.flush();
    }
    static double distance(int [] a, int [] b) {
        double d = 0;
        for (int i = 0; i < a.length; i++) {
            int temp = (a[i]-b[i])*(a[i]-b[i]);
            d+=temp;
        }
        return Math.sqrt(d);
    }
    static boolean isInteger(double d) {
        return d == (int)d;
    }
    static int f(LinkedList<Integer> q) {
        int size = q.size();
        int count = 0;
        size/=2;
        while (size-->0) {
            int first = q.pollFirst();
            int second = q.pollFirst();
            if(first+second>=10) count++;
            int newValue = (first+second)%10;
            q.addLast(newValue);
        }
        return count;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

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

    public Integer nextInt() {
        return Integer.valueOf(next());
    }
    public Long nextLong() {return  Long.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 10000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {    
    ll n,m;
    cin >> n >> m;
    vector<ll> val(m,0);
    for(ll i=0;i<n;i++){
        ll k;
        cin >> k;
        for(ll j=0;j<k;j++){
            ll x;
            cin >> x;
            x--;
            val[x]++;
        }
    }
    ll ans = 0;
    for(ll i=0;i<m;i++){
        if(val[i]==n){
            ans++;
        }
    }
    cout << ans << endl;
} 

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

int main(){
    int i, c = 0;
    string s;
    cin >> s;
    for(i=0; i<s.size(); i++){
        if(i%2 == 0 && s[i] == '0'){
            c++;
        }else if(i%2 == 1 && s[i] == '1'){
            c++;
        }
    }
    cout << min(c, (int)s.size()-c) << '\n';
    return 0;
}

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


string a,b;


int main(void){
    cin>>a>>b;
    if (a=="H"){
        cout<<b<<endl;
    }else{
        if (b=="H"){
            puts("D");
        }else{
            puts("H");
        }
    }
}


Measured memory_bytes: 256
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('b1.in')


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


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


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    S = read_str()
    print('x' * len(S))


main()


Measured memory_bytes: 3700
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long ans = 0;
		for(long i=1; i<=n; i++){
			if(i%3 != 0 && i%5 != 0) {
				ans += i;
			}
		}
		System.out.println(ans);
	}
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,a[200010],tot;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		tot^=a[i];
	}
	rep(i,n) cout<<(tot^a[i])<<' ';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for (int i=1; i<=9; i++){
    for (int j=1; j<=9; j++){
      if (n==i*j){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3628
import math
n,d= map(int, input().split())
X=list(list(map(int, input().split())) for _ in range(n))
cnt=0
for i in range(n):
    for j in range(i+1,n):
        r=0
        for k in range(d):
            r += (X[i][k] - X[j][k])**2
        if r - int(math.sqrt(r))**2==0:
            cnt+=1
print(cnt)

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()
l = inputIL()
l.sort()
if sum(l[:-1]) <= l[-1]:
  No()
else:
  Yes()


Measured memory_bytes: 64108
object Main extends App {

  import scala.io.StdIn._
  val n = readLine.trim.toInt
  val peaces = Array.tabulate(n){_ ⇒ readLine.trim.toLong}
  println(
    calMax(peaces)
  )
  def calMax(peaces: Array[Long]): Long = {
    val n = peaces.length
    def searchIOITurn(from: Int, to: Int)(implicit memo: Array[Array[Option[Long]]]): Long = {
      memo(from)(to) match {
        case Some(r) ⇒ r
        case None if from == to ⇒ 0.also{it ⇒ memo(from)(to) = Some(it)}
        case None ⇒
          (if (peaces(from) < peaces(to)) searchJOITurn(from, (to + n - 1) % n)
          else searchJOITurn((from + 1) % n, to)).also{it ⇒ memo(from)(to) = Some(it)}
      }
    }
    def searchJOITurn(from: Int, to: Int)(implicit memo: Array[Array[Option[Long]]]): Long = {
      memo(from)(to) match {
        case Some(r) ⇒ r
        case None if from == to ⇒  peaces(from).also{it ⇒ memo(from)(to) = Some(it)}
        case None ⇒ List(searchIOITurn((from + 1) % n, to) + peaces(from), searchIOITurn(from, (to + n - 1) % n) + peaces(to)).max.also{it ⇒ memo(from)(to) = Some(it)}
      }
    }
    implicit val memo = Array.tabulate(n){_ ⇒ Array.tabulate(n){_ ⇒ None: Option[Long]}}
    (0 until n).map{it ⇒ searchIOITurn((it + 1) % n, (it + n - 1) % n) + peaces(it)}.max
  }

  implicit class ScopeFunc[T](val value: T) {
    def let[A](func: T ⇒ A): A = func(value)
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}

/*
 */


Measured memory_bytes: 585532
#include <stdio.h>

int main()
{
	char s[10]; scanf("%s",s);
	int ans=0;
	int ans1=0;
	for (int i = 0; i < sizeof(s); ++i)
	{
		if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
			ans1++;
			if(ans1>ans) ans=ans1;
		}else{
			ans1=0;
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, m;
	cin >> n >> m;
	vi x(m);
	Foz(i, m) cin >> x[i];
	sort(all(x));
	vi d;
	Foz(i, m - 1) d.pb(x[i + 1] - x[i]);
	sort(all(d));
	int r = min(n - 1, sz(d));
	while (r--) d.pop_back();
	int ans = 0;
	Trav(x, d) ans += x;
	cout << ans << '\n';
}



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

int main() {
  string ch;
  cin >> ch;
  if (ch.at(2) == ch.at(3) && ch.at(4) == ch.at(5) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private void solve(Scanner sc, PrintWriter out) {
        int H = sc.nextInt();
        int W = sc.nextInt();
        sc.nextLine();
        char[][] A = new char[H][W];
        for (int i = 0; i < H; ++i) {
            String s = sc.nextLine();
            for (int j = 0; j < W; ++j) {
                A[i][j] = s.charAt(j);
            }
        }

        int cx = 0;
        int cy = 0;
        if (A[cy][cx] != '#') {
            out.println("Impossible");
            return;
        }
        while (cx + 1 < W || cy + 1 < H) {
            if (cy + 1 < H && A[cy + 1][cx] == '#'
            && cx + 1 < W && A[cy][cx + 1] == '#') {
                out.println("Impossible");
                return;
            } else if (cy > 0 && A[cy - 1][cx] == '#'
                || cx > 0 && A[cy][cx - 1] == '#') {
                out.println("Impossible");
                return;
            } else if (cy + 1 < H && A[cy + 1][cx] == '#') {
                A[cy][cx] = '$';
                ++cy;
            } else if (cx + 1 < W && A[cy][cx + 1] == '#') {
                A[cy][cx] = '$';
                ++cx;
            } else {
                out.println("Impossible");
                return;
            }
        }
        A[cy][cx] = '$';

        if (debug) {
            for (int i = 0; i < H; ++i) {
                for (int j = 0; j < W; ++j) {
                    System.err.print(A[i][j]);
                }
                System.err.println();
            }
        }
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (A[i][j] == '#') {
                    out.println("Impossible");
                    return;
                }
            }
        }

        out.println("Possible");
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(sc, out);
        out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            System.err.println((G - S) + "ms");
        }
    }
}

Measured memory_bytes: 10324
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
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;
}

int main() {
	// ?????????????????°??????????????????
	int a,b,c;
	cin >> a >> b >> c;
	if (a < b && b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int main(){

    int n;

    cin >> n;

    vector<string> s(n);

    rep(i,n) cin >> s[i];

    int m;
    cin >> m;
    vector<string> t(m);

    rep(i,m) cin >> t[i];
    int ans=0;
    rep(i,n){
        int te=0;
        rep(j,n){
            if(s[i]==s[j]) te++;
        }
        rep(j,m){
            if(t[j]==s[i]) te--;
        }
        ans=max(te,ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	#define MAXN 102
	using namespace std;
	 char arr[MAXN][MAXN];
	 int n,m;
	 bool cr[MAXN];
	 bool cc[MAXN];
  void checkr(int i){
    for (int j = 0; j <((m==1)?1:(m-1)); ++j)
     {
       if(arr[i][j]!=arr[i][j+1]||arr[i][j]=='#'){
         cr[i]=false;
         goto noob;
    }
     } 
     // true if ......
       cr[i]=true;
        noob:;
  }

  void checkc(int j){
  for (int i = 0; i <((n==1)?1:(n-1)); ++i)
     {
       if(arr[i][j]!=arr[i+1][j]||arr[i][j]=='#'){
        
          cc[j]=false;
           goto noob;
     } }
        cc[j]=true;
        noob:;

        
  }
  
	int main()
	{
		
		std::ios::sync_with_stdio(false);
		 cin.tie(0);
		 cout.tie(0);
		
		cin>>n>>m;


		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < m; ++j)
			{
			   cin>>arr[i][j];
			}
		}


     


		for (int i = 0; i < n; ++i)
		{
			checkr(i);
		}
		for (int j = 0; j < m; ++j)
		{
			checkc(j);
		}
          
        for (int i = 0; i < n; ++i)
            {
            	
            	for (int j = 0; j <m ; ++j)
            	{
            		if(cr[i]==true||cc[j]==true){
                    arr[i][j]='*';
                                   		}
            		
            	}
          
            }    
            bool flag=0;
             for (int i = 0; i < n; ++i)
            {
            	flag=0;
            	for (int j = 0; j <m ; ++j)
            	{
                 if(arr[i][j]!='*'){
                 	cout<<arr[i][j];
                    flag=1;
                 }  
                 }
                if(flag)cout<<endl;

             }
         

		
		return 0;
	}


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

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

    uint64_t m = 0;    
    uint64_t a = 0;
    uint64_t r = 0;
    uint64_t c = 0;
    uint64_t h = 0;

    std::string S;
    for (int i = 0; i < N; ++i) {
        std::cin >> S;
        const char b = S[0];

        if (b == 'M') {
            ++m;
        } else if (b == 'A') {
            ++a;
        } else if (b == 'R') {
            ++r;
        } else if (b == 'C') {
            ++c;
        } else if (b == 'H') {
            ++h;
        }
    }

    uint64_t ans = m * a * r
                 + m * a * c
                 + m * a * h
                 + m * r * c
                 + m * r * h
                 + m * c * h
                 + a * r * c
                 + a * r * h
                 + a * c * h
                 + r * c * h;

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

int i,x,n,p[105],yes[105];

void solve()
{
    cin>>x>>n;
    for(i=1;i<=n;++i)
    {
        cin>>p[i];
        yes[p[i]]=1;
    }
    int ans1=x,ans2=x;
    while(yes[ans1])
        ans1++;
    while(yes[ans2])
        ans2--;
    if(abs(ans2-x)>abs(ans1-x))
        cout<<ans1;
    else
        cout<<ans2;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
x=input().split(" ")
n=int(x[0])
s=int(x[1])
number_list=[]
for i in range(n+1):
    for j in range(n-i+1):
        sum=10000*i+5000*j+1000*(n-i-j)
        
        number_list.append(sum)
        if sum==s:
            print(str(i)+" "+str(j)+" "+str(n-i-j))
            break
    else:
        continue
    break
if s not in number_list:
    print(str(-1)+" "+str(-1)+" "+str(-1))

Measured memory_bytes: 82344
#include <iostream>
#include <vector>
#include <set>
#include <cstdlib>
#include <algorithm>
using namespace std;

class Point{
public:
  int x,y;
  Point(int x=0,int y=0):x(x),y(y){}
  bool operator < (const Point &p) const {
    if(x == p.x) return y < p.y;
    else return x < p.x;
  }
};

int area(vector<Point> v){
  int sum = 0;
  int n = v.size();
  for(int i=0;i<n;i++) sum += (v[i].x - v[(i+1)%n].x) * (v[i].y + v[(i+1)%n].y);

  return sum / 2;
}

int main(){
  int n;
  while(cin >> n && n){
    vector<Point> v(n);
    set<Point> s;
    int ans = 0;
    for(int i=0;i<n;i++){
      cin >> v[i].x >> v[i].y;
      s.insert(v[i]);
    }
    sort(v.begin(),v.end());

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	int dx = v[j].x - v[i].x;
	int dy = v[j].y - v[i].y;
	Point p(v[j].x+dy,v[j].y-dx),p2(v[i].x+dy,v[i].y-dx);

	if(s.find(p) != s.end() && s.find(p2) != s.end()){
	  vector<Point> v2;
	  v2.push_back(v[i]);
	  v2.push_back(v[j]);
	  v2.push_back(p);
	  v2.push_back(p2);
	  ans = max(ans,abs(area(v2)));
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll dp[n+1][3];
  rep(i,n+1)rep(j,3) dp[i][j]=-MAXL;
  if(n%2) {
    rep(i,3) dp[i+1][2-i]=a[i];
  } else {
    rep(i,2) dp[i+1][1-i]=a[i];
  }
  REP(i,1,n) {
    rep(j,3) {
      rep(k,j+1) {
        if(i+1+k<n) {
          dp[i+2+k][j-k]=max(dp[i+2+k][j-k],dp[i][j]+a[i+1+k]);
        }
      }
    }
  }
  ll ans=-MAXL;
  if(n%2) {
    rep(i,3) ans=max(ans,dp[n-i][i]);
  } else {
    rep(i,2) ans=max(ans,dp[n-i][i]);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 9904
#include<bits/stdc++.h>
using namespace std;
int n,a,cnt=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a!=i) cnt++;
	}
	if(cnt<=2) cout<<"YES";
	else cout<<"NO";
	return 0;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

vi a;
int n;

int main()
{
    cin >> n;
    REP(i,n){
        int c;
        cin >> c;
        a.push_back(c);
    }
    cout << *max_element(ALL(a)) -  *min_element(ALL(a))<< endl;
}

Measured memory_bytes: 256
N,L = map(int,input().split(' '))

sum_apple_pie = 0
min_abs_apple = float('inf')
min_num = float('inf')
for i in range(N):
    sum_apple_pie += i + L
    if abs(i + L) < min_abs_apple:
        min_abs_apple = abs(i + L)
        min_num = i + L
print(sum_apple_pie - min_num)

Measured memory_bytes: 38384
#include<stdio.h>

void main(){
  int n, n100, n10, n1;
  scanf("%d",&n);
  
  n100 = n/100;
  n10  = (n/10)%10;
  n1   = n%10;
  if(n100 == 7)
    printf("Yes");
  else if(n10 == 7)
    printf("Yes");
  else if(n1 == 7)
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 1652
n = int(input())
ans = 10 ** 10
upanddown = [[] for i in range(200001)]
leftandright = [[] for i in range(200001)]
lis = []
for i in range(n):
    x,y,r = map(str,input().split())
    x,y = int(x),int(y)
    lis.append([x+y,x-y,x,y,r])
    if r == "U":
        upanddown[x].append([y,0])
    elif r == "D":
        upanddown[x].append([y,1])
    elif r == "R":
        leftandright[y].append([x,0])
    else:
        leftandright[y].append([x,1])
  # print(upanddown[11])
for li in upanddown:
    if len(li) >= 2:
        li.sort(key=lambda z:z[1])
        li.sort(key=lambda z:z[0])
        key = 0
        keynum = -1
        for num,r in li:
            if r == 0:
                keynum = num
            else:
                if keynum != -1:
                    ans = min(ans,(num-keynum)*5)
for li in leftandright:
    if len(li) >= 2:
        li.sort(key=lambda z:z[1])
        li.sort(key=lambda z:z[0])
        key = 0
        keynum = -1
        for num,r in li:
            if r == 0:
                keynum = num
            else:
                if keynum != -1:
                    ans = min(ans,(num-keynum)*5)
  # print(ans)
lis.sort(key = lambda z:z[2])
lis.sort(key = lambda z:z[0])

for i in range(n-1):
    if lis[i][0] == lis[i+1][0]:
        if (lis[i][4] == "R" and lis[i+1][4] == "U") or (lis[i][4] == "D" and lis[i+1][4] == "L"):
            ans = min(ans,(lis[i+1][2]-lis[i][2])*10)
lis.sort(key = lambda z:z[2])
lis.sort(key = lambda z:z[1])

for i in range(n-1):
    if lis[i][1] == lis[i+1][1]:
        if (lis[i][4] == "U" and lis[i+1][4] == "L") or (lis[i][4] == "R" and lis[i+1][4] == "D"):
            ans = min(ans,(lis[i+1][2]-lis[i][2])*10)
if ans == 10 ** 10:
    print("SAFE")
else:
    print(ans)

Measured memory_bytes: 111036
#include<bits/stdc++.h>
//#include<unordered_map>
//#include<unordered_set>

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
/*
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
priority_queue<int, greater<int>, pairing_heap_tag> pq[1009];
#define fbo         find_by_order
#define ook         order_of_key
*/
typedef long long ll;
typedef unsigned long long ull;
typedef vector< vector<ll> >matrix;
#define gcd(A,B)        __gcd(A,B)
#define PQ              priority_queue
#define ii              int,int
#define pll             pair<ll,ll>
#define PI              2*acos(0.0)
#define all(v)          v.begin(),v.end()
#define pii             pair<ii>
#define pb              push_back
#define sf(x)           scanf("%I64d",&x)
#define sff(x,y)        scanf("%I64d %I64d",&x,&y)
#define sl(x)           scanf("%lld",&x)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define ff              first
#define ss              second
#define segtree         lt=2*par,rg=2*par+1,mid=(st+en)/2
#define read            freopen("input.txt","r",stdin)
#define write           freopen("output.txt","w",stdout)
#define fast            ios_base::sync_with_stdio(0),cin.tie(0)
#define lead_zero(x)    __builtin_clzll(x)
#define trail_zero(x)   __builtin_ctz(x)
#define total_1s(x)     __builtin_popcount(x)
#define max_ull         18446744073709551615
#define max_ll          9223372036854775807;
#define set(N,cur)      N=(N|(1LL<<cur))
#define reset(N,cur)    N=(N&(~(1LL<<cur)))
#define check(N,cur)    ((N&(1LL<<cur))==0)
#define all(v)          v.begin(),v.end()
#define reunique(v)     v.resize(std::unique(all(v)) - v.begin())
#define loop            int test;scanf("%d",&test);for(int _T=1;_T<=test;_T++)
/* int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
/* int dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction
ll ara[10002];
int main()
{
    int n;
    scanf("%d",&n);
    ll ans=0;
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&ara[i]);
        cnt=0;
        while(ara[i]%2==0)
        {
            ara[i]/=2;
            cnt++;
        }
        ans+=cnt;
    }
    cout<<ans<<endl;
}






Measured memory_bytes: 384
// C++ 14
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <math.h>

#define ll long long
#define Int int
#define loop(x, start, end) for(Int x = start; x < end; x++)
#define loopdown(x, start, end) for(int x = start; x > end; x--)
#define span(a,x,y) a.begin()+x,a.begin()+y
#define span_all(a) a.begin(),a.end()
#define len(x) (x.size())
#define last(x) (*(x.end()-1))

using namespace std;

#define MAX_N 51

Int N;
vector<Int> D(MAX_N, 0);

Int solve() {
  Int sum = 0;
  loop(i,0,N-1) {
    loop(j,i+1,N) {
      sum += D[i] * D[j];
    }
  }
  return sum;
}

int main() {
  cin >> N;
  loop(i,0,N) cin >> D[i];
  cout << solve() << endl;
}

Measured memory_bytes: 256
#include<queue>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  short a[8][8][8][8][8][8][8],b[8],p;
  short *c;
  string s="";
  queue<pair<string,short> > q;
  memset(a,-1,sizeof(a));
  for(i=0;i<8;i++)
    s+=i;
  q.push(make_pair(s,0));
  while(q.empty()==0){
    s=q.front().first;
    p=q.front().second;
    q.pop();
    c=&a[(int)s[0]][(int)s[1]][(int)s[2]][(int)s[3]][(int)s[4]][(int)s[5]][(int)s[6]];
    if(*c==-1){
      *c=p;
      if(0){
      }else if(s[0]==0){
	s[0]=s[1];
	s[1]=0;
	q.push(make_pair(s,p+1));
	s[1]=s[0];
	s[0]=s[4];
	s[4]=0;
	q.push(make_pair(s,p+1));
      }else if(s[1]==0){
	s[1]=s[0];
	s[0]=0;
	q.push(make_pair(s,p+1));
	s[0]=s[1];
	s[1]=s[2];
	s[2]=0;
	q.push(make_pair(s,p+1));
	s[2]=s[1];
	s[1]=s[5];
	s[5]=0;
	q.push(make_pair(s,p+1));
      }else if(s[2]==0){
	s[2]=s[1];
	s[1]=0;
	q.push(make_pair(s,p+1));
	s[1]=s[2];
	s[2]=s[3];
	s[3]=0;
	q.push(make_pair(s,p+1));
	s[3]=s[2];
	s[2]=s[6];
	s[6]=0;
	q.push(make_pair(s,p+1));
      }else if(s[3]==0){
	s[3]=s[2];
	s[2]=0;
	q.push(make_pair(s,p+1));
	s[2]=s[3];
	s[3]=s[7];
	s[7]=0;
	q.push(make_pair(s,p+1));
      }else if(s[4]==0){
	s[4]=s[0];
	s[0]=0;
	q.push(make_pair(s,p+1));
	s[0]=s[4];
	s[4]=s[5];
	s[5]=0;
	q.push(make_pair(s,p+1));
      }else if(s[5]==0){
	s[5]=s[4];
	s[4]=0;
	q.push(make_pair(s,p+1));
	s[4]=s[5];
	s[5]=s[6];
	s[6]=0;
	q.push(make_pair(s,p+1));
	s[6]=s[5];
	s[5]=s[1];
	s[1]=0;
	q.push(make_pair(s,p+1));
      }else if(s[6]==0){
	s[6]=s[5];
	s[5]=0;
	q.push(make_pair(s,p+1));
	s[5]=s[6];
	s[6]=s[7];
	s[7]=0;
	q.push(make_pair(s,p+1));
	s[7]=s[6];
	s[6]=s[2];
	s[2]=0;
	q.push(make_pair(s,p+1));
      }else if(s[7]==0){
	s[7]=s[6];
	s[6]=0;
	q.push(make_pair(s,p+1));
	s[6]=s[7];
	s[7]=s[3];
	s[3]=0;
	q.push(make_pair(s,p+1));
      }
    }
  }
  while(cin>>b[0]){
    for(i=1;i<8;i++)
      cin>>b[i];
    cout<<a[b[0]][b[1]][b[2]][b[3]][b[4]][b[5]][b[6]]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
input=sys.stdin.readline
def main():
    n,x=map(int,input().split())
    l=list(map(int,input().split()))
    q=[0]*(n+1)
    for i in range(1,n+1):
        q[i]=q[i-1]+l[i-1]
    def bs(x):
        l=0 ; r=n
        while l<=r :
            m=(l+r)>>1
            if q[m] <= x :l=m+1
            else : r=m-1
        return l
    print(bs(x))
main()

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

int main(){
	string o, e;
	cin >> o >> e;
	for(int i = 0; i < e.size(); i++){
		printf("%c%c", o[i], e[i]);
	}
	if(o.size() > e.size()){
		printf("%c\n", o[o.size() - 1]);
	} else printf("\n");
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int S=26;

string x;
long long ans;
map<string,int>M;
int n;

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		cin>>x;
		sort(x.begin(),x.end());
		ans+=M[x];
		M[x]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
 
 
int main(){
	int n;
	cin>>n;
	n %= 10;
	if(n==1 || n==0 || n==6 || n==8) cout<<"pon\n";
	else if(n==3) cout<<"bon\n";
	else cout<<"hon\n";
}


Measured memory_bytes: 3604
fun main(args: Array<String>) {
    Main.init()

    Main.execute()

    Main.display()
}

data class Timestamp(var findedAt: Int? = null, var endedAt: Int? = null)

class Main {

    companion object {
        private val graphMatrix = arrayListOf<ArrayList<Boolean>>()

        private val timestampList = arrayListOf<Timestamp>()

        private var currentTime = 0

        fun init() {
            val num = readLine()!!.toInt()

            initgraph(num)

            for (index in 1..num) {
                val inputs = readLine()!!.split(" ")
                val nodeIndex = inputs[0].toInt()
                for (inputIndex in 2 until inputs.size) {

                    val touchedNode = inputs[inputIndex].toInt()
                    graphMatrix[nodeIndex - 1][touchedNode - 1] = true
                }
            }
        }

        fun display() {
            println(timestampList.mapIndexed { index, timestamp ->
                "${index + 1} ${timestamp.findedAt} ${timestamp.endedAt}"
            }.joinToString("\n"))
        }

        /**
         * 深さ優先
         */
        fun execute() {

            // 全て探索するため永久に
            while (true) {
                var index: Int? = null
                for (i in 1..timestampList.size) {
                    if (timestampList[i - 1].findedAt == null) {
                        index = i
                        break
                    }
                }

                if (index == null) break

                dig(index)
            }
        }

        /**
         * 下に掘る
         */
        fun dig(index: Int) {
            // 時間経過
            currentTime++

            // 発見を記録
            timestampList[index - 1].findedAt = currentTime

            graphMatrix[index - 1].forEachIndexed { touchedIndex, b ->
                // エッジがあるなおかつ未探索
                if (b && timestampList[touchedIndex].findedAt == null) {
                    dig(touchedIndex + 1)
                }
            }

            // 時間経過
            currentTime++

            // 発見を記録
            timestampList[index - 1].endedAt = currentTime
        }


        fun initgraph(num: Int) {
            for (i in 0 until num) {
                graphMatrix.add(arrayListOf())
                for (j in 0 until num) {
                    graphMatrix[i].add(false)
                }
                timestampList.add(Timestamp())
            }
        }
    }
}


Measured memory_bytes: 32116
#include<stdio.h>
#include<stdlib.h>
#define SIZE 200005

int from[SIZE] = {0};
int to[SIZE] = {0};

int main()
{
  int i;
  int n, m;
  int a, b;
  scanf("%d %d", &n, &m);

  for(i = 0; i < m; i++){
    scanf("%d %d", &a, &b);
    if(a == 1){
      from[b] = 1;
    }
    if(b == n){
      to[a] = 1;
    }
  }

  for(i = 0; i < SIZE; i++){
    if(from[i] && to[i]){
      printf("POSSIBLE\n");
      return 0;
    }
  }
  return 0*printf("IMPOSSIBLE\n");
}

  
    


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int x, t;
  cin >> x >> t;

  int ans = max(x - t, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  vector<int>b(n);
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  vector<int>c(n-1);
  for(int i=0;i<n-1;i++){
    cin >> c[i];
  }
  
  int ans = 0;
  
  for(int i=0;i<n;i++){
    ans += b[a[i] - 1];
    if(a[i] == a[i-1] + 1) ans += c[a[i] - 2];
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
// cand <genesis?>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const ll base = 7;
const ll N = 1e5 + 9;
const ll inf = 1000100009;
typedef pair<ll,ll> LL;
vector<char> res;
ll n,num[6],i;
string s[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("test.INP", "r", stdin);
    //cout<<cal(104) - cal(103)<<"\n";
    cin>>n>>num[0]>>num[1]>>num[2];
    for (i = 1;i <= n;i++) cin>>s[i];
    for (i=1;i<=n;i++){
        ll x = s[i][0] - 'A';
        ll y = s[i][1] - 'A';
        if (num[x] == 0&&num[y] == 0){
            cout<<"No"; return 0;
        }
        if (num[x] < num[y]){
            num[y]--; num[x]++;
            res.push_back(char(x + 'A'));
        }
        else if (num[x] > num[y]){
            num[y]++; num[x]--;
            res.push_back(char(y + 'A'));
        }
        else{
            if (num[x] == 1){
                if (i == n) res.push_back(char(y + 'A'));
                else{
                    ll p = s[i + 1][0] - 'A';
                    ll q = s[i + 1][1] - 'A';
                    if (p == x||q == x){
                        res.push_back(char(x + 'A'));
                        num[x]++; num[y]--;
                    }
                    else{
                        res.push_back(char(y + 'A'));
                        num[y]++; num[x]--;
                    }
                }

            }
            else{
                num[x]--; num[y]++;
                res.push_back(char(y + 'A'));
            }
        }
    }
    cout<<"Yes\n";
    for (auto i : res) cout<<i<<"\n";
}


Measured memory_bytes: 6888
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1001002003004005006ll;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll dp[101][100001];

int main() {
	int N, W;
	cin >> N >> W;
	vector<int> w(N), v(N);
	rep(i,N) cin >> w[i] >> v[i];

	rep(i,101) rep(j, 100001) dp[i][j] = LINF;
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= 100000; j++) {
			if (j - v[i] >= 0) {
				dp[i+1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			} else {
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	ll res = 0;
	for (int j = 100000; j >= 0; j--) {
		if (dp[N][j] <= W) {
			res = j;
			break;
		}
	}
	cout << res << endl;
}

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

struct Card {
    char value;
    char suit;
};

void swap(struct Card a[], int i, int j) {
    Card tmp = a[i];
    a[i] = a[j];
    a[j] = tmp;
}

void bubbleSort(struct Card a[], int n) {
    for (int i = 0; i < n; ++i) {
        for (int j = n - 1; i - 1 < j; --j) {
            if (a[j].value < a[j - 1].value) {
                swap(a, j, j - 1);
            }
        }
    }
}

void selectionSort(struct Card a[], int n) {
    for (int i = 0; i < n; ++i) {
        int minj = i;
        for (int j = i; j < n; ++j) {
            if (a[j].value < a[minj].value) minj = j;
        }
        swap(a, i, minj);
    }
}

void print(struct Card a[], struct Card b[], int n) {
    for (int i = 0; i < n; ++i) {
        if (a[i].suit != b[i].suit) {
            cout << "Not stable" << endl;
            return ;
        }
    }
    cout << "Stable" << endl;
}

int main() {

    int n;
    cin >> n;

    Card *card1 = new Card[n];
    for (int i = 0; i < n; ++i) {
        cin >> card1[i].suit >> card1[i].value;
    }

    Card *card2 = new Card[n];
    for (int i = 0; i < n; ++i) {
        card2[i] = card1[i];
    }

    bubbleSort(card1, n);

    for (int i = 0; i < n; ++i) {
        if (0 != i) cout << " ";
        cout << card1[i].suit << card1[i].value;
    }
    cout << endl;
    cout << "Stable" << endl;

    selectionSort(card2, n);

    for (int i = 0; i < n; ++i) {
        if (0 != i) cout << " ";
        cout << card2[i].suit << card2[i].value;
    }
    cout << endl;
    print(card1, card2, n);

    delete[] card1;
    delete[] card2;
    return 0;
}

Measured memory_bytes: 1188
require 'prime'

def solve(arr, n)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    arr[m] < n ? l = m : r = m
  end
  arr[r] - arr[l]
end

primes = Prime.each.take(100000)
while n = gets.to_i
  break if n == 0
  puts Prime.prime?(n) ? 0 : solve(primes, n)
end

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int cnt0 = 0, cnt1 = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '0'){
            cnt0++;
        }else{
            cnt1++;
        }
    }
    cout << min(cnt0,cnt1) * 2;
}

Measured memory_bytes: 512
"use strict";

const main = arg => {
    let input = arg.split('\n');
    let AC = 0;
    let WA = 0;
    let TLE = 0;
    let RE = 0;
    
    for (let i = 1; i < input[0]+1; i++) {
        if (input[i] == 'AC') {
            AC = AC +1;
        } else if(input[i] == 'WA') {
            WA = WA + 1;
        } else if(input[i] == 'TLE') {
            TLE = TLE + 1;
        } else if(input[i] == 'RE') {
            RE = RE + 1;
        }
    }
    
    console.log('AC x ' + AC)
    console.log('WA x ' + WA)
    console.log('TLE x ' + TLE)
    console.log('RE x ' + RE)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 43240
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

    int n, d, x;
    cin >> n >> d >> x;
    vector<int> pdf(d);
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        for (int j = 0; j < d; j += a)
        {
            pdf[j]++;
        }
    }
    int ans = accumulate(pdf.begin(), pdf.end(), 0);
    ans += x;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(long long N, std::vector<long long> a){
    int count = 1;
    int tmp = a[1];
    bool ans = false;
    REP(i, N) {
        if (tmp == 2) {
            ans = true;
            break ;
        }
        if (tmp == 1) break ;
        tmp = a[tmp];
        count++;
    }
    if (ans) print(count);
    else print(-1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N + 1);
    for(int i = 1 ; i <= N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const vector<int> v = {0, -1, 0, 1};
const vector<int> h = {-1, 0, 1, 0};

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H+1, vector<char>(W+1));
    queue<vector<int>> que;
    vector<vector<int>> dist(H+1, vector<int>(W+1, -1));

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> s.at(i).at(j);
            if (s.at(i).at(j) == '#') {
                que.push({i, j});
                dist.at(i).at(j) = 0;
            }
            
        } 
    }
    int maxDist = 0;

    while (!que.empty()) {
        vector<int> current = que.front();
        int x = current.at(0);
        int y = current.at(1);
        que.pop();

        for (int i = 0; i < 4; i++) {
            int nx = x + v.at(i);
            int ny = y + h.at(i);

            if (nx < 1 || nx > H || ny < 1 || ny > W) continue;
            if (dist.at(nx).at(ny) != -1) continue;
            if (s.at(nx).at(ny) == '#') continue;
            dist.at(nx).at(ny) = dist.at(x).at(y) + 1;
            que.push({nx, ny});
            maxDist = max(maxDist, dist.at(nx).at(ny));
        }
    }
    cout << maxDist << endl;

    return 0;
}

Measured memory_bytes: 63404
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100005];
ll n;
ll arr[100005];

ll solve(ll m){
    if(m==n-1)
    return 0;
    if(m>=n)
    return INT_MAX;
    if(dp[m]!=-1)
    return dp[m];
    
    ll move1 = abs(arr[m+1]-arr[m])+solve(m+1);
    ll move2 = INT_MAX;
    if(m+2<n)
    move2 = abs(arr[m+2]-arr[m])+solve(m+2);
     return dp[m] = min(move1, move2);
}

int main() {
	//cout<<"GfG!";
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
	cin>>arr[i];
	cout<<solve(0);
	
	return 0;
}

Measured memory_bytes: 9844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  string s;
  cin >> n >> s;

  if (s[0] != 'B' || s[2 * n - 1] != 'B') {
    cout << 0 << '\n';
    return 0;
  }
  vector<ll> cnt(2, 0), a(2 * n, 0);
  cnt[1] = 1, a[0] = 1;
  FOR(i, 1, 2 * n) {
    if (s[i - 1] != s[i]) a[i] = a[i - 1];
    else a[i] = a[i - 1] ^ 1;
    cnt[a[i]]++;
  }
  if (cnt[0] != cnt[1]) {
    cout << 0 << '\n';
    return 0;
  }
  ll ans = 1, res = 0;
  rep(i, 2 * n) {
    if (a[i]) res += a[i];
    else {
      ans = ans * res % mod;
      res--;
    }
  }
  FOR(i, 1, n + 1) ans = ans * i % mod;
  cout << ans << '\n';



  
  
  



  



  

  
  return 0;
}

Measured memory_bytes: 2196