akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main() {
    int N;
    while (cin >> N){
        int M, C;
        cin >> M >> C;
        vector<int> b(M);
        rep(i, M) cin >> b[i];
        int ans = 0;
        rep(i, N) {
            int sum = C;
            rep(j, M) {
                int aj;
                cin >> aj;
                sum += aj * b[j];
            }
            if (sum > 0) ++ans;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int a[3][3],i,j,k;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&a[i][j]);
    }
  }

  int done[3][3];
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      done[i][j]=0;
    }
  }

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

  int b[n];
  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
    for(j=0;j<3;j++){
      for(k=0;k<3;k++){
        if(a[j][k]==b[i]){
          done[j][k]=1;
        }
      }
    }
  }

  if((done[0][0]==1&&done[0][1]==1&&done[0][2])||
      (done[1][0]==1&&done[1][1]==1&&done[1][2])||
      (done[2][0]==1&&done[2][1]==1&&done[2][2])||
      (done[0][0]==1&&done[1][0]==1&&done[2][0])||
      (done[0][1]==1&&done[1][1]==1&&done[2][1])||
      (done[0][2]==1&&done[1][2]==1&&done[2][2])||
      (done[0][0]==1&&done[1][1]==1&&done[2][2])||
      (done[0][2]==1&&done[1][1]==1&&done[2][0])){
        printf("Yes");
        return 0;
      }

  printf("No");

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
constexpr int f(int a){
	return a?a%10+f(a/10):0;
}
template<int N>struct ans{
	int a[37][N+1];
	constexpr ans():a(){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=36;j++)a[j][i]=a[j][i-1];
			a[f(i)][i]+=i;
		}
		for(int i=1;i<=N;i++){
			for(int j=1;j<=36;j++)a[j][i]+=a[j-1][i];
		}
	}
};
void print(int a){
	a?print(a/10),putchar(a%10+48):0;
}
constexpr auto s=ans<10000>();
int t,n,a,b,c;
main(){
	while((c=getchar())>47)n=n*10+c-48;
	while((c=getchar())>47)a=a*10+c-48;
	while((c=getchar())>47)b=b*10+c-48;
	t=s.a[b][n]-s.a[a-1][n];
	t?print(t),0:putchar(48);
}


Measured memory_bytes: 256
from itertools import combinations
import numpy as np

N, D = map(int, input().split())
X = [np.array(input().split(), dtype=np.int) for _ in range(N)]

ans = 0
for x, y in combinations(X, 2):
    d = ((x - y) ** 2).sum() ** 0.5
    if d.is_integer():
        ans += 1
print(ans)

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

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

int main(){
  int A[5];
  rep(i,5)
    cin>>A[i];
  int arr[]={0,1,2,3,4};
  int mn=100000000;
  do{
    int count=0;
    rep(i,4){
      count+=A[arr[i]];
      while(count%10!=0)
	count++;
    }
    count+=A[arr[4]];

    mn=min(mn,count);
  }while(next_permutation(arr,arr+5));


  cout<<mn<<endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main()
{
    int a, b, q;
    cin >> a >> b >> q;
    vector<int64_t> ss(a), ts(b);
    for (auto& s : ss)
    {
        cin >> s;
    }
    for (auto& t : ts)
    {
        cin >> t;
    }
    for (int i = 0; i < q; i++)
    {
        int64_t x;
        cin >> x;

        int64_t min_distance = numeric_limits<int64_t>::max();

        //  s -> t
        for (int j = 0; j < 2; j++)
        {
            auto s = lower_bound(ss.begin(), ss.end(), x);
            if (s == ss.end())
            {
                s--;
            }
            if (0 <= distance(ss.begin(), s) - j)
            {
                s -= j;
            }

            for (int k = 0; k < 2; k++)
            {
                auto t = lower_bound(ts.begin(), ts.end(), *s);
                if (t == ts.end())
                {
                    t--;
                }
                if (0 <= distance(ts.begin(), t) - k)
                {
                    t -= k;
                }
                min_distance = min(min_distance, abs(x - *s) + abs(*s - *t));
            }
        }
        // t -> s
        for (int j = 0; j < 2; j++)
        {
            auto t = lower_bound(ts.begin(), ts.end(), x);
            if (t == ts.end())
            {
                t--;
            }
            const int64_t dt = distance(ts.begin(), t);
            if (0 <= dt - j)
            {
                t -= j;
            }

            for (int k = 0; k < 2; k++)
            {
                auto s = lower_bound(ss.begin(), ss.end(), *t);
                if (s == ss.end())
                {
                    s--;
                }
                const int64_t ds = distance(ss.begin(), s);
                if (0 <= ds - k)
                {
                    s -= k;
                }
                min_distance = min(min_distance, abs(x - *t) + abs(*s - *t));
            }
        }
        cout << min_distance << endl;
    }
}

Measured memory_bytes: 2944
#include<iostream>
#include<cmath>
#include<string>
using namespace std;


class dice{
    public:
    int face[7];
    string name;
    
    dice(){
    
    }
    
    
    void north(){
        face[6] = face[0];
        face[0] = face[1];
        face[1] = face[5];
        face[5] = face[4];
        face[4] = face[6];
       
    }
    
    void south(){
        face[6] = face[0];
        face[0] = face[4];
        face[4] = face[5];
        face[5] = face[1];
        face[1] = face[6];
    }
    
    void east(){
        face[6] = face[0];
        face[0] = face[3];
        face[3] = face[5];
        face[5] = face[2];
        face[2] = face[6];
    }
    
     void west(){
        face[6] = face[0];
        face[0] = face[2];
        face[2] = face[5];
        face[5] = face[3];
        face[3] = face[6];
    }
    
    
};

int main(){
    dice d1;
    string direct;
    for(int i = 0; i < 6; i++){
        cin >> d1.face[i];
        //cout << d1.face[i] << endl;
    }
    cin >> direct;
    //cout << direct << endl;
    
    for(int i = 0; i < direct.size(); i++){
        if(direct[i] == '\n'){
            break;
        } else if(direct[i] == 'N'){
            d1.north();
            
        } else if(direct[i] == 'S'){
            d1.south();
            
           
        } else if(direct[i] == 'E'){
            d1.east();
            

        } else if(direct[i] == 'W'){
            d1.west();
           
        }
        
    }
    cout << d1.face[0] << endl;
    return 0;
    
}


Measured memory_bytes: 3224
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(3)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
#endif
	ll a,b;cin>>a>>b;
	cout<<(a*500LL>=b?"Yes":"No")<<endl;
	return 0;
}



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

#define ll long long int
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

    ll mod_pow(ll a,ll b,ll m)
    {
        ll res=1;
        while(b)
        {
            if(b&1)
                res=(res*a)%m;

            a=(a*a)%m;
            b>>=1;
        }
        return res;
    }

void solve()
{
    string s;
    cin>>s;
    if(s.back()=='s')
    {
        cout<<s<<"es";
    }
    else
        cout<<s<<"s";
    return;
}

int main()
{
    FAST;
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt","w",stdout);
    #endif
    ll q;
    q=1;
    // cin>>q;
    while(q--)
        solve();
    return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <string>
#include <vector>
using f32 = float;
using f64 = double;
using i8 = int_fast8_t;
using u8 = uint_fast8_t;
using i16 = int_fast16_t;
using u16 = uint_fast16_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
void resolver();
inline void fast_io() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
template <class T>
inline std::vector<T> read_vector() {
    size_t n;
    std::cin >> n;
    std::vector<T> ret(n);
    for (T &i : ret) {
        std::cin >> i;
    }
    return ret;
}
void t_case() {
    i64 t;
    std::cin >> t;
    while (t--) {
        resolver();
    }
}

int main(int argc, char *argv[]) {
    fast_io();
    // t_case();
    resolver();
}

void resolver() {
    using namespace std;

    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
ll N;
void func(ll cur, int use, ll& counter) {
  if (cur > N) return;
  if (use == 0b111) counter++; // 3桁のbitで，各桁が3,5,7をそれぞれ使っているかを表している
 
  // ７を追加したので，useの1桁目を1に更新 | はbit各桁のOR演算
  func(cur * 10 + 7, use | 0b001, counter); 
  func(cur * 10 + 5, use | 0b010, counter); // 5を追加
  func(cur * 10 + 3, use | 0b100, counter); // 3を追加
}
 
int main() {
  cin >> N;
  ll ans = 0;
  func(0,0,ans);
  cout << ans << endl;
}
  

Measured memory_bytes: 256
import math
def main():
	A, B = map(int,input().split())
	K = 50
	ans = [["#" if i < K else "." for _ in range(2*K)] for i in range(2*K)]
	num_w = 0
	num_b = 0
	for i in range(A-1):
		k = (i*2//(2*K))*2
		l = (i*2)%(2*K)
		ans[k][l] = "."

	for i in range(B-1):
		k = (i*2//(2*K))*2
		l = (i*2)%(2*K)
		ans[K+1+k][l] = "#"

	l1 = str(2*K) + " " + str(2*K)
	print(l1)
	for i in range(2*K):
		this_ans = ""
		for j in range(2*K):
			this_ans += ans[i][j]
		print(this_ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

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

int main(){
  int x; cin >> x;
  for(int i=x; ; i++) {
    if(isPrime(i)) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

// EOF


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define M 1000000007
#define REP(i,a,b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> p;


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

	string s;
	cin >> s;

	if(s[2] == s[3] and s[4] == s[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
# 2020/04/25
# AtCoder Beginner Contest 090 - B

# Input
a, b = input().split()

# Calc
va = int(a)
vb = int(b)
ans = 0

for i in range(va, vb+1):
    j = 0
    si = str(i)
    kbflg = True
    while j < len(si) // 2:
        if si[j] != si[len(si)-1-j]:
            kbflg = False
        j = j + 1

    if kbflg:
       ans = ans + 1
#       print(i)

# Output
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m), c(n);
    rep(i, m)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        c[a[i]]++;
        c[b[i]]++;
    }
    string  ans = "YES";
    rep(i, n)
    {
        if (c[i]%2!=0) {
            ans="NO";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5652
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for i in range(n):
    a = list(map(int, input().split()))
    z = 0
    for j in range(m):
        z += b[j] * a[j]
    if z + c > 0:
        count += 1
print(count)

Measured memory_bytes: 3188
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        
        String strnum = String.valueOf(a);
        //System.out.println("strnum : " + strnum); 
            if (strnum.contains("7"))
            {
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }      
        //System.out.println(a);
        
        //int b = sc.nextInt();

        //System.out.println(String.format("%d",(int)temp));
        
        /*
        if ((a * b) % 2 == 0)
            System.out.println("Even");
        else
            System.out.println("Odd");
        */
    }
}

Measured memory_bytes: 35736
#include<stdio.h>

int main(void)
{
	int t1, t2, t3, t4,total = 0;
	int x=0, y=0;

	scanf("%d", &t1); total += t1;
	scanf("%d", &t2); total += t2;
	scanf("%d", &t3); total += t3;
	scanf("%d", &t4); total += t4;

	x = total / 60;
	y = total - x * 60;
	printf("%d\n%d\n",x,y);

	return 0;
}

Measured memory_bytes: 596
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    int A,B,N;
    cin >> N >> A >> B;

    int ans = 0;

    for (int i = 1; i <= N; ++i) {
        string K = to_string(i);
        int C = K.size();
        int S = 0;
        for (int j = 0; j < C; ++j) {
            S += K[j] - '0';
        }
        if (S >= A && S <= B) { ans+=i; }
    }
    cout << ans << endl;
}

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

int main(){
    vector<int> x(6);
    for(int i=0;i<6;i++)cin >> x.at(i);
    for(int i=0;i<5;i++){
      for(int j=i+1;j<5;j++){
        if(x.at(j)-x.at(i)>x.at(5)){
          cout << ":(" << endl;
          return 0;
        }
      }
    }
    cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int s,sum=0;
	rep(i,0,10){
		cin>>s;
		sum+=s;
	}
	o(sum);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

int main() {
    int N;
    cin >> N;
    double ans = 0;
    vector<int> perm(N);
    for(int i = 0; i < N; i++) perm[i] = i;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }
    do {
        double a = 0;
        for(int i = 0; i < N - 1; i++) {
            a += hypot(x[perm[i]] - x[perm[i + 1]], y[perm[i]] - y[perm[i + 1]]);
        }
        ans += a;
    } while(next_permutation(WHOLE(perm)));
    for(double i = 1; i <= N; i++) {
        ans /= i;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;


#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;


void Main(){
   int A,B,C,D;
   cin >> A >> B >> C >> D;
  
  cout << max(A*B, C*D) << endl;
 return;
 }
  
int main(){
 cin.tie(nullptr);
 ios_base::sync_with_stdio(false);
 cout << fixed << setprecision(15);
 Main();
 return 0;
 }


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int n;
    cin >> n;

    string s;
    set<string> ans;
    rep(i,0,n){
        cin >> s;
        ans.insert(s);
    }

    cout << sz(ans) << "\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> v;
  for (int i=0;i<n;i++){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  double calc;
  int ans;
  calc=*v.begin();
  for (vector<int>::iterator e=v.begin();e!=v.end();e++){
    calc=(calc+double(*e))/2;
  }
  cout << fixed << setprecision(6) << calc << endl;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// パラメータ準備
		int N = int.Parse(Console.ReadLine()); 
		string[] input1 = Console.ReadLine().Split(' ');
		int T = int.Parse(input1[0]);	
		int A = int.Parse(input1[1]);	
		string[] input2 = Console.ReadLine().Split(' ');
		int[] H = new int[N];			
		
		for( var i = 0; i < N; i++ ){
			H[i] = int.Parse(input2[i]);
		}
		
		int index = 0;
		double MinDiffT = A - ( T - H[0] * 0.006 );
		for( var i = 1; i < N; i++ ){
			double t = T - H[i] * 0.006;
			double diff = A - t;
			if(  Math.Abs(diff) < Math.Abs(MinDiffT) ){
				MinDiffT = diff;
				index = i;
			}
		}
		Console.WriteLine(index + 1);
	}
}

Measured memory_bytes: 11164
# D - Recording

N, C = map(int, input().split())
max_time = 10**5
gantt = [[0] * (max_time + 1) for _ in range(C+1)]
stc = []

for _ in range(N):
    stc.append(list(map(int, input().split())))
    
stc = sorted(stc, key = lambda x: x[0])
stc = sorted(stc, key = lambda x: x[2])    

for idx in range(N):
    s, t, c = stc[idx][0], stc[idx][1], stc[idx][2]
    try:
        if stc[idx-1][2] == c and stc[idx-1][1] == s:
            gantt[c][s+1] += 1
        else:
            gantt[c][s] += 1
    except IndexError:
        gantt[c][s] += 1
    if t+1 <= max_time:
        gantt[c][t+1] -= 1

for c in range(C+1):
    for idx in range(1, max_time+1):
        gantt[c][idx] += gantt[c][idx-1]

ans = 0
for idx in range(1, max_time+1):
    tmp = 0
    for c in range(C+1):
        tmp += gantt[c][idx]
    ans = max(ans, tmp)
    
print(ans)

Measured memory_bytes: 54248
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[55][1000];

int main() {
  int N, A;
  cin>>N>>A;
  int x[N];
  for(int i=0;i<N;++i) {
    cin>>x[i];
    x[i] -= A;
  }
  DP[0][500]++;
  DP[0][500+x[0]]++;
  for(int i=0;i<N-1;++i) {
    for(int j=0;j<1000;++j) {
      if(DP[i][j]>0) {
        DP[i+1][j] += DP[i][j];
        DP[i+1][j+x[i+1]] += DP[i][j];
      }
    }
  }
  cout<<DP[N-1][500]-1<<endl;
}



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

int main() {
  int a,b;
  cin >> a;
  
  b = a/100;
  a = a - 100*b;
  
  if (0<b && b<=12){
    if (0<a && a<=12) cout << "AMBIGUOUS" << endl;
    else cout << "MMYY" << endl;
  }
  else {
    if (0<a && a<=12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
  }
  
  
}


Measured memory_bytes: 256
#ABC137-D
# -*- coding: utf-8 -*-
import sys
from collections import deque

N,M,P=map(int, sys.stdin.readline().split())

al=[ [] for i in range(N+1) ]		#隣接リスト
rev_al=[ [] for i in range(N+1) ]	#reverse隣接リスト
#辺のリスト
edge=[]

for i in range(M):
	a,b,c=map(int, sys.stdin.readline().split())
	al[a].append(b)
	rev_al[b].append(a)
	edge.append((a,b,c-P))


#ゴールからBFS
#訪問した頂点
Visit=[ 0 for _ in range(N+1) ]
q=deque()
q.append(N)
Visit[N]=1
while q:
	fro=q.popleft()
	for to in rev_al[fro]:
		if Visit[to]==0:
			Visit[to]=1
			q.append(to)
			
Visit1=Visit

#スタートからBFS
#訪問した頂点
Visit=[ 0 for _ in range(N+1) ]
q=deque()
q.append(1)
Visit[1]=1
while q:
	fro=q.popleft()
	for to in al[fro]:
		if Visit[to]==0:
			Visit[to]=1
			q.append(to)

Visit2=Visit

#1からもNからも到達可能な頂点の集合
V=[]
for v1,v2 in zip(Visit1,Visit2):
	V.append(v1&v2)

new_N=sum(V)

fedge=[]	#必要な要素だけをフィルターした辺集合
for a,b,c in edge:
	if V[a]==1 and V[b]==1:
		fedge.append((a,b,c))


D=[ float("-inf") ]*(N+1)	#頂点１からの距離 1-indexed
D[1]=0

#Bellman-Ford
for i in range(new_N):
	for a,b,c in fedge:
		if D[a]==float("-inf"): continue
		alt=D[a]+c
		if D[b]<alt:
			D[b]=alt
			if i==new_N-1:
				print -1
				quit()

print max(0,D[N])

Measured memory_bytes: 35688
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		String D = sc.next();
		if(D.equals("25")) System.out.println("Christmas");
		else if(D.equals("24")) System.out.println("Christmas Eve");
		else if(D.equals("23")) System.out.println("Christmas Eve Eve");
		else if(D.equals("22")) System.out.println("Christmas Eve Eve Eve");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21076
n, m, x = map(int, input().split())
costs = []
skills = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    cost = tmp[0]
    skill = tmp[1:]
    costs.append(cost)
    skills.append(skill)


min_cost = float("inf")
for i in range(1 << n):
    cur_skill = [0] * m
    cur_cost = 0
    for j in range(n):
        if (i >> j & 1) == 1:
            cur_cost += costs[j]
            for k in range(m):
                cur_skill[k] += skills[j][k]
    flag = True
    for j in range(m):
        if cur_skill[j] < x:
            flag = False
    if flag:
        min_cost = min(min_cost, cur_cost)

min_cost = -1 if min_cost == float("inf") else min_cost
print(min_cost)



Measured memory_bytes: 9240
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<deque>
#define F first
#define S second
#define INF (1<<28)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef pair<int,int> P;

class Pox
{
public:
  P p;
  int HP;
  int cost;
  Pox(){}
  Pox(P p,int HP,int cost):p(p),HP(HP),cost(cost){}
};

int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

int main()
{
  while(true)
    {
      int w,h;
      cin >> w >> h;
      if(w+h == 0)
	break;

      VVI G;
      int mincost[h][w][7];
      P st,ed;
      G.resize(h);
      for(int i=0;i<h;i++)
	{
	  G[i].resize(w);
	  for(int J=0;J<w;J++)
	    {
	      cin >> G[i][J];
	      if(G[i][J] == 2)
		{
		  st = P(J,i);
		  G[i][J] = 1;
		}
	      else if(G[i][J] == 3)
		{
		  ed = P(J,i);
		  G[i][J] = 1;
		}

	      for(int k=0;k<7;k++)
		mincost[i][J][k] = INF;
	    }
	}

      deque<Pox> deq;
      deq.push_back(Pox(st,6,0));
      mincost[st.S][st.F][6] = 0;
      int ans = INF;

      while(!deq.empty())
	{
	  Pox px = deq.front(); deq.pop_front();
	
	  if(px.p == ed)
	    {
	      mincost[ed.S][ed.F][px.HP] = min(mincost[ed.S][ed.F][px.HP],px.cost);
	      ans = min(ans,mincost[ed.S][ed.F][px.HP]);
	      continue;
	    }

	  if(px.HP <= 1)
	    continue;

	  if(abs(ed.S-px.p.S)+abs(ed.F-px.p.F) + px.cost >= ans)
	    continue;

	  int HP = px.HP;

	  for(int i=0;i<4;i++)
	    {
	      int nx,ny;
	      nx = px.p.F + dx[i];
	      ny = px.p.S + dy[i];
	      if(!(0 <= nx && nx < w && 0 <= ny && ny < h) || G[ny][nx] == 0)
		continue;
	      
	      if(mincost[ny][nx][HP-1] <= px.cost + 1)
		continue;

	      mincost[ny][nx][HP-1] = px.cost + 1;
	      deq.push_back(Pox(P(nx,ny),G[ny][nx] == 4?6:HP-1,px.cost+1));
	    }

	}

      ans == INF? cout << -1 << endl:cout << ans << endl;

    }
  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>

using namespace std;

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

void solve(){
	long long a, b;
	cin >> a >> b;
	if(b < a) swap(a, b);
	if(a <= 0 && 0 <= b){
		cout << "Zero" << endl;
		return;
	}
	if(a > 0){
		cout << "Positive" << endl;
		return;
	}
	if( ((b + 1) - a) % 2 == 1){
		cout << "Negative" << endl;
		return;
	}else{
		cout << "Positive" << endl;
		return;
	}
}

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

	solve();

	return 0;
}

Measured memory_bytes: 256
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

void solve(string s){
	int p=-1;
	int n=s.length();
	LL ans=0;
	for(int i=0; i<n; ++i) {
		if (s[i]=='W') {
			ans+=(i-p-1);
			++p;
		} else {
			;
		}
	}
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	string S;
	cin >> S;
	solve(S);
	return 0;
}



Measured memory_bytes: 772
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int A,B,X;
    cin >> A >> B >> X;
    if(A == X) cout << "YES" << endl;
    else if(A > X) cout << "NO" << endl;
    else if(A+B >= X) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

{
	//freopen("input.txt","r",stdin);
	
	//freopen("output.txt","w",stdout);
	int a[5];
	for(int i=0;i<5;i++)
	{
		cin>> a[i];
	}
	for(int i=0;i<5;i++)
	{
		if(a[i]==0)
		{
			cout<<i+1;
		}
	}

}	

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

int main(){
  vector<int> a(5);
  rep(i,5){
    cin >> a[i];
    if(a[i] != i){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	
	for (int i=1; i<=100; i++)
	{
		c = c-b;
		if ((a<0 && c>0) || (a==0 && c>0))
		{
			cout << "No" << endl;
			break;
		}	
		else if ((a>0 && c==0) || (a>0 && c<0))
		{
			cout << "Yes" << endl;
			break;
		}
		
		a = a-d;
		if ((a<0 && c>0) || (a==0 && c>0))
		{
			cout << "No" << endl;
			break;
		}	
		else if ((a>0 && c==0) || (a>0 && c<0))
		{
			cout << "Yes" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

std::string revString(std::string s) {
	string ret;
	auto it = s.rend();
	while (it != s.rbegin()) {
		ret.push_back(*it);
		++it;
	}
	return ret;
}

signed main() {
	long long n;
	cin >> n;
	vector<long long> v(n);
	rep(n)cin >> v[i];
	cout << *min_element(all(v)) << " " << *max_element(all(v)) << " " << accumulate(all(v), 0l) << endl;
}


Measured memory_bytes: 3168
import math
while 1:
    n=int(raw_input())
    if n==-1:
        break
    r,theta=1.0,0.0
    for i in range(n-1):
        r=(r**2+1.0)**0.5
        theta+=math.asin(1.0/r)
    print r*math.cos(theta)
    print r*math.sin(theta)
exit()

Measured memory_bytes: 6772
n, a, b, c, d = map(lambda x: int(x) - 1, input().split())
s = input()

if c < d:
    if "##" in s[a:d]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[a:c] or "..." not in s[b - 1:d + 2]:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3572
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int dice[24][6] = {{2 ,6 ,3 ,4 ,1 ,5},
        {6 ,5 ,3 ,4 ,2 ,1},
        {5 ,1 ,3 ,4 ,6 ,2},
        {4 ,1 ,5 ,2 ,6 ,3},
        {6 ,4 ,5 ,2 ,3 ,1},
        {3 ,6 ,5 ,2 ,1 ,4},
        {1 ,3 ,5 ,2 ,4 ,6},
        {5 ,3 ,6 ,1 ,4 ,2},
        {3 ,2 ,6 ,1 ,5 ,4},
        {2 ,4 ,6 ,1 ,3 ,5},
        {4 ,5 ,6 ,1 ,2 ,3},
        {1 ,5 ,4 ,3 ,2 ,6},
        {2 ,1 ,4 ,3 ,6 ,5},
        {6 ,2 ,4 ,3 ,5 ,1},
        {5 ,6 ,4 ,3 ,1 ,2},
        {4 ,6 ,2 ,5 ,1 ,3},
        {6 ,3 ,2 ,5 ,4 ,1},
        {3 ,1 ,2 ,5 ,6 ,4},
        {1 ,4 ,2 ,5 ,3 ,6},
        {5 ,4 ,1 ,6 ,3 ,2},
        {3 ,5 ,1 ,6 ,2 ,4},
        {2 ,3 ,1 ,6 ,4 ,5},
        {4 ,2 ,1 ,6 ,5 ,3},
        {1 ,2 ,3 ,4 ,5 ,6}};
    
    int num2[6],i,j,count=0,num[6]={0};
    
    for (i = 0; i < 6; i++) {
        scanf("%d",&num[i]);
    }
    
    for (i = 0 ; i < 6; i++) {
        scanf("%d",&num2[i]);
    }
    
    for (i = 0; i < 24; i++) {
        
        for (j = 0; j < 6; j++) {
            if(num[j] != num2[dice[i][j]-1]){
                break;
            }
            count++;
        }
        
        if (count == 6) {
            printf("Yes\n");
            return 0;
        }
        
        count = 0;
    }
    
    printf("No\n");
    
    
    return 0;
}




 





Measured memory_bytes: 2112
def main():
    n = int(input())
    a = sorted(list(map(int,input().split())))
    dp = [0 for i in range(a[-1]+1)]
    lbl = []
    for i in range(n):
        if dp[a[i]]==2:
            lbl.append(a[i])
            continue
        if dp[a[i]]==1:
            continue
        else:
            for j in range(1,a[-1]//a[i]+1):
                dp[a[i]*j] = 1
            dp[a[i]] = 2
    for i in range(len(lbl)):
        dp[lbl[i]] = 0
    ans = 0
    for i in range(len(dp)):
        if dp[i] == 2:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 32188
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

struct aa {
	int now;
	int dis;
	int gas;
};
class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.gas> r.gas;
	}
};
int main() {
	while (1) {
		int N, M, cap; cin >> N >> M >> cap;
		cap *= 10;
		if (!N)break;
		map<string, int>mp;
		int num = 2;
		vector<vector<pair<int, int>>>edges(6000);
		string sta, goa; cin >> sta >> goa; mp[sta] = 0; mp[goa] = 1;
		for (int i = 0; i < N; ++i) {
			string f, t; cin >> f >> t;
			int dis; cin >> dis;
			if (!mp.count(f)) {
				mp[f] = num++;
			}
			if (!mp.count(t)) {
				mp[t] = num++;
			}
			const int fid = mp[f];
			const int tid = mp[t];
			edges[fid].push_back(make_pair(tid, dis));
			edges[tid].push_back(make_pair(fid, dis));
		}
		edges.resize(mp.size());
		vector<bool>stat(edges.size(),false);
		for (int i = 0; i < M; ++i) {
			string st; cin >> st;
			if (mp.count(st)) {
				stat[mp[st]] = true;
			}
		}
		vector<vector<int>>mindiss(mp.size(), vector<int>(cap + 1, 99999999));
		priority_queue<aa, vector<aa>, Compare>que;
		que.push(aa{ 0,0,cap });
		mindiss[0][cap] = 0;

		while (!que.empty()) {
			aa atop(que.top());
			que.pop();
			const int pregas = atop.gas;
			const int nowdis = atop.dis;
			
			for (auto i : edges[atop.now]) {
				if (pregas >= i.second) {
					const int newid = i.first;
					const int newgas = stat[newid]?cap:atop.gas - i.second;
					const int newdis = nowdis + i.second;
					if (mindiss[newid][newgas]> newdis) {
						mindiss[newid][newgas] = newdis;
						que.push(aa{ newid, newdis ,newgas });
					}
				}
			}
		}
		int ans = 99999999;
		for (int i = 0; i < cap + 1; ++i) {
			ans = min(mindiss[1][i], ans);
		}
		if (ans == 99999999) {
			cout << -1 << endl;
		}
		else {
			cout << ans << endl;

		}
	}
	return 0;
}

Measured memory_bytes: 51080
#include<bits//stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int d=0;
    int b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
        d+=b[i];
        b[i]=d/(i+1);
    }
    sort(b,b+a);
    cout<<b[0]<<endl;
}
//私はすだぽんを愛している


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

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();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[min(rx,ry)] = max(rx,ry);
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }
};

int main(void){
    ll N; cin >> N;
    vector<ll> x(N), y(N); REP(i,N) cin >> x[i] >> y[i];

    ll ans = LL_INF;
    REP(i,N)REP(j,N){
        ll p = x[i]-x[j], q = y[i] - y[j];
        UnionFind uf(N);
        REP(s,N)REP(t,N){
            if(x[s]-x[t]==p && y[s]-y[t]==q) uf.unite(s,t);
        }
        set<int> s; REP(i,N) s.insert(uf.root(i));
        chmin(ans, (ll)s.size());
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int ban[10][5],add,result,did,h,i,j;

  while(cin>>h,h){
  result=0;
  for(i=0;i<h;i++) for(j=0;j<5;j++) cin>>ban[i][j];
  while(1){
  did=0;
  for(i=0;i<h;i++) for(j=0;j<3;j++){
      add=0;
      if(ban[i][j]!=0&&ban[i][j]==ban[i][j+1]&&ban[i][j]==ban[i][j+2]){
        if(j+3<5) if(ban[i][j]==ban[i][j+3]){
            add++;
            ban[i][j+3]=0;
            if(j+4<5) if(ban[i][j]==ban[i][j+4]){
                add++;
                ban[i][j+4]=0;
              }
          }
        add+=3;
        result+=ban[i][j]*add;
        ban[i][j]=ban[i][j+1]=ban[i][j+2]=0;
        did++;
      }
    }

  if(did!=0){
    for(int k=0;k<10;k++) for(i=h-1;i!=0;i--) for(j=0;j<5;j++) if(ban[i][j]==0){
          ban[i][j]=ban[i-1][j];
          ban[i-1][j]=0;
        }
  } else break;

  }

  cout<<result<<endl;

  }
  return 0;
 
}

Measured memory_bytes: 3076
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define hg first
#define p second.first
#define q second.second

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

vector<E> v;

bool comp(E a, E b){
	return (a.hg > b.hg);
}

int main(void){
	int n,i;
	ll cx,cy,x,y,h;
	bool flag = true;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> x >> y >> h;
		v.push_back(E(h,P(x,y)));
	}
	sort(v.begin(),v.end(),comp);
	for(cx=0ll; cx<=100ll; ++cx){
		for(cy=0ll; cy<=100ll; ++cy){
			flag = true;
			h = v[0].hg+abs(v[0].p-cx)+abs(v[0].q-cy);
			for(i=1; i<n; ++i){
				if(max(h-abs(v[i].p-cx)-abs(v[i].q-cy),0ll)!=v[i].hg){
					flag = false;
					break;
				}
			}
			if(flag){
				cout << cx << " " << cy << " " << h << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System;

namespace bla2
{
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split();
            int d = int.Parse(s[0]);
            int n = int.Parse(s[1]);
            if (n == 100)
                n = 101;
            string r = n.ToString();
            for (int i = 0; i < d; i++)
            {
                r += "00";
            }
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

import static java.lang.Integer.*;

public class Main {


    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[][] nums = new int[n][3];
        int[][] dp = new int[n][3];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                nums[i][j] = scan.nextInt();
                dp[i][j] = MIN_VALUE;
                if(i == 0) {
                    dp[i][j] = nums[i][j];
                }
            }
        }
        for (int i = 0; i < n - 1; i++) {
            dp[i + 1][0] = max(dp[i+1][0], max(dp[i][1] + nums[i+1][0], dp[i][2] + nums[i+1][0]));
            dp[i + 1][1] = max(dp[i+1][1], max(dp[i][0] + nums[i+1][1], dp[i][2] + nums[i+1][1]));
            dp[i + 1][2] = max(dp[i+1][2], max(dp[i][1] + nums[i+1][2], dp[i][0] + nums[i+1][2]));
        }

        System.out.println(max(dp[n-1][2], max(dp[n-1][0], dp[n-1][1])));


    }

}


Measured memory_bytes: 103448