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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n, a[101010];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	
	i64 ans = 0;
	if(n & 1){
		for(int i = 0; i < n; i++){
			ans += abs(a[i]-a[n/2]) * 2;
		}
		ans -= min(a[n/2+1]-a[n/2], a[n/2]-a[n/2-1]);
	}
	else{
		for(int i = 0; i < n; i++){
			ans += min(abs(a[i]-a[n/2]), abs(a[i]-a[n/2-1])) * 2;
		}
		ans += (a[n/2] - a[n/2-1]) * (n-1);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

//#define int long long
using ll = long long;
const int INF = 1<<29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

signed main() {
	int N;
	cin >> N;


	int abcount=0,beginb=0,enda=0,aandb=0;
	vector<string> a(N,"");
	rep(i,N){
		cin>>a[i];
		if(a[i][0]=='B')beginb++;
		if(a[i][a[i].size()-1]=='A')enda++;
		if(a[i][0]=='B' && a[i][a[i].size()-1]=='A')aandb++;
		rep(j,a[i].size()-1){
			if(a[i][j]=='A'&&a[i][j+1]=='B')abcount++;
		}
	}
	
	if(N>1){
		abcount+=min(beginb,enda);
		if(aandb>0 && beginb==enda && beginb==aandb)abcount--;
	}

	p(abcount);
	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

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

    int c[n], a[n][m];
    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    int ans = INF;

    rep(iii, 1<<n){
        int ii = iii;
        int num[n], aa[m];
        rep(j, n){
            num[j] = ii%2;
            ii >>=1;
        }
        rep(i, m) aa[i] = 0;

        int tmp = 0;
        rep(i, n) if(num[i]==1){
            tmp += c[i];
            rep(mi, m){
                aa[mi] += a[i][mi];
            }
        }

        bool ok = true;
        rep(mi, m){
            if(aa[mi] < x) ok = false;
        }
        if(ok) chmin(ans, tmp);
    }

    if(ans==INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  char s[ 11 ];
  int res = 0;
  int n;

  scanf ( "%s %d", s, &n );
  while ( n-- )
  {
    char d[ 21 ];

    scanf ( " %s", d );
    memcpy ( d + 10, d, 10 );
    d[ 20 ] = '\0';

    res += !!( strstr ( d, s ) != NULL );
  }

  printf ( "%d\n", res );

  return ( 0 );
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"
#define fi first
#define se second

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

struct point {
    ll x, y, q;
};

int main() {
    fast
    ll n;
    cin >> n;
    vector<point> pnt(n);
    REP(i, 0, n) {
        cin >> pnt[i].x >> pnt[i].y;
        if (pnt[i].x >= 0 && pnt[i].y >= 0)
            pnt[i].q = 1;
        else if (pnt[i].x < 0 && pnt[i].y >= 0)
            pnt[i].q = 2;
        else if (pnt[i].x < 0 && pnt[i].y < 0)
            pnt[i].q = 3;
        else
            pnt[i].q = 4;
    }
    sort(all(pnt), [](point a, point b) {
        if (a.q == b.q) {
            if (!a.x && !b.x)
                return a.y < b.y;
            ll g = __gcd(abs(a.x), abs(b.x)), u = LLONG_MAX, v = LLONG_MAX;
            if (a.q >= 3)
            	u = LLONG_MIN, v = LLONG_MIN;
            g = (a.x * b.x)/g;
            if (a.x)
                u = a.y * (g/a.x);
            if (b.x)
                v = b.y * (g/b.x);
            return u < v;
        }
        return a.q < b.q;
    });
    ll ans = 0, xs = 0, ys = 0, r;
    REP(i, 0, n) {
        xs = 0, ys = 0;
        r = i;
        REP(j, 0, n) {
            xs += pnt[r].x;
            ys += pnt[r].y;
            r = (r+1)%n;
            ans = max(ans, xs*xs + ys*ys);
        }
    }
    cout << fixed << setprecision(32) << sqrt((ld)ans) << endl;
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
*a,=map(int,input().split())
p=10**9+7
cnt=0
ans1=0
for i in range(n):
    x=[j for j in a[:i] if j>a[i]]
    ans1+=len(x)
a=sorted(a)
un=0
for i in range(n):
  y=[j for j in a[i+1:] if j>a[i]]
  un+=len(y)
k%=p
ans=ans1*k+(k*(k-1)//2)*un
print(ans%p)

Measured memory_bytes: 3188
def main():
    mod = 10 ** 9 + 7
    N = 2 * 10 ** 6 + 3

    fac = [0] * N
    finv = [0] * N
    inv = [0] * N

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, N):
        fac[i] = fac[i - 1] * i % mod
        # mod pにおける1, 2, ..., nの逆元
        # inv[i] = mod - inv[mod % i] * (mod // i) % mod
        # finv[i] = finv[i - 1] * inv[i] % mod
    # modにおける1!, 2!, ...の逆元
    finv[N // 2] = pow(fac[N // 2], mod - 2, mod)
    for i in reversed(range(N // 2)):
        finv[i] = (finv[i + 1] * (i + 1)) % mod

    def com(r, c):
        ans = fac[r + c] * finv[r] * finv[c]
        return ans % mod

    def g(r, c):
        return (com(r + 1, c + 1) - 1) % mod

    r1, c1, r2, c2 = map(int, input().split())

    answer = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1)
    answer %= mod
    print(answer)

if __name__ == "__main__":
    main()


Measured memory_bytes: 145140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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(){
    int n;
    cin>>n;
    cout<<180*(n-2)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;
#define MAX 55
char a[MAX][MAX];
int wi[8]={1,1,0,-1,-1,-1,0,1};
int wj[8]={0,-1,-1,-1,0,1,1,1};
int main()
{
	int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#'){
                printf("#");
            }else{
                int cnt=0;
                for(int m=0;m<8;m++){
                    //if(a[i][j]!='.')continue;
                    int dx=i+wi[m],dy=j+wj[m];
                    if(a[dx][dy]=='#'){
                        cnt++;
                    }
                }
                printf("%d",cnt);
            }
        }
        printf("\n");
    }
    return 0;
}

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

using namespace std;

int n, k, x, g, mx;

int main()
{
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    g = __gcd(g, x);
    mx = max(mx, x);
  }
  if (k % g == 0 && k <= mx)
    cout << "POSSIBLE";
  else
    cout << "IMPOSSIBLE";
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define NIL -1
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<char>>;
using P =pair<int,int>;

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

int main(){
    string s;
    cin>>s;
    int l=s.size();
    int ans=753;
    rep(i,l-2){
        int x=(s[i]-'0')*100;
        x+=(s[i+1]-'0')*10;
        x+=(s[i+2]-'0')*1;
        int a=abs(x-753);
        ans=min(ans,a);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int sum=0,m=0,b=n;
	while(n>0){
		m=n%10;
		n/=10;
		sum+=m;
	}
	//cout<<sum<<endl;
	//cout<<b%sum<<endl;
	if(sum==0) printf("No\n");
	else if(b%sum==0) printf("Yes\n");
	else if(b%sum!=0) printf("No\n");
	return 0;
}

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

int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u){
    cout << a-1 << " " << b << endl;
  }else{
    cout << a << " " << b-1 << endl;
  }
}

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

using namespace std;

struct Edge{int to, idx;};
struct State{
  int t, used, pos;
  bool operator < (const State& st) const{
    if(t != st.t) return t < st.t;
    return used < st.used;
  }
  
  bool operator > (const State& st) const {
    return st < *this;
  }
};

const int MAX = 1001;
const int INF = (1<<28);
State T[2][MAX];
int N;
vector<Edge> G[MAX], rG[MAX];

void solve(int from, int to){
  
  priority_queue<State, vector<State>, greater<State> > Q;
  Q.push((State){0, -1, from});
  T[0][from] = (State){0,-1,from};
  
  while(!Q.empty()){
    const State st = Q.top();
    Q.pop();

    const int used = (st.used==-1?0:1);
    if(T[used][st.pos] < st) continue;

    if(used==0){
      for(int i = 0; i < (int)rG[st.pos].size(); i++){
	State nex = st;
	nex.t++;
	nex.pos = rG[st.pos][i].to;
	nex.used = rG[st.pos][i].idx;
	if(nex < T[1][nex.pos]){
	  T[1][nex.pos] = nex;
	  Q.push(nex);
	}
      }
    }

    for(int i = 0; i < (int)G[st.pos].size(); i++){
      State nex = st;
      nex.t++;
      nex.pos = G[st.pos][i].to;
      if(nex < T[used][nex.pos]){
	T[used][nex.pos] = nex;
	Q.push(nex);
      }
    }      
  }
  
  State ans = min(T[0][to], T[1][to]);
  cout << ans.t << " " << ans.used+1 << endl;
}

void init(){
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < MAX; j++) T[i][j] = (State){INF, INF, -1};
  for(int i = 0; i < MAX; i++){
    G[i].clear();
    rG[i].clear();
  }
}

int main(){
  
  while(cin >> N && N){
    init();
    int s,t;
    cin >> s >> t;
    int M;
    cin >> M;
    for(int i = 0; i < M; i++){
      int a, b;
      cin >> a >> b;
      a--; b--;
      G[a].push_back((Edge){b,i});
      rG[b].push_back((Edge){a,i});
    }
    solve(s-1,t-1);
  }
  return 0;
}

Measured memory_bytes: 1928
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl(), k = inl();
        string s = ins();
        if (s[k - 1] == 'A') s[k - 1] = 'a';
        if (s[k - 1] == 'B') s[k - 1] = 'b';
        if (s[k - 1] == 'C') s[k - 1] = 'c';
        cout << s << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

#define N (100)

typedef long long lint;

int n;
int val[N + 1];
lint memo[N + 1][21];

using namespace std;

lint getWay(int i, int num)
{
	lint ret = 0;
	
	if (memo[i][num] >= 0) return (memo[i][num]);
	
	if (i == n - 1) return (num == val[n - 1]);
	
	if (num + val[i] <= 20){
		ret += getWay(i + 1, num + val[i]);
	}
	if (num - val[i] >= 0){
		ret += getWay(i + 1, num - val[i]);
	}
	
	return (memo[i][num] = ret);
}

int main()
{
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d", val + i);
	
	memset(memo, -1, sizeof(memo));
	
	printf("%lld\n", getWay(1, val[0]));
	
	return (0);
}

Measured memory_bytes: 1056
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

typedef pair<int, int> P;

// 0〜Xまでの累積xor
// 各桁における1の数が奇数ならその桁は1となる・・・が、コードが長くなってバグりやすい
// 累積xorは mod 4 周期で変動する
int acc_xor(int x) {
    int ret;
    switch (x % 4) {
    case 0:
        ret = x;
        break;
    case 1:
        ret = 1;
        break;
    case 2:
        ret = x + 1;
        break;
    case 3:
        ret = 0;
        break;
    }
    return ret;
}

signed main() {
    int a, b;
    cin >> a >> b;

    // a以上b以下の値の総和
    // [b以下の値の総和] - [a-1以下の値の総和]  <= 累積和みたいな感じ
    // sum(c) = [a以上b以下の値の総和] とする
    // sum(b) - sum(a-1) = sum(c)
    // sum(c) + sum(a-1) = sum(b)

    // xorでの総和
    // a = [a-1までの累積xor], b = [bまでの累積xor], c = [aからbまでの累積xor] とする
    // a ^ c = b
    // ↓
    // a ^ a ^ b = c ^ a
    // ↓
    // 0 ^ b = c ^ a
    // ↓
    // b = c ^ a
    int ans = acc_xor(b) ^ acc_xor(a - 1);
    cout << ans << endl;
}


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

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s,t;
    cin>>s>>t;
    int slen=s.length();
    int tlen=t.length();
	int c=0;
    if(slen==tlen){
    	for(int i=0;i<slen;i++){
    		if(s[i]!=t[i])
    			c++;
		}
	}
    cout<<c;
}

Measured memory_bytes: 3796
#include <cstdio>
#include <cstring>
#include <algorithm>

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

using namespace std;

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

const int P_MAX=1000000;
bool er[P_MAX+1];
void sieve(){
	rep(i,P_MAX+1) er[i]=(i>=2);
	for(int i=2;i*i<=P_MAX;i++) if(er[i]) for(int j=i*i;j<=P_MAX;j+=i) er[j]=false;
}

int main(){
	sieve();

	static int B[1200][1200];
	memset(B,-1,sizeof B);
	int x=600,y=600;
	B[y][x]=1;
	for(int cnt=2,d=1;cnt<=1000000;){
		rep(i,d) B[y+=dy[0]][x+=dx[0]]=cnt++;
		rep(i,d) B[y+=dy[1]][x+=dx[1]]=cnt++;
		d++;
		rep(i,d) B[y+=dy[2]][x+=dx[2]]=cnt++;
		rep(i,d) B[y+=dy[3]][x+=dx[3]]=cnt++;
		d++;
	}

	for(int n,m;scanf("%d%d",&n,&m),n;){
		static int dp[1200][1200];
		memset(dp,-1,sizeof dp);
		rep(i,1200) rep(j,1200) if(B[i][j]==m) dp[i][j]=(er[B[i][j]]?1:0);
		for(int i=1;i<1200;i++) for(int j=1;j<1199;j++) if(B[i][j]!=-1 && B[i][j]<=n) {
			if(dp[i-1][j-1]!=-1) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+(er[B[i][j]]?1:0));
			if(dp[i-1][j+0]!=-1) dp[i][j]=max(dp[i][j],dp[i-1][j+0]+(er[B[i][j]]?1:0));
			if(dp[i-1][j+1]!=-1) dp[i][j]=max(dp[i][j],dp[i-1][j+1]+(er[B[i][j]]?1:0));
		}

		int ans1=0,ans2=0;
		rep(i,1200) rep(j,1200) if(ans1<dp[i][j] || (ans1==dp[i][j] && ans2<B[i][j] && er[B[i][j]])) ans1=dp[i][j], ans2=B[i][j];
		printf("%d %d\n",ans1,ans2);
	}

	return 0;
}

Measured memory_bytes: 13260
program prob80
    implicit none
    character(3) :: s
    character(3) :: t(7)
    integer :: i
    read(*,*) s
    t = (/"SUN","MON","TUE","WED","THU","FRI","SAT"/)

    do i = 1, 7
        if(t(i) == s) then
            write(*,*) 8-i
        end if
    end do

    stop
contains
end program prob80

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

int main(void){
    // Your code here!
   int n, k, x, y;
   cin >> n >> k >> x >> y;
   if(n <= k){
       cout << n*x << endl;
   } else {
       cout << k * x + (n-k) *y << endl;
   }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  static boolean isInOut_Circle(int[] pos) {
    int[] sq_pos = {pos[0], pos[1]};
    int[] ci_pos = {pos[2], pos[3]};
    int rad = pos[4];

    if (((ci_pos[0] - rad) < 0) || ((ci_pos[0] + rad) > sq_pos[0])) {
      return false;
    } else if (((ci_pos[1] - rad) < 0) || ((ci_pos[1] + rad) > sq_pos[1])) {
      return false;
    } else {
      return true;
    }
  }

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int inNum[] = new int[5];
    for (int i = 0;i < inNum.length ;i++ ) {
      inNum[i] = stdIn.nextInt();
    }

    if (isInOut_Circle(inNum)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26364
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MOD 1000000007

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

  vector<ll> dp = {0, 1};
  dp.resize(2, 0);
  for (auto i = 0; i < n.size(); i++)
  {
    ll d = n[i] - '0';
    auto a = min(dp[0] + d, dp[1] + 10 - d);
    auto b = min(dp[0] + d + 1, dp[1] + 9 - d);
    dp[0] = a;
    dp[1] = b;
  }

  cout << dp[0] << endl;

  return 0;
}


Measured memory_bytes: 1412
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;


int main()
{
	int A[5], R[5];
	int N = 5;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		R[i] = i;
	}
	int ans = mod;
	do {
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += (10 - (sum % 10)) % 10;
			sum += A[R[i]];
		}
		ans = min(ans, sum);
	}while (next_permutation(R, R + N));
	cout << ans << endl;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(;i<100;i++){
            String str = sc.nextLine();
            String[] str2 = str.split(" ");
            int a = Integer.parseInt(str2[0]);
            String x = str2[1];
            int b = Integer.parseInt(str2[2]);
            
           
            if(x.equals("+")){
                System.out.printf("%d\n",a+b);
            }
            if(x.equals("-")){
                System.out.printf("%d\n",a-b);
            }
            if(x.equals("*")){
                System.out.printf("%d\n",a*b);
            }
            if(x.equals("/")){
                System.out.printf("%d\n",a/b);
            }
            if(x.equals("?")){
                break;
            }
        }
        
    }
}


Measured memory_bytes: 26484
#include <stdio.h>


int main(void) {
    int N, Y;
    int i, j;

    scanf("%d %d", &N, &Y);

    Y /= 1000;

    for ( i = 0; i <= N; i++ ) {
        for ( j = 0; j <= N - i;j++ ) {
            if ( (i * 10 + j * 5 + (N - i - j)) == Y ) {
                printf("%d %d %d\n", i, j, (N - i - j));
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
const ll N = 2e5+10;
const ll M=2005;

vector<ll>graph[N];
ll arr[N];


int main(){
    
        #ifdef debug
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout); 
            
        #endif
            ios_base::sync_with_stdio(0);
            cin.tie(0);cout.tie(0);
            
            ll T=1;
            //cin>>T;
            while(T--){
                ll h=0,a=0;
                ll ans=0;
                cin>>h>>a;
                while(h>0){
                    ans++;
                    h-=a;
                }
                cout<<ans<<"\n";
            }
                
            
            
        return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    cin>>n;
    ll a[n+1];
    ll place[n+1];
    rep(i,n){
        cin>>a[i];
        place[a[i]]=i+1;
    }
    set<ll> used;
    used.insert(0);
    used.insert(n+1);
    ll res = 0;
    rep(i,n+1){
        if(i==0){continue;}
        auto it = used.lower_bound(place[i]);
        auto _prev = prev(it);
        ll from = place[i] - *_prev;
        ll to = *it - place[i];
        DEBUG{
            printf("%d from : %lld, to : %lld\n",i,from,to);
        }
        res += from * to * i;
        used.insert(place[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

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

int main(){
    long long n;
    long long ans;
    cin >> n;
    for(int i=0;i<n;i++){
        long long x;
        cin >> x;
        if(i==0){
            ans = x;
        }else{
            ans /= gcd(ans,x);
            ans *=x;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int int_sort( const void * a , const void * b );

int main(void){

  int N,x;
  scanf("%d %d\n", &N, &x);

  int *A;
  A = (int*)malloc(N*sizeof(int));
  for(int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }

  qsort(A,N,sizeof(int),int_sort);

  int ans=0,sum=0;

  for(int i=0; i<N; i++){
    sum += A[i];
    if(sum > x){
      printf("%d\n", i);
      return 0;
    }
  }

  if(sum == x){
    printf("%d\n", N);
  }else{
    printf("%d\n", N-1);
  }
  return 0;
}


int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
    if( *( int * )a == *( int * )b ) {
      return 0;
    }
  return 1;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
int upcmpll(const void *a,const void *b){
    return (*(ll*)a == *(ll*)b?0:(*(ll*)a > *(ll*)b?1:-1));
}
void sort_u(ll *a,int n){qsort(a,n,sizeof(ll),upcmpll);}

int main(){
    int n,c,k;scanf("%d%d%d",&n,&c,&k);
    ll t[101010];
    rep(i,n) scanf("%lld",t+i);
    sort_u(t,n);
    ll ans=1,tmpt=t[0]+k,tmpp=1;
    rep(i,n-1){
        if(t[i+1] <= tmpt && tmpp < c){
            tmpp++;
        }else{
            ans++;
            tmpt = t[i+1]+k;
            tmpp = 1;
        }
    }

    printf("%lld",ans);
}

Measured memory_bytes: 3084
n, k = input().split()
n, k = int(n), int(k)
from math import log2 as lg
from math import ceil

corr = 0

for i in range(1, n+1):
    if i >= k:
        corr += 1/n
        continue
    need = 2 ** (-1 * ceil(lg(k / i)))
    corr += ((1/n) * need)

print(corr)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
	using namespace std;
	typedef long long ll;
	#define endl "\n"
	#define space " "
	#define ll long long int
	#define vl vector<ll>
	#define vvl vector < vll >
	#define pii pair<int,int>
	#define pll pair<ll,ll>
	#define vpl vector < pll >
	#define mod 1000000007
	#define pi 3.1415926535897932384626433
	#define inf 1000000000000000001;
	#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define pb push_back
	#define f first
	#define s second
	
	void solve()
	{
		ll n; cin>>n;
		if(n%1000!=0){
			cout<<1000-(n%1000);
		}
		else cout<<0;
	}

	signed main()
	{

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

	ll T=1;
	// cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
	}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>> n;
    if(n==1) cout<< "Hello World" <<endl;
    else{
        int a,b;
        cin>> a >> b;
        cout<< a+b <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void max(int i){
  int l,r,largest,temp;
  l=2*i;
  r=2*i+1;

  if(l <= H && A[l] > A[i]){
    largest=l;
  }
  else{
    largest = i;
  }
  if(r <= H && A[r] > A[largest]){
    largest=r;
  }
  if(largest != i){
    temp=A[i];
    A[i]=A[largest];
    A[largest]=temp;
    max(largest);
  }
  
}
 


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

  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2;i>=1;i--){
    max(i);
  }
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 3720
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int X,Y,Z;
	scan(X>>Y>>Z);
	swap(X,Y);
	swap(X,Z);
	printf("%d %d %d\n",X,Y,Z);
	return 0;
}


Measured memory_bytes: 3656
n = int(input())
g = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
s = [0]
d = [-1] * n
d[0] = 0
while s:
    p = s.pop()
    for node in g[p]:
        if d[node] == -1:
            s.append(node)
            d[node] = d[p] + 1
idx = 0
for i in range(n):
    if d[i] > d[idx]:
        idx = i
s = [idx]
d = [-1] * n
d[idx] = 0
while s:
    p = s.pop()
    for node in g[p]:
        if d[node] == -1:
            s.append(node)
            d[node] = d[p] + 1
m = 0
for i in range(n):
    if d[i] > m:
        m = d[i]
if m % 3 == 1:
    print('Second')
else:
    print('First')


Measured memory_bytes: 48816
#include <iostream>
#include <vector>
#include <algorithm>

using ll = long long;

ll f(int N, const std::vector<int> &A)
{
    std::vector<ll> nc_min(N+1), nc_max(N+1);
    nc_min[N] = nc_max[N] = A[N];

    for (int d = N - 1; d >= 0; --d)
    {
        nc_min[d] = std::max<ll>(1, nc_min[d+1] / 2) + A[d];
        nc_max[d] = nc_max[d+1] + A[d];
    }

    ll node_count = 1, sum = 0;
    for (int d = 0; d <= N; ++d)
    {
        if (d > 0) node_count *= 2;
        
        if (node_count < nc_min[d]) return -1;

        node_count = std::min(node_count, nc_max[d]);
        sum += node_count;
        node_count -= A[d];
    }
    return sum;
}

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> A(N+1);
    for (int i = 0; i <= N; i++)
        std::cin >> A[i];

    ll ans = f(N, A);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 5008
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    items = set()
    for _ in range(N):
        items.add(input().strip())
    return len(items)


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 31168
N = int(input())
A = list(map(int, input().split()))

if __name__ == '__main__':
    print(" ".join(map(str, A)))
    for i in range(1, N):
        target_num = A[i]
        for j in range(i):
            if A[j] > target_num:
                tmp_idx = i
                while j < tmp_idx:
                    A[tmp_idx] = A[tmp_idx-1]
                    tmp_idx -= 1
                A[j] = target_num
                break
        print(" ".join(map(str, A)))


Measured memory_bytes: 5600
from sys import stdin

input = stdin.readline
import math

def solve():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    cnt = 1
    cur = 7
    while True:
        r = cur % k
        if r == 0:
            print(cnt)
            break
        cur = r * 10 + 7
        cnt += 1

if __name__ == '__main__':
    solve()


Measured memory_bytes: 63024
#include <iostream>
#include <string>

using namespace std;

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

    int cnt0 = 0, cnt1 = 0;
    for (int i = 0; i < static_cast<int>(s.size()); i++) {
        if ((i % 2 == 0 && s[i] == '1') || (i % 2 == 1 && s[i] == '0')) {
            cnt0++;
        } else if ((i % 2 == 0 && s[i] == '0') || (i % 2 == 1 && s[i] == '1')) {
            cnt1++;
        }
    }

    cout << (cnt0 < cnt1 ? cnt0 : cnt1) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a,long long int b){
  if(a<b){
    swap(a,b);
  }
  long long int r;
  while(b>0){
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}
int main(){
  int n;
  cin >> n;
  long long int t[200];
  for(int i=0; i<n; i++){
    cin >> t[i];
  }
  long long int ans=1;
  for(int i=0; i<n; i++){
    ans = ans/gcd(ans,t[i])*t[i];
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int n[3]={1,0,0};
	char a,b,c;
	while(cin>>a>>c>>b)
	{
		int tmp=n[a-'A'];
		n[a-'A']=n[b-'A'];
		n[b-'A']=tmp;
	}
	for(int i=0;i<3;i++)
	{
		if(n[i]==1)
		{
			cout<<(char)(i+'A')<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1132
require 'prime'

def common_divisors(n)
  return [1] if n == 1

  tmp = n.prime_division.map do |e|
    (0..e[1]).to_a.map do |i|
      e[0]**i
    end
  end

  tmp.reduce{|p,q| p.product(q)}.map do |a|
    [a].flatten.reduce(&:*)
  end.sort
end

n,m = gets.split.map(&:to_i)

divs =  common_divisors(m).reverse

divs.each do |d|
  if d * n <= m
    puts d
    exit
  end
end


Measured memory_bytes: 4220
n = int(input())
A = input()
A = A.split()
A = [int(i) for i in A]
A = sorted(A, reverse = True)
#print(A)
ans = 0

for i in range(int(n/2)):
	ans += A[i]*2

ans -= A[0]
#print(ans)
if n&1:
  ans += A[int(n/2)]


print(ans)

Measured memory_bytes: 31600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;

int main(void) {
  int n; cin >> n;
  Vi x(n); rep(i,n) cin >> x[i];
  ll ans = INFL;
  for (int i = 0; i < 100; ++i) {
    ll sum = 0;
    rep(j,n) {
      sum += (i-x[j])*(i-x[j]);
    }
    chmin(ans,sum);
  }
  pl(ans)
  return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#define MAX_INP (100)
#define MAX_DEG (100)

//#define TEST

typedef struct {
	int deg;
	int data[MAX_DEG];
//	unsigned long data;
} TAG_T;

TAG_T graph[MAX_INP];
int n,u,k;

/**------------ SUB ROUTIONE -------------*/
int get_idx(int set_dt,int *idx_p,int *wk_p)
{
	if (set_dt <= 0) {
		printf("ERROR\n");
		return -1;
	}


	*idx_p = (set_dt-1) / 32;
	*wk_p  = set_dt % 32;
//	*wk_p  = set_dt - (*idx_p * 32) - 1;
	if (*wk_p < 0) {
		printf("ERROR1\n");
		return -1;
	}
	if (*idx_p > 3) {
		printf("ERROR2\n");
		return -2;
	}
	return 0;
}
int bit_set(unsigned long *bitmap_p , int setdt)
{
	int idx;
	int wk;
	int rtn;

	if ((rtn=get_idx(setdt,&idx,&wk)) != 0) {
		printf("ERROR 3\n");
		return rtn;
	}
	bitmap_p[idx] |= 1 << (wk-1);
	return 0;
}

int bit_cmp(unsigned long *bitmap_p , int cmpdt)
{
	int idx;
	int wk;
	int rtn;

	if ((rtn=get_idx(cmpdt,&idx,&wk)) != 0) {
		printf("ERROR 4\n");
		return rtn;
	}
	if (((bitmap_p[idx] >> (wk-1)) & 1) != 0) {
		return 1;
	}
	else {
		return 0;
	}
}
/**------------ SUB ROUTIONE -------------*/

void test()
{
	unsigned long data[4];
	int dt;
	int rtn;

	while (1) {
		memset(data,'\0',sizeof(data));
		printf("Input=");
		scanf("%d",&dt);
		bit_set(data,dt);
		printf("bit_set() data[0 1 2 3]=0x%08x 0x%08x 0x%08x 0x%08x\n",data[0],data[1],data[2],data[3]);

		rtn = bit_cmp(data,dt);
		printf("bit_cmp() rtn=%d\n",rtn);
	}
}

int main()
{
	int i,l,v;
	int wk;
	unsigned long data[4];
	char inp[128];
	char *wk_p;
	char *dmy_p;
#ifdef TEST
	test();
#else

	/** INIT **/
	n=u=k=0;

	/** INPUT **/
	gets(inp);
	sscanf(inp,"%d",&n);

	/***************/
	/*--- n     ---*/
	/***************/
	for (i=0 ; i<n ; i++) {
		gets(inp);
		wk_p = strtok(inp, " ");
		sscanf(wk_p,"%d",&u); //???????????????
		wk_p = strtok(NULL, " ");
		sscanf(wk_p,"%d",&k); //????¬???°
		graph[i].deg = k;
//		graph[i].data= 0;
		wk_p = strtok(NULL, " ");
		for (l=0 ; l<k ; l++) {
			sscanf(wk_p,"%d",&v);
			graph[i].data[l] = v;
//			graph[i].data |= 1 << (v-1);
			wk_p = strtok(NULL, " ");
		}

	}


	/*CALC*/
	for (i=0 ; i<n ; i++) {
		k = graph[i].deg;
		data[0]=data[1]=data[2]=data[3]=0;
		for (l=0 ; l<k ; l++) {
			wk = graph[i].data[l];
//			data |= 1 << (wk-1);
			bit_set(data,wk);
		}
		k = n;
		for (l=0 ; l<k ; l++) {
//			wk = (graph[i].data >> l) & 1;
			wk = bit_cmp(data,l+1);
//			if (((data >> l) & 0x00000001) != 0) {
			if (wk != 0) {
				printf("1");
			}
			else {
				printf("0");
			}
			if (l!=(k-1)) {
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
#endif
}

Measured memory_bytes: 616
from math import *
def check(hx,hy,fx,fy,df,w,a):
	if ((hx-fx)**2 + (hy-fy)**2)**0.5 < a and Abs(atan2(hy-fy,hx-fx)-w) < df:
		return True
	else:
		return False

def Abs(e):
	e = abs(e)
	if e > pi: e = 2*pi - e
	return e

while 1:
	H,R = map(int,raw_input().split())
	if H == 0: break
	hxy = [map(int,raw_input().split()) for i in range(H)]
	U,M,S,du,dm,ds = map(int,raw_input().split())
	du,dm,ds = du*pi/360,dm*pi/360,ds*pi/360
	dxy = [map(int,raw_input().split())+[du] for i in range(U)]
	mxy = [map(int,raw_input().split())+[dm] for i in range(M)]
	sxy = [map(int,raw_input().split())+[ds] for i in range(S)]
	fxy = dxy+mxy+sxy
	count = [0]*H
	for i in range(R):
		w,a = map(int,raw_input().split())
		w = w*pi/180
		if w > pi: w -= 2*pi
		for j in range(H):
			hx,hy = hxy[j]
			if not check(hx,hy,0,0,du,w,a):
				continue
			for fx,fy,df in fxy:
				if check(hx,hy,fx,fy,df,w,a):
					break
			else:
				count[j] += 1
	mx = max(count)
	if mx > 0:
		print " ".join(map(str,[i+1 for i in range(H) if count[i] == mx]))
	else:
		print "NA"

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int N;
	cin >> N;

	rep(i,11){
		if(i * 1000 - N >= 0){
			cout << i * 1000 - N << endl;
			return;
		}
	}

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3640
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         //what is dp?
         dp = new long[N][N];
         for(int i=0; i < N; i++)
            Arrays.fill(dp[i], 69);
         System.out.println(dfs(0,N-1));
      }
      static int[] arr;
      static long[][] dp;
      public static long dfs(int a, int b)
      {
         if(a > b)
            return 0;
         int N = arr.length;
         if(a == b)
         {
            int temp = arr[a];
            if(arr.length%2 == 0)
               temp *= -1;
            return dp[a][b] = temp;
         }
         if(dp[a][b] != 69)
            return dp[a][b];
         int turn = N-b+a-1;
         long res = Long.MIN_VALUE;
         if(turn%2 == 0)
            res = Math.max(res, Math.max(arr[a]+dfs(a+1,b),arr[b]+dfs(a,b-1)));
         else
         {
            res = Long.MAX_VALUE;
            res = Math.min(res, Math.min(-1*arr[a]+dfs(a+1,b),-1*arr[b]+dfs(a,b-1)));
         }
         return dp[a][b] = res;
      }
   }

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


int main(){
  ll N,K;
  ll mod = 1e9+7;
  cin >> N >> K;
  ll ans=0;
  for(ll i=K;i<=N+1;++i){
    ans += (2*N-i+1)*i/2 - i*(i-1)/2 + 1;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n,x[200000],y[200000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i];
        y[i]=x[i];
    }
    sort(y,y+n);
    int a=y[n/2-1];
    int b=y[n/2];
    for(int i=0;i<n;i++){
		if(x[i]<=a)cout<<b<<endl;
		else cout<<a<<endl;
	}
    return 0;
}


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

#define int long long

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

string S;

signed main() {
    cin >> S;
    int ans = 0;
    for (int i = 0; i < S.length(); i++) {
        for (int j = 0; i + j < S.length(); j++) {
            if (i + j == S.length() - 1) {
                ans += (S[i] - '0') * pow(10, j) * pow(2, S.length() - j - 1);
            } else {
                ans += (S[i] - '0') * pow(10, j) * pow(2, S.length() - j - 2);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	ll N; cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)cin >> A[i];

	sort(A.begin(), A.end());

	for (int i = 0; i < N - 1; i++) {
		if (A[i] == A[i + 1]) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
    using namespace std;
     
    const int N = 9;
     
    int n, m;
    char a[N][N];
     
    int main(){
        scanf("%d%d", &n, &m);
        for(int i = 0; i < n; i++) scanf("%s", a[i]);
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                for(int x = i + 1; x < n; x++){
                    for(int y = 0; y < j; y++){
                        if(a[i][j] == '#' && a[x][y] == '#'){
                            puts("Impossible");
                            return 0;
                        }
                    }
                }
            }
        }
        puts("Possible");
    }

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

int main() {
    int h,w,k;cin>>h>>w>>k;
    string s[h];
    for (int i=0;i<h;i++)
        cin>>s[i];
    int ans=0;
    for (int i=0;i<1<<h;i++)
        for (int j=0;j<1<<w;j++) {
            int c=0;
            for (int l=0;l<h;l++)
                for (int m=0;m<w;m++)
                    if (~i&1<<l&&~j&1<<m&&s[l][m]=='#')
                        c++;
            if (c==k)
                ans++;
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, X[1009], Y[1009];
    cin>>N;
    
    int pr;
    rep(i,N){
        cin>>X[i]>>Y[i];
        if(i==0){
            pr = (X[i]+Y[i])&1;
        }else{
            if(((X[i]+Y[i])&1)!=pr){
                cout1(-1);
                return 0;
            }
        }
    }
    
    vector<ll> d;
    rep(i,31) d.push_back(1<<i);
    if(pr==0) d.push_back(1);
    
    sort(d.rbegin(), d.rend());
    
    cout1(d.size());
    for(auto x:d) cout<<x<<" ";
    cout<<endl;
    
    rep(i,N){
        ll xx=0;
        ll yy=0;
        int dx[] = { -1, 0, 1, 0};
        int dy[] = { 0, 1, 0, -1};
        string nm = "LURD";
        for(auto len:d){
            int q=0;
            ll best = LLINF;
            rep(j,4){
                ll xxx = xx + len*dx[j];
                ll yyy = yy + len*dy[j];
                ll diff = abs(xxx-X[i]) + abs(yyy-Y[i]);
                if(diff<best){
                    best = diff;
                    q = j;
                }
            }
            cout<<nm[q];
            xx = xx + len*dx[q];
            yy = yy + len*dy[q];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import heapq
sys.setrecursionlimit(10**8)
INF = float("inf")


class MaxHeap(object):
    def __init__(self, x, default=-INF):
        self.heap = [-e for e in x]
        self.default = default
        heapq.heapify(self.heap)

    def push(self, value):
        heapq.heappush(self.heap, -value)

    def pop(self):
        if len(self.heap) == 0:
            return self.default
        else:
            return -heapq.heappop(self.heap)


def argmax(a):
    value, n = -(1 << 31), -1
    for i, v in enumerate(a):
        if value < v:
            n, value = i, v
    return n, value


def solve(X: int, Y: int, A: int, B: int, C: int, p: "List[int]", q: "List[int]", r: "List[int]"):
    ABC = [MaxHeap(p), MaxHeap(q), MaxHeap(r)]

    upper = [X, Y]

    abc = [k.pop() for k in ABC]
    xyz = [0, 0, 0]
    tot = 0
    for _ in range(X+Y):
        i, m = argmax(abc)
        tot += m
        if (i < 2 and xyz[i] < upper[i]-1) or (i == 2):
            abc[i] = ABC[i].pop()
        else:
            abc[i] = -INF
        xyz[i] += 1
    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    q = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    r = [int(next(tokens)) for _ in range(C)]  # type: "List[int]"
    solve(X, Y, A, B, C, p, q, r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 37216