akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define mod 998244353
typedef long long int ll;

const int N = 3001;

ll dp[N][N];

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

    ll a[n];

    for (ll i = 0; i < n; i++)
        cin >> a[i];

    for (ll i = n - 1; i >= 0; i--)
    {
        for (ll j = i; j < n; j++)
        {
            if (i == j)
                dp[i][j] = a[i];
            else
            {
                dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);
            }
        }
    }

    cout << dp[0][n - 1];
}


Measured memory_bytes: 70016
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;

vector<ll> l;
ll N, A, B, C;
ll ans = LLINF;

void dfs(int d, int sa, int sb, int sc, int adj_cost)
{
  if (d == N) {
    if (!sa || !sb || !sc) return;
    ll cost = adj_cost - 30;
    cost += abs(sa - A);
    cost += abs(sb - B);
    cost += abs(sc - C);
    ans = min(ans, cost);
    return ;
  }
  dfs(d + 1, sa, sb, sc, adj_cost);
  dfs(d + 1, sa + l[d], sb, sc, adj_cost + 10);
  dfs(d + 1, sa, sb + l[d], sc, adj_cost + 10);
  dfs(d + 1, sa, sb, sc + l[d], adj_cost + 10);
}

int main()
{
  cin >> N >> A >> B >> C;
  l = vector<ll>(N);
  REP(i, N) cin >> l[i];
  dfs(0, 0, 0, 0, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
signed main(){
    fast();
    int n;
    cin >> n;
    vector<int> a(n+1, 0);
    for(int i=1; i<=n; i++){
        for(int j=i; j<=n; j+=i){
            a[j]++;
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++){
        ans += i*(a[i]);
    }
    cout << ans << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 81276
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a,b,c
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    a=0
    b=0
    c=0
    do i=1,n
        if(mod(x(i),4)==0)then
            a=a+1
        elseif(mod(x(i),2)==0)then
            b=b+1
        else
            c=c+1
        end if
    end do
    if(c-a==1 .and. b==0)then
        write(*,*)'Yes'
    else if(c<=a)then
        write(*,*)'Yes'
    else
        write(*,*)'No'
    end if

   
    stop
end program sample
  



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

typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
vector<ll> fac, finv, inv;

ll combCalc(ll n, ll k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll comb(ll x, ll y){
    fac = finv = inv = vector<ll>(x+1);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<=x; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
    return combCalc(x, y);
}
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;
mint calc(ll N, ll K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}


int main(){
    ll x, y;    cin >> x >> y;
    ll ex=x/2, ox=x%2;
    mint ans=0;
    
    while(0<=ex){
 
        if(2*ex+ox==x && ex+2*ox==y){
            ans = calc(ex+ox, ox);
            break;
        }
 
        ex -= 1; ox += 2;
    }
    cout << ans << endl;
}

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

typedef struct
{
	int x;
	int y;
} POINT;

int main()
{
	POINT campus;
	POINT cat;
	
	int T;
	scanf("%d", &T);
	
	for (int c = 0; c < T; c++){
		int W, H;
		
		scanf("%d %d %d %d", &campus.x, &campus.y, &W, &H);
		
		int cnt = 0;
		
		int N;
		scanf("%d", &N);
		for (int i = 0; i < N; i++){
			scanf("%d %d", &cat.x, &cat.y);
			
			if (
			cat.x >= campus.x && cat.x <= campus.x + W &&
			cat.y >= campus.y && cat.y <= campus.y + H
			){
				cnt++;
			}
		}
		
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 1028
k = int(input())
from collections import deque
dic = {1:1}
queue = deque([[1,1]])
while queue:
    v,cost = queue.popleft()
    v_ = (v+1)%k
    if not v_ in dic or cost+1<dic[v_]:
        dic[v_] = cost+1
        queue.appendleft([v_,cost+1])
    v_ = v*10%k
    if not v_ in dic or cost<dic[v_]:
        dic[v_] = cost
        queue.append([v_,cost])

print(dic[0])

Measured memory_bytes: 20736
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a, b; cin >> a >> b;
  cout << (a-1) + (a<=b) << endl;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const ll INF = 1e18;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;
vii v;
vector<ll> xs;

int main() {
    ios_base::sync_with_stdio(false);
    ll a,b; cin >> a >> b;

    ll last;
    ll ans = 0;
    ll minX, minY;
    ll maxX, maxY;

    for(int i = 0; i < a; i++) { ll x; cin >> x; xs.pb(x); }

    ll sqr = 1;

    for(int i = 0; i < b; i++) {
        ll y; cin >> y;
        if(i) {
            ll possibles = (i*(b-i))%MOD;
            ll area = (((y-last)%MOD)*sqr)%MOD;
            ans = (ans+((area*possibles)%MOD))%MOD;
        } else minY = y;
        last = y;
        maxY = y;
    }

    ll ans1 = ans;
    ans = 0;

    sqr = 1;

    for(int i = 0; i < a; i++) {
        ll x = xs[i];
        if(i) {
            ll possibles = (i*(a-i))%MOD;
            ll area = (((x-last)%MOD)*sqr)%MOD;
            ans = (ans+((area*possibles)%MOD))%MOD;
        }
        last = x;
    }

    cout << (ans*ans1)%MOD << endl;
    return 0;
}



Measured memory_bytes: 1400
#include <iostream>
using namespace std;
#include <string>
 
int main() {
  string s;
  cin >> s;
  
  int n = s.size();
  
  int ans = 0;
  
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[(n-1) - i]) {
      ans++;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int s = Integer.parseInt(in.next());
		int hour = s / 60 / 60;
		int minuit = s / 60 % 60;
		int second = s - hour * 60 * 60 - minuit * 60;
		
		System.out.println(hour + ":" + minuit + ":" + second);
	}
}	


Measured memory_bytes: 26332
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int a,b;
	char c[10]; 
	cin>>a>>b;
	cin>>c;
	if(c[a]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	int tot=0;
	for(int i=1;i<strlen(c);i++){
		if(c[i]<'0' || c[i]>'9'){
			tot++;
		}
	}
	if(tot>1){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
} 

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

#define ll long long

int main(){
  ll n,k;
  cin>>n;
  vector<int> a;
  a.push_back(0);
  for(ll i=0;i<n;i++){
    cin>>k;
    a.push_back(k);
  }
  sort(a.begin(),a.end());
  ll c=0;
  for(ll i=1;i<n;i++){
    c += a[n - i/2];
  }
  cout<<c<<endl;
  return 0;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int a; cin >> a;
	string sh; cin >> sh;
	if (a < 3200)
	{
		cout << "red" << endl;
	}
	else
	{
		cout << sh << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
k = int(input())
lunlun = list(range(1, 10))

for i in range(k - 1):
    a = lunlun[i]
    b = a * 10 + a % 10
    if a % 10 != 0:
        lunlun.append(b - 1)
    lunlun.append(b)
    if a % 10 != 9:
        lunlun.append(b + 1)
print(lunlun[k - 1])

Measured memory_bytes: 15768
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 220;

int vec[N];

int main(){
	int n;
	scanf("%d",&n);

	for(int i = 0; i < 2*n; i++){
		scanf("%d",&vec[i]);
	}
	sort(vec,vec+2*n);
	int ans = 0;
	for(int i = 0; i < 2*n; i+=2){
		ans+=vec[i];
	}
	printf("%d\n", ans);

}

Measured memory_bytes: 128
n = int(input())

a = [i**5 for i in range(120)]
for i in range(120):
   for j in range(i+1,120):
       if a[j]-a[i] == n:
           print(j,i)
           break
       if a[j]+a[i] == n:
           print(j,-i)
           break
   else: continue
   break

Measured memory_bytes: 9140
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,k = inpl()
c = d = 0
if a <= k:
    c = 0
    tmp = k-a
    d = max(b-tmp,0)
else:
    c = a-k
    d = b
print(c,d)

Measured memory_bytes: 66028
#include <stdio.h>

int main(void){

  int total = 0;
  int co, i;

  for(i = 0; i < 5; i++){
    scanf("%d", &co);
    if(co < 40) co = 40;
    total += co;
  }

  printf("%d\n", total / 5);

  return 0;
}

Measured memory_bytes: 600
#include <iostream>

#define MAX 10000
#define NOT_FOUND -1

using namespace std;

//int linearSearch(int[], int, int[]);
int linearSearch(int[], int, int);

int main(){
  int i,n,q,key;
  int sum = 0;
  int S[MAX+1],T[MAX+1];
  
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> S[i];
  }
  cin >> q;
  for(i = 0; i < q; i++){
    //cin >> key;
    cin >> T[i];
    key = T[i];
    if(linearSearch(S,n,key) >= 0){
    //linearSearch(S,n,key);
      sum++;
    }
  }
  cout << sum << endl;
  
  return 0;
}

int linearSearch(int S[], int n, int key){
  int i = 0;
  S[n] = key;
  while(S[i] != key){
    i++;
    if(i == n){
      return NOT_FOUND;
      //return 0;
    }
  }
  return i;
  
}

Measured memory_bytes: 3128
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>

using namespace std;

int main()
{
    int s, l;
    cin >> s >> l;
    vector<int> num(10);
    for (int i = 0; i < l; i++)
    {
        int tem;
        cin >> tem;
        num[tem]++;

    }

    for (int i = s;; i++) {
        string strr = to_string(i);
        bool temp = true;

        for (int j = 0; j < strr.size(); j++) {
            if (num[strr[j] - '0'] == 1) {
                temp = false;
                break;
            }
        }
        if (temp == true) {
            cout << i;
            break;
        }
    }
    

    
    
}

Measured memory_bytes: 3648
N, M = [int(i) for i in input().split()]

A_B_list = []
for i in range(N):
    A_B = [int(i) for i in input().split()]
    A_B_list.append(A_B)

ans = 0
A_B_list = sorted(A_B_list)

for A_B in A_B_list:
    if M - A_B[-1] > 0:
        ans += A_B[0]*A_B[-1]
        M -= A_B[-1]
    else:
        ans += A_B[0]*M
        break

print(ans)

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

int main()
{
    int n; // 商品の種類の数
    int m; // 選択する数
    cin >> n >> m;

    int* a = new int[n]; // 商品の配列

    // 投票数の読み込み
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    int sum = 0; // 総投票数

    // 総投票数を計算する
    for (int i = 0; i < n; i++)
    {
        sum += a[i];
    }

    int count = 0; // 条件を満たさない数

    // 条件を満たさない商品の数を計算する
    for (int i = 0; i < n; i++)
    {
        if ((double)sum / (4 * m) > a[i])
        {
            count++;
        }
    }

    // 判定
    if (n - count >= m)
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min( int a, int b) { return a < b ? a : b;}

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);

	for ( int i = 1; i <= n; i++) {
		scanf("%s", Q[i].name); //Q.name??????????????????? name[100]??????????????????
		scanf("%d", &Q[i].t);
		}
head = 1; tail = n + 1;

while(head != tail ) {
	u = dequeue();
	c = min(q, u.t);
	u.t -= c;
	elaps += c;
	if( u.t > 0 ) enqueue(u);
	else {
		printf("%s %d\n", u.name, elaps);
	}
}

return 0;
}

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

ll solve( vector<ll> &weights, vector<ll> &values, vector<vector<ll> > &memo, ll W, int ind ) {
	if( ind >= values.size() )
		return 0;

	if( memo[ind][W] != -1 ) 
		return memo[ind][W];

	ll res = 0;
	if( weights[ind] <= W ) {
		res += max( values[ind] + solve(weights, values, memo, W-weights[ind], ind+1), 
					solve(weights, values, memo, W, ind+1 ));
	} else {
		res += solve(weights, values, memo, W, ind+1);
	}

	return memo[ind][W] = res;
}

int main() {

  	ll n, W;
  	cin>>n>>W;
  	vector<ll> weights(n, 0);
  	vector<ll> values(n, 0);
  	vector<vector<ll> > memo(n, vector<ll>(W+1, -1));
  	for( int i=0;i<n;i++ ) {
  		cin>>weights[i]>>values[i];
  	}

  	cout<<solve(weights, values, memo, W, 0);

  	return 0;
}

Measured memory_bytes: 79488
use strict;
use warnings;
use utf8;

# 2015/09/01

my $in;

$in = <STDIN>;
$in =~ s/\r\n$|\r$|\n$//;
# my ($n, $k) = split(/ /, $in);


# my $n = <STDIN>;
# $n =~ s/\r\n$|\r$|\n$//;

my $C = index($in, "C");
my $F= rindex($in, "F");


# &p($C);
# &p($F);

if ($C == -1 || $F == -1 ) {
	&p("No");
	exit;
}

if ($C < $F) {
	&p("Yes");
} else {
	&p("No");
}

exit;



sub p{
	my ($str) = @_;
	print $str, "\n";
	return 1;
}


sub pjoin{
	my @Str = @_;
	print join("_", @Str), "\n";
	return 1;
}


sub max{
	my @nums = @_;

	my $max_num;
	foreach my $num (@nums) {
		if (!defined $max_num) {
			$max_num = $num;
		} else {
			if ($num > $max_num) {
				$max_num = $num;
			}
		}
	}
	return $max_num;
}


sub min{
	my @nums = @_;

	my $min_num;
	foreach my $num (@nums) {
		if (!defined $min_num){
			$min_num = $num;
		} else {
			if ($num < $min_num){
				$min_num = $num;
			}
		}
	}
	return $min_num;
}



Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
/*int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int ans = a>2*b ? a-2*b : 0;
    printf("%d\n",ans);
    return 0;
}

int d[55];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++)
    {
        scanf("%d",&d[i]);
    }
    int ans = 0;
    for(int i = 1;i <= n;i ++)
    {
        for(int j = i+1;j <= n;j ++)
        {
            ans += d[i]*d[j];
        }
    }
    printf("%d\n",ans);
    return 0;
}
char s[100000+10];
int main()
{
    int len;
    scanf("%s",s);
    len = strlen(s);
    int cur = 0;
    int cnt = 0;
    while(cur != len-1)
    {
        if(s[cur] != s[cur+1])
            cnt ++;
        cur ++;
    }
    printf("%d\n",cnt);
    return 0;
}
*/
bool is_tri(int a,int b,int c)
{
    return c < a+b;
}

int L[2000+10];
int main()
{
    int n,cnt = 0;
    scanf("%d",&n);
    for(int i = 1;i <= n;i ++)
    {
        scanf("%d",&L[i]);
    }
    std::sort(L+1,L+n+1);
    for(register int i = 1;i <= n-2;i ++)
        for(register int j = i+1;j <= n-1;j ++)
            for(register int k = j+1;k <= n;k ++)
            {
                if(is_tri(L[i],L[j],L[k]))
                {
                    cnt ++;
                }
            }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

#define EPS 0.00001
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define PI (acos(-1.0))
#define POSARG(a) (arg((a)) > 0.0? arg((a)) : 2.0*PI + arg((a)))

using namespace std;

typedef complex<double> P;

int n;

int solve(vector<P> vc)
{	
	int res = 1;
	
	FOR(j, 0, n)
		FOR(i, j+1, n)
		{
			int tmpp = 2;
			int tmpn = 2;
			
			if(abs(vc[j]-vc[i]) > 2.0)
				continue;
			
			double cs = abs(vc[j]-vc[i])/2.0, sn = sqrt(1.0-cs*cs);	//線分IJと円の中心の距離
			P mid = (vc[j]+vc[i])/2.0;//線分IJの中点
			P nml = (vc[j]-vc[i])*P(0, 1);
			nml = nml/abs(nml);//線分IJの単位法線ベクトル
			P c1 = mid + nml*sn, c2 = mid - nml*sn;//円の中心2つ
						
			FOR(k, 0, n)
			{	
				if( k != j && k != i )
				{
					if( abs(vc[k]-c1) < 1.0+EPS)
					{
						tmpp++;
					}
					
					if( abs(vc[k]-c2) < 1.0+EPS)
					{
						tmpn++;
					}
				}
			}
			
			res = max(res, max(tmpp, tmpn));
		}
		
	return res;
}

int main()
{
	while(cin >> n, n)
	{
		vector<P> vc = vector<P>();
		
		FOR(i, 0, n)
		{
			double x, y;
			cin >> x >> y;
			vc.push_back(P(x,y));
		}

		cout << solve(vc) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,count=0;
cin>>n;
string s;
for(int i=0;i<n;i++)
cin>>s[i];
for(int i=0;i<n-2;i++)
{
if(s[i]=='A' && s[i+1] == 'B' && s[i+2]  == 'C')
count++;

}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

int mod;

int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);

		return half * half % mod;
	}
	else {

		return a * modpow(a, p - 1) % mod;
	}
}
long long modinv(long long a) {
	return modpow(a, mod - 2);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, X; cin >> N >> X >> mod;
	int ans = 0;
	VI A;
	vector<bool>F(mod, false);
	int tmp;

	while (1) {
		if (F[X]) {
			tmp = X;
			break;
		}
		else {
			F[X] = true;
		}
		A.push_back(X);
		X *= X;
		X %= mod;
	}
	REP(i, A.size()) {
		if (A[i] == tmp)break;
		ans += A[i];
		N--;
		if (N == 0)break;
	}
	VI B;
	bool f = 0;
	REP(i, A.size()) {
		if (A[i] == tmp)f = 1;
		if (f)B.push_back(A[i]);
	}
	int sum = 0;
	REP(i, B.size())sum += B[i];
	ans += sum * (N / B.size());
	N %= B.size();
	while (N--) ans += B[N];
	
	cout << ans << endl;




	return 0;
}



Measured memory_bytes: 4284
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		a=a%b;
		String ans="NO";
		for(int i=1;i<=b;i++) {
			if(a*i%b==c) {
				ans="YES";
			}
		}
		System.out.println(ans);
	}
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





Measured memory_bytes: 22484
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
      	int Y = sc.nextInt();
		
      	int ans = 0;
		for(int i = 0;i<=X;i++){
          for(int j = 0;j<=X;j++){
            if(i*2+j*4 == Y && i + j ==X){
              ans = 1;
              break;
            }
          }
        }
      	if (ans == 0)
            System.out.println("No");
        else
            System.out.println("Yes");
    }
}

Measured memory_bytes: 35764
s = input()

ans = 1
if not s[0] == "A":
    ans = 0

count = 0
for i in range(2, len(s)-1):
    if s[i] == "C":
        count += 1

if not count == 1:
    ans = 0

group = set([chr(i) for i in range(97, 97+26)])

num = 0
for i in range(len(s)):
    if s[i] in group:
        num += 1

if not num == len(s) - 2:
    ans = 0

if ans == 0:
    print("WA")
else:
    print("AC")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> X(N + 1), Y(N + 1), T(N + 1);
    T.at(0) = 0;
    X.at(0) = 0;
    Y.at(0) = 0;
    for(int i = 1; i <= N; i++){
        cin >> T.at(i) >> X.at(i) >> Y.at(i);
    }
    bool ans = true;
    for(int i = 0; i < N; i++){
        int dt = T.at(i + 1) - T.at(i);
        int d = abs(X.at(i + 1) - X.at(i)) + abs(Y.at(i + 1) - Y.at(i));
        if(dt < d){
            ans = false;
        }
        if(dt % 2 != d % 2){
            ans = false;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k; 
    vector<int> h(n);
    for(auto& x : h) {
        cin >> x;
    }
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for(int i=0; i<n; ++i) {
        for(int j=1; j<=k; ++j) {
            if(i+j < n)
                dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << "\n";
	return 0;
}


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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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;
}
//

using Graph = vector<vector<int>>;
Graph G;
int N, Q;
lint ans[202020];

int dfs(int v, int p, int cost) {
  ans[v] += cost;
  cost = ans[v];
  for (auto nv : G[v]) {
    if (nv == p) continue;
    dfs(nv, v, cost);
  }
}

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

  cin >> N >> Q;

  G.assign(N, vector<int>());
  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i, Q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  dfs(0, -1, 0);

  rep(i, N) { cout << ans[i] << (i != N - 1 ? " " : ""); }
  cout << endl;

  return 0;
}

Measured memory_bytes: 24320
#include <iostream>
using namespace std;
int main() {
  int divisors[1000010],m[1000010];
  memset(m,0,sizeof(m));
  memset(divisors,0,sizeof(divisors));
  int n,mx = -1; cin >> n;
  int arr[n],cnt=0; for (int i=0; i<n; i++) {
    cin >> arr[i]; m[arr[i]]++;
    mx = max(mx,arr[i]);
  }
  sort(arr,arr+n);
  for (int i=0; i<n; i++) {
    int start = (m[arr[i]]>1)?arr[i]*1:arr[i]*2;
    for (int j = start; j<=mx; j+=arr[i]) {
      divisors[j]++;
    }
  }
  for (int i=0; i<n; i++) if (!divisors[arr[i]]) cnt ++;
  cout << cnt << endl;
}





Measured memory_bytes: 11736
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

template<class T>struct costflowGraph{
	typedef pair<T, int> P;
	struct edge{
		int to, cap, rev;
		T cost;
		edge(int to, int cap, T cost, int rev) :
			to(to), cap(cap), cost(cost), rev(rev){
			}
	};
	
	int n, *prevv, *preve;
	T *dist;
	vector<vector<edge> > G;
	
	costflowGraph(int sz) : n(sz){
		G.resize(n);
		dist = new T[n];
		prevv = new int[n]; preve = new int[n];
	}
	~costflowGraph(){
		delete dist;
		delete prevv; delete preve;
	}
	
	void add(int s, int t, int cap, T cost){
		G[s].pb(edge(t, cap, cost, G[t].size()));
		G[t].pb(edge(s, 0, -cost, G[s].size() - 1));
	}
	T min_cost_flow(int s, int t, int f){
		T res = 0;
		while(f > 0){
			fill(dist, dist + n, inf);
			dist[s] = 0;
			while(1){
				bool update = 0;
				rep(v, n){
					if(dist[v] == inf) continue;
					rep(i, G[v].size()){
						edge &e = G[v][i];
						if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + EPS){
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i;
							update = 1;
						}
					}
				}
				if(!update) break;
			}
			if(dist[t] == inf) return -1;
		
			int d = f;
			for(int v = t; v != s; v = prevv[v]) d = min(d, G[prevv[v]][preve[v]].cap);
			f -= d;
			res += d * dist[t];
			for(int v = t; v != s; v = prevv[v]){
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}
};

int n, a[1000], b[1000];

int main(){
	vi v;
	cin >> n;
	rep(i, n){
		cin >> a[i] >> b[i];
		v.pb(a[i]);
		v.pb(b[i]);
	}
	sort(all(v));
	v.erase(unique(all(v)), v.end());
	
	int ans = 0;
	int s = n + v.size() + 1, t = s + 1;
	costflowGraph<int> g(t + 1);
	rep(i, n){
		g.add(s, i, 1, 0);
		int c = a[i] + b[i];
		g.add(i, lower_bound(all(v), a[i]) - v.begin() + n, 1, a[i]);
		g.add(i, lower_bound(all(v), b[i]) - v.begin() + n, 1, b[i]);
		g.add(i, n + v.size(), 1, c);
		ans += c;
	}
	rep(i, v.size()) g.add(n + i, t, 1, 0);
	g.add(n + v.size(), t, inf, 0);
	
	cout << ans - g.min_cost_flow(s, t, n) << endl;
	
	
	return 0;
}

Measured memory_bytes: 1532
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	private static final boolean TEST = false;

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		System.out.println(solve(a));
		in.close();
	}

	private static int solve(int[] a) {
		int ans = 0;
		int[] l = new int[a.length];
		int[] r = new int[a.length];

		l[0] = a[0];
		for (int i = 1; i < a.length - 1; i++)
			l[i] = gcm(l[i - 1], a[i]);

		r[r.length - 1] = a[a.length - 1];
		for (int i = r.length - 2; i > 0; i--)
			r[i] = gcm(r[i + 1], a[i]);

		ans = Math.max(r[1], l[l.length - 2]);
		for (int i = 1; i < a.length - 1; i++)
			ans = Math.max(ans, gcm(l[i - 1], r[i + 1]));

		return ans;
	}

	private static int gcm(int a, int b) {
		if (a == b)
			return a;
		if (b == 0)
			return a;
		if (a == 0)
			return b;
		if (a > b)
			return gcm(a % b, b);
		else
			return gcm(a, b % a);
	}
}

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

int num_data[12345];

int sosu(int num){
	if (num == 2) return true;
	int max = sqrt((float)num);
	if (num % 2 == 0) return false;
	for (int a = 3; a <= max; a += 2){
		if (num % a == 0) return false;
	}
	return true;
}

int main(){
	int numbers = 0;
	int now_num = 0;
	int ans = 0;
	scanf("%d", &numbers);
	for (int a = 0; a < numbers; a++){
		scanf("%d", &now_num);
		if (sosu(now_num) == true) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
 string s;
  cin>>s;
 string t;
  cin>>t;
  int sum=0;
  if(s[0]==t[2]){
    sum+=1;
  }
  if(s[1]==t[1]){
    sum+=1;
  }
  if(s[2]==t[0]){
	sum+=1;
  }
  if(sum==3){
cout<<"YES"<<endl;
  }
  if(sum<=2){
cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>

#define REP(i, n) for(i=0;i<n;i++)
#define MOD_NUM (1000000007)

int main(void)
{
	int a, b;
	int gcd;
	long long int lcm;

	while ((scanf("%d %d", &a, &b)) != EOF){
		int i;

		gcd = 1;
		for (i = 2; i <= a && i <= b; i++){
			if (a % i == 0 && b % i == 0){
				gcd *= i;

				a /= i;
				b /= i;
				i--;
			}
		}
		lcm = gcd * a * b;

		printf("%d %lld\n", gcd, lcm);
	}

	return 0;
}


Measured memory_bytes: 2572
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v;
    rep(i,n){
        int a, b;
        cin >> a >> b;
        v.emplace_back(b, a);
    }
    sort(v.begin(), v.end());
    int t = 0;
    rep(i,n){
        if(t + v[i].second > v[i].first){
            cout << "No" << endl;
            return 0;
        }
        t += v[i].second;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100001;


int main(){
  int N = in(), A[MAX], b;
  long ans = 0;
  rep(i, N+1) A[i] = in();

  rep(i, N){
    b = in();
    if(b >=  A[i] + A[i+1]){
      ans += A[i] + A[i+1];
      A[i+1] = 0;
    }else if(b > A[i]){
      ans += b;
      A[i+1] = A[i+1] - (b-A[i]);
    }else{
      ans += b;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

bool isPrime(int x);

int main(){
	int size=0,count=0;
	int array[10000]={};
	scanf("%d",&size);
	for(int i=0; i<size; i++){
		scanf("%d",&array[i]);
	}
	for(int i=0; i<size; i++){
		if(isPrime(array[i])==true){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

bool isPrime(int x){
	for(int i=2; i*i<=x; i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}



Measured memory_bytes: 2792
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b;
    cin>>a>>b;
    a%=500;
    if(a<=b){
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<iomanip>
#include<cmath>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point{
    double x, y;

    Point(double x = 0, double y = 0) : x(x), y(y) {}

    Point operator + (Point p){ return Point(x+p.x, y+p.y); }
    Point operator - (Point p){ return Point(x-p.x, y-p.y); }
    Point operator * (double a){ return Point(a*x, a*y); }
    Point operator / (double a){ return Point(x/a, y/a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x + y*y; }

    bool operator < (const Point &p) const{
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const{
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
};

typedef Point Vector;


struct Segment{
    Point p1, p2;
};

typedef Segment Line;


double norm(Point a){
    return a.x * a.x + a.y * a.y;
}

double abs(Point a){
    return sqrt(norm(a));
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}


bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
    return isOrthogonal(a1-a2, b1-b2);
}
bool isOrthogonal(Segment s1, Segment s2){
    return equals(dot(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b){
    return equals(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2){
    return isParallel(a1-a2, b1-b2);
}
bool isParallel(Segment s1, Segment s2){
    return equals(cross(s1.p2-s1.p1, s2.p2-s2.p1), 0.0);
}


Point project(Segment s, Point p){
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

Point reflect(Segment s, Point p){
    return p + (project(s, p) - p) * 2.0;
}



int main(){
    double a, b, c, d;
    cin >> a >> b >> c >> d;
    Segment s({Point(a,b), Point(c,d)});

    int q;
    cin >> q;

    while(q-- > 0){
        double x, y;
        cin >> x >> y;
        Point res = reflect(s, Point(x,y));
        cout << fixed << setprecision(12) << res.x << " " << res.y << endl;
    }

    return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
long long tree_diameter(vector<vector<pair<int, int>>> &E){
	int N = E.size();
	vector<long long> d1(N, INF);
	d1[0] = 0;
	queue<int> Q1;
	Q1.push(0);
	while (!Q1.empty()){
		int v = Q1.front();
		Q1.pop();
		for (auto P : E[v]){
			int c = P.first;
			int w = P.second;
			if (d1[w] == INF){
				d1[w] = d1[v] + c;
				Q1.push(w);
			}
		}
	}
	int s = max_element(d1.begin(), d1.end()) - d1.begin();
	vector<long long> d2(N, INF);
	d2[s] = 0;
	queue<int> Q2;
	Q2.push(s);
	while (!Q2.empty()){
		int v = Q2.front();
		Q2.pop();
		for (auto P : E[v]){
			int c = P.first;
			int w = P.second;
			if (d2[w] == INF){
				d2[w] = d2[v] + c;
				Q2.push(w);
			}
		}
	}
	return *max_element(d2.begin(), d2.end());
}
int main(){
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> E(N);
  for (int i = 0; i < N - 1; i++){
    int s, t, w;
    cin >> s >> t >> w;
    E[s].push_back(make_pair(w, t));
    E[t].push_back(make_pair(w, s));
  }
  cout << tree_diameter(E) << endl;
}


Measured memory_bytes: 10724
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map[T](converter)
  }

  implicit val idConverter: String => String = s => s
  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val (a,_b) = get[Long, String]

    val b:Long = _b.replace(".","")

    out.println(a * b / 100)
    out.flush()
  }
}

Measured memory_bytes: 54656
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N;
    cin >> N;
    int a[N];
    REP(i,N) cin >> a[i];

    int ans = 0;
    int search = 1;
    REP(i,N){
        if(a[i] != search) ans++;
        else search++;
    }
    if(ans == N) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet;

import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.LongStream;

public class Main {
    static final long MOD = 998244353;
    private final long n;

    final List<Long> POWER6;
    final List<Long> POWER9;

    public Main(final long n) {
        this.n = n;

        POWER6 = LongStream.range(1, 12).mapToObj(i -> (long) Math.pow(6, i)).collect(toList());
        POWER9 = LongStream.range(1, 12).mapToObj(i -> (long) Math.pow(9, i)).collect(toList());
    }

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final long n = scanner.nextLong();

        final long result = new Main(n).calculate();

        System.out.println(result);
    }

    long calculate() {
        return calcRecursive(0, n);
    }

    long calcRecursive(final long depth, final long currentN) {
        if (currentN < 9) {
            switch ((int) currentN) {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                    return depth + currentN;
                default:
                    return depth + 1 + currentN % 6;
            }

        }

        return Math.min(
                calcRecursive(depth + 1, currentN - POWER6.get(binarySearchInsertionPoint(POWER6, currentN))),
                calcRecursive(depth + 1, currentN - POWER9.get(binarySearchInsertionPoint(POWER9, currentN)))
        );
    }

    int binarySearchInsertionPoint(final List<Long> list, final long target) {
        final int i = Collections.binarySearch(list, target);
        if (i >= 0) {
            return i;
        }
        if (i == -1) {
            return -1;
        }
        return -i - 2;
    }

    long c(final long p, final long q) {
        if (q == 1) {
            return p;
        }

        if (q * 2 < p) {
            return c(p, p - q);
        }

        long result = 1;
        final Set<Long> hashSet = new TreeSet<>(LongStream.rangeClosed(2, q).boxed().collect(toSet()));
        for (long i = p; i > p - q; --i) {
            final long i_ = i;
            final Long div = hashSet.stream().filter(k -> i_ % k == 0).findFirst().orElse(1L);
            hashSet.remove(div);
            result *= (i / div);
            if (result > MOD) {
                result = result % MOD;
            }
        }
        return result;
    }
}


Measured memory_bytes: 29456