akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
int a[200005], b[200005], c[200005];
int s[100005], t[100005];
int asc1(const void* x, const void* y)
{
	if (a[*(int*)x] > a[*(int*)y])return 1;
	if (a[*(int*)x] < a[*(int*)y])return -1;
	if (b[*(int*)x] > b[*(int*)y])return 1;
	if (b[*(int*)x] < b[*(int*)y])return -1;
	if (c[*(int*)x] > c[*(int*)y])return 1;
	if (c[*(int*)x] < c[*(int*)y])return -1;
	return 0;
}
int asc2(const void* x, const void* y)
{
	if (s[*(int*)x] > s[*(int*)y])return 1;
	if (s[*(int*)x] < s[*(int*)y])return -1;
	if (t[*(int*)x] > t[*(int*)y])return 1;
	if (t[*(int*)x] < t[*(int*)y])return -1;
	return 0;
}
int main()
{
	int n, m, l;
	scanf("%d %d %d", &n, &m, &l);
	int i, j, k;
	for (i = 0; i < m; i++)
	{
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		a[i]--;
		b[i]--;
	}
	for (i = 0; i < m; i++)
	{
		a[i + m] = b[i];
		b[i + m] = a[i];
		c[i + m] = c[i];
	}
	int d[200005];
	for (i = 0; i < 2 * m; i++)
		d[i] = i;
	qsort(d, 2 * m, sizeof(int), asc1);
	int q;
	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d %d", &s[i], &t[i]);
		s[i]--;
		t[i]--;
	}
	int e[100005];
	for (i = 0; i < q; i++)
		e[i] = i;
	qsort(e, q, sizeof(int), asc2);
	int count[302], tank[302], visited[302];
	int ans[100005], f;
	int max, mid, min;
	for (k = 0; k < q; k++)
	{
		f = 0;
		if (k == 0)f = 1;
		else if (s[e[k]] != s[e[k - 1]])f = 1;
		if (f > 0)
		{
			for (i = 0; i < n; i++)
			{
				count[i] = -1;
				tank[i] = 0;
				visited[i] = 0;
			}
			count[s[e[k]]] = 0;
			tank[s[e[k]]] = l;
			for (;;)
			{
				f = -1;
				for (i = 0; i < n; i++)
				{
					if (count[i] >= 0 && visited[i] == 0)
					{
						if (f < 0)
							f = i;
						else if (count[i] < count[f])
							f = i;
						else if (count[i] == count[f] && tank[i] > tank[f])
							f = i;
					}
				}
				if (f < 0)break;
				visited[f] = 1;
				min = 0;
				max = 2 * m;
				while (max - min > 1)
				{
					mid = (max + min) / 2;
					if (a[d[mid]] < f)
						min = mid;
					else
						max = mid;
				}
				if (min >= 2 * m)continue;
				if (a[d[min]] < f)
					min++;
				if (min < 2 * m)
				{
					while (a[d[min]] == f)
					{
						if (visited[b[d[min]]] == 0)
						{
							if (tank[f] >= c[d[min]])
							{
								if (count[b[d[min]]] == -1 || count[b[d[min]]] > count[f])
								{
									count[b[d[min]]] = count[f];
									tank[b[d[min]]] = tank[f] - c[d[min]];
								}
								else if (count[b[d[min]]] == count[f] && tank[b[d[min]]] < tank[f] - c[d[min]])
								{
									count[b[d[min]]] = count[f];
									tank[b[d[min]]] = tank[f] - c[d[min]];
								}
							}
							else if (l >= c[d[min]])
							{
								if (count[b[d[min]]] == -1 || count[b[d[min]]] > count[f] + 1)
								{
									count[b[d[min]]] = count[f] + 1;
									tank[b[d[min]]] = l - c[d[min]];
								}
								else if (count[b[d[min]]] == count[f] + 1 && tank[b[d[min]]] < l - c[d[min]])
								{
									count[b[d[min]]] = count[f] + 1;
									tank[b[d[min]]] = l - c[d[min]];
								}
							}
						}
						min++;
						if (min == 2 * m)
							break;
					}
				}
			}
		}
		ans[e[k]] = count[t[e[k]]];
	}
	for (i = 0; i < q; i++)
		printf("%d\n", ans[i]);
}

Measured memory_bytes: 3356
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll ;

int main()
{
    int a,b; cin>>a>>b;
    int c,d; cin>>c>>d;
    
    cout << (double) a*b/2;
    cout << ' ';
    if (a==2*c&&b==2*d) cout << 1;
    else cout << 0;
}

Measured memory_bytes: 256
N = int(input())
As = [0]
As.extend(map(int, input().split()))
As.append(0)

sum = 0
pos = 0
for i in range(1, N + 2):
    sum += abs(pos - As[i])
    pos = As[i]

for i in range(1, N + 1):
    skip_pos = As[i]
    pre_pos = As[i - 1]
    post_pos = As[i + 1]

    if (pre_pos - skip_pos) * (post_pos - skip_pos) <= 0:
        print(sum)
    else:
        print(sum - abs(pre_pos - skip_pos) - abs(post_pos - skip_pos) + abs(pre_pos - post_pos))


Measured memory_bytes: 14048
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  n <- getInt
  as <- getIntVec n

  let t :: Int
      t = V.foldr1 xor as

  forM_ [0..(n-1)] $ \i -> do
    let a = as V.! i
    when (i > 0) $ putStr " "
    putStr $ show (t `xor` a)

  putStrLn ""


Measured memory_bytes: 12600
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll M;
ll d[200010], c[200010];
ll ans;

ll reduce( ll x )
{
  while( x > 9 )
  {
    ll sum = 0;

    while( x > 0 )
    {
      sum += x%10;
      x /= 10;

      if( x > 0 )
        ++ans;
    }

    x = sum;
  }

  return x;
}

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

  ll dS = 0, sS = 0;

  rep( i, M )
  {
    std::cin >> d[i] >> c[i];

    dS += c[i];
    sS += d[i]*c[i];
  }

  std::cout << (dS-1)+(sS-1)/9 << std::endl;

  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n; cin >> n;
  ll ans = 0;
  rep(i, n) {
    int a; cin >> a;
    ans += a-1;
  }  
  cout << ans << endl;
  system("pause");
}

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

int main() {
    long long N, A, B; cin >> N >> A >> B;
    if(N == 1 && A != B) cout << 0 << '\n';
    else if(A > B) cout << 0 << '\n';
    else cout << (N - 2) * (B - A) + 1 << '\n';
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        int ans = 100;
        for (char c = 'a'; c <= 'z'; c++) {
            int[] a = new int[s.length + 1];
            a[s.length] = 101;
            for (int i = s.length - 1; i >= 0; i--)
                a[i] = s[i] == c ? 0 : a[i + 1] + 1;
            for (int i = 0, max = 0; i < s.length; i++)
                ans = Math.min(ans, Math.max(max = Math.max(max, a[i]), s.length - i - 1));
        }
        System.out.println(ans);
    }
}

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

bool C(ll X,ll A,ll B){
	for(ll i=max(1LL,X/2-3);i<=min(X+1,X/2+3);i++){
		if(X<A&&i==X+1)break;
		if(i==A)continue;
		ll c=i-(A<=i);
		ll j=X+(B<=X)+1-c;
		if(B<=X&&j<=B)j--;
		if(i*j>=A*B)return 0;
	}
	return 1;
}
int main(){
	int q;cin>>q;
	rep(i,q){
		ll a,b;scanf("%lld%lld",&a,&b);
		if(a>b)swap(a,b);
		ll l=0,r=INT_MAX;
		while(r-l>1){
			ll t=(l+r)/2;
			if(C(t,a,b))l=t;
			else r=t;
		}
		printf("%lld\n",l);
	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var (
		N, L int
	)
	fmt.Scan(&N, &L)
	S := make([]string, N+10)
	for i := 0; i < N; i++ {
		fmt.Scan(&S[i])
	}

	sort.Strings(S)
	fmt.Println(strings.Join(S, ""))
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1'000'000'000'000'000'000ll + 7;

const double eps = 1e-8;

const i64 MAXN = 200'000 + 6;

i64 n;
i64 a[MAXN];
i64 ps[MAXN];
i64 pre[MAXN];
i64 post[MAXN];

void fillps() {
    ps[0] = a[0];
    ps[1] = a[1];

    for (i64 i = 2; i < n; i++) {
        ps[i] = a[i] + ps[i - 2];
    }
}

void fillpre(i64* pre) {
    pre[0] = max(a[0], a[1]);

    for (i64 i = 2; i < n; i += 2) {
        pre[i] = max(ps[i], pre[i - 2] + a[i + 1]);
    }
}


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    for (i64 i = 0; i < n; i++) {
        cin >> a[i];
    }

    fillps();
    fillpre(pre);

    reverse(a, a + n);
    fillps();
    fillpre(post);

    if (n % 2 == 0) {
        i64 R = pre[n - 2];
        cout << R << endl;
        return 0;
    }

    i64 R = pre[n - 1];
    for (i64 i = 0; i < n; i += 2) {
        i64 j = n - 1 - i;
        i64 t = (i ? pre[i - 2] : 0) + (j ? post[j - 2] : 0);
        R = max(R, t);
    }

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 9852
import sys

input = sys.stdin.readline

N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
F = tuple(map(int, input().split()))


def can_eat(t):
    F_time = sorted([t // f for f in F])
    training = 0
    for i in range(N):
        training += max(0, A[i] - F_time[i])
    return training <= K


# bisect
l, r = -1, 10 ** 12
while r - l > 1:
    m = (r + l) // 2
    if can_eat(m):
        r = m
    else:
        l = m
print(r)


Measured memory_bytes: 219536
#include<stdio.h>
int main(void)
{
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		x = a;
		a = b;
		b = x;
	}
	if(a>c){
		x = a;
		a = c;
		c = x;
	}
	if(b>c){
		x = b;
		b = c;
		c = x;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
#import<cstdio>
int main(){for(int n,a,c,r,t;c=r=scanf("%d",&n),n;printf("%d\n",r))for(char d[]="234657",s[9];n--;r+=*d%7)scanf("%s",s),*s%6-4?a=*s%5+*s%2*2+c&3,t=*d,*d=d[++a],d[a]=d[5],d[5]=d[a=++a%4+1],d[a]=t:c+=*s+3;}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

int rgb123(char rgb){
  switch(rgb){
  case 'R': return 0;
  case 'G': return 1;
  case 'B': return 2;
  }
  return -1;
}


void solve(long long N, std::string S) {
  vec<vec<ll>> cumsum(3, vec<ll>(N+1,0));
  // 色ごとの累積和
  rep(i,N){
    char c = S[i];
    int j = rgb123(c);
    //dump(i,c,j);
    rep(k,3) cumsum[k][i+1] = cumsum[k][i] + (k==j ? 1 : 0);
  }
  //dump(cumsum);
  ll ret = 0;
  rep(i,N){
    int ci = rgb123(S[i]);
    rep(j,i+1,N){
      if(S[i]==S[j]) continue;
      int cj = rgb123(S[j]);
      int col = 3 - ci - cj;  // 色を決定
      ret += cumsum[col][N] - cumsum[col][j+1];
      int k = 2*j-i;
      if(k>=0 && k<N && S[k]!=S[i] && S[k]!=S[j]) ret -= 1LL;
    }
  }
  cout << ret << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 3756
use bigint;
sub nCk{my($n,$k)=@_;
	$f[$n]/$f[$k]/$f[$n-$k]
}
($N,$A,$B)=glob<>;
@v=sort{$b<=>$a}glob<>;
$s+=$_ for@v[0..$A-1];
$l=$r=$A-1;
$l--while$l-1>=0&&$v[$l-1]==$v[$A-1];
$r++while$r+1<$N&&$v[$r+1]==$v[$A-1];
@f=1;
$f[$_]=$f[$_-1]*$_ for 1..$N;
$p+=nCk($r-$l+1,$_-$l)for$A..($l?$A:$B);
printf"%f\n%d",$s/$A,$p


Measured memory_bytes: 5248
def judge(lst_D, number):
    str_number = str(number)
    for d in lst_D:
        if d in str_number:
            return False
    return True


def main():
    N, K = map(int, input().split())
    lst_D = list(input().split())

    cost = N
    while True:
        if judge(lst_D, cost):
            print(cost)
            break
        cost += 1


if __name__ == "__main__":
    main()

Measured memory_bytes: 3316
import java.awt.geom.Line2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			String[] tmpArray = str.split(" ");
			float[] input = new float[8];
			for(int i = 0; i < input.length ; i++){
				input[i] = Float.parseFloat(tmpArray[i]);
			}
			
			Line2D.Float l1 = new Line2D.Float(input[0], input[1], input[2], input[3]);
			Line2D.Float l2 = new Line2D.Float(input[4], input[5], input[6], input[7]);
			
			if(ProductCalculator.isOrthogonal(l1, l2)){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}

}

class ProductCalculator {
	public static float crossProduct(Line2D.Float l1, Line2D.Float l2){
		Vector2D v1 = new Vector2D(l1);
		Vector2D v2 = new Vector2D(l2);
		
		return v1.x*v2.y - v1.y*v2.x;
	}
	
	public static float innerProduct(Line2D.Float l1, Line2D.Float l2){
		Vector2D v1 = new Vector2D(l1);
		Vector2D v2 = new Vector2D(l2);
		
		return v1.x*v2.x + v1.y*v2.y;
	}
	
	public static float innerProduct(Vector2D v1, Vector2D v2){
		
		return v1.x*v2.x + v1.y*v2.y;
	}
	
	public static boolean isOrthogonal(Line2D.Float l1, Line2D.Float l2){
		Vector2D v1 = new Vector2D(l1);
		Vector2D v2 = new Vector2D(l2);
		
//		if(v1.isZero() || v2.isZero()){
//			return false;
//		}
		
		if(innerProduct(v1, v2) == 0){
			return true;
		}
		else {
			return false;
		}
	}
}

class Vector2D {
	float x;
	float y;
	
	public Vector2D (Line2D.Float l){
		x = l.x2 - l.x1;
		y = l.y2 - l.y1;
	}
	
	public boolean isZero(){
		if(x == 0 && y == 0){
			return true;
		}
		else {
			return false;
		}
	}
	
}

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

class uf{
public:
  uf();
  uf(int _n){
    init(_n);
  }
  void init(int _n){
    n = _n;
    rank.resize(n);
    parent.resize(n);
    for (int i = 0; i < n; i++) {
      rank[i] = 0;
      parent[i] = i;
    }
  }
  int find(int x){
    if(x == parent[x])return x;
    else return parent[x] = find(parent[x]);
  }
  
  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y]){
      parent[x] = y;
    }else{
      parent[y] = x;
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y){
    return find(x) == find(y);
  }
private:
  int n;
  vector<int> rank, parent;
};


struct edge{
  int u, v, cost;
  bool operator<(const edge &e)const{
    return cost < e.cost;
  }
};

vector<edge> kruskal(vector<edge> &es, int v){
  sort(es.begin(), es.end());
  uf u(v);
  vector<edge> res;
  for (int i = 0; i < es.size(); i++) {
    edge &e = es[i];
    if(!u.same(e.u, e.v)){
      u.unite(e.u, e.v);
      res.push_back(es[i]);
    }
  }
  return res;
}

int main(){
  int n, m;
  while(std::cin >> n >> m, n){
    vector<edge> ve(m);
    for (int i = 0; i < m; i++) {
      std::cin >> ve[i].u >> ve[i].v >> ve[i].cost;
      ve[i].u--;ve[i].v--;
    }
    vector<edge> ans = kruskal(ve, n);
    std::cout << ans[(n - 1)/2].cost << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1348
import java.util.*;

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

      double n = sc.nextDouble();

      double check;

      if(n%2==0){
        check = n;
      }
      else{
        check = n+1;
      }

      double ans = (check/2)/n;


      System.out.println(ans);

    }
}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main(){
    int n;
	int size[] = {0, 60, 80, 100, 120, 140, 160};
	int weight[] = {0, 2, 5, 10, 15, 20, 25};
	int cost[] = {600, 800, 1000, 1200,	1400, 1600, 0};
	while(cin >> n, n) {
		int ret = 0;
		rep(i,n) {
			int x, w, a = 0;
			rep(j,3) {
				cin >> x;
				a += x;
			}
			cin >> w;
			for(int j = 6; j >= 0; --j) { 
				if(size[j] < a) {
					ret += cost[j];
					break;
				}
				if(weight[j] < w) {
					ret += cost[j];
					break;
				}
			}
		}
		cout << ret << endl;
	}
    return 0;
}

Measured memory_bytes: 1160
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;

    ll n, m, k, h;
    long double x, y;
    cin>>n;
    x=n;
    y=x/1.08;
    m=y;
    k=(long double)(m)*1.08;
    if(k==n)cout<<m<<endl;
    else{
        m++;
        k=(long double)(m)*1.08;
        if(k==n)cout<<m<<endl;
        else{
            cout<<":("<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3600
#include <iostream>
#include <math.h>

int main() {
    int n;
    std::cin >> n;
    if (n < 105) {
        std::cout << 0 << std::endl;
        return 0;
    }
    int num = 1;
    for (int k = 107; k <= n; k+=2) {
        int sk = sqrt((double) k);
        if (k == sk*sk) {
            continue;
        }
        int cnt = 1;
        for(int i = 3; i <= sk; i+=2) {
            if (k%i == 0) cnt++;
            if (cnt > 4) {
                break;
            }
        }
        if (cnt == 4) {
            num++;
        }
    }
    std::cout << num << std::endl;
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    a *= b;
    if(a % 2) cout << "Odd" << endl;
    else cout << "Even" << endl;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxx = 2e5 + 7;
int n, k;
int a[maxx], b[maxx];
set <int> sst;

int main() {
	bool flg = 0;
	cin >> n >> k;
	for(int i = 1; i <= k; i++) cin >> a[i] >> b[i];
	for(int i = 1; i <= k; i++) {
		if(a[i] == 1) sst.insert(b[i]);
	}
	for(int i = 1; i <= k; i++) {
		if(b[i] == n) {
			if(sst.find(a[i]) != sst.end()) {
				flg = 1; break;
			}
		}
	}
	if(flg) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
}

Measured memory_bytes: 6528
#include <iostream>

using namespace std;

char S[101];
int N;

int count(int n)
{
	int sum = 0;
	int A[26];
	for (int i = 0; i < 26; i++) {
		A[i] = 0;
	}
	for (int i = 0; i <= n; i++) {
		A[S[i] - 'a'] = 1;
	}
	for (int i = n + 1; i < N; i++) {
		sum += A[S[i] - 'a'];
		A[S[i] - 'a'] = 0;
	}
	return sum;
}

int main()
{
	cin >> N >> S;
	int m = 0;
	for (int i = 0; i < N - 1; i++) {
		int t = count(i);
		m = m < t ? t : m;
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef long long ll;
const int N=2e5+5;
const int p=1e9+7;
#define PI acos(-1)
ll qpow(ll a,ll n){ll res=1;while(n){if(n&1)res=res*a%p;a=a*a%p;n>>=1;}return res;}
struct node{
    ll v;
    int id;
}a[2005];
ll dp[2005][2005];
bool cmp(node x,node y)
{
    return x.v>y.v;
}
void work()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i].v);
        a[i].id=i;
    }
    sort(a+1,a+n+1,cmp);
    dp[2][n]=a[1].v*abs(1-a[1].id);
    dp[1][n-1]=a[1].v*abs(n-a[1].id);
    for(int i=2;i<=n;i++){
        for(int j=1;j<=i;j++){
            int l=j;
            int r=n-i+j;
            dp[l+1][r]=max(dp[l+1][r],dp[l][r]+a[i].v*abs(a[i].id-l));
            dp[l][r-1]=max(dp[l][r-1],dp[l][r]+a[i].v*abs(a[i].id-r));
        }
    }
    ll ans=0;
    for(int i=1;i<=n+1;i++){
        ans=max(ans,dp[i][i-1]);
    }
    printf("%lld\n",ans);
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T=1;
    //scanf("%d",&T);
    //cin>>T;
    while(T--){
        work();
    }
}

Measured memory_bytes: 26420
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    string s, t;
    cin >> s >> t;

    s += '$';
    t += '$';

    vector<vector<int>> dp(3010, vector<int>(3010, -1));
    vector<vector<pair<int, int>>> par(3100, vector<pair<int, int>>(3100, {-1,-1}));
    dp[0][0] = 0;
    rep(spos, 0, s.size()+1)
        rep(tpos, 0, t.size()+1)
        {
            if (s[spos] == t[tpos] and dp[spos+1][tpos+1] < dp[spos][tpos]+1)
            {
                dp[spos+1][tpos+1] = dp[spos][tpos]+1;
                par[spos+1][tpos+1] = make_pair(spos, tpos);
            }
            if (dp[spos+1][tpos] < dp[spos][tpos])
            {
                dp[spos+1][tpos] = dp[spos][tpos];
                par[spos+1][tpos] = make_pair(spos, tpos);
            }
            if (dp[spos][tpos+1] < dp[spos][tpos])
            {
                dp[spos][tpos+1] = dp[spos][tpos];
                par[spos][tpos+1] = make_pair(spos, tpos);
            }
        }

    // cout << dp[s.size()][t.size()] << endl;

    string res = "";
    pair<int, int> now = {s.size(), t.size()};
    while (now.first > 0 and now.second > 0)
    {
        pair<int, int> prev = par[now.first][now.second];
        // cout << now.first << ' ' << now.second << ' ' << prev.first << ' ' << prev.second << endl;

        if (now.first - prev.first + now.second - prev.second == 2)
            res += s[prev.first];

        swap(prev, now);
    }
    reverse(res.begin(), res.end());
    res.pop_back();

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 110976
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
double go(double x, int y) {
	if (y == 0)return 1.0;
	if (y == 1) {
		return x;
	}
	if (y & 1) {
		return 0.5 * go(x, y - 1);
	}
	else {
		double tmp = go(x, y / 2);
		return tmp * tmp;
	}
}
int main() { // E,F , virtual
	ios_base::sync_with_stdio(false); cin.tie(NULL); /*cout.tie(NULL);*/
	double n; double k; cin >> n >> k;
	double x = 1 / n;
	double ans = 0.0;
	for (double i = 1; i <= n; i += 1.0) {
		if (i >= k) {
			ans += x;
		}
		else {
			int y = ceil(log2(k / i));
			ans += x * go(0.5, y);
		}
	}
	printf("%.11f", ans);
}


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

P calc(P a,P b,P c,P d){
  P a2=(a-d)/(d-c);
  P b2=(b-d)/(d-c);
  return a+(b-a)*( imag(a2) / ( imag(a2)-imag(b2) ) );
}

int main(){
  int n;
  double ax,ay,bx,by,cx,cy,dx,dy;
  scanf("%d",&n);
  while(n--){
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy,&dx,&dy);
    P ans=calc(P(ax,ay),P(bx,by),P(cx,cy),P(dx,dy));
    printf("%.8f %.8f\n",ans.real(),ans.imag());
  }
  return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(int a){cout << a << el; return 0;}
int out(string s = "NO"){cout << s << el; return 0;}
template <class T>
inline int out(vector<T>&v,string c = " "){
    for(int i = 0; i < v.size(); ++i){
        if(i) cout << c; cout << v[i];
    } cout << el;return 0;
}
signed main(){
    int H,N; cin >> H >> N;
    int sum = 0;
    rep(i,N){
        int a; cin >> a;
        sum += a;
    }
    if(sum >= H)out("Yes");
    else out("No");
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

int main(){
  string S;
  cin >> S;
  vector<string> w(3);
  for(int i = 0;i < 3;i++){
    w.at(i) = S.at(i);
  }
  if(w.at(0) == "R"){
    if(w.at(1) == "R"){
      if(w.at(2) == "R"){
        cout << 3 << endl;
      }else{
        cout << 2 << endl;
      }
    }else{
      cout << 1 << endl;
    }
  }else{
    if(w.at(1) == "R"){
      if(w.at(2) == "R"){
        cout << 2 << endl;
      }else{
        cout << 1 << endl;
      }
    }else{
      if(w.at(2) == "R"){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
  }
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define max(l,r) ((l)>(r)?(l):(r))
#define min(l,r) ((l)<(r)?(l):(r))

int main(){
    ll a,b,c,d; scanf("%lld%lld%lld%lld", &a,&b,&c,&d);
    ll ans = max(max(a*c,a*d),max(b*c,b*d));

    printf("%lld\n", ans);
    //rep(i, n) scanf("%lld", ans+i);
    //if(ans){ puts("YES"); rep(i,n) printf("%lld ", a[i]);}else puts("NO");
}


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

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int Start = (H2 * 60 + M2) - (H1 * 60 + M1) - K;
  cout << Start << endl;
  
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  int N;
  cin >> N;
  vector<ll>A(N);
  for (int i = 0; i < N; i ++) cin >> A[i];
  sort(A.begin(), A.end());
  ll fi = 0;
  ll se = 0;
  for (int i = 0; i < N - 1; i ++) {
    if (A[i] == A[i + 1]) {
      i ++;
      se = fi;
      fi = A[i];
    }
  }
  cout << fi * se << endl;
}


Measured memory_bytes: 3972
def string(s, t):
	summ1 = 0
	summ2 = 0
	for i in range(len(s)):
		summ1 += ord(s[i])
	for j in range(len(t)):
		summ2 += ord(t[j])
	if summ1 > summ2:
		print(t, end="")
		print(s)
	else:
		print(t, end="")
		print(s)


s, t = map(str, input().split())
string(s, t)

Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

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

	vector<string> s(h);
	for (int i = 0; i < h; i++) cin >> s[i];

	vector<vector<int>> holi(h, vector<int>(w, 0));
	vector<vector<int>> vert(h, vector<int>(w, 0));

	int cnt = 0;

	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (j == w - 1 && s[i][j] == '.') cnt++;
			if (s[i][j] == '#' || j == w - 1){
				for (int k = j; k >= max(j - cnt, 0); k--){
					holi[i][k] = cnt;
				}
				cnt = 0;
			} else {
				cnt++;
			}
		}
		cnt = 0;
	}

	cnt = 0;

	for (int j = 0; j < w; j++){
		for (int i = 0; i < h; i++){
			if (i == h - 1 && s[i][j] == '.') cnt++;
			if (s[i][j] == '#' || i == h - 1){
				for (int k = i; k >= max(i - cnt, 0); k--){
					vert[k][j] = cnt;
				}
				cnt = 0;
			} else {
				cnt++;
			}
		}
		cnt = 0;
	}

	int ans = 0;
	for (int i = 0; i < h; i++){
		for (int j = 0; j < w; j++){
			if (s[i][j] == '#') continue;
			ans = max(ans, holi[i][j] + vert[i][j] - 1);
		}
	}

	cout << ans << endl;
} 


Measured memory_bytes: 35712
a,b,c=map(int,input().split())
t=max(a,b,c)
aa=t-a
bb=t-b
cc=t-c
if aa==0:
    ans=min(bb,cc)+(max(bb,cc)-min(bb,cc))//2
    if bb%2!=cc%2:
        print(ans+2)
    else:
        print(ans)
elif bb==0:
    ans=min(aa,cc)+((max(aa,cc)-min(aa,cc))//2)
    #print(ans)
    if aa%2!=cc%2:
        print(ans+2)
    else:
        print(ans)
else:
    ans=min(bb,aa)+(max(bb,aa)-min(bb,aa))//2
    if bb%2!=aa%2:
        print(ans+2)
    else:
        print(ans)

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

int main(){
	long double N,D,a2,b2,ab2,nuevaA,nuevaB, contador=0;
  long double distancia;
  cin>>N>>D; 

  vector<int> a(N,0);
  vector<int> b(N,0);

  for (int i =0; i<N; i++){
    cin>> a[i] >> b[i];
    if (a[i]<0){
      nuevaA=a[i]*(-1);
    }
    else{
      nuevaA=a[i];
    }

    if (b[i]<0){
      nuevaB=b[i]*(-1);
    }
    else{
      nuevaB=b[i];
    }
    a2=nuevaA*nuevaA;
    b2=nuevaB*nuevaB;
    ab2=a2+b2;
    distancia= sqrt(ab2);
     //cout<< distancia<< endl;
    if(distancia<=D){
      contador++;
    }
  }

    cout<< contador;
}

Measured memory_bytes: 4916
import java.util.*;
public class Main {
	
	static int cmp=0;
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),A[]=new int[n];
		
		for(int i=0;i<n;i++)A[i]=Integer.parseInt(in.next());
		
		margeSort(A,0,A.length-1);
		for(int i=0;i<n-1;i++)System.out.print(A[i]+" ");
		System.out.println(A[n-1]);
		System.out.println(cmp);
	}
	
	static void margeSort(int A[],int left,int right) {
		int middle=(left+right)/2;
		if(left<right) {
			margeSort(A,left,middle);
			margeSort(A,middle+1,right);
		}
		else return;
		
		int k=left,l=middle+1,cnt=0,B[]=new int[right-left+1];
		while(k<=middle && l<=right) {
			if(A[k]<=A[l])B[cnt++]=A[k++];
			else B[cnt++]=A[l++];
			cmp++;
		}
		
		while(k<=middle) { 
			B[cnt++]=A[k++];
			cmp++;
		}
		while(l<=right) {
			B[cnt++]=A[l++];
			cmp++;
		}
		
		for(int i=0;i<B.length;i++)A[left+i]=B[i];
	}

}



Measured memory_bytes: 143068
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <limits.h>
#include <assert.h>
#include <algorithm>

using namespace std;

struct equation {
  // x_a - x_b = c
  int a;
  int b;
  int c;
};

int n, m;

// table[a] = x_a
// table[b] = x_b
// x_a - x_b = c
bool apply(vector<int>* table, const equation& equ) {
  bool find_a = (*table)[equ.a] != INT_MIN;
  bool find_b = (*table)[equ.b] != INT_MIN;
  if(find_a && find_b) {
    int c_desired = (*table)[equ.a] - (*table)[equ.b];
    return equ.c == c_desired;
  } else if(find_a) {
    // x_b = x_a - c
    int x_b = (*table)[equ.a] - equ.c;
    (*table)[equ.b] = x_b;
    return true;
  } else if(find_b) {
    // x_a = x_b + c
    int x_a = (*table)[equ.b] + equ.c;
    (*table)[equ.a] = x_a;
    return true;
  } else {
    assert(false);
  }
}

bool solve(const vector<equation>& equs) {
  vector<set<int> > connection(n + 1);
  for(int i = 0; i < equs.size(); i++) {
    int a = equs[i].a;
    int b = equs[i].b;
    connection[a].insert(i);
    connection[b].insert(i);
  }
  vector<int> table(n + 1, INT_MIN);
  vector<bool> visited(n + 1, false);
  queue<int> q;
  for(int i = 0; i < equs.size(); i++) {
    const equation& e = equs[i];
    int a = e.a;
    if(visited[a])
      continue;
    table[a] = 0;
    q.push(a);
    while(!q.empty()) {
      int x = q.front();
      q.pop();
      if(visited[x])
        continue;
      visited[x] = true;
      for(auto &y : connection[x]) {
        const equation& e2 = equs[y];
        int other = e2.a == x ? e2.b : e2.a;
        if(visited[other])
          continue;
        if(!apply(&table, e2))
          return false;
        q.push(other);
      }
    }
  }
  return true;
}

void random_test(int n1, int m1) {
  n = n1;
  m = m1;
  vector<equation> equs(m);
  for(int i = 0; i < m; i++) {
    equs[i].a = (rand() % n1) + 1;
    equs[i].b = (rand() % n1) + 1;
    equs[i].c = 0;
  }
  solve(equs);
}

int main() {
  //srand (time(NULL));
  //random_test(100000, 200000);
  //return 0;
  cin >> n >> m;
  vector<equation> equs(m);
  int a, b, c;
  for(int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    equs[i].a = a;
    equs[i].b = b;
    equs[i].c = c;
  }
  if(solve(equs))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 27008
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int a[4], b[4], s, t; 
	
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
		cin >> b[0] >> b[1] >> b[2] >> b[3];
		s = t = 0;
		for(int i = 0; i < 4; i++){
			if(a[i] == b[i]){
				a[i] = b[i] = -1;
				s++;
			}
		}
		
		for(int i = 0; i < 4 && s != 4; i++){
			for(int j = 0; j < 4 && a[i] != -1; j++){
				if(a[i] == b[j]){
					t++;
				}
			}
		}
		
		cout << s << " " << t << endl;
	}
	
	return 0;
}

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

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

Measured memory_bytes: 256
#include<iostream>
#define mod 1000000007
using namespace std;
int n, m, i, j, sol, ii;
int d[3005][3005][2];
int main(){
    cin>> n >> m;
    for(i = 0; i <= n; i++){
        d[0][i][0] = 1;
    }
    for(i = 0; i < m; i++){
        for(j = 0; j <= n; j++){
            if( (j == 0 || j == n) && i != 0){
                d[i][j][1] = (d[i][j][1] + d[i][j][0]) % mod;
                d[i][j][0] = 0;
            }
            for(ii = 0; ii < 2; ii++){
                if(j != 0){
                    d[i + 1][j - 1][ii] = (d[i + 1][j - 1][ii] + d[i][j][ii]) % mod;
                    d[i + 1][j][ii] = (d[i + 1][j][ii] + d[i][j][ii]) % mod;
                }
                if(j != n){
                    d[i + 1][j][ii] = (d[i + 1][j][ii] + d[i][j][ii]) % mod;
                    d[i + 1][j + 1][ii] = (d[i + 1][j + 1][ii] + d[i][j][ii]) % mod;
                }
            }
        }
    }
    for(j = 0; j <= n; j++){
        if(j == 0 || j == n){
            d[m][j][1] = (d[m][j][0] + d[m][j][1]) % mod;
        }
        sol = (sol + d[m][j][1]) % mod;
    }
    cout<< sol;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 2123;
int main() {
    int fi = 0, se = 0;
    for (int i = 0, x; i<3; ++i) {
        scanf("%d", &x);
        if (x == 5) ++fi;
        if (x == 7) ++se;
    }
    puts(fi == 2 && se == 1? "YES" : "NO");
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int n,x; cin>>n>>x;
        vi m(n);
        int ans=n;
        rep(i,n)
        {
                cin>>m[i];
                x-=m[i];
        }
        sort(all(m));
        ans+=x/m[0];
        cout<<ans<<endl;
}


Measured memory_bytes: 256
@menus = []
while menu = gets do
    @menus << menu.to_i
end

min_amari_point = 0
min_amari_menu  = 9

@menus.each_with_index do |menu,i|
    if min_amari_menu >= menu%10 and menu%10 != 0
        min_amari_point = i
        min_amari_menu  = menu%10
    end
end

total = 0
last_menu = @menus[min_amari_point]
@menus.delete_at(min_amari_point)
@menus.each do |menu|
    if menu%10 != 0
        total = menu + total + (10 - (menu%10))
    elsif  menu%10 == 0
        total = menu + total
    end 
end

puts total + last_menu


Measured memory_bytes: 1788
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int calc(vector<int> v, int k){
  int n = v.size();
  int tmp = 1;
  REP(i,k)tmp *= v[i];
  int res = tmp;
  REP(i,n-k){
    tmp /= v[i];
    tmp *= v[i+k];
    res = max(res, tmp);
  }
  return res;
}
int main(){
  int n,k;
  while(cin>>n>>k,n||k){
    vector<int> v(n);
    REP(i,n)cin>>v[i];
    int S = calc(v, k);
    int ans = -INF;
    REP(i,n)REP(j,n){
      swap(v[i], v[j]);
      int S2 = calc(v,k);
      ans = max(ans, S2-S);
      swap(v[i], v[j]);
    }
    if(ans >= 0)cout<<ans<<endl;
    else cout<<"NOGAME"<<endl;
  }
  return 0;
}

Measured memory_bytes: 904
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var x int
	fmt.Fscan(r, &x)

	u1 := x / 500
	u2 := (x % 500) / 5

	fmt.Println(u1*1000 + u2*5)

}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	int n, a;
	while(cin >> n, n) {
		int ret[7] = {};
		rep(i,n) {
			cin >> a;
			ret[a/10 >= 7 ? 6 : a/10]++;	
		}
		rep(i,7) {
			cout << ret[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
N=int(input())
s=[int(input())for i in range(N)]
s.sort()
ans=0
if(sum(s))%10:
        ans=max(ans,sum(s))
else:
    for i in s:
        if(sum(s)-i)%10:
            ans=max(ans,sum(s)-i)
print(ans)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
    int n;
    cin >> n;
    std::vector<int> a(n);
    for(int i=0; i<n; i++){
    	cin >> a[i];
    }
    int ans =0;
    for(int i=0; i<n; i++){
    	for(int j=i+1; j<n; j++){
    		ans+=a[i]*a[j];
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612